How to change the delay of a link in NS2 simulatio

2019-07-23 03:49发布

问题:

I need to run a NS2 simulation that the delay of a link will change during the runtime, and I use following procedure in tcl script:

$ns delay $node3 $node4 $delay_time 

to change the delay in a link between $node3 and $node4.
But it only works when it's set before the simulation starts.
If I want to change the delay in a certain time, e.g.

$ns at 1.0 "$ns delay $node3 $node4 10ms"

It doesn't work.So how to change the delay of a link during runtime?

Thanks for any help.

回答1:

I have been looking for this answer on and off for quite some time myself. I have been constantly making my way back here to this depressingly unanswered question. Here it is.

Say as above, you have $node3 and $node4.

To get your link, use

set myLink [[$ns link $n(0) $n(1)] link]

Note that this is not just the link, it is the link_ within the Link (manual page 68 http://www.isi.edu/nsnam/ns/doc/ns_doc.pdf or html version http://www.isi.edu/nsnam/ns/doc/node63.html). This is the part that manages the link delay. In order to change the link delay, use

$myLink set delay_ 1ms

This part was found in ns-2.35/tcl/lib/ns-link.tcl