Sie sind auf Seite 1von 8

0

More

Next Blog

Create Blog Sign In

surajpatilworld
Thursday, 19 February 2015

About Me

suraj patil

Adding a malicious node in NS2 in AODV Protocol

Follow

Adding a malicious node is ns2 using aodv protocol. The node which is declared as malicious will
simply drop the router packet (DROP_RTR_ROUTE_LOOP).
Two files have to be modified.
1. aodv.h
2. aodv.cc
aodv.h file changes
Declare a boolean variable malicious as shown below in the protected scope in the class AODV

105

View my complete profile

Blog Archive

2015 (6)
February (5)
awk scripts for analysis of trace files in
ns2

bool malicious;

Step by step installation of ns-2.34 on


ubuntu 14....

aodv.cc file changes

Adding a malicious node in NS2 in


AODV Protocol A...

1. Initialize the malicious varible with a value "false". Declare it inside the constructor as shown
below
AODV::AODV(nsaddr_t id):Agent(PT_AODV)...
{
.......
malicious = false;
}

how to clone protocol in ns2


How to install multiple ns2 versions on
same machi...
January (1)

2. Add the following statement to the aodv.cc file in the "if(argc==2)" statment.
if(strcmp(argv[1], "malicious") == 0) {
malicious = true;
return TCL_OK;
}
3. Implement the behavior of the malicious node by setting the following code in the
rt_resolve(Packet *p) function. The malicious node will simply drop the packet as indicated below.
if(malicious==true)
{
drop(p,DROP_RTR_ROUTE_LOOP);
}
Once done, recompile ns2 as given below
Open Terminal -> Go to ~ns-2.35/ directory and type the command make to compile
$ cd /home/pradeep/ns-allinone-2.35/ns-2.35/
$ make clean
$ make
# it will take time to compile
$ sudo make install
Once the compilation is done, Check the malicious behavior using the Tcl Script by setting any
one node as malicious node. The command to set the malicious node is
$ns at 0.0 "[$n(1) set ragent_] malicious"
The variable referred for node2 is n1 (set n(1) [$ns node])
you can disable the packet dropping by adding # before above line
#$ns at 0.0 "[$n(1) set ragent_] malicious"

aodv.tcl file

converted by Web2PDFConvert.com

#======================================================================
# Define options
#======================================================================
set val(chan)
Channel/WirelessChannel ;# channel type
set val(prop)
Propagation/TwoRayGround ;# radio-propagation model
set val(ant)
Antenna/OmniAntenna ;# Antenna type
set val(ll)
LL
;# Link layer type
set val(ifq)
Queue/DropTail/PriQueue ;# Interface queue type
set val(ifqlen)
50
;# max packet in ifq
set val(netif)
Phy/WirelessPhy
;# network interface type
set val(mac)
Mac/802_11
;# MAC type
set val(nn)
6
;# number of mobilenodes
set val(rp)
AODV
;# routing protocol
set val(x)
800
set val(y)
800

set ns [new Simulator]


#ns-random 0
set f [open out.tr w]
$ns trace-all $f
set namtrace [open out.nam w]
$ns namtrace-all-wireless $namtrace $val(x) $val(y)
set topo [new Topography]
$topo load_flatgrid 800 800
create-god $val(nn)
set chan_1 [new $val(chan)]
set chan_2 [new $val(chan)]
set chan_3 [new $val(chan)]
set chan_4 [new $val(chan)]
set chan_5 [new $val(chan)]
set chan_6 [new $val(chan)]
# CONFIGURE AND CREATE 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) \
#-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace ON \
-movementTrace OFF \
-channel $chan_1
proc finish {} {
global ns namtrace
$ns flush-trace
close $namtrace
exec nam -r 5m out.nam &
exit 0
}
# define color index
$ns color 0 blue
$ns color 1 red
$ns color 2 chocolate
$ns color 3 red
$ns color 4 brown
$ns color 5 tan
$ns color 6 gold
$ns color 7 black
set n(0) [$ns node]
$ns at 0.0 "$n(0) color blue"
$n(0) color "0"
$n(0) shape "circle"
set n(1) [$ns node]
converted by Web2PDFConvert.com

$ns at 0.0 "$n(1) color red"


