I am a Postdoctoral Research Fellow with The SUTD-MIT International Design Centre (IDC), Singapore University of Technology and Design (SUTD). My research topic is about protocol and algorithm design, resource allocation and localisation in wireless sensor network, UAV network and Ad Hoc network. I also enjoy the mobile programming (Android and Objective-C) and web server development. Thanks for sharing.
Apr 3, 2012
How to program nodes movement using FOR loop in NS2
In fact, we know how to set the nodes` movement in NS2, it could be < $ns at TIME "$NODE1 setdest $val(X1) $val(Y1) SPEED" >. However, for some scenario, it may contain a large number of nodes` movement and simulation time could be one or several hours. It is impossible to program in this static way.
So we consider using a FOR loop. Here is an example where a node is moving up and down. The simulation time can be any value and we just need five lines program. The program is like the following,
for {set i 1} {$i < ($val(stop))} {set i [expr {$i + 10}]} {
$ns at $i "$node_(1) setdest $val(X1) $val(Y1) NodeSpeed"
set i [expr {$i + 10}]
$ns at $i "$node_(1) setdest $val(X2) $val(Y2) NodeSpeed"
}
Labels:
NS2 For Loop
Subscribe to:
Post Comments (Atom)
This comment has been removed by the author.
ReplyDeleteDoes this really work?? I could not implement it
ReplyDeleteSydney Cyber Army: How To Program Nodes Movement Using For Loop In Ns2 >>>>> Download Now
ReplyDelete>>>>> Download Full
Sydney Cyber Army: How To Program Nodes Movement Using For Loop In Ns2 >>>>> Download LINK
>>>>> Download Now
Sydney Cyber Army: How To Program Nodes Movement Using For Loop In Ns2 >>>>> Download Full
>>>>> Download LINK hG