Applicable Versions | NetSim Academic | NetSim Standard | NetSim Pro |
Applicable Releases | v1 |
Converting sumo mobility to a .csv file
NetSim lets you handle mobility with file-based methods and even generate SUMO mobility as a file if you prefer.
To create a file containing SUMO (Simulation of Urban MObility) mobility data, follow these steps:
Step 1: Create a sumo cfg file of the desired network.
Step 2: After obtaining the Sumo cfg file, proceed to create the trace file via the command line by executing the following command:
sumo -c Configuration.sumo.cfg --fcd-output sumoTrace.xml
Step 3: After generating the Sumo trace file, convert it into a text file by utilizing the traceExporter.py tool, located at the following path:
"C:\Program Files (x86)\Eclipse\Sumo\tools\traceExporter.py" --fcd-input sumoTrace.xml --ns2mobility-output sumomobility.txt
After generating the sumomobility.txt file, it may be necessary to make certain modifications before using it as an input for vehicles in NetSim..
Modifications to Mobility file generated:
The file needs to be modified as per NetSim’s requirement.
The following modifications are required:
Step 1: Remove the $node_(0) set X_ 694.9 from the file, as setting of the position prior to the simulation is not mandatory.
$ns_ at 0.0 "$node_(0) setdest 694.9 401.65 0.00"
$ns_ at 0.4 "$node_(0) setdest 694.79 401.65 0.27"
$ns_ at 0.8 "$node_(0) setdest 694.59 401.65 0.50"
$ns_ at 1.2 "$node_(0) setdest 694.3 401.65 0.73"
$ns_ at 1.6 "$node_(0) setdest 693.93 401.65 0.92"
$ns_ at 2.0 "$node_(0) setdest 693.46 401.65 1.17"
$ns_ at 2.0 "$node_(1) setdest 105.1 98.35 0.00"
$ns_ at 2.4 "$node_(0) setdest 692.89 401.65 1.43"
$ns_ at 2.4 "$node_(1) setdest 105.2 98.35 0.26"
$ns_ at 2.8 "$node_(0) setdest 692.25 401.65 1.60"
$ns_ at 2.8 "$node_(1) setdest 105.42 98.35 0.53"
$ns_ at 3.2 "$node_(0) setdest 691.51 401.65 1.85"
$ns_ at 3.2 "$node_(1) setdest 105.71 98.35 0.73"
$ns_ at 3.2 "$node_(2) setdest 105.1 398.35 0.00"
Step 2: Replace the “$ns_at ” with “” (nothing) as shown below:
0.0 "$node_(0) setdest 694.9 401.65 0.00"
0.4 "$node_(0) setdest 694.79 401.65 0.27"
0.8 "$node_(0) setdest 694.59 401.65 0.50"
1.2 "$node_(0) setdest 694.3 401.65 0.73"
1.6 "$node_(0) setdest 693.93 401.65 0.92"
2.0 "$node_(0) setdest 693.46 401.65 1.17"
2.0 "$node_(1) setdest 105.1 98.35 0.00"
2.4 "$node_(0) setdest 692.89 401.65 1.43"
2.4 "$node_(1) setdest 105.2 98.35 0.26"
2.8 "$node_(0) setdest 692.25 401.65 1.60"
2.8 "$node_(1) setdest 105.42 98.35 0.53"
3.2 "$node_(0) setdest 691.51 401.65 1.85"
3.2 "$node_(1) setdest 105.71 98.35 0.73"
3.2 "$node_(2) setdest 105.1 398.35 0.00"
Step 3: Replace all occurrences of “setdest” with “” (nothing) as shown below:
0.0 "$node_(0) 694.9 401.65 0.00"
0.4 "$node_(0) 694.79 401.65 0.27"
0.8 "$node_(0) 694.59 401.65 0.50"
1.2 "$node_(0) 694.3 401.65 0.73"
1.6 "$node_(0) 693.93 401.65 0.92"
2.0 "$node_(0) 693.46 401.65 1.17"
2.0 "$node_(1) 105.1 98.35 0.00"
2.4 "$node_(0) 692.89 401.65 1.43"
2.4 "$node_(1) 105.2 98.35 0.26"
2.8 "$node_(0) 692.25 401.65 1.60"
2.8 "$node_(1) 105.42 98.35 0.53"
3.2 "$node_(0) 691.51 401.65 1.85"
3.2 "$node_(1) 105.71 98.35 0.73"
3.2 "$node_(2) 105.1 398.35 0.00"
Step 4: Also replace “$node_(” with “” nothing
0.0 "0) 694.9 401.65 0.00"
0.4 "0) 694.79 401.65 0.27"
0.8 "0) 694.59 401.65 0.50"
1.2 "0) 694.3 401.65 0.73"
1.6 "0) 693.93 401.65 0.92"
2.0 "0) 693.46 401.65 1.17"
2.0 "1) 105.1 98.35 0.00"
2.4 "0) 692.89 401.65 1.43"
2.4 "1) 105.2 98.35 0.26"
2.8 "0) 692.25 401.65 1.60"
2.8 "1) 105.42 98.35 0.53"
3.2 "0) 691.51 401.65 1.85"
3.2 "1) 105.71 98.35 0.73"
3.2 "2) 105.1 398.35 0.00"
Step 5: Now start replacing the node ids (1: n). For NetSim the node ID starts with 1.
Note: Start with the last node ID and replace till the first to avoid repetitions (in this case 4 is replaced with 5)
0.0 "1 694.9 401.65 0.00"
0.4 "1 694.79 401.65 0.27"
0.8 "1 694.59 401.65 0.50"
1.2 "1 694.3 401.65 0.73"
1.6 "1 693.93 401.65 0.92"
2.0 "1 693.46 401.65 1.17"
2.0 "2 105.1 98.35 0.00"
2.4 "1 692.89 401.65 1.43"
2.4 "2 105.2 98.35 0.26"
2.8 "1 692.25 401.65 1.60"
2.8 "2 105.42 98.35 0.53"
3.2 "1 691.51 401.65 1.85"
3.2 "2 105.71 98.35 0.73"
3.2 "3 105.1 398.35 0.00"
3.6 "1 690.66 401.65 2.13"
3.6 "2 106.11 98.35 1.00"
3.6 "3 105.21 398.35 0.27"
4.0 "1 689.74 401.65 2.29"
4.0 "2 106.63 98.35 1.29"
4.0 "3 105.44 398.35 0.57"
4.0 "4 694.9 101.65 0.00"
Step 6: Remove the quotes by replacing it with nothing as shown below:
0.0 1 694.9 401.65 0.00
0.4 1 694.79 401.65 0.27
0.8 1 694.59 401.65 0.50
1.2 1 694.3 401.65 0.73
1.6 1 693.93 401.65 0.92
2.0 1 693.46 401.65 1.17
2.0 2 105.1 98.35 0.00
2.4 1 692.89 401.65 1.43
2.4 2 105.2 98.35 0.26
2.8 1 692.25 401.65 1.60
2.8 2 105.42 98.35 0.53
3.2 1 691.51 401.65 1.85
Step 7: As a final step, replace the spaces with tab spaces in the file.
0.0 1 694.9 401.65 0.00
0.4 1 694.79 401.65 0.27
0.8 1 694.59 401.65 0.50
1.2 1 694.3 401.65 0.73
1.6 1 693.93 401.65 0.92
2.0 1 693.46 401.65 1.17
2.0 2 105.1 98.35 0.00
2.4 1 692.89 401.65 1.43
2.4 2 105.2 98.35 0.26
2.8 1 692.25 401.65 1.60
2.8 2 105.42 98.35 0.53
3.2 1 691.51 401.65 1.85
3.2 2 105.71 98.35 0.73
3.2 3 105.1 398.35 0.00
The mobility file has been modified per NetSim requirement.
Adding mobility to the vehicles in NetSim
Change the mobility model from sumo to file-based mobility and copy-paste the contents from the sumomobility.txt file to the CSV file in NetSim.
With the following modifications user can run the vanet scenario’s with sumo mobility in form of a file based input.