I need to simulate packet loss for a little programming assignment I'm working on which involves implementing a multicast chat application using UDP sockets. I need to build reliability into the system (sequence numbers and acknowledgements etc.) and thought it might be sensible to test the behaviour of my program under WAN-style network conditions. Originally I was just going to randomly drop packets in my server, but then I thought to myself that there ought to be an OS-level way of doing it. Indeed, there is and here is my bash script that demonstrates it.