Skip to content

Instantly share code, notes, and snippets.

@bradfa
Last active November 21, 2018 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradfa/ea319bd7dd23694d645869d005b3b6c3 to your computer and use it in GitHub Desktop.
Save bradfa/ea319bd7dd23694d645869d005b3b6c3 to your computer and use it in GitHub Desktop.
Network slowdown/latency simulation

Lots of good info with examples: https://wiki.linuxfoundation.org/networking/netem

Can induce a reduction in throughput for a network interface like:

sudo tc qdisc add dev br0 root tbf rate 5mbit burst 8096 latency 100ms

Set the "rate" to your desired outbound throughput for the interface. The "burst" and "latency" numbers coordinate some underlying configurations which aren't critical to really understand so long as they're big enough.

Since on my system br0 is a bridge between a second Ethernet interface and a Wi-Fi interface which routes to my main Ethernet interface, any "outgoing" traffic is both traffic going to client devices on the Wi-Fi network as well as traffic going to the main Ethernet interface, so it's a symmetric throughput limit. I'm not yet sure how to set it so that outbound to clients is different than outbound to the main Ethernet interface, which would allow simulating non-symmetric connections like a normal consumer home internet setup.

To induce some added latency, do like:

sudo tc qdisc add dev br0 root netem delay 100ms

To remove all of the qdisc setups, do like:

sudo tc qdisc del dev br0 root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment