Monday, December 23, 2013

How to limit network bandwidth and introduce latency

So you want to test clients of some service like nfs in case network or service is slow. In order to do this you need to limit network throughput, introduce latency and jitter (latency variation). Ok, I bet you know how to do this
tc qdisc add dev eth0 root handle 1: prio
tc qdisc add dev eth0 parent 1:3 handle 30: tbf rate 1mbit buffer 10kb limit 3000
tc qdisc add dev eth0 parent 30:1 handle 31: netem delay 100ms 10ms distribution normal
tc filter add dev eth0 protocol ip parent 1:0 prio 3 u32 match ip dst 192.168.44.4/32 flowid 1:3
See Linux Advanced Routing & Traffic Control HOWTO.
Simple test. On server side
iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[  4] local 192.168.44.4 port 5001 connected with 192.168.44.26 port 37494
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-14.6 sec  1.52 MBytes    870 Kbits/sec
On client side
iperf -c 192.168.44.4
------------------------------------------------------------
Client connecting to 192.168.44.4, TCP port 5001
TCP window size: 16.0 KByte (default)
------------------------------------------------------------
[  3] local 192.168.44.26 port 37494 connected with 192.168.44.4 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-11.8 sec  1.52 MBytes  1.08 Mbits/sec
Cleanup
tc qdisc del dev eth0 root

No comments:

Post a Comment