WAN in the box

Turn your PC into a WAN simulator

To add a delay of 100 msec

tc qdisc add dev eth0 root netem delay 100 msec

Note, this is one way delay in the outbound direction

To add a delay in the inbound direction

modprobe ifb
ip link set dev ifb0 up
tc qdisc add dev eth0 ingress
tc filter add dev eth0 parent ffff: protocol ip u32 match u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0
tc qdisc add dev ifb0 root netem delay 100msec

This will result in a two way delay of 200 msec

To add a rate limit

tc qdisc add dev eth0 root netem rate 20kbit

To add loss

tc qdisc change dev eth0 root netem loss 0.1%

To learn more, check the man page: http://man7.org/linux/man-pages/man8/tc-netem.8.html