NS2中的数据包common头结构hdr_cmn
来源:互联网 发布:人体断层解剖学软件 编辑:程序博客网 时间:2024/03/29 12:31
在aomdv_rqueue.cc中多次遇到了HDR_CMN(p),查遍了AOMDV协议都没有找到定义,最后还是度娘出了结果,在下边列出。不得不说,看得越深入,涉及到NS底层的实现也越多。
-----------------------------------------------------------------------------------------------------------------
HDR_CMN(p)的定义位于/ns-allinone-2.35/ns-2.35/common/packet.h中,是宏定义,返回结构体hdr_cmn的access(p):
#define HDR_CMN(p) (hdr_cmn::access(p))
hdr_cmn代表数据包的common头。AOMDV协议中用到的有时间戳参数ts,以及函数access(p)(在aomdv_rqueue.cc中):
struct hdr_cmn {enum dir_t { DOWN= -1, NONE= 0, UP= 1 };packet_t ptype_;// packet type (see above)intsize_;// simulated packet sizeintuid_;// unique idinterror_;// error flagint errbitcnt_; // # of corrupted bits jahnint fecsize_;doublets_;// timestamp: for q-delay measurement//时间戳在这里intiface_;// receiving interface (label)dir_tdirection_;// direction: 0=none, 1=up, -1=down// source routing char src_rt_valid;double ts_arr_; // Required by Marker of JOBS //Monarch extn beginsnsaddr_t prev_hop_; // IP addr of forwarding hopnsaddr_t next_hop_;// next hop for this packetint addr_type_; // type of next_hop_ addrnsaddr_t last_hop_; // for tracing on multi-user channels// AOMDV patchint aomdv_salvage_count_; // called if pkt can't obtain media or isn't ack'd. not called if // droped by a queue FailureCallback xmit_failure_; void *xmit_failure_data_; /* * MONARCH wants to know if the MAC layer is passing this back because * it could not get the RTS through or because it did not receive * an ACK. */ int xmit_reason_;#define XMIT_REASON_RTS 0x01#define XMIT_REASON_ACK 0x02 // filled in by GOD on first transmission, used for trace analysis int num_forwards_;// how many times this pkt was forwarded int opt_num_forwards_; // optimal #forwards// Monarch extn ends;// tx time for this packet in secdouble txtime_;inline double& txtime() { return(txtime_); }static int offset_;// offset for this headerinline static int& offset() { return offset_; }inline static hdr_cmn* access(const Packet* p) { //access()在这里return (hdr_cmn*) p->access(offset_);} /* per-field member functions */inline packet_t& ptype() { return (ptype_); }inline int& size() { return (size_); }inline int& uid() { return (uid_); }inline int& error() { return error_; }inline int& errbitcnt() {return errbitcnt_; }inline int& fecsize() {return fecsize_; }inline double& timestamp() { return (ts_); }inline int& iface() { return (iface_); }inline dir_t& direction() { return (direction_); }// monarch_begininline nsaddr_t& next_hop() { return (next_hop_); }inline int& addr_type() { return (addr_type_); }inline int& num_forwards() { return (num_forwards_); }inline int& opt_num_forwards() { return (opt_num_forwards_); } //monarch_endModulationScheme mod_scheme_;inline ModulationScheme& mod_scheme() { return (mod_scheme_); }};hdr_cmn的access(p)调用了Packet类的access(off)函数,off为偏移量,若偏移量大于0,则返回包头指针bits_偏移了off后的指针:
inline unsigned char* access(int off) const {if (off < 0)abort();return (&bits_[off]);}
包头指针bits_是packet类的成员变量:
unsigned char* bits_;// header bits
0 0
- NS2中的数据包common头结构hdr_cmn
- NS2数据包结构解析
- ns2中的packet common包头
- ns2中AODV协议HDR_CMN(p)的含义
- NS2数据包分析
- NS2数据包分析
- NS2中数据包Packet分析
- IP头结构中的checksum
- 数据包结构
- struct hdr_cmn
- NS2包结构解析
- NS2中数据包Packet的分析
- NS2中数据包Packet的分析
- NS2中数据包Packet的分析
- NS2中数据包Packet的分析
- 以太网数据包TCP、IP、ICMP、UDP、ARP协议头结构详解
- NS2中的Packet类
- ns2中的timer
- android 显示gif图片
- 如何简化从hbase中查询数据
- 使用boost.python在python调用C++接口(windows)
- linux ------ 闲聊input设备
- windows与office
- NS2中的数据包common头结构hdr_cmn
- unity3d 制作动态天空盒——实现时时环境反射
- BZOJ3170[TJOI2013]松鼠聚会
- 修改ubuntu下Eclipse默认的黑色注释
- 程序员必知的8大排序(java实现)(一)(插入+希尔+简单选择)
- iOS开发xcode报错:"xxxxxx"has been modified since the precompiled header was built
- js动态获取当前点击事件的属性值
- C语言--单链表创建、求长度、查找前驱结点、删除结点
- java操作文件和文件夹