Simulating slow network performance on a Mac

Submitted by Jochus on Tue, 19/06/2012 - 21:07 | Posted in: Mac


If you ever want to simulate a slow performance network, you can use the following script on a Mac:

#!/bin/sh
#
# Use ipfw to throttle bandwidth.
# usage:
# ./throttle.sh     # Throttle at default (60KB/s)
# ./throttle.sh 5   # Throttle at custom speed (5KB/s)
# ./throttle.sh off # Turn throttling off
 
# flush rules
ipfw del pipe 1
ipfw del pipe 2
ipfw -q -f flush
ipfw -q -f pipe flush
 
speed=60
[ ! -z $1 ] && speed=$1
 
if [ "$1" == "off" ]; then
    echo "disabling BW limit."
    exit
else
    # simulate slow connection <to specific hosts>
    echo "enabling bw limit at ${speed}KByte/s"
    ipfw add pipe 1 ip from any to any
    ipfw add pipe 2 ip from any to any
    ipfw pipe 1 config bw ${speed}KByte/s
    ipfw pipe 2 config bw ${speed}KByte/s
fi

(source)

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.