Traffic Shaping tc-htb, burst has no effect

2.9k views Asked by At

I’m doing some tests to try to understand the tc-htb arguments. I’m using VmWare Player (version 2.0.5) with Windows 7 as host and Ubuntu (version 4.4.0-93) as guest.

My plan is to use iperf to generate a known data stream(udp 100Mbits/sec) via localhost and then limit the bandwidth with tc-htb. Monitoring the result with Wireshark.

Iperf setup:

  • server:
    iperf –s –u –p 12345
  • client:
    perf –c 127.0.0.1 –u –p 12345 –t 30 –b 100m

Testing rate argument:

I start Wireshark and start sending data with iperf, after 10 sec I execute a script with the tc commands:

tc qdisc add dev lo root handle 1: htb tc class add dev lo parent 1: classid 1:1 htb rate 50mbit ceil 75mbit tc filter add dev lo protocol ip parent 1: prio 1 u 32 match ip dport 12345 0xffff flowid 1:1

The I/O Graph in Wireshark shows that the bandwidth drops from 100 Mbit/s to 50 Mbit/s. Ok.

Testing burst argument:

I’m starting with the same bandwidth limitation as above and after another 10 sec I run a script with the command:

tc class change dev lo parent 1: classid 1:1 htb rate 50mbit ceil 75mbit burst 15k

In the I/O Graph I’m expecting a peek from 50mbit (rate level) up to 75mbit (ceil level). The change command has no effect, the level is at 50mbit. I have also tested with larger burst values, no effect. What am I doing wrong?

1

There are 1 answers

1
user8598591 On

'ceil' specifies how much bandwidth a traffic class can borrow from a parent class if there is spare bandwidth available from peer classes. However ,when applied to the root qdisc there is no parent to borrow from - so specifying ceil different to rate is meaningless for a class on a root qdisc.

'burst' specifies the amount of packets that are sent (at full link speed) from one class before stopping to serve another class, & the rate shaping being achieved by averaging the bursts over time. If applied to root with no child classes, it will only affect the accuracy of the averaging (smoothing), & won't do anything to the true average rate.

try adding child classes:

tc qdisc add dev lo root handle 1: htb
tc class add dev lo parent 1: classid 1:1 htb rate 100mbit
tc class add dev lo parent 1:1: classid 1:10 htb rate 50mbit ceil 100mbit
tc class add dev lo parent 1:1: classid 1:20 htb rate 50mbit ceil 75mbit

tc filter add dev lo protocol ip parent 1: prio 1 u 32 match ip dport 12345 0xffff flowid 1:10
tc filter add dev lo protocol ip parent 1: prio 1 u 32 match ip dport 54321 0xffff flowid 1:20

an iperf session to port 12345 should hit 100mbps, then drop to 50mbps each when iperf session to 54321 is started. Stop iperf to port 12345, then traffic to 54321 should hit 75mbps.