Monday, April 29, 2013

NS-2 NAM Error

If following is the error when you run

$nam sample.nam
node 0 is not defined… node 0 is not defined… node 1 is not defined… node 1 is not defined… node 1 is not defined… node 0 is not defined… node 0 is not defined… node 0 is not defined… node 1 is not defined… node 1 is not defined… node 1 is not defined… node 0 is not defined… node 0 is not defined… node 0 is not defined… node 1 is not defined… node 1 is not defined… node 1 is not defined… node 0 is not defined… node 0 is not defined… node 0 is not defined… node 1 is not defined
 
Solution:
 $node_(0) set X_ 1236.434683198672
$node_(0) set Y_ 179.979610823970
$node_(0) set Z_ 0.000000000000
$node_(1) set X_ 1790.717030099859
$node_(1) set Y_ 83.776877593619
$node_(1) set Z_ 0.000000000000
 $ns_ at 0.000000000000 "$node_(0) setdest 8.478589906252 340.108921691462 0.138306462152"
$ns_ at 0.000000000000 "$node_(1) setdest 758.184447675563 73.841187162084 0.696734621404"
Add following two line at the after the mobility declaration.
$ns_ initial_node_pos $node_(1) 20
$ns_ initial_node_pos $node_(0) 20