Linux traffic shaping for large bandwidth (more than 1Gig)

bandwidth-controltraffic-shaping

I am doing an experiment between three computers that are connected with 10Gig interfaces and have RTT of 100 microseconds. Let's say these are machines A, B, and C. Machine A is communicating with B and C. Machines B and C do not communicate with one another.

I want to throttle bandwidth such that the machines A and B have 5Gbps bandwidth and 100 millisecond latency. Whereas, the machines A and C does not have any bandwidth and latency throttling. My goal is to emulate a wide area network with large bandwidth available.

I have tried using HTB and prio to throttle the bandwidth and latency. However, the maximum bandwidth reached is about 350 Mbps. I tested through iperf. My understanding is that we cannot have bandwidth more than 1Gig using TC.

Is there any way or any tool to throttle bandwidth above 1Gig?

I am using the following TC commands:

sudo tc qdisc del dev p4p1 root
sudo tc qdisc add dev p4p1 handle 1: root htb r2q 1000
sudo tc class add dev p4p1 parent 1: classid 1:3 htb rate 1000Mbps
sudo tc qdisc add dev p4p1 parent 1:3 handle 23: netem delay 50ms limit 100000000
sudo tc filter add dev p4p1 protocol ip prio 9 u32 match ip dst 10.96.0.1 flowid 1:3

Best Answer

I had the same trouble you found. Eventually I found something that worked at the 2Gbps I needed to throttle at. This is the script. Modify as you require.

#!/bin/sh
#
# Incoming traffic control
#
DEV=eth0
RATE="2000mbit"

tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 10
tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATE} burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${RATE} ceil ${RATE} burst 15k
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10

echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV

#
# Outgoing traffic control
#
DEV=eth2
tc qdisc del dev $DEV root
tc qdisc add dev $DEV root handle 1: htb default 10
tc class add dev $DEV parent 1: classid 1:1 htb rate ${RATE} burst 15k
tc class add dev $DEV parent 1:1 classid 1:10 htb rate ${RATE} ceil ${RATE} burst 15k
tc qdisc add dev $DEV parent 1:10 handle 10: sfq perturb 10

echo;echo "tc configuration for $DEV:"
tc qdisc show dev $DEV
tc class show dev $DEV
Related Topic