Skip to content

Instantly share code, notes, and snippets.

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 edsonhoraciojunior/025cf202934f210b00033363bfbfa7c0 to your computer and use it in GitHub Desktop.
Save edsonhoraciojunior/025cf202934f210b00033363bfbfa7c0 to your computer and use it in GitHub Desktop.
Emulate slow Internet connection speed on localhost with netem (Ubuntu)
#Refer: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Delaying_only_some_traffic
#Refer: http://www.bomisofmab.com/blog/?p=100
#Refer: http://drija.com/linux/41983/simulating-a-low-bandwidth-high-latency-network-connection-on-linux/
#Setup the rate control and delay
sudo tc qdisc add dev enp3s0 root handle 1: htb default 12
# rate control - slow outgoing traffic
sudo tc class add dev enp3s0 parent 1:1 classid 1:12 htb rate 56kbps ceil 128kbps
# delay and packet loss
sudo tc qdisc add dev enp3s0 parent 1:12 netem delay 1000ms loss 80%
# remove the config
sudo tc qdisc del dev enp3s0 root
# to see what is configured on an interface, do this
sudo tc -s qdisc ls dev enp3s0
# use ifconfig (if on Ubuntu) to see which interfaces you have to replace enp3s0 with other value
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment