NS3网络仿真(13): FdNetDevice的问题
2015-08-18 21:27
246 查看
快乐虾http://blog.csdn.net/lights_joy/欢迎转载,但请保留作者信息
在前面的小节中,我们使用FdNetDevice进行了实时仿真,利用NS3向一台实际的机器发送ping包,但得到的结果显然有点偏离我们的预期结果,因为ping包的响应时间明显长于正常情况下的响应时间。
这个是用NS3发送ping包的结果:
使用WireShark在NS3使用的适配器上抓包,这个是在物理网卡上抓到的包:
显然对端的响应是没有问题的,莫非问题出现在winpcap的发送上?刚好学习ICMPv4时也遇到了这样的问题,一并解决它。在网上搜了一把,貌似问题出现在打开winpcap设备时指定的参数:
这里的read timeout值直接来源于winpcap的示例代码,查一下此参数的意义:
read_timeout,: read timeoutin milliseconds. The read timeout is used to arrange that the read notnecessarily return immediately when a packet is seen, but that it waits forsome amount of time to allow more packets to arrive and to read multiplepackets from the OS kernel in one operation. Not all platforms support a readtimeout; on platforms that don't, the read timeout is ignored.
将此值改为1。再执行仿真
这个结果好多了~~~,再改为-1试试:
更好的结果,只是此时的CPU使用率更高。
在前面的小节中,我们使用FdNetDevice进行了实时仿真,利用NS3向一台实际的机器发送ping包,但得到的结果显然有点偏离我们的预期结果,因为ping包的响应时间明显长于正常情况下的响应时间。
这个是用NS3发送ping包的结果:
使用WireShark在NS3使用的适配器上抓包,这个是在物理网卡上抓到的包:
显然对端的响应是没有问题的,莫非问题出现在winpcap的发送上?刚好学习ICMPv4时也遇到了这样的问题,一并解决它。在网上搜了一把,貌似问题出现在打开winpcap设备时指定的参数:
if ((adhandle = pcap_open_live(m_deviceName.c_str(), // name of the device 65536, // portion of the packet to capture. // 65536 grants that the whole packet will be captured on all the MACs. 1, // promiscuous mode (nonzero means promiscuous) 1000, // read timeout errbuf // error buffer )) == NULL) { fprintf(stderr, "\nUnable to open the adapter. %s is not supported by WinPcap\n", m_deviceName.c_str()); return -1; }
这里的read timeout值直接来源于winpcap的示例代码,查一下此参数的意义:
read_timeout,: read timeoutin milliseconds. The read timeout is used to arrange that the read notnecessarily return immediately when a packet is seen, but that it waits forsome amount of time to allow more packets to arrive and to read multiplepackets from the OS kernel in one operation. Not all platforms support a readtimeout; on platforms that don't, the read timeout is ignored.
将此值改为1。再执行仿真
这个结果好多了~~~,再改为-1试试:
更好的结果,只是此时的CPU使用率更高。
相关文章推荐
- Okhttp 使用实例
- TCP为什么要三次握手而不采用两次握手
- Android之HttpClient的使用方法
- HTTP协议总结
- 生产环境中跨节点隔离网络构架解析
- linux网络编程poll与epoll区别
- linux下网络编程send,recv,read,write的区别
- 龙与虎PSP汉化版.iso 下載地址:http://www.400gb.com/file/81103616 【龙与虎PSP汉化版】 b-toradorap.cso 下载地址:http://www
- winform通过https与服务器进行通信
- 使用Jmeter进行http接口测试
- linux下socket网络通信详解
- TinyXml 操作XML 常用操作 http://www.cnblogs.com/cy568searchx/p/3670400.html
- 搭建Python HTTP服务
- 类型“System.Net.Http.HttpResponseMessage”在未被引用的程序集中定
- iOS安全系列之一:HTTPS
- 通过网络获取图片并缓存
- 网络编程的面试题
- TCP快速重传与快速恢复原理分析
- 书摘---网络搜集整理 (1--10)
- 网络篇----第三方框架AFN02 文件上传