如何在NS2仿真中更改链接的延迟? [英] How to change the delay of a link in NS2 simulation?
问题描述
我需要运行NS2仿真,以更改链接的延迟 在运行时,我在tcl脚本中使用以下过程:
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
更改$ node3和$ node4之间的链接的延迟.
但是,只有在模拟开始之前进行了设置,它才有效.
如果要在特定时间内更改延迟,例如
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?
感谢您的帮助.
推荐答案
我很长时间以来一直在寻找这个答案.我一直在不断地回到这个令人沮丧而又无法回答的问题.在这里.
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.
如上所述,您有$ node3和$ node4.
Say as above, you have $node3 and $node4.
要获取链接,请使用
set myLink [[$ns link $n(0) $n(1)] link]
请注意,这不仅是链接,还是链接内的link_(手册第68页 http://www.isi.edu/nsnam/ns/doc/ns_doc.pdf 或html版本
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
该部分在ns-2.35/tcl/lib/ns-link.tcl中找到
This part was found in ns-2.35/tcl/lib/ns-link.tcl
这篇关于如何在NS2仿真中更改链接的延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!