Openwrt - QoS

 

目錄

 


GUI Packages

 

 * Do NOT install multiple QoS-packages simultaneously!

  • luci-app-qos       # Depends: qos-scripts(awk script)
  • luci-app-nft-qos   # Depends: nft-qos

 


luci-app-qos

 

在 Panel 的 Network menu 內多了 QoS. 它是 qos-scripts 的 panel

Notes

 * 使用 QoS 可以沒有 GUI

 


qos-scripts

 

此 awk script 利用了 sch_hfsc 及 sch_fq_codel

  • HFSC = Hierarchical fair-service curve scheduler

對 'interfce' 的 Egress 及 Ingress 進行了 ts

/usr/bin/qos-stat      # 查看 tc 的設定

啟用 & 套用

/etc/init.d/qos enable

/etc/init.d/qos restart

Config

/etc/config/qos

# 設定在 "wan" NIC 行 QoS, 並且有 'Default' 這分類

config interface 'wan'
        option classgroup 'Default'
        option enabled '1'
        option overhead '1'
        option download '100000'
        option upload '100000'

overhead # Default: 1

功效: decrease upload and download ratio to prevent link saturation

download & upload # Unit: kbs

設定帶寬. script 會以它修改參數

# 設定 'Default' 一共有 4 大類 Priority Express Normal Bulk

config classgroup 'Default'
        option classes 'Priority Express Normal Bulk'
        option default 'Normal'

classes: Specifies the list of names of classes

default: Defines which class is considered default

# 預設分類的設定 (e.g. Priority)

config class 'Priority'
        option packetsize '400'
        option avgrate '10'
        option priority '20'

packetsize (in bytes)

avgrate (in %)

Average rate for this class

priority (in %)

limitrate (in %) # Default: 100. 預設的 rule 沒有使用它

Defines to how much percent of the available bandwidth this class is capped to

Priority or Express

As it turns out, it depends on the application. Priority boosts low-bandwidth small frames, such as TCP-ACKs and DNS more than Express. Express is for prioritizing bigger frames, which would include stuff like VoIP (port 5060).

Classify is not run on a connection that had already been assigned a traffic class,
 so it is the initial connection-tracked classification.

# reclassify

config reclassify
        option target 'Priority'
        option proto 'icmp'

"reclassify" can override the traffic class per packet,
 without altering the connection tracking mark.

Rule 的次序

Classify gets processed first, then Reclassify and finally "Normal" and then
based on the order in the configuration file (top to bottom)

config classgroup 'Default'
        option classes 'Priority Express Normal Bulk'
        option default 'Normal'

config class 'Normal'
        option packetsize '1500'
        option packetdelay '100'
        option avgrate '10'
        option priority '5'

自定 rule 的地方

config classify
        option target 'Priority'
        option ports '22,53'
        option comment 'ssh, dns'

target

The four defaults are: Priority, Express, Normal and Bulk

mark

Packets matching this, belong to the bucket defined in target

direction

Packets matching this traffic direction (in or out) belong to the bucket defined in target

srchost

LAN 內的 IP (e.g. 192.168.0.11)

dsthost

WAN 外的 IP (e.g. 8.8.8.8)

port & portrange & srcports & dstports

ports '22,53'

portrange '1024-65535'

1

config classify
        option comment 'router sshd'
        option target 'Priority'
        option proto 'tcp'
        option srchost '192.168.33.21'
        option srcports '2222'

2

config classgroup 'Default'
        option classes 'Priority Express Normal Bulk Group1 Group2'
        option default 'Normal'

 

3

config class "Group1"
        option limitrate   50

config class "Group2"
        option limitrate   25

4

config classify
        option comment 'user1'
        option srchost '192.168.8.11'
        option target 'Group1'

config classify
       option comment 'user2'
       option srchost '192.168.8.12'
       option target 'Group2'

 

Creative Commons license icon Creative Commons license icon