Skip to content

Instantly share code, notes, and snippets.

@laurisvan
Last active December 24, 2015 10:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save laurisvan/6783674 to your computer and use it in GitHub Desktop.
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''.
#!/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