Skip to content

Instantly share code, notes, and snippets.

@fcalderan
Last active March 8, 2017 14:37
Show Gist options
  • Save fcalderan/5091548 to your computer and use it in GitHub Desktop.
Save fcalderan/5091548 to your computer and use it in GitHub Desktop.
A small bash utility for testing slower connection. Use chmod +x perftest.sh to make the script executable. Thanks to Matteo Rosati for sharing basic commands
#!/bin/sh
CMD="$1"
RATE="$2"
DELAY="$3"
if [ "$RATE" = "" ] ; then
RATE=500
fi
if [ "$DELAY" = "" ] ; then
DELAY=500
fi
if [ "$CMD" = "start" ] ; then
echo "\033[33mStarting test with low connectivity: \033[0m"
echo "\033[37m=> ipfw add pipe 1 all from any to any \033[0m"
sudo ipfw add pipe 1 all from any to any
echo "\033[37m=> sudo ipfw pipe 1 config bw ${RATE}Kbit/s delay ${DELAY}ms\n"
sudo ipfw pipe 1 config bw "$RATE"Kbit/s delay "$DELAY"ms
elif [ "$CMD" = "end" ] ; then
echo "\033[33mEnding low connectivity test \033[0m"
echo "\033[37m=> sudo ipfw flush"
sudo ipfw flush
else
echo "\033[33mAvailable commands"
echo "\033[37m=> perftest start [transfer-rate] [delay]"
echo "\033[37m [transfer-rate] in Kbit/sec \033[33m(default: 500Kbit/sec)"
echo "\033[37m [latency] in msec \033[33m(default: 500ms)"
echo "\033[37m\n=> perftest end\n"
fi
@fcalderan
Copy link
Author

A screenshot of the script execution can be found here:
https://twitter.com/fcalderan/status/308991106098532352/

tested so far only on my MacOs 10.6.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment