Skip to main content

MANET Routing Protocols using ns3

#AODV #OLSR #MANETs #DSDV #DSR

Download the Code here: 
https://drive.google.com/open?id=1OkVOsifjN9UfQjPGvfR7OuS-x_GBRgCV

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


Comparison of MANET routing Protocols 1. AODV
2. DSDV
3. DSR
4. OLSR
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

https://www.nsnam.com 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:
/home/networks/ns-allinone-3.29/ns-3.29/examples/routing/manet-routing-compare.cc

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…

Random Number Generation using ns2

Random variables is an important concept in networks as the modeling of network traffic and other packet arrival times are mostly random models. Hence there is a necessity of modeling such metrics in ns2. NS2 supports various random models using different seed generations.

Seeds are numbers that are helpful in generating the random numbers. The seed number 0 indicates that the random number order changes every time the simulation is running. But other than 0, the order in which the random number generated are same.


The following listing 1 shows the random number generation for various distributions. This listing will just tell you how to create random number generation for various distributions. For seeing the output, refer to listing 2

Listing 1 – Random Number Generation Sample
#create the random number generation using RNG
set rand1 [new RNG]
set rand2 [new RNG]
set rand3 [new RNG]
#$repli is the value set already and it can be either 1 or <1 or >1
for {set i 1} {$i < $repli} {incr i} {
$rand1 next-substream;
$rand2 next-substream;
$rand3 next-substream;
}

Here are the distributions
Pareto Distribution
set r1 [new RandomVariable/Pareto]
$r1 use-rng $rand1
$r1 set avg_ 10.0
$r1 set shape_ 1.2

Constant – Specifies the constant number
set r2 [new RandomVariable/Constant]
$r2 use-rng $rand2
$r2 set val_ 5.0

Uniform distribution – Specifies the min and max number
set r3 [new RandomVariable/Uniform]
$r3 use-rng $rand3
$r3 set min_ 0.0
$r3 set max_ 10.0

Exponential distribution.- Specified the average value:
set r4 [new RandomVariable/Exponential]
$r4 use-rng $rand1
$r4 set avg_ 5

Hyperexponential distribution
set r5 [new RandomVariable/HyperExponential]
$r5 use-rng $rand2
$r5 set avg_ 1.0
$r5 set cov_ 4.0


The following listing 2 creates the random number generation for two different distributions uniform and exponential. The replication number is supplied through the command line option. If no replication number is supplied, it will be taken as 0 and it a value less than 1 is supplied then, it will be running with value 1. So the following example uses the replication number as 0, 1 or any higher number > 1 and it uses a seed value of 9999
The syntax for setting the seed value is

$defaultRNG seed N

Where N is a interger which may take 0 or 1 or any positive number

Listing 2 – Random number generation – Case 1
#filename : randtest1.tcl
#
# Usage: ns randtest.tcl [replication number]
#

if {$argc > 1} {
    puts "Usage: ns randtest1.tcl \[replication number\]"
    exit
}
set run 1
if {$argc == 1} {
    set run [lindex $argv 0]
}
if {$run < 1} {
    set run 1
}

# seed the default RNG
global defaultRNG
$defaultRNG seed 9999

# create the RNGs and set them to the correct substream
set arrivaldist [new RNG]
set size [new RNG]
for {set j 1} {$j < $run} {incr j} {
    $arrivaldist next-substream
    $size next-substream
}

# arrival_ is a exponential random variable describing the time between
# consecutive packet arrivals
set arrival_ [new RandomVariable/Exponential]
$arrival_ set avg_ 5
$arrival_ use-rng $arrivaldist

# size_ is a uniform random variable describing packet sizes
set size_ [new RandomVariable/Uniform]
$size_ set min_ 100
$size_ set max_ 5000
$size_ use-rng $size

# print the first 5 arrival times and sizes
for {set j 0} {$j < 5} {incr j} {
    puts [format "%-8.3f  %-4d" [$arrival_ value] \
            [expr round([$size_ value])]]
}
Here is the sample output for above file
Prompt] ~/ns-allinone-2.35/ns-2.35/tcl/ex $ ns randtest1.tcl 0
6.358     4783
5.828     1732
1.469     2188
0.732     3076
4.002     626
Prompt]~/ns-allinone-2.35/ns-2.35/tcl/ex $ ns randtest1.tcl 1
6.358     4783
5.828     1732
1.469     2188
0.732     3076
4.002     626
Prompt]~/ns-allinone-2.35/ns-2.35/tcl/ex $ ns randtest1.tcl 2
2.091     153
12.085    4732
3.588     2329
1.201     230
5.161     2980
Prompt]~/ns-allinone-2.35/ns-2.35/tcl/ex $ ns randtest1.tcl 3
2.515     1119
3.154     3118
9.673     1201
13.346    2515
7.052     2115
Prompt]~/ns-allinone-2.35/ns-2.35/tcl/ex $ ns randtest1.tcl 100
8.940     2149
0.888     4870
0.998     4860
1.801     1205
18.224    2534
Prompt]~/ns-allinone-2.35/ns-2.35/tcl/ex $ ns randtest1.tcl 0.5
6.358     4783
5.828     1732
1.469     2188
0.732     3076
4.002     626



Comments

Popular posts from this blog

Routing in VANETs using ns3

Part 1
WAVE - Wireless Access for Vehicular environments. vanet-routing-compare.cc 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. https://www.nsnam.com 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   https://www.youtube.com/watch?v=IJYeIpUqjQI&t=850s
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 (osmWebWizard.py) 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/tora.cc~ns-2.35/tora/tora.h~ns-2.35/imep/imep.cc 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: tora.cc Open the tora.cc and include the follow…