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

感情迁移 提交于 2019-12-11 05:49:09

问题


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



来源:https://stackoverflow.com/questions/8386123/how-to-change-the-delay-of-a-link-in-ns2-simulation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!