Skip to main content


Showing posts from December, 2018

Mannasim Installation in NS2 - NS2 Tutorial # 18

Real Time Vehicular Traffic Simulation Using SUMO and OpenStreetMap - NS...

Its about the VANET simulation using SUMO with Open Street Map. and the entire simulation is ported to ns2 for packet tracing and network animation.

Please check my website for any source codes.
Also Subscribe to my channel and share it.

Subscribe to My Youtube Channel - Engineering Clinic

VANET Simulation using SUMO and MOVE - NS2 Tutorial # 16

Its about generating a tcl script for VANET Simulations using SUMO and MOVE software. It uses Sumo 0.12.3 version for creating the xml files
Also a new Video similar to this, but latest OS, no issues in creating a traffic.

Subscribe to My Youtube Channel - Engineering Clinic

LEACH Protocol in ns2 - NS2 Tutorial # 15

LEACH (MIT uAMPS) Protocol in ns-2.35
This video is about the installation instructions for LEACH protocol in ns-2.35. It tells you the complete instruction on how to start and where to start.

Subscribe to My Youtube Channel - Engineering Clinic

Congestion Control in TCP using NS2 - NS2 Tutorial # 14

Congestion Control in TCP using NS2

Subscribe to My Youtube Channel - Engineering Clinic

How to add a Protocol in ns2 - NS2 Tutorial #13

How to add a new protocol in ns2
I am going to use the version ns-2.35

protoname was one of the best unicast routing protocol for ns2.


Protoname -| Simp
protoname -| simp

you can download teh source code from

There are totally 5 files in the source code converted to
protoname.h -| simp.h
protoname_pkt.h -| simp_pkt.h -|
protoname_rtable.h -| simp_rtable.h

In this new protocol, we have to
1. Add the source code (the 5 files given above)
2. existing code modification (within ns2)
3. Make an entry in the
4. Recompile ns2
5. Test the protocol using a TCL file.

Addition of source code is done.

Existing code modification - Very important.

in ns2, inforamtion about compilation is scattered... we need to make modifications at multiple locations. What are the files that are needed for modification.

all the file locations are here.

To add a packet data

Blackhole attack in ns2 - NS2 Tutorial # 12

How to add a black hole attack in AODV protocol in ns2.

You can download the source codes.

Black hole is the basic attack in a network, here we are going mitigate this attack in ns2.

Trust value, based on the trust value, if the value is less, then we can make it as an attacker node.

High trust, medium trust and low trust (integer)

Trusted or not (boolean)

To make a node attacker node (preferanly a black hole attack, how to do that?)

AODV protocol as it is easy to implement in ns2.

Step 1: Declare the attacker variable
We will two files aodv.h and files
in aodv.h file,
create a variable name as given below in the protected scope

bool attacker;

Step 2: initialize the attacker variable as false.
In file, initialize the attacker to be false inside the constructor.

Step 3: if a node is a blackhole, what happens to attacker value
in the command() function of file inside the block
if(argc==2), include the following lines


AODV simulation in NS2 (Part 1) - NS2 Tutorial # 11

Detailed Explanation of AODV protocol.
Lecture 11 - AODV - Part 1
Todays topic on AODV protocol

AODV - Adhoc Ondemand Distance Vector

the location of the source code for Aodv is in the folder

My suggestion is
Always try to understand the header file first.. later you can move on to source file (.cc files)

I will go through aodv.h file first and then file next....
let me explain....

I should know where my work is residing, for example in AODV

should I work on

Routing Table
Energy Management
Quality oif Service
Link Failure
Logs or tracing
Neighbour management
Attacks (Black hole, gray hole, etc...)

so prefer to stay at the header files first...

Now the action begins.

how do i modify the AODV protocol as per my small piece of algorithm...

I would like to print the nodes that are forwarding the packets.

Two information will be recorded in a text file separately..

Name of the file: aodv_output.dat
data recorded will be: forwarded packet, node index (…

Creation of a New Agent in ns2 - NS2 Tutorial # 10

We know that the file is stored in the folder

Open the file ns-2.35/
and make an entry of your own file (in this case, it is

Find a vairable inside the called
and make an entry there as shown below

pradeep/tspagent.o \

Save the file and open a terminal, go to the folder ~ns-2.35/ and execute the command one by one

$] ./configure
$] make

Correct any mistakes or errors in your .cc file and run the above commands.

