[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] some problem about variable link delay realizing
Sorry, the previous message was incomplete.
You have to make a function like record() and use the [$dy value]
command
e.g.
set dy [new RandomVariable/Uniform]
$dy set min_10
$dy set max_20
$ns simplex-link node0 node1 9600bps dy DropTail
set interval 0.01
proc record {interval} {
global dy node0 node1
#Get an instance of the simulator
set ns [Simulator instance]
#Get a value of the random variable
set new_delay [$dy value]
#Change link delay
$ns delay $node0 $node1 $new_delay duplex
#Set the time after which the procedure should be called again
set time $interval
$ns at [expr $now_str+$interval] "record $interval"
}
This command will change the delay of the link every $interval seconds.
But it will slow down the simulations, because in order to change the
delay for each packet, the interval should be very small. There should
be a way to issue the command for every packet to be sent, using the
evalf command, but I don't know which .c file is responsible for
dequeuing and sending the data. Any suggestions? I have done it in tcl
for every file to be sent. When I want to send a file of x bytes,
instead of calling $tcp send x, I call $tcp mysend x, and the mysend
command changes the delay before sending like below:
Agent/TCP instproc mysend {size} {
#change delay
$self changedel
$self send $size
}
Agent/TCP instproc change_del {} {
#change delay of link from agent node to node0
global ns dy node0
#get node where agent resides
set mynode [$self set node_]
set new_delay [$dy value]
$ns delay $node0 $mynode $new_delay duplex
}
luorui999 wrote:
>
>
> Thanks for your good advice!
>
> More precisely, my question is this, for ns-2 command,
>
> set dy [new RandomVariable/Uniform]
>
> $dy set min_10
>
> $dy set max_20
>
> $ns simplex-link node0 node1 9600bps dy DropTail
>
> may I use these commands make the link delay between node0 and node1
> vary as a random variable according to uniform distribution in the
> simulation?
>
> ----- Original Message -----
>
>
> You can use the delay command to change the delay of a link.
>
> $ns delay $node1 $node2 $new_delay duplex
>
> However if you do that, the nam will not visualise it very
> well (at
> least mine, nam 1.0a9)
>
> luorui999 wrote:
>
> >
> >
> > hi,
> >
> > I am a new user of ns-2, I am just simulating a system
> whose link
> > delay is variable, that is,the time that packet cost on
> the link is
> > not constant, but is random variable, the continus two
> packet on the
> > link may have different link delay, who can tell me how to
> realize it
> > with ns-2?
> >
> > thanks very much!
> >
> -----------------------------------------------------------------------
>
> > 24P!J1Kx6(KQ:|PBNEVPPD#,HHARW#:X11>)Ij0BT2Bz3I9&#!
>
>
>
>
>
> -----------------------------------------------------------------------
>