Sometimes it's useful to test your product in adverse network conditions. Networking is a very complex layer and it's fortunate that the popularity of TCP throughout the last decade shields us from the implementation that has been moved within the kernel code.
Many bugs in applications using networking are obscured by the developer's use of a fast network - he may use the product on a daily basis and still not hit certain conditions that are only met in conjunction with using the product on a slow network.
If your product has auto-update functionality, there's some code that will try to query the home server for a new version. This usually occurs over HTTP (that's how Sparkle does it).
Have you ever wondered how your product's auto-update code behaves when there's a 10 second delay on the network?
The IP firewall running on your Leopard box makes it very easy to find out.
Here's how you create a 10 second delay for your HTTP traffic towards a given host:
First we configure a pipe that delays packets by 10000 milliseconds:
Then we redirect the traffic we want to delay through that given pipe:
Listing the rules from the IP firewalls shows the new rule we've just added:
Testing with network delays
Once you've configured the firewall, you can test your product. As a side note, the auto-update from Sparkle behaves admirably - it will run the query in the background so the 10 second delay is not experienced within the application.
Resetting the delay rule
To clear the ipfw rules once you're done testing:
Many bugs in applications using networking are obscured by the developer's use of a fast network - he may use the product on a daily basis and still not hit certain conditions that are only met in conjunction with using the product on a slow network.
If your product has auto-update functionality, there's some code that will try to query the home server for a new version. This usually occurs over HTTP (that's how Sparkle does it).
Have you ever wondered how your product's auto-update code behaves when there's a 10 second delay on the network?
The IP firewall running on your Leopard box makes it very easy to find out.
Here's how you create a 10 second delay for your HTTP traffic towards a given host:
First we configure a pipe that delays packets by 10000 milliseconds:
sudo ipfw pipe 1 config noerror delay 10000
Then we redirect the traffic we want to delay through that given pipe:
sudo ipfw add prob 1 pipe 1 tcp from any to www.home.com http
Listing the rules from the IP firewalls shows the new rule we've just added:
cristi:~ diciu$ sudo ipfw list
Password:
00100 pipe 1 tcp from any to 192.168.1.1 dst-port 80
65535 allow ip from any to any
Testing with network delays
Once you've configured the firewall, you can test your product. As a side note, the auto-update from Sparkle behaves admirably - it will run the query in the background so the 10 second delay is not experienced within the application.
Resetting the delay rule
To clear the ipfw rules once you're done testing:
cristi:~ diciu$ sudo ipfw flush
Are you sure? [yn] y
Flushed all rules.