Successful OTcl and C++ linkages....

Thank you and Stay tuned for more lectures

Next lecture will be on AODV protocol and its modification.

Refer my website for downloading the source code and refer my videos at
share and subscribe.

Thank you......

Subscribe to My Youtube Channel - Engineering Clinic

Performance Evaluation of Adhoc Routing Protocols in ns2 - NS2 Tutorial...

PErformance Evaluation of Adhoc Routing Protocols using NS2

Very old Project as well as a topic, but this will give an idea of how to compare multiple protocols or agents.

1 hour Project*

* - you should know ns2 already
should know how to write AWK scripts
Should know about energy model
Should know about wireless networks and protocols

To know the above concepts, check my Ns2 Lecture series videos in Youtube and come back to this video

AODV - Adhoc On Demand Distance Vector
DSDV - Destination Sequenced Distance Vector
DSR - Dynamic Source Routing

Lcture 8 - AWK Scripts
Average throughput
Instant throughput
Residual Energy
Packet Delivery ratio

To download the source codes, visit

Going inside the project

Step 1:
Use the same network and same disntace, energy, etc when you compare multiple protocols

Step 2:
Generate Scenario, You need not write the code in TCL (of course you can modify).
We use NSG for creating a…

AWK Scripts for NS2 - NS2 Tutorial # 8

AWK Scripts for ns2
This is one of the important in ns2 as we are going to analyse the performance metrics of the network

In this session, we are going to see the following metrics.

1. Average Throughput
2. instant Throughput
3. Packet Delivery Ratio
4. Residual Energy of the nodes.

A - Aho
W - Weinberger
K - Keninghan

Easy to implement and process.




In ns2, new trace format, there could be as many as 52 columns. Each column specify some parameters. Viewers are requested to go through these parameters through the documentation.

in aAWK,
$1 refers 1st column
$2 refers 2nd column and so on...

awk can be run using either of these commands

$] awk -f filename.awk

$] gawk -f filename.awk

Average throughput is done

you can download this source code in

Instant Throughput

with two values to plot the characteristics.

Residual Energy of the individual nodes AND ALSO THE AVERAGE RESIDUAL ENERGY OF ALL NODES.

We have seen…

Energy Model in ns2 - NS2 Tutorial # 6

This video shows how to implement energy Model in ns2. The following six lines are crucial in mentioning energy in ns2. These lines are added to the node-config parameter. Refer for downloading the source code.

-energyModel "EnergyModel" \
-initialEnergy 3.0 \
-txPower 0.9 \
-rxPower 0.5 \
-idlePower 0.45 \
-sleepPower 0.05 \

Subscribe to My Youtube Channel - Engineering Clinic

Wireless network Coding in ns2 - NS2 Tutorial # 5

Wired Network Coding in ns2 - NS2 Tutorial # 4

Before starts this video, go to this link and learn the design of this network

Its about Wired network coding in TCL in ns2. Its is step by step instruction that shows the complete source code of tcl and the network animation and trace file.
Refer to Lecture 3 - wired Network design for complete information on how to design a network

Subscribe to My Youtube Channel - Engineering Clinic

Installation of NS2 in Ubuntu 18.04 - NS2 Tutorial # 2

ns2 installation in ubuntu 18.04

$] tar zxvf ns-allinone-2.35.tar.gz

$] sudo apt install gcc-4.8 g++-4.8

Subscribe to My Youtube Channel - Engineering Clinic

if you have installed ubuntu just now, you can try these commands also in the beginning

$ sudo apt update
$ sudo apt install build-essential autoconf automake libxmu-dev

$ cd ns-allinone-2.35/ns-2.35
$ gedit
$ gedit linkstate/ls.h

$ cd ..
$ ./install

export PATH=$PATH:/home/pradeepkumar/ns-allinone-2.35/bin:/home/pradeepkumar/ns-allinone-2.35/tcl8.5.10/unix:/home/pradeepkumar/ns-allinone-2.35/tk8.5.10/unix
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pradeepkumar/ns-allinone-2.35/otcl-1.14:/home/pradeepkumar/ns-allinone-2.35/lib

Introduction to NS2 - NS2 Tutorial # 1

Its about introduction to network simulator 2. Its gives information on basics of linux, basics of ns2 and its architecture.

It also tells how to write a basic OTCL Code.

Stay tuned for more lectures and workouts.

Subscribe to My Youtube Channel - Engineering Clinic