What is Wormhole Attack
In aim of gaining sensitive information or disrupt the communication in the network, two attacker nodes collaboratively forms the tunnel and launches the attack known as wormhole attack.
Types and capacity of Wormhole Attack
There are two types of wormhole attacks.
- Hidden Attack
- Exposed Attack
In Hidden attack, genuine routers involved in the data transmission are unaware of the presence of malicious nodes in the path. In exposed attack, existence of the malicious nodes are known to the genuine routers but their malicious behavior is not known.
Two attackers are located in far way distance from each other and can be communicated directly with high transmission power capacity or they can communicate with each other normally in multihop manner.
How it is launched
In hidden attack case, attackers do not include their ID during the transmission of route request packet (RREQ). Hence source and destination consider themselves as direct neighbor to each other.
In exposed attack case, both attackers are located in multihop. During RREQ transmission second attackers modify the hop count field in RREQ packet to least value and pretends like both are direct neighbors so that data transmission can be initiated through them.
How it degrades the network performance
Wormhole attacker either can drop the data or redirect the data to other nodes in the network. Hence it affects the packet delivery ratio and throughput in the network. In some cases, if the wormhole attackers deliver the data to destination it will be reached with certain delay due to the creation long path by wormhole attackers.
How to create wormhole attack in NS2
Mobile Adhoc network is created with the number of nodes as run time argument. Each node is configured with wireless node configuration options. Node 0 is source and Node 1 is destination. Node2 and 3 are wormhole attackers and they are configured to be located far away from each other and Exposed attack is launched here. Routing agent corresponding to the attacker nodes are configured as wormhole1 and wormhole2. AODV routing protocol is used at the network layer. Regarding c++ part, aodv.cc file is modified in such a way that during route discovery process, attacker decreases the hopcount value in RREQ packet and also when the data is transmitted via attacker1 forwards it to attacker2 which drops the data without forwarding to nexthop or destination.
Sample code & Screenshots
TCL part:
if {$argc != 1} {
error "\nCommand: ns test.tcl \n\n "
}
# Define options
set val(chan) Channel/WirelessChannel ; # channel type
set val(prop) Propagation/TwoRayGround ; # radio-propagation model
set val(netif) Phy/WirelessPhy ; # network interface type
set val(mac) Mac/802_11 ; # MAC type
set val(ifq) Queue/DropTail/PriQueue ; # interface queue type
set val(ll) LL ; # link layer type
set val(ant) Antenna/OmniAntenna ; # antenna model
set val(ifqlen) 50 ; # max packet in ifq
set val(nn) [lindex $argv 0] ; # number of mobilenodes
set val(rp) AODV ; # routing protocol
set val(x) 1000 ; # X dimension of topography
set val(y) 1000 ; # Y dimension of topography
set val(stop) 40 ; # time of simulation end
# Event scheduler object creation
set ns [new Simulator]
# Creating trace file and nam file
set tracefd [open test.tr w]
set namtrace [open test.nam w]
set r [open Normal_path.tr w]
set s [open Wormhole_path.tr w]
set t [open Routers_Between_Wormhole.tr w]
set ad [open delayhop.tr w]
#set to [open topology.tr w]
$ns trace-all $tracefd
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
# set up topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
set god_ [create-god $val(nn)]
set chan_1_ [new $val(chan)]
#configure the nodes
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-channel $chan_1_ \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON \
set node_(0) [$ns node]
set node_(1) [$ns node]
set node_(2) [$ns node]
set node_(3) [$ns node]
#configure the nodes
$ns node-config -adhocRouting $val(rp) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-topoInstance $topo \
-channel $chan_1_ \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF \
-movementTrace ON \
for {set i 4} {$i < $val(nn)} { incr i } {
set node_($i) [$ns node]
}
# Initial node color plus labeling color
for {set i 0} {$i < $val(nn) } {incr i } {
$node_($i) color black
$ns at 0.0 "$node_($i) color black"
}
# Provide initial location of mobile nodes
$node_(0) set X_ 0
$node_(0) set Y_ 0
$node_(0) set Z_ 0.0
$node_(1) set X_ 1000
$node_(1) set Y_ 1000
$node_(1) set Z_ 0.0
$node_(2) set X_ 10
$node_(2) set Y_ 287
$node_(2) set Z_ 0.0
$node_(3) set X_ 705
$node_(3) set Y_ 944
$node_(3) set Z_ 0.0
set xx(0) 0
set yy(0) 0
set xx(1) 1000
set yy(1) 1000
set xx(2) 24
set yy(2) 258
set xx(3) 705
set yy(3) 944
for {set i 4} {$i < $val(nn) } { incr i } {
set xx($i) [expr rand()*$val(x)]
set yy($i) [expr rand()*$val(y)]
$node_($i) set X_ $xx($i)
$node_($i) set Y_ $yy($i)
}
set Sender 0
set Receiver 1
set Attacker1 2
set Attacker2 3
$ns at 0.0 "[$node_($Attacker1) set ragent_] wormhole1"
$ns at 0.0 "[$node_($Attacker2) set ragent_] wormhole2"
set udp [new Agent/UDP]
$ns attach-agent $node_($Sender) $udp
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 1024
$cbr set interval_ 0.1
$cbr attach-agent $udp
set null [new Agent/Null]
$ns attach-agent $node_($Receiver) $null
$ns connect $udp $null
$ns at 1.0 "$cbr start"
$ns at 30.0 "$cbr stop"
$ns at 0.1 "$node_(0) label Sender"
$ns at 0.1 "$node_(1) label Receiver"
$ns at 0.1 "$node_(2) label Wormhole_attacker1"
$ns at 0.1 "$node_(3) label Wormhole_attacker2"
$ns at 0.1 "$node_(0) color blue"
$ns at 0.1 "$node_(1) color blue"
$ns at 0.1 "$node_(2) color red"
$ns at 0.1 "$node_(3) color red"
# Define node initial position in nam
$ns initial_node_pos $node_(0) 70
$ns initial_node_pos $node_(1) 70
for {set i 2} {$i < $val(nn) } { incr i } {
$ns initial_node_pos $node_($i) 50
}
# telling nodes when the simulation ends
for {set i 0} {$i < $val(nn) } { incr i } {
$ns at $val(stop) "$node_($i) reset";
}
# Ending nam and the simulation
$ns at $val(stop) "$ns nam-end-wireless $val(stop)"
$ns at $val(stop) "stop"
$ns at 40.01 "puts \"end simulation\"";
#stop procedure:
proc stop {} {
global ns tracefd namtrace val
$ns flush-trace
close $tracefd
close $namtrace
exec nam test.nam &
exit 0
}
$ns run
Network Animation Result
