Throttle the network's bandwidth in OS X to simulate mobile connections
With the rise of responsive websites for mobile devices it becomes even more important to see how a website performs and feels at low bandwidths. But how do we simulate low bandwidths like EDGE?
There are a few quite sophisticated apps that achieve this by creating a proxy server with limited bandwidth. CharlesProxy is one of them and has a bunch of other features which might be useful for some people, but not for this simple task. Besides it costs some money.
Gladly OS X has a built-in tool to do this: ipfw, a FreeBSD sponsored firewall program. Yup, this might work under other *NIXes too and is command-line-voodoo.
But fear not! Fire up your terminal and enter:
sudo ipfw pipe 1 config bandwith 56Kbit/s
sudo ipfw add 1 pipe 1 src-port 80
And we’re done. Now our bandwidth is limited to 56Kbit/s. This even works for local servers - as long as they run on port 80, otherwise just change the port of the pipe. But I’m sure you already figured that out.
The format for the bandwidth’s unit is documented as: [K|M]{bit/s|Byte/s}. This makes it easy to target various speeds easily. To see how our site feels with the bandwidth of EDGE we would write:
sudo ipfw pipe 1 config bw 384Kbit/s
Though I’m not sure if that’s the correct value for EDGE - feel free correct me if I’m wrong.
sudo ipfw delete 1
This will remove the throttled pipe and we’re able to surf at full speed again.
Friday, 21. September 2012.
Filed under:
Tagged: osx, terminal, tipps, network