Emulating a high latency network connection using Linux and TC

Often it is necessary for testing purposes to recreate the networking conditions found in a high latency network, such as a satellite link.

Firstly create a network bridge that can be placed inbetween the test network and its router (assuming eth0 and eth1 are the bridged interfaces).

To increase network latency use the following command:

tc qdisc add dev eth0 root netem delay 1000ms
tc qdisc add dev eth1 root netem delay 1000ms

which will delay every IP packet going through the bridge by 2 seconds (1 second in either direction)

To create some variation to the latency (jitter), add an additional argument:

tc qdisc add dev eth0 root netem delay 1000ms 50ms
tc qdisc add dev eth1 root netem delay 1000ms 50ms

which will cause upto ±100ms of latency (±50ms in either direction)

To reset this delay and remove the 2 seconds of latency:

tc qdisc del dev eth0 root
tc qdisc del dev eth1 root