欢迎来到天天文库
浏览记录
ID:55292208
大小:46.00 KB
页数:11页
时间:2020-05-09
《邻节点请求与回复控制包函数.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、NEIGHBOR_REQUEST//邻节点请求NEIGHBOR_REPLY//邻节点回复Neighbor_request//邻节点请求Neighbor_reply//邻节点回复neighbor_request//邻节点请求neighbor_reply//邻节点回复nbrq//邻节点请求nbrp//邻节点回复1.在aodv_packet.h中:(1)首先在aodv_packet..h控制包头文件中对所添加的控制包进行定义:#defineAODVTYPE_HELLO0x01#defineAODVTYPE_RREQ0x02#defineAODVTYPE_RREP0x04#defineA
2、ODVTYPE_RERR0x08#defineAODVTYPE_RREP_ACK0x10#defineAODVTYPE_NEIGHBOR_REQUEST0x20#defineAODVTYPE_NEIGHBOR_REPLY0x40(2)接着添加数据包申请内存空间的宏/**AODVRoutingProtocolHeaderMacros*/#defineHDR_AODV(p)((structhdr_aodv*)hdr_aodv::access(p))#defineHDR_AODV_REQUEST(p)((structhdr_aodv_request*)hdr_aodv::access(
3、p))#defineHDR_AODV_REPLY(p)((structhdr_aodv_reply*)hdr_aodv::access(p))#defineHDR_AODV_ERROR(p)((structhdr_aodv_error*)hdr_aodv::access(p))#defineHDR_AODV_RREP_ACK(p)((structhdr_aodv_rrep_ack*)hdr_aodv::access(p))#defineHDR_AODV_NEIGHBOR_REQUEST(p)((structhdr_aodv_neighbor_request*)hdr_aodv::
4、access(p))#defineHDR_AODV_NEIGHBOR_REPLY(p)((structhdr_aodv_neighbor_reply*)hdr_aodv::access(p))(3)接着要具体定义新的数据包格式了。我这里定义的AODV的格式如下所示:邻节点请求数据包格式:structhdr_aodv_neighbor_request{u_int8_tnbrq_type;//类型编号u_int8_treserved[3];//保留字,没用到u_int8_tmal_count;//Maliciousnodenumberu_int32_tnbrq_bcast_id;//
5、BroadcastIDnsaddr_tmalicious_node_addr[AODV_MAX_NEIGHBOR_REQUEST];//maliciousdoubleobs[AODV_MAX_NEIGHBOR_REQUEST];nsaddr_tsrc_addr;//源节点inlineintsize()//计算数据包的大小{intsz=0;/*sz=sizeof(u_int8_t)//type+sizeof(nsaddr_t)//malicious_node_addr+sizeof(nsaddr_t)//src_addr+sizeof(u_int32_t)//nbrq_bcast_
6、id*/sz=(2*mal_count+3)*sizeof(u_int32_t);assert(sz);returnsz;}};邻节点回复数据包格式:structhdr_aodv_neighbor_reply{u_int8_tnbrp_type;//类型编号u_int8_treserved[3];//保留字,没用到u_int8_tmal_count;//Maliciousnodenumberu_int32_tnbrp_bcast_id;//BroadcastIDnsaddr_tmalicious_node_addr[AODV_MAX_NEIGHBOR_REPLY];//malic
7、iousdoubleobs[AODV_MAX_NEIGHBOR_REPLY];nsaddr_tsrc_addr;//源节点inlineintsize()//计算数据包的大小{intsz=0;/*sz=sizeof(u_int8_t)//type+sizeof(nsaddr_t)//malicious_node_addr+sizeof(nsaddr_t)//src_addr+sizeof(u_int32_t)//nbrp_bcast_id*/sz=(2*mal_count+3)*s
此文档下载收益归作者所有