How to Create IDS in MANET in NS2

Description

In IDS.tcl, data transmission from source to destination is carried out via intermediate nodes. Attacker is configured with property of forwarding only limited number of packets. Data transmission is observed by the common neighbor called guard node that overhears the current transmission and it finds the ratio of number of packets forwarded to the number of packets received. If the ratio is low, then guard node detects the node as attacker node.

#Filename: IDS.tcl

set udp [new Agent/UDP]
$ns attach-agent $node_(0) $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_(2) $null
$ns connect $udp $null
$ns at $now "$cbr start"
$ns at [expr $now + 5.0] "$cbr stop"

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.5
$cbr attach-agent $udp
set null [new Agent/Null]
$ns attach-agent $node_(3) $null
$ns connect $udp $null
$ns at $now "$cbr start"
$ns at [expr $now + 5.0] "$cbr stop"