hi, 
 

I want to record the node's neibor count:

 

my try:

step 1: add a variable in aodv.h,used to record the numbers of neighbors,i 
modify the code as follows:

aodv_rtable         rthead;                 // routing table

        aodv_ncache         nbhead;                 // Neighbor Cache

        aodv_bcache          bihead;                 // Broadcast ID Cache

        //*******add for NCR************

         int     nbcount;

        //****************************** 

step 2:      modify the struct "hdr_aodv_request" in file  "aodv_packet.h":as 
follows

//   u_int8_t        reserved[2];

          u_int8_t       NCR;

          u_int8_t       reserved;

 

step 3:modify "void AODV::recvHello(Packet *p)" in file "aodv.cc":as follows

    void AODV::recvHello(Packet *p) {

       //struct hdr_ip *ih = HDR_IP(p);

        struct hdr_aodv_reply *rp = HDR_AODV_REPLY(p);

        AODV_Neighbor *nb;

        nb = nb_lookup(rp->rp_dst);

        if(nb == 0) {

           nb_insert(rp->rp_dst);

           //**********add for NCR********

             nbcount++;

           //******************************

         }

        else {

           nb->nb_expire = CURRENT_TIME +(1.5 * ALLOWED_HELLO_LOSS * 
HELLO_INTERVAL);

         }

         Packet::free(p);

    }

 

    modify  "void AODV::nb_purge()" as follows:    

    AODV::nb_purge() {

        AODV_Neighbor *nb = nbhead.lh_first;

        AODV_Neighbor *nbn;

        double now = CURRENT_TIME;

        for(; nb; nb = nbn) {

           nbn = nb->nb_link.le_next;

           if(nb->nb_expire <= now) {

             nb_delete(nb->nb_addr);

             //*****add for NCR*********

             nbcount--;

             //*************************

           }

        }

     modify the "void AODV::sendRequest(nsaddr_t dst)" in file "cmu_trace.cc"as 
follows:

 sprintf(pt_->buffer() + offset,

                     "[0x%x %d %d [%d %d] [%d %d]] %d (REQUEST3)",

                     rq->rq_type,

                        rq->rq_hop_count,

                        rq->rq_bcast_id,

                        rq->rq_dst,

                        rq->rq_dst_seqno,

                        rq->rq_src,

                        rq->rq_src_seqno,

                        //****

                        rq->NCR);

                        //*****

²        the result: 

s 10.000000000 _0_ AGT  --- 0 tcp 40 [0 0 0 0] ------- [0:0 8:0 32 0] [0 0] 0 0

r 10.000000000 _0_ RTR  --- 0 tcp 40 [0 0 0 0] ------- [0:0 8:0 32 0] [0 0] 0 0

s 10.000000000 _0_ RTR  --- 0 AODV 48 [0 0 0 0] ------- [0:255 -1:255 30 0] 
[0x2 1 1 [8 0] [0 8]] 2 (REQUEST3)

r 10.001340360 _1_ RTR  --- 0 AODV 48 [0 ffffffff 0 800] ------- [0:255 -1:255 
30 0] [0x2 1 1 [8 0] [0 8]] 2(REQUEST3)

r 10.001340810 _2_ RTR  --- 0 AODV 48 [0 ffffffff 0 800] ------- [0:255 -1:255 
30 0] [0x2 1 1 [8 0] [0 8]] 2(REQUEST3)

s 10.006801271 _2_ RTR  --- 0 AODV 48 [0 ffffffff 0 800] ------- [2:255 -1:255 
29 0] [0x2 2 1 [8 0] [0 8]] 2 (REQUEST3)

r 10.008081677 _3_ RTR  --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 
29 0] [0x2 2 1 [8 0] [0 8]] 2 (REQUEST3)

r 10.008081837 _1_ RTR  --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 
29 0] [0x2 2 1 [8 0] [0 8]] 2 (REQUEST3)

r 10.008081986 _4_ RTR  --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 
29 0] [0x2 2 1 [8 0] [0 8]] 2 (REQUEST3)

r 10.008082081 _0_ RTR  --- 0 AODV 48 [0 ffffffff 2 800] ------- [2:255 -1:255 
29 0] [0x2 2 1 [8 0] [0 8]] 2 (REQUEST3)

… …

 

Reply via email to