NS3网络仿真(13): FdNetDevice的问题

快乐虾

http://blog.csdn.net/lights_joy/

欢迎转载,但请保留作者信息


在前面的小节中,我们使用FdNetDevice进行了实时仿真,利用NS3向一台实际的机器发送ping包,但得到的结果显然有点偏离我们的预期结果,因为ping包的响应时间明显长于正常情况下的响应时间。


这个是用NS3发送ping包的结果:


使用WireSharkNS3使用的适配器上抓包,这个是在物理网卡上抓到的包:


显然对端的响应是没有问题的,莫非问题出现在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使用率更高。











评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌云阁主

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值