Awkward and Proud

Simulate network latency for application testing

Sometimes it’s useful to test your web application for situations where internet connections are less than stellar. It turns out that Mac OS X has a builtin utility called ipfw than, among other things, can do just this.

I first saw this technique from Joe Miller’s post on the subject. I packaged up the settings he mentioned into a little shell script:

You can drop that somewhere in your $PATH and chmod +x to make it executable. You can call it whatever you want, but I called mine “hinder”. After that, it’s simply a matter of using it:

$ hinder www.google.com

Now when you visit google.com, you should see some marked slowness. To reset, just run:

$ hinder reset

Google is now fast again.

The script works by adding 250ms delay to both directions of network traffic. It also adds a packet-loss percentage of 10%. You can play with these numbers to get even more latency simulation. Enjoy!