Research breakthrough possible @S-Logix pro@slogix.in

Office Address

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

Social List

How to add malicious node in NS2?

Description

Attacker node is configured as malicious in TCL script. Attacker node drops all the packets that passes through it. In order to do this, aodv.cc and aodv.h files in ns-allinone package should be modified. In aodv.cc file, packet drop functionality is added to the forwarder node if it is attacker. Hence when we invoke modified aodv agent to the attacker node, packet drop functionality will be carried out instead of forwarding activity.

Sample Code

#Filename: sample.tcl

puts "Enter the Attacker ID:"
gets stdin attacker
set source 0
set destination 1
$ns at 0.0 "$node_($source) label source"
$ns at 0.0 "$node_($destination) label destination"
$ns at 0.0 "$node_($source) color blue"
$ns at 0.0 "$node_($destination) color blue"
$ns at 0.0 "$node_($attacker) color red"
$ns at 0.0 "$node_($attacker) label ATTACKER"
#===================================
# Set node $attacker as attacker
#===================================
$ns at 0.0 "[$node_($attacker) set ragent_] malicious"
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_($destination) $null
$ns connect $udp $null
$ns at 1.0 "$cbr start"
$ns at 40.0 "$cbr stop"

Screenshots

Malicious Node in NS2