Skip to content

Instantly share code, notes, and snippets.

@philwo
Last active July 10, 2023 06:20
Show Gist options
  • Save philwo/171396bc20f31ba5daea80437777f2ba to your computer and use it in GitHub Desktop.
Save philwo/171396bc20f31ba5daea80437777f2ba to your computer and use it in GitHub Desktop.
Simulate limited bandwidth / latency on localhost
#!/bin/bash
set -euo pipefail
bandwidth="1000mbit"
latency="200ms"
jitter="50ms"
correlation="25%"
case "$1" in
start)
sudo tc qdisc del dev lo root 2> /dev/null || true
sudo tc qdisc add dev lo root netem delay ${latency} ${jitter} ${correlation} rate ${bandwidth}
;;
stop)
sudo tc qdisc del dev lo root
;;
status)
tc -s qdisc ls dev lo
;;
*)
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