Skip to content

Instantly share code, notes, and snippets.

@nebirhos
Forked from trongthanh/gist:1196596
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nebirhos/884fab515f59f9d29e45 to your computer and use it in GitHub Desktop.
Save nebirhos/884fab515f59f9d29e45 to your computer and use it in GitHub Desktop.
Emulate slow Internet connection speed on localhost with netem (Ubuntu)
#!/bin/bash
# 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/
case "$1" in
start)
# Setup the rate control and delay
sudo tc qdisc add dev lo root handle 1: htb default 12
sudo tc class add dev lo parent 1:1 classid 1:12 htb rate 56kbps ceil 128kbps
sudo tc qdisc add dev lo parent 1:12 netem delay 200ms
;;
stop)
# Remove the rate control/delay
sudo tc qdisc del dev lo root
;;
status)
# To see what is configured on an interface, do this
sudo tc -s qdisc ls dev lo
;;
*)
echo "Emulate slow Internet connection speed on localhost with netem (Ubuntu)"
echo "Original script https://gist.github.com/trongthanh/1196596"
echo "Usage $0 {start|stop|status}"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment