Search This Blog

Showing posts with label AODV. Show all posts
Showing posts with label AODV. Show all posts

[ns-3] Cloning MANET Routing Protocols in ns-3

8

Labels: , , , , , , ,

This post provides a "python script" to clone AODV, DSDV, OLSR or DSR in ns-3. By cloning, we mean that an identical copy of an existing protocol is created in ns-3, but with a different name. 

Once the clone is created, you can modify it for your research work without affecting the original code of existing protocols in ns-3.

Warning: DSR cloning will work only for ns-3.25 and higher versions of ns-3!

Contributed by: Kriti Nagori and Meenakshy Balachandran, Wireless Information Networking Group (WiNG), NITK Surathkal.

Steps to create a clone:

1. Download the python script: clone-manet-routing.py

2. Place it in ns-allinone-3.xx/ns-3.xx/src directory

3. Go to ns-allinone-3.xx/ns-3.xx/src via terminal and give the following command:

chmod 777 clone-manet-routing.py

4. Give the following command to create a clone of AODV:

./clone-manet-routing.py aodv myaodv

5. Go to ns-allinone-3.xx/ns-3.xx/ via terminal and give the following commands:

./waf configure --enable-examples

./waf

You are done with it!

Note: Replace aodv by dsdv, olsr or dsr in Step 4 to clone DSDV, OLSR or DSR respectively.

Verifying the working of a clone:

1. Copy myaodv.cc from ns-allinone-3.xx/ns-3.xx/src/myaodv/examples

2. Paste it in ns-allinone-3.xx/ns-3.xx/scratch

3. Give the following command from ns-3.xx directory to run it:

./waf --run scratch/myaodv

If the command succeeds, you have successfully cloned AODV to MYAODV.

Hope it helps.

Regards,
Mohit P. Tahiliani

[ns-3] Blackhole Attack Simulation in ns-3

53

Labels: , , , , , , , ,

The patch provided in this post enables a ns-3 user to simulate "Blackhole Attack in ns-3" for Mobile Ad hoc Network (MANET) Simulations. Blackhole attack has been implemented using Ad hoc On demand Distance Vector (AODV) routing protocol.

This patch is available for:
1. ns-allinone-3.25    -  Blackhole-ns-3.25.patch
2. ns-allinone-3.24.1 -  Blackhole-ns-3.24.1.patch
2. ns-allinone-3.24    -  Blackhole-ns-3.24.patch
3. ns-allinone-3.23    -  Blackhole-ns-3.23.patch
4. ns-allinone-3.22    -  Blackhole-ns-3.22.patch
5. ns-allinone-3.21    -  Blackhole-ns-3.21.patch
6. ns-allinone-3.20    -  Blackhole-ns-3.20.patch

Patch for ns-3.20 Contributed by: Shalini Satre, Wireless Information Networking Group (WiNG), NITK Surathkal.

Material provided with this post:
1. A patch to simulate Blackhole attack in ns-3 and steps to apply that patch.
2. Sample C++ Program to ensure that the patch is applied correctly!

Follow the steps given below to apply Blackhole patch to ns-3.25:

Note: (i) Steps remain same for applying the patch to other versions of ns-3, except that you should use ns-3.xx instead of ns-3.25 wherever applicable. (ii) This blog post is updated whenever a new version of ns-3 is released.

If ns-3 is "not installed" in your machine:

1. Download ns-allinone-3.25.tar.bz2

2. Download Blackhole-ns-3.25.patch

3. Unzip ns-allinone-3.25.tar.bz2. You will get a folder named ns-allinone-3.25

4. Paste the downloaded Blackhole-ns3 patch in the above mentioned folder.

5. Give the following command:

patch -p1 < Blackhole-ns-3.25.patch

6. Go in ns-allinone-3.25 via terminal and give the following command to install ns-3.25

./build.py --enable-examples --enable-tests

You are done with it!

If ns-3 is "already installed" on your machine:

1. Paste the downloaded Blackhole-ns-3.25 patch in ns-allinone-3.25 directory.

2. Give the following command:

patch -p1 < Blackhole-ns-3.25.patch

3. Go in ns-allinone-3.25/ns-3.25 directory and give the following commands:

./waf

You are done with it!

Sample C++ Program to verify the working of Blackhole Patch:

Download the zipped folder from the link given below and extract the files from it:

sample-program-blackhole-ns3.zip

Put both the extracted files in the following folder:

ns-allinone-3.25/ns-3.25/scratch

How to use these files for verification?

I. Go to ns-allinone-3.25/ns-3.25 via terminal and give the following command:

./waf --run scratch/blackhole

You will get an output as shown below:

[Click on the Image to enlarge]

Acknowledgements: 

1. Thanks to Shalini Satre for developing this patch and providing a sample C++ Program to verify its working.

