Applicable VersionsNetSim Standard NetSim Pro


Applicable Releases
v13.1
v13.2v13.3


Overview: Users have the option of using inbuilt mobility models or interfacing external mobility files to NetSim. An example application on where External mobility files are used is in VANET simulations. Here VANET simulators such as SUMO are used to create the vehicular network and set the road and traffic conditions. Per these settings, the simulation is run in SUMO and a mobility file is generated. This file is then taken as input by NetSim's VANET module and the networking/communication effects are simulated and measured in NetSim.

Format: The name of the trace File generated should be kept as mobility.txt and it should be in the NetSim Mobility File format. The user can generate the trace file by any traffic simulator and modify it as per the NetSim mobility file format.

Shown below is the format for NetSim Mobiliy File -


# To write comments, use # tag
# User needs to specify the total number of Nodes and Environment size as shown below
#nodes: <No. of Nodes> max x = <X_Environment_Size>, max y: <Y_Environment_Size>
#First specify the location of all the devices as per their X, Y and Z Axis
$node_(<Node _ID - 1>) set X_ <Initial X_Coordinate>
$node_(<Node _ ID - 1>) set Y_ <Initial Y_ Coordinate >
$node_(<Node _ ID - 1>) set Z_ <Initial Z_ Coordinate >
#Specify the new location of the specific device at the specific time
$time <Time_in_Secs> "$node_(<Node_ ID - 1>) <X_Coordinate> <Y_ Coordinate > <Z_Coordinate >"


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 the NetSim bin path so as to provide it as input for file-based mobility.

(In v11.1 and higher versions of Netsim, the mobility text file can be copy-pasted in the Open Mobility File option present in the general properties the device)


Related Articles:


https://support.tetcos.com/support/solutions/articles/14000134854-how-to-set-the-speed-of-a-vehicle-in-sumo-based-on-feedback-from-netsim-


NetSim VANETs page: https://tetcos.com/vanets.html