Ask Your Question
2

How do we emulate a network delay ? [closed]

asked 2011-09-29 01:23:40 -0500

shanks gravatar image

updated 2011-09-30 04:03:26 -0500

At times while testing it is required that we cover scenarios where there is a delay in network or check how any application behaves during slow network.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by zoltanh721
close date 2014-06-27 17:42:36.057345

2 Answers

Sort by » oldest newest most voted
4

answered 2011-09-29 01:33:06 -0500

shanks gravatar image

Emulating network delays:

[root@shanks ~]# ping shifu.kungfupanda.com
PING shifu.kungfupanda.com (XX.XX.XXX.XX) 56(84) bytes of data.
64 bytes from shifu.kungfupanda.com (XX.XX.XXX.XX): icmp_seq=1 ttl=63 time=0.299 ms
64 bytes from shifu.kungfupanda.com (XX.XX.XXX.XX): icmp_seq=2 ttl=63 time=0.263 ms
64 bytes from shifu.kungfupanda.com (XX.XX.XXX.XX): icmp_seq=3 ttl=63 time=0.239 ms
--- shifu.kungfupanda.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2368ms
rtt min/avg/max/mdev = 0.239/0.267/0.299/0.024 ms


[root@shanks ~]# tc qdisc add dev br0 root netem delay 3s

tc - show / manipulate traffic control settings

qdisc - is short for ’queueing discipline’ and it is elementary to understanding traffic control. Whenever the kernel needs to send a packet to an interface, it is enqueued to the qdisc configured for that interface. Immediately afterwards, the kernel tries to get as many packets as possible from the qdisc, for giving them to the network adaptor driver.

netem - provides Network Emulation functionality for testing protocols.

[root@shanks ~]# ping shifu.kungfupanda.com
PING shifu.kungfupanda.com (XX.XX.XXX.XX) 56(84) bytes of data.
64 bytes from shifu.kungfupanda.com (XX.XX.XXX.XX): icmp_seq=1 ttl=63 time=3000 ms
64 bytes from shifu.kungfupanda.com (XX.XX.XXX.XX): icmp_seq=2 ttl=63 time=3000 ms
64 bytes from shifu.kungfupanda.com (XX.XX.XXX.XX): icmp_seq=3 ttl=63 time=3000 ms
--- shifu.kungfupanda.com ping statistics ---
9 packets transmitted, 6 received, 33% packet loss, time 10568ms
rtt min/avg/max/mdev = 3000.183/3000.261/3000.333/1.415 ms, pipe 4

Notice the ping test shows an increase of 3seconds

Random packet loss:

[root@shanks ~]# tc qdisc add dev br0 root netem loss 0.1%

This causes 1/10th of a percent (i.e 1 out of 1000) packets to be randomly dropped.

Erase all settings:

[root@shanks ~]# tc qdisc del dev br0 root

More info: http://www.linuxfoundation.org/collaborate/workgroups/networking/netem#Emulating_wide_area_network_delays

edit flag offensive delete link more
1

answered 2011-11-29 04:54:12 -0500

andrew gravatar image

If you need something a little more sophisticated than netem, Jeremy Stretch recommends wanem: http://packetlife.net/blog/2011/jan/12/emulating-wans-wanem/

http://sourceforge.net/projects/wanem/

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2011-09-29 01:23:40 -0500

Seen: 1,786 times

Last updated: Nov 29 '11