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"


}

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Does this really work?? I could not implement it

    ReplyDelete
  3. Sydney Cyber Army: How To Program Nodes Movement Using For Loop In Ns2 >>>>> Download Now

    >>>>> 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

    ReplyDelete