Skip to main content

How to add trust table in NS2.

I am assuming AODV protocol. In rtable.cc add below code


trust_entry::trust_entry()
{
   //Initialize as per your need.
}
trust_entry::~trust_entry()
{
  //Deconstruct as per your need.
}

trust_entry* trust_store::trust_lookup(
nsaddr_t node_id)
{
     trust_entry *rp = trusthead.lh_first;
     for (; rp; rp = rp->trust_link.le_next) {
             if (rp->node_id == node_id)
                 break;
     }
    return rp;
}
void trust_store::trust_delete(
nsaddr_t node_id)
{
    trust_entry *rp = trust_lookup(node_id);

    if (rp)
    {
        LIST_REMOVE(rp, trust_link);
        delete rp;
    }

}

trust_entry*
trust_store::trust_insert(
nsaddr_t node_id, nsaddr_t prev_node,nsaddr_t next_node,int32_t trust_value)
{
    trust_entry *rp;
    //assert(tr_lookup(dst_seq_no) == 0);
    rp = new trust_entry;
    assert(rp);
    rp->node_id = node_id;
    rp->prev_node = prev_node;
    rp->next_node = next_node;
    rp->trust_value = trust_value;
    LIST_INSERT_HEAD(&trusthead, rp, trust_link);
    return rp;
}

trust_entry* trust_store::trust_update(
nsaddr_t node_id,nsaddr_t prev_node,nsaddr_t next_node, int32_t trust_value)
{    trust_delete(node_id);
    trust_insert(node_id,prev_
node,next_node,trust_value);
}
In rtable.h add below code


class trust_entry
{
    friend class AODV;
    friend class trust_store;
public:
    trust_entry();
    ~trust_entry();
    nsaddr_t node_id;
    nsaddr_t prev_node;
    nsaddr_t next_node;
    int32_t trust_value;
protected:
    LIST_ENTRY(trust_entry) trust_link;
};

class trust_store
{

public:
    trust_store()
    {
        LIST_INIT(&trusthead);
    }
    trust_entry* head()
    {
        return trusthead.lh_first;
    }
    trust_entry* trust_insert(nsaddr_t node_id,nsaddr_t prev_node,nsaddr_t next_node,int32_t trust_value);
    trust_entry* trust_lookup(nsaddr_t node_id);
    void trust_delete(nsaddr_t node_id);
    trust_entry* trust_update(nsaddr_t node_id,nsaddr_t prev_node,nsaddr_t next_node, int32_t trust_value);
private:
    LIST_HEAD(trust_head, trust_entry) trusthead;
};


while using in aodv code i.e. aodv.cc add below code to aodv.h

trust_store             tstore;

and if u want to access functions for adding route entry in aodv.cc then add below code in aodv.cc
tstore.trust_insert(node_id,prev_node,next_node,trust_value);
Note:- replace above four parameters with your own. Like wise u can access update, delete and lookup.

All the best!

