Simulating latency and other network issues on Linux

If for some reason you need to simulate latency, latency, loss, duplication or re-ordering on a linux machine, use netem (command tc) as root

Adding a delay of 100ms on interface eth0:

tc qdisc add dev eth0 root netem delay 100ms

Changing the rule:

tc qdisc change dev eth0 root netem delay 150ms

Removing the rule is a simple:

tc qdisc del dev eth0 root netem delay 100ms

Simulate a delay of 100ms with a variation or plus or minus 10ms:

tc qdisc change dev eth0 root netem delay 100ms 10ms

Simulate packet loss:

tc qdisc change dev eth0 root netem loss 0.1%

Simulate packet deduplication:

tc qdisc change dev eth0 root netem duplicate 1%

Simulate packet reordering:

tc qdisc change dev eth0 root netem delay 10ms reorder 25% 50%

More info: https://wiki.linuxfoundation.org/networking/netem




Thanks for reading this post!


Did you find an issue in this article?

- click on the following Github link
- log into Github with your account
- click on the line number containing the error
- click on the "..." button
- choose "Reference in new issue"
- add a title and your comment
- click "Submit new issue"

Your feedback is much appreciated! πŸ€œπŸΌπŸ€›πŸΌ

You can also drop me a line below!