大网数据广告活动
服务器运维问答

Testing Linux HTB fall short of expectation

· 52CE 我爱测

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 - / | \…

问题原文

原帖链接 · Tony Tannous · CC BY-SA 3.0

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 ?


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


What am I doing wrong ?

已采纳解答

原帖链接 · Jaroslav Kucera · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-11-23)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。