+91 94 448 29 228 --- E-Mail ID:networksimulators2@gmail.com

Ns2 code for Selfish Nodes

What is selfish node?

  • Selfish node aims to save its resources to the maximum
  • Nodes that do not forward other’s packets, thus maximizing their benefit at the expense of all others.
  • It is one such attack in which a malicious node doing a routing misbehavior in the route discovery packets of the routing protocol to advertise itself as having the shortest path to the node whose packets it wants to intercept.

Sample Ns2 Code for Selfish Nodes.

MAODV_rt_entry*
MAODV_rtable::rt_lookup(nsaddr_t id)
{
MAODV_rt_entry *rt = rthead.lh_first;

 for(; rt; rt = rt->rt_link.le_next) {
   if(rt->rt_dst == id)
     break;
 }
 return rt;

}

void
MAODV_rtable::rt_delete(nsaddr_t id)
{
MAODV_rt_entry *rt = rt_lookup(id);

 if(rt) {
   LIST_REMOVE(rt, rt_link);
   delete rt;
 }

}

MAODV_rt_entry*
MAODV_rtable::rt_add(nsaddr_t id)
{
MAODV_rt_entry *rt;

 assert(rt_lookup(id) == 0);
 rt = new MAODV_rt_entry;
 assert(rt);
 rt->rt_dst = id;
 LIST_INSERT_HEAD(&rthead, rt, rt_link);
 return rt;
}
Architecture-of-selfish-nodes

Architecture-of-selfish-nodes

Characteristics of selfish node:

  • Dropping of data packets.
  • Don’t participate in routing process.
  • Don’t reply or send hello messages.
  • Intentionally delay the RREQ packets.

 


NS2 Member Accounts | |
© 2005 - 2018 Vanet Projects

© 2005 - 2018 Matlab Projects