Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tcl script for blackhole attack graph
#1

Black-[/size][/font]hole attack implemented in tcl


Hole Attack Implemented In TCL

In sample20.tcl, while simulating Blackhole attack in MANET, 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.

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.

Sample Code Segment
#Filename: sample20.tcl

# BLACKHOLE ATTACK #
# Sample two wireless mobile nodes communication -
# 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 ;# page link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 9 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 500 ;# time of simulation end

# -Event scheduler object creation #

set ns [new Simulator]

# Creating trace file and nam file

set tracefd [open sample20.tr w]
set namtrace [open sample20.nam w]

set r [open distance.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)]

# unity gain, omni-directional antennas
# set up the antennas to be centered in the node and 1.5 meters above it
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 3.65262e-10 ;
Phy/WirelessPhy set RXThresh_ 3.65262e-10 ;#250m
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0

#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 0} {$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
}

for {set i 0} {$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 source 1
set destination 2
set now 1.0
set time 3.0

set udp [new Agent/UDP]
$ns attach-agent $node_(1) $udp

set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 100
$cbr set interval_ 0.1
$cbr attach-agent $udp

set null [new Agent/Null]
$ns attach-agent $node_(0) $null

$ns connect $udp $null
$ns at $now $cbr start
$ns at [expr $now + $time] $cbr stop

$ns at [expr $now] $ns trace-annotate \ Source broadcast route request packet \

$ns at [expr $now] $ns trace-annotate \ Attacker sends false route reply to source node$source \

$ns at 1.0 $node_($source) label Source
$ns at 1.0 $node_($destination) label Destination
$ns at 1.0 $node_(0) label Attacker

$ns at 1.0 $node_($source) color blue
$ns at 1.0 $node_($destination) color blue
$ns at 1.0 $node_(0) color red

set now [expr $now+$time]
set time 10.0

set udp [new Agent/UDP]
$ns attach-agent $node_($source) $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_(0) $null

$ns connect $udp $null
$ns at $now $cbr start
$ns at [expr $now + $time] $cbr stop

$ns at [expr $now] $ns trace-annotate \ Source node transfers data to attacker $n($source-0) which does not have shorest route to Destination $destination\
$ns at [expr $now] $ns trace-annotate \ Attacker $n($source-0) does not forward data to Destination $destination creating Blackhole attack in MANET\
Reply

#2
Hole Attack Implemented In TCL

In sample20.tcl, while simulating Blackhole attack in MANET, 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.

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.

Sample Code Segment
#Filename: sample20.tcl

# BLACKHOLE ATTACK #
# Sample two wireless mobile nodes communication -
# 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 ;# page link layer type
set val(ant) Antenna/OmniAntenna ;# antenna model
set val(ifqlen) 50 ;# max packet in ifq
set val(nn) 9 ;# number of mobilenodes
set val(rp) AODV ;# routing protocol
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 500 ;# time of simulation end

# -Event scheduler object creation #

set ns [new Simulator]

# Creating trace file and nam file

set tracefd [open sample20.tr w]
set namtrace [open sample20.nam w]

set r [open distance.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)]

# unity gain, omni-directional antennas
# set up the antennas to be centered in the node and 1.5 meters above it
Antenna/OmniAntenna set X_ 0
Antenna/OmniAntenna set Y_ 0
Antenna/OmniAntenna set Z_ 1.5
Antenna/OmniAntenna set Gt_ 1.0
Antenna/OmniAntenna set Gr_ 1.0

# Initialize the SharedMedia interface with parameters to make
# it work like the 914MHz Lucent WaveLAN DSS radio interface
Phy/WirelessPhy set CPThresh_ 10.0
Phy/WirelessPhy set CSThresh_ 3.65262e-10 ;
Phy/WirelessPhy set RXThresh_ 3.65262e-10 ;#250m
Phy/WirelessPhy set Rb_ 2*1e6
Phy/WirelessPhy set Pt_ 0.2818
Phy/WirelessPhy set freq_ 914e+6
Phy/WirelessPhy set L_ 1.0

#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 0} {$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
}

for {set i 0} {$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 source 1
set destination 2
set now 1.0
set time 3.0

set udp [new Agent/UDP]
$ns attach-agent $node_(1) $udp

set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 100
$cbr set interval_ 0.1
$cbr attach-agent $udp

set null [new Agent/Null]
$ns attach-agent $node_(0) $null

$ns connect $udp $null
$ns at $now $cbr start
$ns at [expr $now + $time] $cbr stop

$ns at [expr $now] $ns trace-annotate \ Source broadcast route request packet \

$ns at [expr $now] $ns trace-annotate \ Attacker sends false route reply to source node$source \

$ns at 1.0 $node_($source) label Source
$ns at 1.0 $node_($destination) label Destination
$ns at 1.0 $node_(0) label Attacker

$ns at 1.0 $node_($source) color blue
$ns at 1.0 $node_($destination) color blue
$ns at 1.0 $node_(0) color red

set now [expr $now+$time]
set time 10.0

set udp [new Agent/UDP]
$ns attach-agent $node_($source) $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_(0) $null

$ns connect $udp $null
$ns at $now $cbr start
$ns at [expr $now + $time] $cbr stop

$ns at [expr $now] $ns trace-annotate \ Source node transfers data to attacker $n($source-0) which does not have shorest route to Destination $destination\
$ns at [expr $now] $ns trace-annotate \ Attacker $n($source-0) does not forward data to Destination $destination creating Blackhole attack in MANET\
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Powered By MyBB, © 2002-2024 iAndrew & Melroy van den Berg.