Last active
July 10, 2023 06:20
-
-
Save philwo/171396bc20f31ba5daea80437777f2ba to your computer and use it in GitHub Desktop.
Simulate limited bandwidth / latency on localhost
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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