$n(1) color "blue"
$n(1) shape "circle"
set n(2) [$ns node]
$n(2) color "tan"
$n(2) shape "circle"
set n(3) [$ns node]
$n(3) color "red"
$n(3) shape "circle"
set n(4) [$ns node]
$n(4) color "tan"
$n(4) shape "circle"
set n(5) [$ns node]
$ns at 0.0 "$n(5) color blue"
$n(5) color "red"
$n(5) shape "circle"

for {set i 0} {$i < $val(nn)} {incr i} {


$ns initial_node_pos $n($i) 30+i*100
}
#$ns at 0.0 "[$n(1) set ragent_] malicious"
$ns at 0.0 "$n(0) setdest 100.0 100.0 3000.0"
$ns at 0.0 "$n(1) setdest 200.0 200.0 3000.0"
$ns at 0.0 "$n(2) setdest 300.0 200.0 3000.0"
$ns at 0.0 "$n(3) setdest 400.0 300.0 3000.0"
$ns at 0.0 "$n(4) setdest 500.0 300.0 3000.0"
$ns at 0.0 "$n(5) setdest 600.0 400.0 3000.0"
# CONFIGURE AND SET UP A FLOW
set sink0 [new Agent/LossMonitor]
set sink1 [new Agent/LossMonitor]
set sink2 [new Agent/LossMonitor]
set sink3 [new Agent/LossMonitor]
set sink4 [new Agent/LossMonitor]
set sink5 [new Agent/LossMonitor]
$ns attach-agent $n(0) $sink0
$ns attach-agent $n(1) $sink1
$ns attach-agent $n(2) $sink2
$ns attach-agent $n(3) $sink3
$ns attach-agent $n(4) $sink4
$ns attach-agent $n(5) $sink5
#$ns attach-agent $sink2 $sink3
set tcp0 [new Agent/TCP]
$ns attach-agent $n(0) $tcp0
set tcp1 [new Agent/TCP]
$ns attach-agent $n(1) $tcp1
set tcp2 [new Agent/TCP]
$ns attach-agent $n(2) $tcp2
set tcp3 [new Agent/TCP]
$ns attach-agent $n(3) $tcp3
set tcp4 [new Agent/TCP]
$ns attach-agent $n(4) $tcp4
set tcp5 [new Agent/TCP]
$ns attach-agent $n(5) $tcp5

proc attach-CBR-traffic { node sink size interval } {


#Get an instance of the simulator
set ns [Simulator instance]
#Create a CBR agent and attach it to the node
set cbr [new Agent/CBR]
$ns attach-agent $node $cbr
$cbr set packetSize_ $size
$cbr set interval_ $interval
#Attach CBR source to sink;
$ns connect $cbr $sink
return $cbr
}
set cbr0 [attach-CBR-traffic $n(0) $sink5 1000 .030]
$ns at 0.5 "$cbr0 start"
$ns at 5.5 "finish"
puts "Start of simulation.."
$ns run

converted by Web2PDFConvert.com

For video tutorial


https://www.youtube.com/watch?v=ca-yFicgDZs
thank you!
Posted by suraj patil at 03:25
Recommend this on Google

Labels: blackhole attack in aodv routing protocol, blackhole attack in ns2, malicious node in aodv protocol

34 comments:
Deepalakshhmi sridharan 1 March 2015 at 03:26
i use the above code but is not working 4 me.pls help asap.this is so urgent
i get the following error
num_nodes is set 6
INITIALIZE THE LIST xListHead
ns: _o44 malicious:
(_o44 cmd line 1)
invoked from within
"_o44 cmd malicious"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o44" line 2)
(SplitObject unknown line 2)
invoked from within
"_o44 malicious"
Reply
Replies
Abdullah Mukhtar 15 April 2015 at 05:02
i have also facing these type of error... if anyone have solution to these type of error
plz help us..,,,,plz share ur code for this specific email idshahir.mukhtar@gmail.com

suraj patil

15 April 2015 at 05:35

Refer this
https://www.youtube.com/watch?v=ca-yFicgDZs

Abdullah Mukhtar 16 April 2015 at 02:48

Abdullah Mukhtar 16 April 2015 at 02:49


