How to Launch Flooding Attack in NS2

Description

Flooding attack is characterized by sending more data than the available bandwidth. In flooding_attack.tcl, data transmission from source to destination is carried out via intermediate nodes with excessive data. Attacker drains the energy of its neighbors by sending more data than their available bandwidth.

#Filename: flooding_attack.tcl

for {set i 0} {$i < $val(nn)} {incr i} {
set now 1.0
set udp [new Agent/UDP]
$ns attach-agent $node_(2) $udp
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 1024
$cbr set interval_ 0.001
$cbr attach-agent $udp
set null [new Agent/Null]
$ns attach-agent $node_($i) $null
$ns connect $udp $null
$ns at $now "$cbr start"
$ns at [expr $now + 2.0] "$cbr stop"
}

Data flow

Flooding attack launching in NS2