[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ns] delay command in NS



Hi Vincent,
This is an e-mail that I send to Huan, hope it helps,

Enrique


Hi Huan,

I tested the script and you still have to reset both TCP and TCPSink 
agents
after successfully transmitting a file. This code works:

set ns [new Simulator]

set file [open test.out w]

proc finish {} {
     global file
     close $file
     exit 0
}

set n0 [$ns node]
set n1 [$ns node]

$ns duplex-link $n0 $n1 10kb 2ms DropTail

Agent/TCP instproc done {} {
     $self instvar sink
     global file
     set ns [Simulator instance]
     $ns at [expr [$ns now]+30.0] "$self send 20000"
     $self reset
     $sink reset
     puts $file "Finishing sending at [$ns now], rescheduling for [expr 
[$ns now]+30.0]..."
     puts "Scheduling for [expr [$ns now]+30.0]..."
}

set tcp [new Agent/TCP]
$ns attach-agent $n0 $tcp
set tcpsink [new Agent/TCPSink]
$ns attach-agent $n1 $tcpsink
$tcp set sink $tcpsink

$ns connect $tcp $tcpsink

$ns at 1.0 "$tcp send 20000"
$ns at 150.0 "finish"
$ns run

If instead of 30 seconds you wish the wait time to be random, you can 
use one of
the random variate generators from ns. Hope this helps.

Enrique


On Monday, May 28, 2001, at 09:38  AM, Vincent Loo wrote:

> hello Enrique, Huan and all,
>
> i saw this on the ns-list and i was wondering how to use this "done" 
> script, as i want to do the same delaying effect.
>
> and can i ask how to do the RNG in ns? cos i don't follow the RNG 
> example.
>
> thanks
>
>
>
> --- Huan Pham <[email protected]>
>> wrote:
>> Hi Enrique and NS users,
>>
>> Thank you very much for your help, But I think your code asks TCP to 
>> schedule
>> the next transmission based on the Current "Sending" time, not based 
>> on the
>> time when TCP finishes sucessfully its transmission with ACKs 
>> confirmation.
>>
>> For example, according to your current solution, if you start sending 
>> first
>> chunk of packets at 1.0 second, your next schedule time will be 31.0, 
>> 61.0,
>> .... no matter how much it takes to transmit 20000 bytes!
>>
>> What I want to simulate is the "user behaviour". To do that I have to 
>> take
>> the Thinking time (random time) and transmission time & ACK feedback 
>> time
>> into acount. Then, if it takes 2 seconds to get the ACK feedbacks, the 
>> next
>> tranmission time will be 33.0, 65.0 , ...  The expected outcome will 
>> be some
>> thing like this: " if transmission time (application delay) is big, 
>> users
>> themself will ease their traffic generation". And we may experience 
>> less
>> traffic load.
>>
>> Are there any available traffic model that have done this?
>>
>> Thanks again very much for your help. I would appreciate very much your
>> alternative solution to my problem.
>>
>> Huan Pham
>>
>>
>> Enrique Campos-Nanez wrote:
>>
>>> You can use the "done" call back for the TCP agent,
>>> and schedule a future event at that time. For example:
>>>
>>> Agent/TCP instproc done {} {
>>>         set ns [Simulator instance]
>>>         $ns at [expr [$ns now]+30.0] "$self send 20000"
>>> }
>>>
>>> By the way, the FTP session is not necessary if you are only sending
>>> information
>>> in this fashion.
>>>
>>> Enrique Campos-Nanez
>>>
>>> On Thursday, May 17, 2001, at 07:45 PM, Huan Pham wrote:
>>>
>>>>
>>>> What I want to simulate now is to have a FTP  traffic source. It
>>>> generate 20 packets, each of 1000 bytes. It waits until transmission
>>>> finished.  Then it delays an random time (let's say 30 seconds in
>>>> average, stands for user reading time) before keep produce another 
>>>> more
>>>> 20 packets.
>>>>
>>>> Can anyone tell me, if NS know when FTP finishes transmission , and
>>>> what is the command  to do "Delay 30 second "  in  NS.
>>>>
>>>> Thanks
>>
>> --
>>
>> Huan Pham - PhD Student
>> School of Information Technology
>> James Cook University, QLD4811, Australia
>> Phone: 61-7-4781 6909    Mobile: 61-418-875084
>> Fax: 61-7-4781 4029
>> Homepage: http://www.cs.jcu.edu.au/~huan
>
> _____________________________________________________________
> Free web-based email for Perth, Western Australia ---> 
> http://www.perthmail.com