network testing: using IPFW to add latency or limit bandwidth

If you need to test an iOS app’s network performance, this technique helps make the simulator perform a little more like it is out on a real mobile network.  This is also helpful testing / simulating any other scenario that may involve slow WAN links, dial up connections, Satellite links, etc.

ipfw to add latency or limit bandwidth:

as root, run:

ipfw add pipe 1 ip from any to any out
ipfw add pipe 2 ip from any to any in
ipfw pipe 1 config delay 150 bw 50kbit/s
ipfw pipe 2 config delay 150 bw 200kbit/s

to reset:

ipfw flush