Say I have 100kbps bandwidth

                - Root - 100kbps
                /       \
               /         \
              /           \
             /             \
            /               \
           /                 \
Assured  30kbps             10kbps

And I assure Class A 30kbps, and Class B 10kbps. 60kbps are the reserve or the excess bandwidth

In the HTB manual it says

Any unused bandwidth can be used by any class which needs it (in proportion of its allocated share).

However when I run the following test, which is illustrated in the above ascii art:

tc qdisc add dev eno1 root handle 1: htb
tc class add dev eno1 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
tc class add dev eno1 parent 1:1 classid 1:10 htb rate 10kbps ceil 100kbps
tc class add dev eno1 parent 1:1 classid 1:20 htb rate 30kbps ceil 100kbps
tc filter add dev eno1 protocol ip parent 1:0 prio 1 u32 match ip dport 8000 0xffff flowid 1:10
tc filter add dev eno1 protocol ip parent 1:0 prio 1 u32 match ip dport 8001 0xffff flowid 1:20

I get the following results: 56kbps for Class A and 37kbps for Class B

Which is a ratio of ~1.5, whereas I expected the ratio to be 3:1, as the early allocation.

It seems that the 30 and 10 were served, then the excess was divided equally between the two classes which makes sense as in the code it says that the RedBlack tree holding these two classes, the scheduler does a RR on them.

My question, is the excess bandwidth divided equally as results and code suggest? (perhaps I misunderstood the code)

Or should I be expecting a 3:1 ratio between class A and B ?

  • A link to the code you were reading could improve the question. – kasperd Jun 23 at 14:39
  • @kasperd here is the code and also added in the body of the question. – Tony Tannous Jun 23 at 15:22
up vote 3 down vote accepted
+100

Look at the "quantum" in HTB docs. All unallocated bw is handled by WRR algorithm according to classe's quantums.

As far as I know, the "allocated share" means ceil. So, if you want the 3:1 ratio, you need to write:

tc class add dev eno1 parent 1:1 classid 1:10 htb rate 10kbps ceil 100kbps
tc class add dev eno1 parent 1:1 classid 1:20 htb rate 30kbps ceil 300kbps

Since the root class has a ceil at 100kbps, it will not offer more than 100kbps, and the 300kbps option is only here to specify the ratio.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.