What I Learned Today
Emulate network latency using tc

Use this code:

PATH=$PATH:/sbin
lat=$1  ## desired bandwidth in megabits per sec
destip=$2  ## destination host to limit traffic to

if [[ -z $lat ]]
then
        lat=100
fi

if [[ -z $destip ]]
then
        echo "using default IP: 192.168.245.21"
        destip=192.168.245.21
fi

echo "note this may not work for VMs since it uses eth instead of peth0"

tc qdisc del dev eth0 root

tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: netem \
     delay ${lat}ms 
## add to end of previous line for distribution: 10ms distribution normal

## I think the line below is for bandwidth
#tc qdisc add dev eth0 parent 30:1 tbf rate 20kbit buffer 1600 limit 3000

tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 \
     match ip dst $destip/32 flowid 1:3

(Source: linuxfoundation.org)