Node Creation in NS2

  • Node can be created using the following command

    set ns [new Simulator] ;# Simulator instanceset node_(0) [$ns node]

  • Multiple nodes can be created as follows

    set ns [new Simulator] ;# Simulator instance
    set totalNodes 50 ;#Total Number of nodes in the network
    for {set i 0} {$i < $totalNodes } { incr i } {
    set node_($i) [$ns node]
    }