This repository contains a specialized implementation of the Optimized Link State Routing (OLSR) protocol for the NS-3 Network Simulator. It is designed for Network Layer Security research within Mobile Ad-hoc Networks (MANETs).
Modified by Oded Ofek (2025), this version introduces a sophisticated Blackhole Attack and Link Spoofing capabilities directly into the core protocol logic. By manipulating both the Control Plane and the Data Plane, a malicious node can effectively position itself as a central routing hub and silently discard network traffic.
The implementation utilizes four distinct techniques to compromise the network topology and disrupt data delivery:
In standard OLSR, nodes select Multi-Point Relays (MPRs) based on their advertised willingness to forward traffic.
- Modification: When the
IsMaliciousattribute is enabled, the node overrides its default willingness. - Implementation: The node sets its
Willingnessfield toWILL_ALWAYS(value 7) in all outgoingHELLOmessages. - Impact: According to RFC 3626, neighbors are forced to prioritize this node as an MPR, ensuring the attacker is included in nearly all routing paths.
The Advertised Neighbor Sequence Number (ANSN) is used by nodes to verify the freshness of topology information.
- Modification: The attacker artificially manipulates the sequence number arithmetic.
- Implementation: In the
SendTcfunction, the attacker increments the ANSN by a large offset (+200) before broadcasting updates. - Impact: Neighboring nodes perceive the attacker's topology information as significantly newer than legitimate updates, causing valid routing table entries to be overwritten by the malicious path.
- Modification: The node advertises symmetric links with non-existent (phantom) neighbors.
- Implementation: The node generates
HELLOmessages containing fake IP addresses (starting from200.0.0.1/0xC8000001) with aSYM_LINK/SYM_NEIGHstatus. - Impact: This artificially inflates the node's degree of connectivity. Pathfinding algorithms like Dijkstra will perceive the attacker as the most efficient "short-cut" for traffic, attracting flows from across the network.
- Modification: Interception and destruction of transit traffic.
- Implementation: Within the
RouteInputfunction, if the node is malicious, it intercepts unicast packets destined for other nodes. - Impact: The protocol returns
true(signaling successful processing) but intentionally fails to invoke theUnicastForwardCallback. Packets are dropped from memory without generating ICMP error messages, making the attack difficult to detect through standard diagnostic tools.
The source files are organized to mirror the standard NS-3 module tree for seamless integration:
| File | Description |
|---|---|
olsr-routing-protocol.h |
Defines the m_isMalicious flag and m_spoofedLinksCount attribute. |
olsr-routing-protocol.cc |
Implements the attack logic in SendHello, SendTc, and RouteInput. |
README.md |
Comprehensive documentation of the implementation. |
- A working installation of NS-3 (v3.35 or higher recommended).
- Basic knowledge of compiling NS-3 using the
./ns3build system.
- Backup your original OLSR files located in
src/olsr/model/. - Copy the modified
olsr-routing-protocol.handolsr-routing-protocol.ccfrom this repository intosrc/olsr/model/. - Rebuild the simulator:
./ns3 build
You can dynamically enable or disable the attack behavior in your NS-3 simulation scripts using the attribute system:
Ptr<Node> node = nodes.Get(5);
Ptr<olsr::RoutingProtocol> protocol = node->GetObject<olsr::RoutingProtocol>();
protocol->SetAttribute("IsMalicious", BooleanValue(true));
protocol->SetAttribute("SpoofedLinksCount", UintegerValue(15));🔧 Configurable Attributes
IsMalicious Boolean flag to toggle Blackhole behavior, ANSN poisoning, and Willingness manipulation.
SpoofedLinksCount Number of fake symmetric neighbors advertised in HELLO messages.
This implementation is intended strictly for academic and research purposes, such as evaluating protocol vulnerabilities or testing Intrusion Detection Systems (IDS). Unauthorized use of these techniques in real-world environments is prohibited...