Search This Blog

[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