VANET simulators such as SUMO can output the mobility file per the ns2movements file format. The steps below explain how to make a ns2movements.tcl file compatible with NetSim mobility.txt file format.


NS2 mobility file format: .tcl

NetSim mobility file format: .txt


A Sample ns2mobility.tcl is shown below:


$node_(0) set X_ 5.1

$node_(0) set Y_ 495.05

$node_(0) set Z_ 0

$ns_ at 0.0 "$node_(0) setdest 5.1 495.05 0.00"

$node_(1) set X_ 994.9

$node_(1) set Y_ 504.95

$node_(1) set Z_ 0

$ns_ at 0.0 "$node_(1) setdest 994.9 504.95 0.00"

$node_(2) set X_ 504.95

$node_(2) set Y_ 5.1

$node_(2) set Z_ 0

$ns_ at 0.0 "$node_(2) setdest 504.95 5.1 0.00"

$node_(3) set X_ 495.05

$node_(3) set Y_ 994.9

$node_(3) set Z_ 0

$ns_ at 0.0 "$node_(3) setdest 495.05 994.9 0.00"

$ns_ at 1.0 "$node_(0) setdest 7.38 495.05 2.28"

$ns_ at 1.0 "$node_(1) setdest 993.27 504.95 1.63"

$ns_ at 1.0 "$node_(2) setdest 504.95 7.64 2.54"

$ns_ at 1.0 "$node_(3) setdest 495.05 993.07 1.83"

$ns_ at 2.0 "$node_(0) setdest 11.91 495.05 4.53"

$ns_ at 2.0 "$node_(1) setdest 989.77 504.95 3.50"

$ns_ at 2.0 "$node_(2) setdest 504.95 12.2 4.56"

$ns_ at 2.0 "$node_(3) setdest 495.05 989.24 3.83"


The above file contains the position coordinates for 4 nodes.


Step 1: Create a new text file and initially specify the following details:


#

#nodes:<no:of nodes>  max x =<grid length>, max y:<grid length>

#


In this case it will be:

#

#nodes: 4  max x = 1000.0, max y: 1000.0

#


Step 2: Cut and paste the initial positions ($node definitions) of all the four devices together in the beginning.

#

#nodes:4  max x=1000.0, max y:1000.0

#

$node_(0) set X_ 5.1

$node_(0) set Y_ 495.05

$node_(0) set Z_ 0

$node_(1) set X_ 994.9

$node_(1) set Y_ 504.95

$node_(1) set Z_ 0

$node_(2) set X_ 504.95

$node_(2) set Y_ 5.1

$node_(2) set Z_ 0

$node_(3) set X_ 495.05

$node_(3) set Y_ 994.9

$node_(3) set Z_ 0


These are the initial positions of the devices. 


Step 3: The position coordinates of each device with respect to time ($ns_ at definitions) can come below.


#

#nodes: 4  max x = 1000.0, max y: 1000.0

#

$node_(0) set X_ 5.1

$node_(0) set Y_ 495.05

$node_(0) set Z_ 0

$node_(1) set X_ 994.9

$node_(1) set Y_ 504.95

$node_(1) set Z_ 0

$node_(2) set X_ 504.95

$node_(2) set Y_ 5.1

$node_(2) set Z_ 0

$node_(3) set X_ 495.05

$node_(3) set Y_ 994.9

$node_(3) set Z_ 0

$ns_ at 0.0 "$node_(0) setdest 5.1 495.05 0.00"

$ns_ at 0.0 "$node_(1) setdest 994.9 504.95 0.00"

$ns_ at 0.0 "$node_(2) setdest 504.95 5.1 0.00"

$ns_ at 0.0 "$node_(3) setdest 495.05 994.9 0.00"

$ns_ at 1.0 "$node_(0) setdest 7.38 495.05 2.28"

$ns_ at 1.0 "$node_(1) setdest 993.27 504.95 1.63"

$ns_ at 1.0 "$node_(2) setdest 504.95 7.64 2.54"

$ns_ at 1.0 "$node_(3) setdest 495.05 993.07 1.83"

$ns_ at 2.0 "$node_(0) setdest 11.91 495.05 4.53"

$ns_ at 2.0 "$node_(1) setdest 989.77 504.95 3.50"

$ns_ at 2.0 "$node_(2) setdest 504.95 12.2 4.56"

$ns_ at 2.0 "$node_(3) setdest 495.05 989.24 3.83"


Step 5: Replace all the occurrences of "$ns_ at" with "$time" as shown below:


#
#nodes: 4  max x = 1000.0, max y: 1000.0
#
$node_(0) set X_ 5.1
$node_(0) set Y_ 495.05
$node_(0) set Z_ 0
$node_(1) set X_ 994.9
$node_(1) set Y_ 504.95
$node_(1) set Z_ 0
$node_(2) set X_ 504.95
$node_(2) set Y_ 5.1
$node_(2) set Z_ 0
$node_(3) set X_ 495.05
$node_(3) set Y_ 994.9
$node_(3) set Z_ 0
$time 0.0 "$node_(0) setdest 5.1 495.05 0.00"
$time 0.0 "$node_(1) setdest 994.9 504.95 0.00"
$time 0.0 "$node_(2) setdest 504.95 5.1 0.00"
$time 0.0 "$node_(3) setdest 495.05 994.9 0.00"
$time 1.0 "$node_(0) setdest 7.38 495.05 2.28"
$time 1.0 "$node_(1) setdest 993.27 504.95 1.63"
$time 1.0 "$node_(2) setdest 504.95 7.64 2.54"
$time 1.0 "$node_(3) setdest 495.05 993.07 1.83"
$time 2.0 "$node_(0) setdest 11.91 495.05 4.53"
$time 2.0 "$node_(1) setdest 989.77 504.95 3.50"
$time 2.0 "$node_(2) setdest 504.95 12.2 4.56"
$time 2.0 "$node_(3) setdest 495.05 989.24 3.83"


Step 6: Replace all occurrences of "setdest " with "" (nothing) as shown below:


#
#nodes: 4  max x = 1000.0, max y: 1000.0
#
$node_(0) set X_ 5.1
$node_(0) set Y_ 495.05
$node_(0) set Z_ 0
$node_(1) set X_ 994.9
$node_(1) set Y_ 504.95
$node_(1) set Z_ 0
$node_(2) set X_ 504.95
$node_(2) set Y_ 5.1
$node_(2) set Z_ 0
$node_(3) set X_ 495.05
$node_(3) set Y_ 994.9
$node_(3) set Z_ 0
$time 0.0 "$node_(0) 5.1 495.05 0.00"
$time 0.0 "$node_(1) 994.9 504.95 0.00"
$time 0.0 "$node_(2) 504.95 5.1 0.00"
$time 0.0 "$node_(3) 495.05 994.9 0.00"
$time 1.0 "$node_(0) 7.38 495.05 2.28"
$time 1.0 "$node_(1) 993.27 504.95 1.63"
$time 1.0 "$node_(2) 504.95 7.64 2.54"
$time 1.0 "$node_(3) 495.05 993.07 1.83"
$time 2.0 "$node_(0) 11.91 495.05 4.53"
$time 2.0 "$node_(1) 989.77 504.95 3.50"
$time 2.0 "$node_(2) 504.95 12.2 4.56"
$time 2.0 "$node_(3) 495.05 989.24 3.83"


Step 7: Save this file in the name mobility.txt and place it in NetSim bin path so as to provide it as input for file-based mobility.


A sample ns2mobility.tcl and an equivalent NetSim mobility.txt file containing position coordinates for 6 nodes is attached herewith for reference.