NS2中的数据包common头结构hdr_cmn
在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)int size_; // simulated packet sizeint uid_; // unique idint error_; // error flagint errbitcnt_; // # of corrupted bits jahnint fecsize_;double ts_; // timestamp: for q-delay measurement//时间戳在这里int iface_; // receiving interface (label)dir_t direction_; // 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 queueFailureCallback 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 analysisint num_forwards_; // how many times this pkt was forwardedint 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
NS2中的数据包common头结构hdr_cmn相关推荐
- 网卡驱动和队列层中的数据包接收
一.从网卡说起 这并非是一个网卡驱动分析的专门文档,只是对网卡处理数据包的流程进行一个重点的分析.这里以Intel的e100驱动为例进行分析. 大多数网卡都是一个PCI设备,PCI设备都包含了一个标准 ...
- Linux内核中网络数据包的接收-第一部分 概念和框架
与网络数据包的发送不同,网络收包是异步的的.由于你不确定谁会在什么时候突然发一个网络包给你.因此这个网络收包逻辑事实上包括两件事: 1.数据包到来后的通知 2.收到通知并从数据包中获取数据这两件事发生 ...
- linux数据包注释,关于 linux中TCP数据包(SKB)序列号的小笔记
关于 SKB序列号的小笔记 为了修改TCP协议,现在遇到了要改动tcp分组的序列号,但是只是在tcp_sendmsg函数中找到了SKB的end_seq 一直没有找到seq 不清楚在那里初始化了,就 ...
- 网络游戏中的数据包设计和定义(初论)
接触了一段时间的网游封包设计,有了一些初步的思路,想借这篇文章总结一下,同时也作个记录,以利于以后更新自己的思路. 网络游戏的技术研发,分为三个主要的方面:服务器设计,客户端设计,数据库设计.而在服务 ...
- SOCKET通信中TCP数据包大小的确定
MSS(maximun segment size) 最大分段大小,TCP有一个最大分段大小,用于通告对端每个分段中能发送的最大TCP数据量.MSS的目的是告诉对端其重组缓冲区大小的实际 ...
- Linux内核中网络数据包的接收框架
与网络数据包的发送不同,网络收包是异步的的,因为你不确定谁会在什么时候突然发一个网络包给你,因此这个网络收包逻辑其实包含两件事: 1.数据包到来后的通知 2.收到通知并从数据包中获取数据 这两件事发生 ...
- linux内核中IP数据包的输入与输出
IP层主要函数之间的调用关系如下图所示: 上面的图主要是拷贝的<Linux内核源码剖析----TCP/IP实现上册>中的图11.3,原图中有部分错误,所以这里重新绘制了一下,并且去掉了一些 ...
- python中的数据包处理模块scapy调研笔记
Scapy简介 Scapy的是一个强大的交互式数据包处理程序(使用python编写).它能够伪造或者解码大量的网络协议数据包,能够发送.捕捉.匹配请求和回复包等等.它可以很容易地处理一些典型操作,比如 ...
- 数据包过滤 系统 linux,Ubuntu16.04安装libpcap开发库对pcap文件中的数据包进行过滤...
Ubuntu16.04下安装了Wireshark的话,应该是已经安装了libpcap0.8的包,如下图: 使用sudo apt-get install libpcap-dev安装开发包,安装后系统显示 ...
最新文章
- 采集练习(一) php 获得全国的小学(数据来自腾讯朋友网)
- 浅谈javascript中的数据类型和引用类型
- waf可以查看post请求吗_WAFNinja:一款绕过WAF的渗透工具
- 如何设计折叠样式的屏幕(类似MIGO的屏幕)
- 获取一段html的内容简介
- 如何设计一个高可用的运营系统
- SQL 导出表数据存储过程
- 1036: [ZJOI2008]树的统计Count(树链剖分)
- ubuntu下tftp服务器环境搭建
- 渗透测试工具——Metasploit
- 基于ipv6的多分支大学校园网设计与实现
- 17.	Zigbee应用程序框架开发指南 - 使用Ember AppBuilder设计应用程序
- html设置右键失灵,鼠标右键失灵是怎么回事
- MySQL 递归 sql语句 WITH表达式实现
- Copy BOM and Rounting 说明
- 电商黑马,集体倒在2019!
- Anaconda创建环境及环境配置
- 教你玩转九四玩手游联运系统
- WebLogic 12c 配置 https
- windows系统中正斜杠/和反斜杠\的区别
热门文章
- poj 4124:海贼王之伟大航路
- 自然语言处理学习2:英语分词1word_tokenize, WordPunctTokenizer, TreebankWordTokenizer , WhitespaceTokenizer等
- Confluence 6 新 Confluence 安装配置一个数据源连接
- 听雨小筑---开张纪念
- 测试工程师必会能力之缺陷分析入门
- NIOP 1999 导弹问题 最长升降序子序列 DP[小思路]
- 2018沈阳集训day1
- 2011高清影音产品市场日渐成熟 产业要求更高
- 电话聊天狂人(25 分)
- 深度学习常用的数据集,包括各种数据跟图像数据。