Users were complaining about a feature that would sometimes fail for no apparent reason. After some time investigating the issue, I suspected an unreliable internet connection might be responsible for these failures. In order to test my theory, I wanted to simulate random packet loss on my development machine to see if I then experienced the same failures.
We can use a program called ipfw
to simulate packet loss. From the manual, ipfw
is an "IP firewall and traffic shaper control program."
It wasn't immediately obvious how to use this program at first, so here is a summary of what I did. Also, the man page tells me it's deprecated, but worked for me today.