Research breakthrough possible @S-Logix

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • +91- 81240 01111

Social List

How to create Blackhole attack in MANET using NS2?


A Mobile Ad hoc Network (MANET) comprises of mobile nodes that moves independently in an open environment. Communication between the nodes in a MANET is enabled with the aid of intermediate routers. The nature of MANET such as open medium, dynamic network topology, lack of centralized monitoring, and lack of clear defense mechanisms makes it vulnerable to several routing attacks. In MANET routing, there is a high probability for intermediate nodes to be malicious that might be a threat to the security. Blackhole is the common attack in ad hoc routing in which the malicious node uses the process of routing to state itself of being the shortest path to the destination. Once it receives the data packets, it drops the data packets instead of forwarding them to its neighbors. In sample20.tcl, the blackhole attacker does not obey the communication model. Data Transmission is established between nodes using UDP agent and CBR traffic. Sender sends the data via attacker. Source node transfers data to attacker that does not have shortest route to Destination. Attacker does not forward data to its neighbors

Source Code

TCL part :

#*******Data Transmission from Source to Destination*****

set udp [new Agent/UDP]

$ns attach-agent $node_($source) $udp

set null [new Agent/Null]

$ns attach-agent $node_($destination) $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$ns at 3.0 "$cbr start"

$ns at 3.1 "$ns trace-annotate \" Data transmission from source node to destination node\""

$ns at 5.0 "[$node_(5) set ragent_] malicious"

$ns at 5.0 "$node_(5) color red"

$ns at 5.0 "$node_(5) label Attacker"

$ns at 5.1 "$ns trace-annotate \" Node_5 is malicious node which node drops the packet \""

$ns at 10.0 "$cbr stop"

C++ part :

if (malicious == true) {
if (ch->ptype_ == PT_CBR) {


Blackhole attack in MANET