ns2中aodv协议中路由链表的操作
来源:互联网 发布:linux文件绝对路径 编辑:程序博客网 时间:2024/05/16 08:09
aodv协议中对路由链表的操作部分大多在lib/bsd-list.h文件中
双向链表
/*
* List definitions.
*/
//创建指向链表第一个元素的指针
#define LIST_HEAD(name, type) \
struct name { \
type *lh_first;/* first element */\
}
//创建匿名结构体 只包含该节点的前驱和后继,注意:后继为一级指针;前驱为二级指针
//后继指向的是下一个节点,而前驱指向的是前一个节点的后继,即它的前驱是一个指向指针的指针,画图会更清晰一些
#define LIST_ENTRY(type)\
struct { \
type *le_next;/* next element */\
type **le_prev;/* address of previous next element */\
}
/*
* List functions.
*/
//初始化路由链表
#define LIST_INIT(head) {\
(head)->lh_first = NULL;\
}
//在链表中某个节点的后面插入一个新的节点
//其中listelm为链表中的某个节点,elm为新加节点,field为结构体,包含该节点的前驱和后继(弄明白这一点后面就都不难理解了)
#define LIST_INSERT_AFTER(listelm, elm, field) { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)\
(listelm)->field.le_next->field.le_prev =\
&(elm)->field.le_next;\
(listelm)->field.le_next = (elm);\
(elm)->field.le_prev = &(listelm)->field.le_next;\
}
//在链表中某个节点的前面插入一个新的节点
//其中listelm为链表中的某个节点,elm为新加节点,field为结构体,包含该节点的前驱和后继
#define LIST_INSERT_BEFORE(listelm, elm, field) { \
(elm)->field.le_prev = (listelm)->field.le_prev;\
(elm)->field.le_next = (listelm);\
*(listelm)->field.le_prev = (elm);\
(listelm)->field.le_prev = &(elm)->field.le_next;\
}
//头节点处插入
#define LIST_INSERT_HEAD(head, elm, field) { \
if (((elm)->field.le_next = (head)->lh_first) != NULL)\
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm);\
(elm)->field.le_prev = &(head)->lh_first;\
}
//删除路由链表中某个节点,删除失效路由
#define LIST_REMOVE(elm, field) { \
if ((elm)->field.le_next != NULL)\
(elm)->field.le_next->field.le_prev = \
(elm)->field.le_prev;\
*(elm)->field.le_prev = (elm)->field.le_next;\
}
#endif /* !_NS_BSD_LIST_H_ */
aodv.rtable.h中对邻接表类的定义
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
};
- ns2中aodv协议中路由链表的操作
- ns2中AODV协议HDR_CMN(p)的含义
- NS2中AODV协议混杂模式配置
- NS2中DSDV, AODV, DSR协议评估
- 基于NS2的网络路由协议仿真(AODV、COPE+AODV)
- AODV中路由表及控制消息结构(包含aodv开源代码)
- AODV中路由表及控制消息结构(包含aodv开源代码)
- NS2中路由性能分析
- ns2--AODV协议分析
- ns2,AODV协议解析
- 对ns2中aodv源文件的浅析
- NS2下AODV协议aodv.cc注释
- NS2下AODV协议aodv.cc注释
- NS2下AODV协议aodv.cc注释
- NS2中基于AODV协议实现的请求洪泛攻击
- NS2中基于AODV协议的请求洪泛攻击防御
- 在NS2 AODV协议中添加blackhole attacker(黑洞攻击)
- ns2下完善基于AODV的TDMA协议
- 分布式图并行计算框架:PowerGraph
- ARM(三) ISA介绍之Data Processing Instructions(数据运算指令)
- 右值引用、move与move constructor
- group by 与 partition by的区别
- 还原TexturePacker plist 文件以及图片的方法 (切开各小图片)
- ns2中aodv协议中路由链表的操作
- 【图像算法】浮点数转定点数
- linux知识小结
- iOS9 HTTP 不能正常使用的解决办法
- HDU 1052 田忌赛马 (贪心_好题)
- python基础知识-函数
- 【jQuery】:first过滤选择器
- CATransition动画精讲
- 【1】网页的构造块(《HTML5与CSS3基础教程 (第8版)》)