⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aodvsec_rtable.h

📁 本文件是基于NS2的AODVSEC协议的仿真源代码
💻 H
字号:
#ifndef __aodvsec_rtable_h__
#define __aodvsec_rtable_h__

#include <assert.h>
#include <sys/types.h>
#include <config.h>
#include <lib/bsd-list.h>
#include <scheduler.h>

#define CURRENT_TIME    Scheduler::instance().clock()
#define INFINITY2        0xff

/*
   AODVSEC Neighbor Cache Entry
*/
class AODVSEC_Neighbor {
        friend class AODVSEC;
        friend class aodvsec_rt_entry;
 public:
        AODVSEC_Neighbor(u_int32_t a) { nb_addr = a; }

 protected:
        LIST_ENTRY(AODVSEC_Neighbor) nb_link;
        nsaddr_t        nb_addr;
        double          nb_expire;      // ALLOWED_HELLO_LOSS * HELLO_INTERVAL
};

LIST_HEAD(aodvsec_ncache, AODVSEC_Neighbor);

/*
   AODVSEC Precursor list data structure
*/
class AODVSEC_Precursor {
        friend class AODVSEC;
        friend class aodvsec_rt_entry;
 public:
        AODVSEC_Precursor(u_int32_t a) { pc_addr = a; }

 protected:
        LIST_ENTRY(AODVSEC_Precursor) pc_link;
        nsaddr_t        pc_addr;	// precursor address
};

LIST_HEAD(aodvsec_precursors, AODVSEC_Precursor);


/*
  Route Table Entry
*/

class aodvsec_rt_entry {
        friend class aodvsec_rtable;
        friend class AODVSEC;
	friend class LocalRepairTimersec;
 public:
        aodvsec_rt_entry();
        ~aodvsec_rt_entry();

        void            nb_insert(nsaddr_t id);
        AODVSEC_Neighbor*  nb_lookup(nsaddr_t id);

        void            pc_insert(nsaddr_t id);
        AODVSEC_Precursor* pc_lookup(nsaddr_t id);
        void 		pc_delete(nsaddr_t id);
        void 		pc_delete(void);
        bool 		pc_empty(void);

        double          rt_req_timeout;         // when I can send another req
        u_int8_t        rt_req_cnt;             // number of route requests
	
 protected:
        LIST_ENTRY(aodvsec_rt_entry) rt_link;

        nsaddr_t        rt_dst;
        u_int32_t       rt_seqno;
	/* u_int8_t 	rt_interface; */
        u_int16_t       rt_hops;       		// hop count
	int 		rt_last_hop_count;	// last valid hop count
        nsaddr_t        rt_nexthop;    		// next hop IP address
	/* list of precursors */ 
        aodvsec_precursors rt_pclist;
        double          rt_expire;     		// when entry expires
        u_int8_t        rt_flags;
		u_int8_t        signe_for_rrep[124];//验证签名的过程用验证源IP代替
		nsaddr_t        signe;//........................................
		u_int32_t       sip;//...............................................
		u_int32_t       lifetime;//...........................................

#define RTF_DOWN 0
#define RTF_UP 1
#define RTF_IN_REPAIR 2

        /*
         *  Must receive 4 errors within 3 seconds in order to mark
         *  the route down.
        u_int8_t        rt_errors;      // error count
        double          rt_error_time;
#define MAX_RT_ERROR            4       // errors
#define MAX_RT_ERROR_TIME       3       // seconds
         */

#define MAX_HISTORY	3
	double 		rt_disc_latency[MAX_HISTORY];
	char 		hist_indx;
        int 		rt_req_last_ttl;        // last ttl value used
	// last few route discovery latencies
	// double 		rt_length [MAX_HISTORY];
	// last few route lengths

        /*
         * a list of neighbors that are using this route.
         */
        aodvsec_ncache          rt_nblist;
};


/*
  The Routing Table
*/

class aodvsec_rtable {
 public:
	aodvsec_rtable() { LIST_INIT(&rthead); }

        aodvsec_rt_entry*       head() { return rthead.lh_first; }

        aodvsec_rt_entry*       rt_add(nsaddr_t id);
        void                 rt_delete(nsaddr_t id);
        aodvsec_rt_entry*       rt_lookup(nsaddr_t id);

 private:
        LIST_HEAD(aodvsec_rthead, aodvsec_rt_entry) rthead;
};

#endif /* _aodvsec__rtable_h__ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -