Skip to main content

MANET Routing Protocols using ns3


Download the Code here:

Check the Video for Detailed instruction and how to use the plots, graphs and source code.

Comparison of MANET routing Protocols 1. AODV
3. DSR
using NS3 (Network Simulator 3)
B.Tech, M.Tech, PhD...
1. Reactive Vs Proactive routing
2. PErformance comparison of MANET protocols
3. AODV Vs DSDV Comparison and also at my channel.

What Version: ns-3.29
My Ubunut OS is: Ubuntu 18.04

This file we are going to use for our simulation:

Once you under stand the code, now lets run this example

Step 1: Copy the above file in to ~ns-3.29/scratch/ folder

Step 2: Understand this code.
Step 3: Run this code
Open the terminal, Go to ns-3.29 and run the following command

$] ./waf --run scratch/manet-routing-compare

enable the following header file

#include "ns3/flo…

RIOT OS (An Operating System for IoT)


The Internet of Things (IoT) is used with heterogeneous devices. They range from 8 bit to 32 bit microcontrollers from different manufacturers. Traditional Operating system (OS) or the conventional embedded OS may not suit the requirements that these tiny devices demand (low power, small in size and low memory foot print). RIOT Operating system is a free and open source arachtiecture which is friendly to IoT applications and proved to be a perfect OS for IoT Systems.
It started in the year 2008 as an Operating system for Wireless Sensor nodes, later the OS is fine tuned for IOT systems.

Features of RIOT

The OS is actively developed and maintained.
  • There are no new programming environments, C or C++ can be used directly with existing tools like gcc, gdb, etc.
  • Less hardware dependent code
  • Supports 8,16 ad 32 bit microcontroller platforms
  • Energy efficieny is maintained
  • less interrupt latency, so real time capability is ensured
  • multi threading is enabled
  • Supports the entire Network Stack of IoT (802.15.4 Zigbee, 6LoWPAN, ICMP6, Ipv6,RPL, CoAP, etc)
  • Both static and dynamic memory allocation
  • POSIX complaint (Partial)
  • All output can be seen the in terminal if hardware is not available, however there is a visualization tool called RIOT-TV is provided 
  • MSP430 
  • ARM7 
  • Cortex-M0, M3 ,M4
  • x86, etc
  • Radio receivers
  • Environmental sensors like humidity, temperature, pressure, alcohol gas sensors
  • accelerometer
  • gyroscopes
  • ultrasonic sensors, light and servo motor

Contiki OS
Tiny OS
Minimum RAM and ROM needed
C and C++ Support
No support (nesc)
Full support
Multi threading
No (protothreads are used here)
Real Time
  • msp 430 GCC compiler 
  • msp 430 libraries
  • avr utils,
  • arm based gcc 
  • gcc multilibrary
  • etc

Architecture, Board and Driver Support

It supports various architecture like
and it supports the native port, where one can simulate the output within the OS it was running. So RIOT is supported in Linux as well as OS X.
There are in built drivers for the following sensors (without a need of hardware, these sensors can be modeled in native mode also)
Most of the sensor boards have support from this OS like TelosB, ST Microcontroller sensor boards, Zolertia, MSP 430 boards,Aruduino sensors, Atmel, and the list is so huge.
It also support virtualization that the code and application can run as a simple unix process. It also uses wireshark for packet sniffing.

Comparison with Contiki OS and Tiny OS

There are other two OS called Contiki OS (Already featured in OSFY) and Tiny OS which are suitable for IoT applications. But RIOT takes an upper hand in terms of memory usage and support.
The following table shows the comparision between these OS
Table 1: Comparison of various OS for IoT
Figure 1 and Figure 2 represents the block and Network stack diagram of IoT. Except for RPL, all the modules have the support from RIOT OS (for RPL alone, there is a partial support from RIOT)
Network Stack for IoT
Network Stack for IoT

Component of IoT
Component of IoT

