Lately we tend to have the need to reproduce issues which are limited to WAN connections and are difficult to reproduce when running two instances of MegaGlest on the same host (or on a LAN). That's because there is (almost) no latency there:
root@atibox:~# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_req=1 ttl=64 time=0.025 ms
64 bytes from 127.0.0.1: icmp_req=2 ttl=64 time=0.025 ms
64 bytes from 127.0.0.1: icmp_req=3 ttl=64 time=0.022 ms
64 bytes from 127.0.0.1: icmp_req=4 ttl=64 time=0.024 ms
^C
--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.022/0.024/0.025/0.001 ms
root@atibox:~#
Luckily, on Linux, it's rather easy to inject arbitrary latency on a given network device:
root@atibox:~# tc qdisc add dev lo root netem delay 50ms
root@atibox:~# ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_req=1 ttl=64 time=100 ms
64 bytes from 127.0.0.1: icmp_req=2 ttl=64 time=100 ms
64 bytes from 127.0.0.1: icmp_req=3 ttl=64 time=100 ms
64 bytes from 127.0.0.1: icmp_req=4 ttl=64 time=100 ms
64 bytes from 127.0.0.1: icmp_req=5 ttl=64 time=100 ms
64 bytes from 127.0.0.1: icmp_req=6 ttl=64 time=100 ms
64 bytes from 127.0.0.1: icmp_req=7 ttl=64 time=100 ms
^C
--- 127.0.0.1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6005ms
rtt min/avg/max/mdev = 100.046/100.062/100.075/0.239 ms
root@atibox:~#
To undo, run the sme command with s/add/del/.
This is not a fully adequate emulation, though, since you always have the same latency, so packets will still arrive in the same order, and you're not emulating any other properties which would be varying on a real network link. It's worth a shot, though.
For more complex tests there are WANEM and dummynet: