Search code examples
network-programmingtclns2otcl

How to change the delay of a link in NS2 simulation?


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.


Solution

  • 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