How to simulate a slow network connection on Mac OS-X

Mobile connections especially while moving in a car or train will always have a lot more latency and packet loss than a typical DSL or cable connection.

How long does a page load on Edge or 3G?

Simulating a slow and/or lossy network connection gives you the impression a typical user on a mobile network has while using your application or website.

  • How long until the first content is displayed?
  • How long till interaction is possible?
  • How long till all content is loaded and the blue loading bar on iOS disappears?
  • How laggy is interaction and loading of additional pages?

On Mac OS-X there is two super easy ways to simulate a slow network. Both can be set to unbearable conditions up to those in a stadium with 50000 people where thousands are using their mobile phone to send pictures and or messages.

I will show you the quick one first:

ipfw (IP Firewall and Traffic shaper control program)

This command line tool is already installed. It comes with FreeBSD on which OS-X is based.

There is endless ways to configure ipfw - i will just show you a simple way to limit the network for a quick test. If you need to do more fancy stuff please type man ipfw and read the docs.

First we need to define a pipe where our traffic gets routed through. Open up a terminal window and type:

sudo ipfw add pipe 1 all from any to any

To limit all in and outgoing traffic to 200Kbit/s with a horrible 500ms delay type:

sudo ipfw pipe 1 config bw 200Kbit/s delay 500ms

That’s it already. Notice how all your webbrowsers load the pages and images real sloooow. Do your testing now.

At some point you might have enough and want to reset your settings.

Type: sudo ipfw flush to delete all rules.

Included in the free Xcode download is the Network Link Conditioner. A tool with an easy to use GUI to set typical network profiles like a lossy WLAN router or a slow and lossy Edge connection.

Make sure you have installed Xcode from the Mac App-Store.

Now start Xcode and in the Xcode menu select Open Developer Tools -> More Developer Tools…

Installing Network Link Conditioner

You might need to register on the Apple Developer Network now if you haven’t done so, yet.

On the following page look for the Hardware IO Tools for Xcode in the latest revision:

Installing Network Link Conditioner - Hardware IO Tools for Xcode

Download the .dmg file and install the Network Link Conditioner.prefPane into your System Preferences.

Installing Network Link Conditioner - System Preferences

Now click the little lock to switch the Network Link Conditioner to ON.

Using Network Link Conditioner

Select a profile from the list or click on Manage Profiles… to create your own profile.

Using Network Link Conditioner - Profiles

No matter which tool you use: Don’t forget to turn them off again ;)

share