2013-02-21 110 views
0

我正在寻找一个很好的方法来启用数据包丢失。我遇到了ubuntu的这个命令。该命令应该使接口wlan11丢失接收到的数据包的10%(0.10)。命令启用数据包丢失

sudo iptables -A INPUT -i wlan11 -m statistic --mode random --probability 0.10 -j DROP 

这个命令很好用,或者有我可以使用的更好/简单的命令/方法。

谢谢。

回答

1

您评论Simulate delayed and dropped packets on Linux?看起来它拥有大量的选票,并使用netem来涵盖模拟丢包的问题。

Packet loss 

Random packet loss is specified in the 'tc' command in percent. The smallest possible non-zero value is: 

2−32 = 0.0000000232% 

# tc qdisc change dev eth0 root netem loss 0.1% 
This causes 1/10th of a percent (i.e. 1 out of 1000) packets to be randomly dropped. 

An optional correlation may also be added. This causes the random number generator to be less random and can be used to emulate packet burst losses. 

# tc qdisc change dev eth0 root netem loss 0.3% 25% 
This will cause 0.3% of packets to be lost, and each successive probability depends by a quarter on the last one. 

Probn = 0.25 × Probn-1 + 0.75 × Random 

希望能帮助并提供更好的方法来处理这个问题!