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.
#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"