這個實驗的目標是希望可以得到目前封包的排程狀況,因此,我們就可以知道下一個要傳出去的封包是要傳送給哪一個裝置。不過,一直沒有找到相關的資訊,倒是找到 Linux 中如何管理資料封包排程的資訊,記錄在此,作為之後參考。
從 Linux 的角度出發,說到封包排程直覺會想到 Queueing Discipline (QDisc) 這個指令,不過,查詢該指令和 OpenWRT 相關的資料後,多數的應用都在 QoS 的控制以及流量限制。在 OpenWRT 官方網站上可以找到以下兩篇資訊:
root@GL-AR750S:~# tc qdisc show
qdisc noqueue 0: dev lo root refcnt 2
qdisc fq_codel 0: dev eth0 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 4Mb ecn
qdisc noqueue 0: dev br-lan root refcnt 2
qdisc noqueue 0: dev eth0.1 root refcnt 2
qdisc noqueue 0: dev eth0.2 root refcnt 2
qdisc noqueue 0: dev wlan1-2 root refcnt 2
qdisc noqueue 0: dev wlan0-2 root refcnt 2
qdisc noqueue 0: dev wlan1 root refcnt 2
qdisc noqueue 0: dev wlan0 root refcnt 2
root@GL-AR750S:~# tc -s qdisc show dev eth0
qdisc fq_codel 0: root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 4Mb ecn
Sent 1922621977 bytes 15414519 pkts (dropped 0, overlimits 0)
maxpacket 1456 drop_overlimit 0 new_flow_count 447 ecn_mark 0
new_flows_len 0 old_flows_len 0
root@GL-AR750S:~# tc -s qdisc show dev wlan0
qdisc noqueue 0: root refcnt 2
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
root@GL-AR750S:~# tc -s qdisc show dev wlan1
qdisc noqueue 0: root refcnt 2
Sent 0 bytes 0 pkts (dropped 0, overlimits 0)
tc qdisc add dev wlan0 root handle 1: htb default 20
root@GL-AR750S:~# tc qdisc show
qdisc noqueue 0: dev lo root refcnt 2
qdisc fq_codel 0: dev eth0 root refcnt 2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 4Mb ecn
qdisc noqueue 0: dev br-lan root refcnt 2
qdisc noqueue 0: dev eth0.1 root refcnt 2
qdisc noqueue 0: dev eth0.2 root refcnt 2
qdisc noqueue 0: dev wlan1-2 root refcnt 2
qdisc noqueue 0: dev wlan0-2 root refcnt 2
qdisc noqueue 0: dev wlan1 root refcnt 2
qdisc htb 1: dev wlan0 root refcnt 5 r2q 10 default 32 direct_packets_stat 0 direct_qlen 1000
root@GL-AR750S:~# tc -s qdisc show dev wlan0
qdisc htb 1: root refcnt 5 r2q 10 default 32 direct_packets_stat 201 direct_qlen 1000
Sent 31945 bytes 201 pkts (dropped 0, overlimits 0)