This guide provides steps to generate mobility traces for VANET using OpenStreetMap (OSM) data and SUMO (Simulation of Urban MObility).
Go to OpenStreetMap and export the map.osm
file. Customize the map as needed.
Rename the downloaded file to map.osm.xml
.
Install SUMO and its tools using the following commands:
sudo add-apt-repository ppa:sumo/stable
sudo apt-get update
sudo apt-get install sumo sumo-tools sumo-doc
export SUMO_HOME=/usr/share/sumo
Convert the OSM data to a SUMO network using the following command:
netconvert --osm-files map.osm.xml -o map.net.xml
Generate vehicle mobility using the following command:
python /usr/share/sumo/tools/randomTrips.py -n map.net.xml -r map.rou.xml -b 0 -e 200 --insertion-density 60
- --insertion-density: How much vehicles arrive in the simulation per hour per kilometer of road
- --period: Sets the departure period between vehicles to seconds.
To visualize the generated vehicles on the map, use:
sumo-gui -n map.net.xml -r map.rou.xml
Create a SUMO configuration file:
nano config.sumocfg
Write the configuration and save the file. Then, export the mobility traces:
sumo -c config.sumocfg --fcd-output map.fcd.xml
python /usr/share/sumo/tools/traceExporter.py -i map.fcd.xml -n map.net.xml --ns2mobility-output ns3mobility.tcl
Now you have the mobility traces ready for use in NS-3.
If you want to have an analysis of the density of nodes in the network over time, as well as the entry and exit times of nodes, you can use a Python file. Results attached! also you can find some results in ./200s-insertion-density-30-240
folder.
python3 plot.py
To simplify the generation of different scenarios on a map, a script file has been developed that you can customize and easily create different scenarios by running it. In the scenario below, the insertion density is set to 60.
./sumo_file_generator.sh 60