Skip to main content

Routing in VANETs using ns3

Part 1
WAVE - Wireless Access for Vehicular environments. It might take more than an hour. The readers are requested to be patient. SUMO, VANETs, routing comparison 1. Explain the full source code (1550 lines of code) 2. Creating a real scenario using osm (Open Street Map Web Wizard) 3. Performance analysis for various vanet protocols. Location of the source code /home/pradeepkumar/ns-allinone-3.27/ns-3.27/src/wave/examples
Move this file to the scratch/ for inclusion of all modules. Step 1: Explanation of source code. Copy the file to scratch folder. This is just Part 1 of the VANET comparison

Part 2
Please watch the First Part before watching this video  

Part 2 - Analysis of the results.

Please go through the first video (Part 1) and then watch this video (PArt 2)

#VANETs #NS3 #Routing

1. SUMO for web traffic (
2. Convert this into mobility.tcl file and that can be loaded to file (as discussed in part1)
3. We will be analysing various metrics like 
Receive Rate
Packets Received
Mac PHY overhead
Throughput and other metrics.
Files that are generated
mobility.tcl (for generating traffic in the network)
.tr (Ascii Trace, throughput and goodput)
.flowmon (FlowMonitor)
.xml (for NetAnim)
.pcap (Wireshark)

Step 1 - SUMO

$] export SUMO_HOME=/home/pradeepkumar/sumo/
$] cd sumo/tools
$] python

Once the data generated

$] sumo -c osm.sumocfg --fcd-output trace.xml
sumo has a file, this file has to be processed.

$]  python -i 2019-08-18-20-47-08/trace.xml --ns2mobility-output=/home/pradeepkumar/mobility.tcl

from the mobility.tcl file,there are 
32 nodes (vehicles) and 249 seconds

Step 2:
NS3 part
Copy the file file to the scratch folder. 
$] cp ns-allinone-3.27/ns-3.27/src/wave/examples/ ns-allinone-3.27/ns-3.27/scratch/

Do the modifications in line numbe 2392 as indicated in the video

My simulation will be running for various protocols like OLSR, AODV and DSDV
Scenario 2 is used for Selaiyur, Tambaram, Chennai, India
Total time is 30 seconds 
Vehicle movement is 20m/s

$] ./waf --run "scratch/vanet-routing-compare --protocol=1 --scenario=2"
1 - OLSR 
4. DSR

To process the results, we used gnuplot and LibreOFfice Spreadsheet
Gnuplot Code.

set terminal pdf
set output "RR.pdf"
set title "Receive Rate"
set xlabel "Simulation Time (Seconds)"
set ylabel "Receive Rate"
plot "AODV.csv" using 1:2 with linespoints title "AODV", "OLSR.csv" using 1:2 with linespoints title "OLSR","DSDV.csv" using 1:2 with linespoints title "DSDV","DSR.csv" using 1:2 with linespoints title "DSR" 

set terminal pdf
set output "PR.pdf"
set title "Packets Receives"
set xlabel "Simulation Time (Seconds)"
set ylabel "PAckets Received"
plot "AODV.csv" using 1:3 with linespoints title "AODV", "OLSR.csv" using 1:3 with linespoints title "OLSR","DSDV.csv" using 1:3 with linespoints title "DSDV","DSR.csv" using 1:3 with linespoints title "DSR" 

set terminal pdf
set output "macphy.pdf"
set title "Mac Phy OVerhead"
set xlabel "Simulation Time (Seconds)"
set ylabel "Overhead"
plot "AODV.csv" using 1:22 with linespoints title "AODV", "OLSR.csv" using 1:22 with linespoints title "OLSR","DSDV.csv" using 1:22 with linespoints title "DSDV","DSR.csv" using 1:22 with linespoints title "DSR" 

WE have done the basic simulations.. and plotting of characteristics. 
Similar way , we can do it for other results also.

In the next video, I will be showcasing how to use flowmonitor for plotting the various losses, bitrates in the system or network.

python scripts to read the flowmonitors.

Thanks for watching. please share the videos to your friends and ask them to subscribe. 

Thank you....


  1. how can i count my number of neighbor in AODV using ns2.35?
    please help me
    thank you

  2. Thank you sir for this effective tutorials on VANETs. sir I need use fuzzy logic in VANETs. Can you provide some information how we can do this in ns3?

  3. Your web site is very useful for students and researchers. Thank you so much

  4. Hello Dr. Kumar!
    Congratulations of videos. Its much helping me in master´s degree.
    Health, Peace and Success.
    Thank you very much!

    ;-) Edivaldo Pastori Valentini

  5. Sir i got this error can you help me to resolve it
    /home/sarath/ns-allinone-3.29/ns-3.29/build/../src/wave/examples/ undefined reference to `ns3::AnimationInterface::~AnimationInterface()'
    collect2: error: ld returned 1 exit status

  6. Dr, plss I need your help. Am a big fan of your website. Have sent a mail but u didn't reply.

    There is code I need you to explain for me sir.

    RSA algorithm on AODV.

    This is the link to the file

  7. sir, how to find the energy spend by a node in routing process?


Post a Comment

Popular posts from this blog

ns3 installation in Ubuntu 16.04

This post serves the installation instructions of ns3 in ubuntu 16.04 version. Some of my students are working in ns3, this post will benefit them in installing ns3.

OS Used: Ubuntu 16.04.4
ns3 version: ns3 version 3.27

The same procedure will be applied for OS like Debian, Linux Mint.

Fresh installation of Ubuntu 16.04 Let you try the fresh installation of ubuntu in your hard disk along with windows.
Installation of ns3 dependencies ns3 needs so many dependencies, developmental libraries, drivers, etc. so install all those
$] sudo apt update  $] sudo apt upgrade
$] sudo apt-get install build-essential autoconf automake libxmu-dev python-pygoocanvas python-pygraphviz cvs mercurial bzr git cmake p7zip-full python-matplotlib python-tk python-dev python-kiwi python-gnome2 python-gnome2-desktop-dev python-rsvg qt4-dev-tools qt4-qmake qt4-qmake qt4-default gnuplot-x11 wireshark
The above command make take some time to download, compile and install it, Be Patient. 
Installing ns3 Download the…

TORA Protocol in NS-2.35 (NS2)

This post tells you how to enable the TORA (Temporally ordered routing Algorithm) protocol in Network Simulator 2 (ns-2.35)

TORA is a protocol in wireless adhoc networks that works with timing parameters. NS-2.35 comes with the TORA protocol by default but it has to be tweaked manually to make it run.
This post will help you to do that.

You can watch this video for detailed instructions:

Step 1: Generate a Scenario for TORA protoco using NS2 Scenario Generator NSG Software.
We have created a tcl file using NSG2.1.jar

$] java -jar NSG2.1.jar

Three files have to be modified
~ns-2.35/tora/ There are various websites that tells you how to configure TORA by making changes to the above three files.  Change 1: tora.h In the tora.h file, go to the end of the File before the agent completes, include these two lines

#include <classifier/classifier-port.h>
protected: PortClassifier *dmux_;

Change 2: Open the and include the follow…