We needed to simulate latency and packet loss on Linux. Here's what we ended up doing on our Debian Testing boxes to make it happen:
aptitude install tcng
# load netem module
modprobein=`lsmod | grep sch_netem | wc -l`
if [ modprobein == 0 ] ; then
modprobe sch_netem
fi
# clear it out first
tc qdisc del dev eth1 root
# delay/lose packets on egress
tc qdisc add dev eth1 root netem delay 600msec 50msec drop 25% corrupt 0% duplicate 5% reorder 5%
This adds packet delay of 600ms +/- 50ms, drops 25% of packets, corrupts 0% of them, duplicates 5%, and reorders 5%.
Be warned that when you do this on your interface through which your shell communicates that your interactive shell becomes extremely slow and unresponsive. Luckily SSH is pretty resilient against this sort of nastiness (that is, you can cope), but it isn't pleasant to edit a commandline or txt file in this mode.
Note that this only affects OUTGOING packets. In our case, we wanted to simulate this nastiness between two boxes, so we ran these commands on both machines so that packets would get lost, mangled, and delayed in both directions.
To clear up what's going on, simply run the command from above for "clear it out":
tc qdisc del dev eth1 root
That'll stop the mangling, delaying, and losing of packets again. Your shell will become responsive. You will breathe a sigh of relief.
--
PhiloVivero - 04 Jan 2007