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

📄 aodv_rtable.h

📁 linux平台下,在ns2里面实现的基于价格的分布式优化算法源代码
💻 H
字号:
/*Copyright (c) 1997, 1998 Carnegie Mellon University.  All RightsReserved. Permission to use, copy, modify, and distribute thissoftware and its documentation is hereby granted (including forcommercial or for-profit use), provided that both the copyright notice and this permission notice appear in all copies of the software, derivative works, or modified versions, and any portions thereof, and that both notices appear in supporting documentation, and that credit is given to Carnegie Mellon University in all publications reporting on direct or indirect use of this code or its derivatives.ALL CODE, SOFTWARE, PROTOCOLS, AND ARCHITECTURES DEVELOPED BY THE CMUMONARCH PROJECT ARE EXPERIMENTAL AND ARE KNOWN TO HAVE BUGS, SOME OFWHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON PROVIDES THISSOFTWARE OR OTHER INTELLECTUAL PROPERTY IN ITS ``AS IS'' CONDITION,AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULARPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITYBE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ORBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCEOR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE ORINTELLECTUAL PROPERTY, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.Carnegie Mellon encourages (but does not require) users of thissoftware or intellectual property to return any improvements orextensions that they make, and to grant Carnegie Mellon the rights to redistribute these changes without encumbrance.The AODV code developed by the CMU/MONARCH group was optimized and tuned by Samir Das and Mahesh Marina, University of Cincinnati. The work was partially done in Sun Microsystems.*/#ifndef __aodv_rtable_h__#define __aodv_rtable_h__#include <assert.h>#include <sys/types.h>#include <config.h>#include <lib/bsd-list.h>#include <scheduler.h>//Yuan add//#define CENTRAL#define INIT_CLIQUE_PRICE       0.005#define VIEW_INTERVAL           1              // 1000 ms#define RATE_INTERVAL           1              // 1000 ms#define HELLO_INTERVAL          1               // 1000 ms#define ALLOWED_HELLO_LOSS      3               // packets#define MAX_FLOW_PER_NB 10      //max number of flows at a node to a neighbor node; should be given the value of the number of flows in the network#define NUM_COMM_HOP 0          //the range of views that a node will send in hello msg. 0 -- only the view of the node itself and its direct neighor will be sent#define MAX_VIEW_PER_NODE 500   //max number of view entries at a node#define MAX_CLIQUE          100 //max number of cliques at a node#define CURRENT_TIME    Scheduler::instance().clock()#define INFINITY2        0xff/*   AODV Neighbor Cache Entry*/class AODV_Neighbor {        friend class AODV;        friend class aodv_rt_entry; public:        AODV_Neighbor(u_int32_t a) { nb_addr = a; } protected:        LIST_ENTRY(AODV_Neighbor) nb_link;        nsaddr_t        nb_addr;        double          nb_expire;      // ALLOWED_HELLO_LOSS * HELLO_INTERVAL//Yuan add        		double			nb_aggr_rate;        double          nb_rate[MAX_FLOW_PER_NB]; // if nb_rate[flowid] >0, then the node forwards for flow with flowid, otherwise nb_rate[flowid] ==0		double          nb_rate_expire[MAX_FLOW_PER_NB];        double          nb_price;		double			nb_grad;        u_int8_t        nb_flag;        //the price is valid};LIST_HEAD(aodv_ncache, AODV_Neighbor);//Yuan add/* * AODV View list data structure. privide 3-hop both connectivity and load * (rate) information */class AODV_View {    friend class AODV;public:	AODV_View (u_int32_t a, u_int32_t b, double grad, double timestamp) {view_one = a; view_other = b; view_grad = grad;view_timestamp = timestamp;}    LIST_ENTRY(AODV_View) view_link;    nsaddr_t    view_one;    u_int8_t         one_hop;    nsaddr_t    view_other;    u_int8_t         other_hop;    double      view_grad; // if rate == 0, then the view entry is to provide connectivity information, if rate >=, it provide load information    double      view_timestamp;	double		hop_timestamp;};LIST_HEAD(aodv_vcache, AODV_View);//Yuan add/* * Clique data structure. for each neighbor. */class AODV_Clique {    friend class AODV;    friend class AODV_View;    friend class AODV_Neighbor;public:    AODV_Clique (AODV_View **subflow, int num_subflow, AODV* ra);        int isSameClique(AODV_View **subflow, int num_subflow); 	int isSameClique(char* clique_ID_2,int clique_num_subflow_2);protected:    LIST_ENTRY(AODV_Clique) clique_link;    u_int8_t clique_ID[2*MAX_VIEW_PER_NODE];    u_int8_t clique_num_subflow;    double clique_price;	u_int8_t clique_tag; // is this a master node?//    int clique_time;    AODV *ra;};LIST_HEAD(aodv_qcache,AODV_Clique);/*   AODV Precursor list data structure*/class AODV_Precursor {        friend class AODV;        friend class aodv_rt_entry; public:        AODV_Precursor(u_int32_t a) { pc_addr = a; } protected:        LIST_ENTRY(AODV_Precursor) pc_link;        nsaddr_t        pc_addr;	// precursor address};LIST_HEAD(aodv_precursors, AODV_Precursor);/*  Route Table Entry*/class aodv_rt_entry {        friend class aodv_rtable;        friend class AODV;	friend class LocalRepairTimer; public:        aodv_rt_entry();        ~aodv_rt_entry();        void            nb_insert(nsaddr_t id);        AODV_Neighbor*  nb_lookup(nsaddr_t id);        void            pc_insert(nsaddr_t id);        AODV_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(aodv_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 */         aodv_precursors rt_pclist;        double          rt_expire;     		// when entry expires        u_int8_t        rt_flags;#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.         */        aodv_ncache          rt_nblist;};/*  The Routing Table*/class aodv_rtable { public:	aodv_rtable() { LIST_INIT(&rthead); }        aodv_rt_entry*       head() { return rthead.lh_first; }        aodv_rt_entry*       rt_add(nsaddr_t id);        void                 rt_delete(nsaddr_t id);        aodv_rt_entry*       rt_lookup(nsaddr_t id); private:        LIST_HEAD(aodv_rthead, aodv_rt_entry) rthead;};#endif /* _aodv__rtable_h__ */

⌨️ 快捷键说明

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