Simulating Slow or Laggy Network Connections on OS X

December 04, 2009 · 1 min read

A client recently reported that their site was loading painfully slowly from certain remote locations. We got the specs of their network connection, but every single time I need to simulate bandwidth limits or latency on OS X I end up searching for the same commands. So here they are, written down once and for all.

Set up the pipe

First, configure an ipfw pipe with the bandwidth limit and delay you want to simulate.

sudo ipfw pipe 1 config bw 16Kbit/s delay 350ms

Attach it to HTTP traffic

Next, attach the pipe to all traffic going to or coming from port 80.

sudo ipfw add 1 pipe 1 src-port 80
sudo ipfw add 2 pipe 1 dst-port 80

All HTTP traffic is now throttled through your simulated connection. Do your testing, experience the pain your users feel, and then clean up.

Tear it down

Once you're done (or once you get frustrated with how slowly everything loads), remove the firewall rules and delete the pipe.

sudo ipfw delete 1
sudo ipfw delete 2
sudo ipfw pipe 1 delete

And you're back to full speed. Adjust the bw and delay values to match whatever real-world connection you're trying to reproduce.