Ubuntu – What tools are available to simulate certain network conditions on Ubuntu

networkingtestingtraffic-shapingUbuntu

In order to test our deployment I want to simulate certain network events like connection losses, timeout, limited bandwidths etc.

I already googled for this but haven't found something that really suited my needs. ipfw seems to be what I need but I can't seem to find an ipfw package for Ubuntu. Also I'd like to know whether there are alternatives or even better tools for my task.

Best Answer

You can simulate those things with firewall.

Userland tool to modify firewall rules is called iptables

for example if you want to simulate 5 seconds of connection loss you can do this

iptables -I INPUT -p tcp -s source.ip.for.which.you.want.to.appear.to.timeout --dpor $port -j DROP ; sleep 5; iptables -D INPUT -p tcp -s source.ip.for.which.you.want.to.appear.to.timeout --dpor $port -j DROP ;