Comments

  1. Already its perfect but still if you had provided the screenshot of the output, it's likely to add advantage.

    ReplyDelete
  2. Please can you help me How to detect misbehaving/selfish node and ignore it from network.

    ReplyDelete
  3. Hi! Durgesh, its a good work from u.

    Can u please mail me some useful codes of ns2 related to trust model. I'm doing my project on trust model in WSN.
    So it'll be a great help from U...

    Thanks in advance


    With Regards,
    SUNIL M R
    email: sungowda2008@gmail.com

    ReplyDelete
  4. how can i add new table for AODV to store Node ID and Dest. Seq. # of multiple RREPs????

    ReplyDelete
  5. how can i store RREQ for some time of interval at destination node in AODV routing protocol?

    ReplyDelete
    Replies
    1. hi did u got some clue how to do that becoz i too need to do the same .....

      Delete
  6. Has anyone implemented Trust aware routing framework (TARF) or Reputation based framework for sensor networks (RFSN) in NS2?

    ReplyDelete
  7. Can u please mail me code of aodv modified with watchdog in ns2
    So it'll be a great help from U...

    ReplyDelete
  8. Please can you help me How to detect black hole node and ignore it from network.

    ReplyDelete
  9. Please can you help me How to detect black hole node and ignore it from network.
    if possible pls email me on krish05051990@gmail.com

    ReplyDelete
  10. hello! how to link trust table with nodes?? what changes i have to do?? in trace file i need those trust values.. how to add it??

    ReplyDelete
  11. i add this code in ns2.35 but get error in .cc file trust_store::trust_insert(nsaddr_t node_id, nsaddr_t prev_node,nsaddr_t next_node,int32_t trust_value) missing & and ?

    ReplyDelete
    Replies
    1. i am facing the same problem have u solve this problem

      Delete
  12. HI Durgesh, Pls let me knw how to generate Ddos Attack using NS2. mail it to gautamjprakash@gmail.com

    ReplyDelete
  13. you have to do ur project sir

    ReplyDelete
  14. hi durgesh, pls send me a code for path recomputing with few parameters in OLSR protocol based on TRUST in MANET using NS2. mail it to veeracharm@gmail.com

    ReplyDelete
  15. pls send me a code for path recomputing with few parameters in AODV protocol based on TRUST in MANET using NS2. mail it to veeracharm@gmail.com

    ReplyDelete
  16. can u send me code for trust value calculation based on node behavior.........

    ReplyDelete
  17. aodv/aodv.cc:1415:1: error: ‘tstore’ does not name a type
    tstore.trust_insert(node_id,prev_node,next_node,trust_value); i am geeting this error when i add last code in adov.cc file...... pls help me soon...... its urgent....... and also tell how to print the trust table.......

    ReplyDelete
  18. aodv/aodv.cc:1415:1: error: ‘tstore’ does not name a type
    tstore.trust_insert(node_id,prev_node,next_node,trust_value); pls help ne to solve this problem

    ReplyDelete
  19. Please can you help me How can create Blacklist in ns2.35 for AODV.
    I am a student and I work in the final my project. So if you do not have mind please help me. Thanks in advance...
    fawazalghfari@gmail.com

    ReplyDelete
  20. this error has occured to me,invalid command name "trust_entry::trust_entry()"
    while execinvalid command name "trust_entry::trust_entry()"
    while executing
    "trust_entry::trust_entry()"
    (file "rtable.cc" line 1)
    invoked from within
    "source.orig rtable.cc"
    ("uplevel" body line 1)
    invoked from within
    "uplevel source.orig [list $fileName]"
    invoked from within
    "if [$instance_ is_http_url $fileName] {
    set buffer [$instance_ read_url $fileName]
    uplevel eval $buffer
    } else {
    uplevel source.orig [list $fileName]
    ..."
    (procedure "source" line 8)
    invoked from within
    "source rtable.cc"
    (file "aodvattacker.tcl" line 61)uting
    "trust_entry::trust_entry()"
    (file "rtable.cc" line 1)
    invoked from within
    "source.orig rtable.cc"
    ("uplevel" body line 1)
    invoked from within
    "uplevel source.orig [list $fileName]"
    invoked from within
    "if [$instance_ is_http_url $fileName] {
    set buffer [$instance_ read_url $fileName]
    uplevel eval $buffer
    } else {
    uplevel source.orig [list $fileName]
    ..."
    (procedure "source" line 8)
    invoked from within
    "source rtable.cc"
    (file "aodvattacker.tcl" line 61)
    were to use this rtable.cc,rtable.h in linux ns2 code

    ReplyDelete
  21. sir i ma working in aodv routing aodv .cc and aodv.h can be modified after make comand is get error make:****no target specified make stop.
    make clean
    make:****no target specified make stop.
    make depend
    make:****no target specified make depend stop.
    make sudo install
    make:****no target specified make sudo stop.
    how to solve thsis error

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. cd installing ns-2.35 /ns-2.35 then execute make

      Delete
  22. i need a code for trust value for sinkhole nodes in manet please mail me
    mail id: ajothimani05@gmail.com

    ReplyDelete
  23. hello sir how to link trust table with nodes?? what changes i have to do?? in trace file i need those trust values.. how to add it??

    ReplyDelete
  24. please mail me the trust based aodv in ns2 for sinkhole nodes sir please help me sir

    ReplyDelete
    Replies
    1. drop me a mail at durgeshpkshirsagar@gmail.com

      Delete
  25. I am working on trust and energy aware routing protocol.. Please, Help me sir. I want code for this trust based aodv.

    ReplyDelete
  26. sir how to initialise i am a beginner pls help

    ReplyDelete
  27. sir pls provide me code for round trip time calculation and trust value of node
    email - tejashreephatak786@gmail.com

    ReplyDelete
  28. Hi,
    how to add node trust certificate in ns2? i need to have node authentication for my simulation..and need to generate certificate for each node with some parameters.

    ReplyDelete
  29. Dear sir,
    can you sand me all the file in which you have done all changes for implementation of trust based AODV.
    please it's really very urgent.
    thanks in advance!!
    my mail id: itssubhashsingh@gmail.com

    ReplyDelete
  30. How are you?
    can you send me all the file in which you have done all changes for implementation of trust based AODV?
    My mail id is klaudiadiah@gmail.com

    ReplyDelete
  31. sir i m working on sybil attack can u help me how to create a sybil node in ns2 and how to detect and prevent it. u can email me at waqasjunaid1@gmail.com

    ReplyDelete
  32. Sir can u please help me how to avoid black hole attack in ns2

    ReplyDelete
  33. sir can u pls send me ccode for trust calculation in ns-2.35.urgent pls.....mail me at shyamalajinju@gmail.com

    ReplyDelete
  34. hello,
    i use all the steps mentioned above but i am getting Segmentation fault (core dumped) error. Can any one tell me the solution

    ReplyDelete
    Replies
    1. if someone have proper code then lease mail me at anaccna@gmail.com

      Delete
  35. tstore.trust_insert(node_id,prev_node,next_node,trust_value);
    how to give values of node_id, prev_node,next_node nad trust_value? please help me

    ReplyDelete
  36. my mail id is gethzi.akila@gmail.com

    ReplyDelete
  37. I wanted to implement Black Hole Attack Prevention Method Using
    Dynamic Threshold in Mobile Ad Hoc Networks, can someone help me with its AODV NS2 Codes. my email is christopher1ermwaka@gmail.com

    ReplyDelete

Post a Comment

Popular posts from this blog

How to use promiscuous mode in AODV NS2

Introduction:-           In Promiscuous mode each node in the network listens the packets transmitted by its own neighbor nodes.            In NS-2, some time we have to calculate the packet drops or analyze the process. For the same we need to set the network to operate in promiscuous mode. Here, I am going to explain how we can set our wireless network in promiscuous mode with AODV as Routing protocol using NS2 simulator. 1) We need to modify in total 3 files, so it's good to take a backup of it.     Files are: ns-allinone-2.34/ns-2.34/aodv/aodv.cc ns-allinone-2.34/ns-2.34/aodv/aodv.h ns-allinone-2.34/ns-2.34/tcl/lib/ns-mobilenode.tcl 2) Open the file ns-allinone-2.34/ns-2.34/aodv/aodv.h in your favorite editor     and make the changes as shown in blue color.   #include <mac.h>   class AODV: public Tap, public Agent {   public:   void tap(const Packet *p);   ......   protected:   Mac *mac_;   ......  }

Runtime packet loss calculation in NS2

Hello friend, here I am going to present a method to calculate the runtime packet loss. I am going to show this using ns2 2.34 and AODV.       Sometime we require packet loss to calculate trust value (in case of Trust Based protocols where it is done by no. of packets sent - no. of packets received).        I am going to show the calculation for a particular pair of nodes. Steps involved:- A) We will have to add a node as a malicious node which will drop the packets      intentionally. You can add a malicious node using this link. B) Second, we'll set the AODV in promiscuous mode, where every node will      listen to its neighbors. 1) We need to modify in total 3 files to set AODV in promiscuous mode, so it's     good to take a backup of it.     Files are: ns-allinone-2.34/ns-2.34/aodv/aodv.cc ns-allinone-2.34/ns-2.34/aodv/aodv.h ns-allinone-2.34/ns-2.34/tcl/lib/ns-mobilenode.tcl 2) Open the file ns-allinone-2.34/ns-2.34/aodv/aodv.h in your favorite edito