I was asked to today if it was possible to add latency and packet loss to a device in order to replicated network problems. After a while googleing i found tc +netem. This allows you do funcy stuff to replicated network problems. If i wanted to add 100ms of latency i could do
You can also add variation
This causes the added delay to be 100ms ± 10ms.
or even better
This causes the added delay to be 100ms ± 10ms with the next random element depending 25% on the last one.
If we also wanted to add packet loss we can do
This would cause 1 out of 1000 packets to be randomly dropped.
To emulate packet loss “in a row”
This will cause 0.3% of packets to be lost, and each successive probability depends by a quarter on the last one.