How to simulate WAN delay/latency in GNS3

Download or create a QEMU linux where tc (traffic control) is working.
I chosed Debian Lenny standard from http://people.debian.org/~aurel32/qemu/armel/
o Run it one time outside GNS3, we need bridging utilities to be installed:
 qemu -name QEMU1 -m 256 -serial telnet:127.0.0.1:3000,server,nowait -no-acpi debian_lenny_i386_standard.img
o telnet to the host
 telnet 127.0.0.1 3000 or use putty
o Install bridge-utils
 aptitude install bridge-utils
o After you installed bridge-utils add the QEMU host to GNS3 (like in Linux microcore article)
o Add the host to GNS3 working area, connect the links to the routers/hosts and start the network:
o Set the delay and jitter and drop values for this connection:
 (I usually add 6 eth connections, in the mentioned QEMU image the first eth link is not eth0 but eth1)

 # Bring up the interfaces without IP addresses
 ifconfig eth1 0.0.0.0 up
 ifconfig eth2 0.0.0.0 up
 ifconfig eth3 0.0.0.0 up
 ifconfig eth4 0.0.0.0 up
 ifconfig eth5 0.0.0.0 up
 ifconfig eth6 0.0.0.0 up
 # Create a bridge group
 brctl addbr br0
 # Add the interfaces to the bridge group
 brctl addif br0 eth1
 brctl addif br0 eth2
 brctl addif br0 eth3
 brctl addif br0 eth4
 brctl addif br0 eth5
 brctl addif br0 eth6
 # Bring the bridge group up
 ifconfig br0 up
 # Check the interfaces – all up, no problems?
 ifconfig
 # Remove the root traffic control from the interfaces
 tc qdisc del dev eth1 root
 tc qdisc del dev eth2 root
 tc qdisc del dev eth3 root
 tc qdisc del dev eth4 root
 tc qdisc del dev eth5 root
 tc qdisc del dev eth6 root
 tc qdisc add dev eth1 root handle 1:0 netem delay 120msec
 tc qdisc add dev eth2 root handle 1:0 netem delay 120msec
 tc qdisc add dev eth3 root handle 1:0 netem delay 120msec
 tc qdisc add dev eth4 root handle 1:0 netem delay 120msec
 tc qdisc add dev eth5 root handle 1:0 netem delay 120msec
 tc qdisc add dev eth6 root handle 1:0 netem delay 120msec

 o Real WAN shows variable delay sometime, this adds 100ms ± 10ms with a correlation value (the next random element depending 25% on the last one).
 tc qdisc change dev eth0 root netem delay 100ms 10ms 25%
 o Delay distribution
 tc qdisc change dev eth0 root netem delay 100ms 20ms distribution normal
 o Random packet loss
 tc qdisc change dev eth0 root netem loss 0.1%
 o Packet duplication
 tc qdisc change dev eth0 root netem duplicate 1%
 o Packet corruption
 tc qdisc change dev eth0 root netem corrupt 0.1% 
o Packet re-ordering, 2 method, please do not mix them (the 2nd is more realistic)
– 1st way: gap uses a fixed sequence and reorders every Nth packet
 tc qdisc change dev eth0 root netem gap 5 delay 10ms
– 2nd way: a certain percentage of the packets to get mis-ordered:
 tc qdisc change dev eth0 root netem delay 10ms reorder 25% 50%

Leave a Reply

Your email address will not be published. Required fields are marked *

*