Skip to content

Instantly share code, notes, and snippets.

@nikcorg
Forked from laurisvan/simulate_3g.sh
Created October 2, 2013 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikcorg/6789406 to your computer and use it in GitHub Desktop.
Save nikcorg/6789406 to your computer and use it in GitHub Desktop.
#!/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