can you please solve my problem to access remotely my pc ....if you have time to do
that...it humble request to you,,,...because i watched you video but can"t remove it.....

suraj patil

16 April 2015 at 03:23

ok.Will tell you.


Reply

suraj patil

1 March 2015 at 21:29

the above code has been tested by me and its working. Just follow the steps exactly given
above. I have provided a video tutorial also for that. I hope itll help you.
Reply

Mandeep singh 29 March 2015 at 06:14


hey,can you please help me in adding malicious node in PUMA multicast routing protocol.i'll be
really thankful to you.
Reply

John Carter 9 April 2015 at 00:00

converted by Web2PDFConvert.com

Nice post dear. I like it Omni ceiling mount antenna & gps antenna manufacturers & 4G
antenna manufacturers
Reply

Diego Rojas 23 September 2015 at 15:48


How about a nice day ..
I could tell if it's possible to clone the SAODV protocol in ns2, it's for my thesis I would
appreciate if you can help me
greetings from Ecuador
Reply
Replies
suraj patil

15 November 2015 at 06:35

Their is a another post in my blog related to protocol cloning. Refer that blog.
Reply

john harris 13 October 2015 at 23:20


Your blog is really helps for my search and amazingly it was on my searching criteria.. Thanks a
lot.
ceiling mount antenna & das antenna manufacturer
Reply

varsha 29 October 2015 at 00:14


Hello suraj,
i am M.E. student and need to implement node authentication of Wireless sensor using ECDSA
algorithm... i ahve done coding for key generation, exchange signature generation andd
verification using ECC ,, can you please help me how to use same c++ code for ns2? and also
about tcl scripts .. writing and calling etc
Awaiting for earliest reply!!!
Thanks
Varsha
Reply
Replies
suraj patil

15 November 2015 at 06:33

Refer my video tutorials. It'll help you.


Reply

V Dharman 30 October 2015 at 06:35


hello suraj,
i am working aodv in adhoc adding malicious node in aodv.cc and aodv.h file chages after make
the command is error occur its no target specified is comming what is that error sir pls help me
Reply

Miscellaneous videos 30 October 2015 at 07:24


Reply

Miscellaneous videos 30 October 2015 at 07:26


Here you used aodv protocol.
On which layer you implemented that, how should I know that?
Help please?
Reply
Replies
suraj patil

15 November 2015 at 06:32

It's routing layer attack.

converted by Web2PDFConvert.com

Reply

V Dharman 4 November 2015 at 04:19


hello suraj sir i am dharman studying in M.e -cse my project is detection and prevention of gray
hole attack in manet using aodv routing protocols...i can add malicious node in aodv.cc aodv.h
file after im try to do make cmnd but no use ..and i try to make camnd use i get make****.no
target to specified make..
make clean
make
make depend
make install
above mention the line give my terminal i get only for error...
./configure i will run means its working ...what is the that problem sir ...after that i give ns % get
percetage symbols sir its sucessfully ns2 is installed my machine....
its very urget for my project pls help me i am struck this step
Reply

V Dharman 12 November 2015 at 02:36


sir i m Dharman v please provide this error solution of this problem ...
Reply

V Dharman 15 November 2015 at 05:33


sir i m dharman sir above the code is executed but not do packet dropping sir...
Reply

V Dharman 15 November 2015 at 06:11


dharman@dharman-HP-15-Notebook-PC:~/ns-allinone-2.35/ns-2.35/aodv$ ns grayattack.tcl
num_nodes is set 6
INITIALIZE THE LIST xListHead
using backward compatible Agent/CBR; use Application/Traffic/CBR instead
Start of simulation..
ns: malicious": invalid command name "malicious""
while executing
"malicious""
what is that error sir pls help me and gcc -O2 -pipe -Wl,--export-dynamic tclAppInit.o L/home/dharman/ns-allinone-2.35/tcl8.5.10/unix -ltcl8.5 -ldl -lieee -lm \
-Wl,-rpath,/home/dharman/ns-allinone-2.35/lib -o tclsh
tcl8.5.10 make succeeded.
Installing libtcl8.5.a to /home/dharman/ns-allinone-2.35/lib/
Installing tclsh as /home/dharman/ns-allinone-2.35/bin/tclsh8.5
Installing tclConfig.sh to /home/dharman/ns-allinone-2.35/lib/
Installing libtclstub8.5.a to /home/dharman/ns-allinone-2.35/lib/
Installing message catalogs
Creating msgs
error deleting "/home/dharman/ns-allinone-2.35/lib/tcl8.5/msgs/eu.msg": not owner
while executing
"file delete -force -- $d2"
(procedure "copyDir" line 5)
invoked from within
"copyDir [file normalize [lindex $argv 0]] [file normalize [lindex $argv 1]]"
(file "/home/dharman/ns-allinone-2.35/tcl8.5.10/unix/../tools/installData.tcl" line 50)
make: *** [install-msgs] Error 1
tcl8.5.10 installation failed.
Tcl is not part of the ns project. Please see www.Scriptics.com
to see if they have a fix for your platform.
pls help me what this error sir
Reply
Replies
suraj patil

