In a wireless network, the mobility of a node from a location to another location can be enabled using the keyword “setdest” in Tool Command Language (TCL) script. The specifications for a node’s target location include x-coordinate, y-coordinate along with the speed. The target location of a node should lie within the network area. The tcl script in sample6.tcl shows the mobility model of the nodes in the area of 500m 500m.
#Filename: sample6.tcl
#******************* MOBILITY MODEL ***************************#
#Fixing the co-ordinate of simutaion area
set val(x) 500
set val(y) 500
for {set i 0} {$i < 3} {incr i} {
$node_($i) set X_ [expr rand()*$val(x)]
$node_($i) set Y_ [expr rand()*$val(y)]
$node_($i) set Z_ 0
}
#******************Defining Mobility ************************#
# For mobility 300= movement x value, 100=movement y value, 50=speed in m/s
$ns at 2.0 "$node_(2) setdest 300 100 50"
#*****************Defining Random Mobility *******************#
#Random mobility for all the nodes
for {set i 1} {$i < 3} {incr i} {
set xr [expr rand()*$val(x)]
set yr [expr rand()*$val(y)]
$ns at 2.0 "$node_($i) setdest $xr $yr 50"
}
Before Mobility of mobile node2
After mobility of mobile node2