Last active
December 24, 2015 10:19
-
-
Save laurisvan/6783674 to your computer and use it in GitHub Desktop.
Simple 3G emulation on OS/X. Remember to reset the IP Firewall after doing this by 'sudo ipfw flush''.
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/sh | |
# | |
# simulate_3g.sh - Simulate a sluggish 3G network with delays & packet loss | |
# Usage: simulate_3g.sh 8080 8081 | |
# Make sure only root can run our script | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
# Simulate http over 3G, 300kbit/s with 5% packet loss and 200ms delays | |
# into all ports given as a parameter | |
ipfw pipe 1 config delay 200 plr 0.1 bw 300kbit/s | |
for var in "$@" | |
do | |
ipfw add 1 pipe 1 dst-port $var | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment