Settting up selfish nodes on AODV protocol

232 views
Skip to first unread message

Shanen Leen

unread,
May 6, 2017, 12:18:29 PM5/6/17
to ns-3-users
Hi,

I want to use AODV protocol to simulate some selfish/malicious(Drop packets with some probability/drop all the packets) nodes in a MANET.
I have gone through this thread and came up with following. Source files are also attached.

--- aodv-routing-protocol.h
Added a boolean field IsMalicious along with getters and setters.

--- aodv-routing-protocol.cc
In RoutingProtocol::GetTypeId(void) method, I've added

.AddAttribute("IsMalicious", "Is the node malicious",
BooleanValue(false),
MakeBooleanAccessor(&RoutingProtocol::SetMaliciousEnable,
&RoutingProtocol::GetMaliciousEnable),
MakeBooleanChecker())

And at the end of RoutingProtocol::RouteInput(...) method,
       if (GetMaliciousEnable()) {
std::cout << "---Malcious Node: Packet dropped\n";
return false;
}
else {
        // Forwarding
        return Forwarding(p, header, ucb, ecb);
        }

I just wanna drop the packet if the node is malicious.


As the simulation script I've used the example "manet-routing-compare.cc" and tweaked it.
-Made AODV as the protocol by setting "m_protocol(2)" in the RoutingExperiment::RoutingExperiment() constructor.

In the script's RoutingExperiment::Run(..) method, I have 3 node containers(One for all nodes, one for malicious, one for good nodes).
Then I created 2 AodvHelpers. First one create good nodes. On the second helper I'm calling Set("IsMalicious", BooleanValue(true)).

Then on the "InternetStackHelper" I'm calling,
internet.SetRoutingHelper(aodv);
internet.Install(goodNodes);

internet.SetRoutingHelper(maliciousAodv);
internet.Install(malNodes);


After all I'm not getting the "---Malcious Node: Packet dropped" message. And there's no increase no. of packets dropped in the FlowMonitor output either.
Can someone help me to figure out the issue here.

Thanks!
manet-routing-compare.cc
aodv-routing-protocol.cc
aodv-routing-protocol.h

Tommaso Pecorella

unread,
May 6, 2017, 7:06:47 PM5/6/17
to ns-3-users
I don't see any malicious node in your script:

 for (x = 0; x < nGoodNodes; x++) {
   goodNodes
.Add(adhocNodes.Get(x));
 
}

 
for (; x < nWifis; x++) {
   goodNodes
.Add(adhocNodes.Get(x));
 
}

T.

Shanen Leen

unread,
May 6, 2017, 11:10:43 PM5/6/17
to ns-3-users
Thanks Tommaso. 
Now I get the expected behavior.

For anyone who will see this in future,
Just change "goodNodes" in the second loop to "malNodes".

bekha Km

unread,
Jan 27, 2019, 4:36:03 AM1/27/19
to ns-3-users
may I get ur help sir?
here is my mail id bekan...@gmail.com don't hesitate to contact me!
Reply all
Reply to author
Forward
0 new messages