15 November 2015 at 06:31

Refer video tutorial. The link is given at the end.


Reply

V Dharman 15 November 2015 at 06:34


above mention error is ./install i will give i m getting this error sir please provide above mention
the problem....
Reply

Smartboy33 19 November 2015 at 00:39


I am trying to modify AODV routing protocol using NS 2.35. I have made some changes to the

converted by Web2PDFConvert.com

files aodv.cc and aodv.h. Now, to apply these changes I have run a **make** command inside
ns-allinone-2.35/ns-2.35 folder and getting the following error message:
In file included from aodv/aodv_logs.cc:31:0:
./aodv/aodv.h:53:18: fatal error: list.h: No such file or directory
#include
^
compilation terminated.
make: *** [aodv/aodv_logs.o] Error 1
How will I solve this?
Reply
Replies
Mona Sayed 4 December 2015 at 05:47
I changed the type of cache of DSR from mobicache to linkcache and then compiled
ns2.35 . it gives me the following error:
dsr/linkcache .cc: fatal error: list.h: no such file or directory.
Please if you find a solution send it to me : elexten1@yahoo.com
suraj have you got any suggestions to solve this error?
please help me . Thanks in advance
Reply

V Dharman 23 November 2015 at 05:49


hi suraj sir i am tired to change that error please sir what is that error
compilation terminated ..
make:****no target specified make...
Reply

Aziz aydn 29 November 2015 at 07:36


hi suraj I want to change the malicious node.how can I do.can you help me?
example
$ns at 0.5 "$cbr0 start"
$ns at 3.0 "$cbr0 stop"
$ns at 3.5 "$cbr0 start"
$ns at 0.0 "[$n(1) set ragent_] malicious2"
$ns at 0.0 "[$n(3) set ragent_] malicious"
$ns at 0.0 "$n(3) color gold"
$ns at 5.5 "finish"
Reply

V Dharman 3 December 2015 at 04:11


Sir, I have run this code with no error but i am not getting the packets dropped or i couldn't
visualize any change in the event field in trace file. Please help me with this
Reply

V Dharman 3 December 2015 at 04:12


I have changed both files..add malicious code in tcl file.still not getting proper result i.e node is
not ableto droping the packets
Reply

V Dharman 3 December 2015 at 04:15


i check whether out .tr trace file is generated comes on drooped packet .but i could not visible to
packet drop.i check whether awk is packet drooped result is =0 what is my problem .
Reply

V Dharman 5 December 2015 at 05:34


sir its coming to error in ns error in free() invalid pointer :0*0000000029c508 *** aborted (core
dumbed)what is that problem
Reply

Azeez Muhammed 24 January 2016 at 12:07


Greeting Suraj, thanks for your blog Sir. Pls I urgently need ReverseAODV tcl file and Jellyfish
code for my project. I will be glad if you can kindly assist to get these. Thanks in advance.
Reply

converted by Web2PDFConvert.com

Ravi Kumar Singh 29 April 2016 at 09:38


if(strcmp(argv[1], "malicious""?") == 0) {
malicious = true;
return TCL_OK;
}
One more parameter to be added at ?
Reply

Newer Post

Home

Older Post

Subscribe to: Post Comments (Atom)

Simple template. Powered by Blogger.

converted by Web2PDFConvert.com

Das könnte Ihnen auch gefallen