0

I am looking for a reliable way to drop packets in linux as if you have bad networking. Looking at stack overflow (and the internet) there seem to be two good possibilities pointed out in this answer. Both of these should get 5% packet loss.

  1. tc qdisc change dev eth0 root netem loss 5%
  2. iptables -A INPUT -m statistic --mode random --probability 0.05 -j DROP

However, the netem documentation states the following:

When loss is used locally (not on a bridge or router), the loss is reported to the upper level protocols. This may cause TCP to resend and behave as if there was no loss. When testing protocol reponse to loss it is best to use a netem on a bridge or router

From my (very limited) understanding, both solutions (netem and iptables) use the same solution, and so will suffer the same drawbacks.

Is there any way to acurately simulate dropped packets without resorting to running programs on the switch or a bridge? Would corrupting the packets be a poor man's way to "drop" them, since the CRC will have to re-request them?

Thankyou.

Community
  • 1
  • 1
vitiral
  • 8,446
  • 8
  • 29
  • 43
  • Well, the "oldschool" way would be to unisolate the cable and add some real disturbance to the wires by exposing them to a mobile antenna or similar. Not exactly *accurate* but authentic. – Rob Nov 17 '15 at 06:16
  • Haha, I think I should say that I need a programatic way to do this in software if possible. – vitiral Nov 17 '15 at 06:18
  • Not really an answer but IMO, the simplest thing would be to have a network configuration close to what you want to simulate. If you have routers in prod, then you should have some in your testing configuration. It doesn't necessarly mean multiple boxes, it can be a virtual setup. – Colin Pitrat Feb 25 '16 at 09:16
  • An option you can dig is to introduce an insanely big delay on a fraction of the traffic, however, it's again not really an answer as AFAIK `tc` doesn't allow to do it. It may be the occasion to code it :-) – Colin Pitrat Feb 25 '16 at 09:17
  • it would be nice to be able to do this at the router level. If so, then netem would do the trick. I will have to look into this more. – vitiral Feb 26 '16 at 22:25

0 Answers0