0

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

1 Answers1

0

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
hookenz
  • 14,472
  • 23
  • 88
  • 143
  • Thanks, this helped me to achieve nearly 2Gbps. However, it is not working in combination with the delay. If I use netem delay 50ms instead of sfq, the bandwidth falls to 200Mbps. Probably some buffer configuration is required to allow large bandwidth-delay product. – Sajjad Rizvi May 26 '17 at 09:11
  • Yeah, I just needed to tune TCP a bit and that improved the bandwidth: [Linux Tune Network Stack (Buffers Size) To Increase Networking Performance](https://www.cyberciti.biz/faq/linux-tcp-tuning/) – Sajjad Rizvi May 26 '17 at 19:49
  • Actually, I forgot about that. I had some similar tuning to improve performance. Glad you got it working. – hookenz May 28 '17 at 23:38