Dynamic Topology in TCL

  • The dynamic topology can be created in ns2 using rand function.
  • Each node is assigned with a random location within area (Val(x)*Val(y)) using rand function.

    set ns [new Simulator]
    set node_(0) [$ns node]
    set Val(x) 500
    set Val(y) 500
    $node_(0) set X_ [expr rand()*$val(x)]
    $node_(0) set Y_ [expr rand()*$val(y)]
    $node_(0) set Z_ 0
    ns → Simulator instance
    rand() → Random Function
    $val(x) → X dimension of the network
    $val(y) → Y dimension of the network