Installation of RIOT in LinuxOS Used for installing : Linux Mint 17.2 and Ubuntu 14.04.2Architecture used: 64 bit OSInstalling RIOT needs lot of packages that are prerequisites like
Assume if you have installed just now, follow the steps to install

pradeepkumar $] sudo apt-get update
pradeepkumar $] sudo apt-get install libc6-dev-i386 build-essential binutils-msp430 gcc-msp430 msp430-libc libncurses5-dev openjdk-7-jre openjdk-7-jdk avrdude avr-libc gcc-avr gdb-avr binutils-avr mspdebug msp430mcu autoconf automake libxmu-dev gcc-arm-none-eabi openocd git bridge-utils gcc-multilib socket
The OS can be downloaded as a zip file from github ( , else you can clone it using the following command
pradeepkumar $] git clone

The folder RIOT/ or RIOT-Master/ contains various subfolders
->boards  (This folder has all the drivers for the boards that are supported by the OS)
->cpu (this folder contains the architecture supported by RIOT)
  ->cores  (Core of the OS like kernel, modules, etc)
->doc (Documentation)
->examples (some examples like hello word, border router, Ipv6 formation, etc)
->drivers (drivers for all the sensors)
Simple Example
These type of Operating systems can be learnt only through the examples given within the source code of the application. This OS has some examples in the examples/ folder and one can go through the source code and run it using the following method. There are more examples available in the github of RIOT (
If sufficient board or hardware is not available, then the code can be run in the terminal itself (native mode)
To run the hello-world example from the examples folder

pradeepkumar $] cd RIOT-Master/examples/hello-world
pradeepkumar $] make flash
pradeepkumar $] make term 
Running a hello-world example
Running a hello-world example

hello world application run in the terminal
hello world application run in the terminal

RIOT native interrupts/signals initialized.
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: UNKNOWN (builddir: /home/pradeepkumar/RIOT-master))
Hello World!You are running RIOT on a(n) native board.
This board features a(n) native MCU.
Press Ctl+C to quit the application
make flash will compile and show the text and data size occupied by the memory. Since this application is run under native mode, the output can be viewed using make term command.
Networking Applcation in RIOT
There are few number of applications avaiable in RIOT. One such application is a socket application which works with the POSIX API with UDP as the protocol. All the relevant source codes are avaialble in the directory itself
pradeepkumar $ ] cd RIOT-Master/examples/posix-socket/
pradeepkumar $ ] make flash
pradeepkumar $ ] sudo make term
output of the above command
/home/pradeepkumar/RIOT-master/examples/posix_sockets/bin/native/posix_sockets.elf tap0
RIOT native interrupts/signals initialized.
RIOT native board initialized.
RIOT native hardware initialization complete.
main(): This is RIOT! (Version: UNKNOWN (builddir: /home/pradeepkumar/RIOT-master))
RIOT socket example application
All up, running the shell now
> help

posix in riot
POSIX Application

udp                  send data over UDP and listen on UDP ports
reboot              Reboot the node
ps                   Prints information about running threads.
random_init          initializes the PRNG
random_get          returns 32 bit of pseudo randomness;
ifconfig             Configure network interfaces
txtsnd               send raw data
ncache              manage neighbor cache by hand
routers              IPv6 default router list
Figure 5 shows the above configuration: Routers can be configured, txt messages can be sent, running processes details can be found out, etc can be done using the application

There are only limited number of Operating systems available for the IoT sensors and among these OS, RIOT really has a well documented API with huge support for most of the boards, architecture and sensors. The main advantage being, RIOT is actively developed and maintained, there is a incremental version every month.  Students and electronic hobby enthusiasts are using arduino and Raspberry Pi for their IoT applications these days, RIOT really help these boards and sensors to achieve low memory footprint and low energy efficiency without any compromise on the performance of the IoT Systems.

NB: This article is published in the "Open Source for You Magazine" February 2016 Edition.


Popular posts from this blog

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 t…

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…