Blackhole Attack Mitigation in AODV Protocol Using NS3 (v3.44) on Ubuntu 24.04

Are you a network security researcher or student exploring wireless network vulnerabilities? This post walks you through how to mitigate blackhole attacks in the AODV routing protocol using NS-3 (Network Simulator 3), specifically version ns-3.44 on Ubuntu 24.04. We’ll also guide you on modifying key NS3 source files and provide insights on testing your implementation.

๐Ÿ“บ Watch the full setup and demo on my YouTube channel for step-by-step video instructions.

๐Ÿ› ️ Tools and Environment

  • Network Simulator: NS-3.44

  • Operating System: Ubuntu 24.04 (64-bit recommended)

  • Routing Protocol: AODV (Ad hoc On-Demand Distance Vector)

  • Attack Type: Blackhole Attack in Wireless Ad Hoc Networks

๐Ÿšจ What Is a Blackhole Attack in AODV?

A Blackhole Attack occurs when a malicious node in a wireless network advertises itself as having the shortest path to all destinations, causing data packets to be misrouted and dropped. This is a critical vulnerability in AODV-based MANETs (Mobile Ad hoc Networks).

To download the source code: 

https://github.com/tspradeepkumar/ns3_blackholeAttack/

Step-by-Step Instructions to Implement Blackhole Mitigation

✅ Step 1: Modify AODV Protocol Source Files

You need to replace the default AODV implementation with your custom one that includes blackhole attack detection and mitigation logic.

Files to Replace:

  1. aodv-routing-protocol.cc

  2. aodv-routing-protocol.h

Destination Folder:

~/ns-allinone-3.44/ns-3.44/src/aodv/model/

⚠️ Important: Backup the original files before replacing them.

✅ Step 2: Rebuild NS3 with the New AODV Implementation

Open your terminal and run the following commands to configure and build NS3:

$ cd ~/ns-allinone-3.44/ns-3.44
$ ./ns3 configure --enable-examples --enable-tests $ ./ns3 build

This compiles NS3 with your modified AODV protocol, now capable of detecting and mitigating blackhole attacks.


✅ Step 3: Test the Blackhole Attack Simulation

Create and copy two new source files for testing:

  1. blackhole.cc – Main file to simulate the blackhole scenario

  2. myapp.h – Supports UDP-based communication for traffic generation

Destination Folder:

~/ns-allinone-3.44/ns-3.44/scratch/

After placing the files, run the simulation and observe the results.


๐Ÿ“Š Output Results: Blackhole Attack Mitigation in Action

Without Blackhole Attack:

  • Packets Sent = Packets Received

  • No Packet Loss

  • Ideal behaviour of a secure wireless network

blackhole attack
Without a blackhole attack


With Blackhole Attack:

  • Packets Dropped

  • Received Bytes < Transmitted Bytes

  • Indicates data interception or loss due to malicious nodes

blackhole attack
With a blackhole attack


๐Ÿ“ˆ Flow Analysis – Flow ID vs Delay:

You can also analyse FlowMonitor output to study how delay varies across flows in both attack and mitigation scenarios.

blackhole attack
Blackhole attack flow

๐Ÿ“บ Watch the Complete Video Tutorial 

  • Blackhole Attack NS3

  • AODV Protocol NS3 Simulation

  • NS-3.44 Blackhole Mitigation

  • Wireless Network Security Ubuntu

  • Mobile Ad Hoc Network Attack Detection

  • How to Detect Blackhole Attack in AODV

  • NS3 Blackhole Simulation Tutorial

  • Secure AODV Routing in NS-3


Comments

Popular posts from this blog

Installing ns3 in Ubuntu 22.04 | Complete Instructions

How to Create Ubuntu 24.04 Bootable USB Using Rufus [Step-by-Step Guide]

Installation of NS2 in Ubuntu 22.04 | NS2 Tutorial 2