2. Thanks to ns-3 mailing list on Google Groups for their wonderful support and encouragement!

Hope it helps.

Regards,
Mohit P. Tahiliani

Blackhole Attack in ns-2

92

Labels: , , ,

The patch provided in this post enables a ns-2 user to simulate "Blackhole Attack in ns-2" for Mobile Ad hoc Network (MANET) Simulations. Blackhole attack has been implemented using Ad hoc On demand Distance Vector (AODV) routing protocol. As of now the patch will only work on ns-2.35 version! Patches for older versions of ns-2 will be provided soon.

Material provided with this post:

1. A patch to simulate Blackhole attack in ns-2.35 and steps to apply that patch.
2. Sample TCL script to demonstrate how to configure a malicious nodes.
3. AWK Script that calculates Packet Delivery Ratio (to confirm whether the code really works!)

Follow the steps given below to apply Blackhole patch to ns-2.35:

1. Download ns-allinone-2.35.tar.gz

2. Download Blackhole.patch

3. Unzip ns-allinone-2.35.tar.gz. You will get a folder named ns-allinone-2.35

4. Paste the downloaded Blackhole patch in the above mentioned folder.

5. Give the following command:

patch -p1 -t < Blackhole.patch

6. Go in ns-allinone-2.35 via terminal and give the following command (It is always recommended to be in root mode while giving the below command):

./install

If you already have an installed copy of ns-allinone-2.35, then follow the steps given below to apply the Blackhole patch:

1. Paste the downloaded Blackhole patch in ns-allinone-2.35 directory.

2. Give the following command:

patch -p1 -t < Blackhole.patch

3. Go in ns-allinone-2.35/ns-2.35 directory and give the following commands:

./configure
make clean
make
make install

You are done with it!

Sample TCL Script and AWK Script to verify the working of Blackhole Patch:

Download blackhole.tcl and pdf.awk from the links given below and keep them in the same folder:

blackhole.tcl

pdf.awk

How to use these files for verification?

I. Open blackhole.tcl and comment the following line (remember: # is used for commenting)

$ns at 0.0 "[$n5 set ragent_] hacker"

$n5 in the above line represents node 5. The word "hacker" has been used to represent "attacker". You may try making any other node as an hacker also. 

0.0 in the above line indicates that from beginning of the simulation itself, node 5 acts an attacker in the network. Blackhole attack is mainly launched during the Route Establishment phase and hence it is important to configure a node to be an attacker from the beginning of the simulation.

We comment the above line so that we can first analyze the behavior of a normal network without Blackhole attack. At a later point, we will uncomment this line and analyze the behavior of the network when it is attacked by node 5.

II. Run blackhole.tcl by giving the following command:

ns blackhole.tcl

III. Give the following command to run the pdf.awk and note down the results:

awk -f pdf.awk blackhole.tr

IV. Open blackhole.tcl again and uncomment the line which you commented earlier (i.e., this time the attacker will attack the network)

V. Run blackhole.tcl by using the same command as mentioned in Step II.

VI. Note down new results by running the pdf.awk as mentioned in Step III.

You would observe that none of the packets are delivered and ratio turns out to be zero.

You can also verify the working of the patch by observing packet drops in NAM window. Here is one snapshot which shows the same:

[Click on the Image to enlarge]

Acknowledgements: 

1. Thanks to E. Talipov's link: http://elmurod.net/en/index.php/archives/196 using which a major part of the patch has been designed.

2. Thanks to Gaurav Gupta for designing the sample TCL script named "blackhole.tcl" and also for his assistance in shaping up this patch.

3. Thanks to Knud F. L. for his crucial feedback on the design of the patch.

Hope it helps.

Regards,
Mohit P. Tahiliani

AWK Scripts for Normalized Routing Load/ Normalized Routing Overhead

49

Labels: , , , , ,

Normalized Routing Load (or Normalized Routing Overhead) is defined as the total number of routing packet transmitted per data packet.

It is calculated by dividing the total number of routing packets sent (includes forwarded routing packets as well) by the total number of data packets received.

AWK Script to calculate Normalized Routing Load for Old trace format can be downloaded from the link given below:

AWK Script for Normalized Routing Load - Old Trace Format:

nrl_ot.awk

AWK Script to calculate Normalized Routing Load for New trace format can be downloaded from the link given below:

AWK Script for Normalized Routing Load - New Trace Format:

nrl_nt.awk

If there are any problems encountered in downloading above files, please visit the link given below:

http://www.mediafire.com/?z1c2cxdt1a31d

These scripts work for AODV, DSDV, DSR and OLSR. To use these scripts for other routing protocols, just add the name of that routing protocol in appropriate loop within this script.

Note: Please report any bugs if encountered.

Hope it helps.

Regards,
Mohit P. Tahiliani

Related Blogs: 
4. AWK Scripts for NS2