1

I am trying to test Linux HTB, doing the simplest example just to see it actually works.
I am creating a root and giving it 200kbps, then I create 3 classes which each one gets assigned a portion of the 200kbps.

              - Root -
             /   |    \
            /    |     \
           /     |      \
          /      |       \
         /       |        \
        /        |         \
    100kbps    60kbps     40kbps

What I want to see at the end is that when they run for 60 seconds I get that first class used half of the bandwidth, second one 30% of the bandwidth and the last class used 20% of the bandwidth.


Now comes the setting up for the test.
I created the above tree, and applied the filters.

tc qdisc add dev eno2 root handle 1: htb default 30
tc class add dev eno2 parent 1: classid 1:1 htb rate 200kbps ceil 200kbps
tc class add dev eno2 parent 1:1 classid 1:10 htb rate 100kbps ceil 200kbps
tc class add dev eno2 parent 1:1 classid 1:20 htb rate 60kbps ceil 200kbps
tc class add dev eno2 parent 1:1 classid 1:30 htb rate 40kbps ceil 200kbps
tc filter add dev eno2 protocol ip parent 1:0 prio 1 u32 match ip dport 80 0xffff flowid 1:10
tc filter add dev eno2 protocol ip parent 1:0 prio 1 u32 match ip dport 25 0xffff flowid 1:20
tc filter add dev eno2 protocol ip parent 1:0 prio 1 u32 match ip dport 36 0xffff flowid 1:30

For the testing I used iperf.
I opened 3 terminals for the servers:

sudo iperf -s -p 25 -i 1
sudo iperf -s -p 36 -i 1
sudo iperf -s -p 80 -i 1

Then connected the 3 clients with a parameter of how much time to run (60 seconds).

iperf -c 132.74.120.45 -p 25 -t 60
iperf -c 132.74.120.45 -p 36 -t 60
iperf -c 132.74.120.45 -p 80 -t 60

Results are a bit odd... it seems that each used the same amount of bandwidth regardless of the original allocation ? enter image description here


Furthermore, I did check the queue discipline is HTB using bmon command as you can see in the picture below. enter image description here


What am I doing wrong ?

  • 2
    Is the 132.74.120.45 (the one you're running iperf in server mode) third server? Are all connections going through your HTB shaper host eno2 as outgoing traffic? – Jaroslav Kucera Nov 23 '17 at 10:00
  • @JaroslavKucera, thanks for your response, I typed on my computer ifconfig and saw eno2 with and ip so I used them. I am not an expert in networking. I hope it was a right approach – Tony Tannous Nov 23 '17 at 10:09
1

The HTB traffic shaping only works on outgoing devices. So if you want to test the functionality, you have to test it against the destination which can be reached through the shaped interface. See the drawing:

PC---\
PC----switch----(eno1)router with HTB shaping(eno2)----Internet
PC---/                                        ^^^^ 
                               Shaping is done on the ougtoing device

So the traffic on the internal network isn't limited. Only the traffic, which goes outside the network (through eno2 in this case) is limited with HTB queuing discipline.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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