NS2 Code for Mobile Node

Mobile Nodes are very similar to Wired Nodes.The Difference between Mobile and wired nodes are as follows

  • Links are used via a wireless channel.
  • Nodes have a location during  simulation.

Types of node movement:

  • Random movement
  • Explicitly setting node movement from the otcl script


Architecture of mobile node



Journal Support for NS2 Projects:




Sample NS2 Code for Mobile Node


# Provide initial location of mobilenodes
$node_(0) set X_ 5.0
$node_(0) set Y_ 5.0
$node_(0) set Z_ 0.0

$node_(1) set X_ 490.0
$node_(1) set Y_ 285.0
$node_(1) set Z_ 0.0

$node_(2) set X_ 150.0
$node_(2) set Y_ 240.0
$node_(2) set Z_ 0.0

# Generation of movements
$ns at 10.0 "$node_(0) setdest 250.0 250.0 3.0"
$ns at 15.0 "$node_(1) setdest 45.0 285.0 5.0"
$ns at 110.0 "$node_(0) setdest 480.0 300.0 5.0"