流量整形器:sfq 外部分类器未按预期工作

流量整形器:sfq 外部分类器未按预期工作

我有一个 Ubuntu 14.04.1 LTS,内核为 3.13.0-44-generic。我的流量整形规则:

# Add disciplines for DL device
tc qdisc add dev $devDL root handle 1:0 htb default 12

# Add classes for DL device
tc class add dev $devDL parent 1:0 classid 1:1 htb rate $bwDL ceil $bwDL quantum $quantum
tc class add dev $devDL parent 1:1 classid 1:11 htb prio 1 rate $bwPrivateDL ceil $bwDL quantum $quantum
tc class add dev $devDL parent 1:1 classid 1:12 htb prio 2 rate $bwPublicDL ceil $bwPublicDL quantum $quantum

tc qdisc add dev $devDL parent 1:11 sfq divisor $divisor perturb $perturb
tc qdisc add dev $devDL parent 1:12 sfq divisor $divisor perturb $perturb

# Add filters for DL device
if [ -s $filePrivate ]; then
    for ip in `grep -v "#" $filePrivate`; do
    if [ `expr index $ip :` = 0 ]; then
        tc filter add dev $devDL protocol all prio 1 parent 1:0 u32 match ip dst $ip flowid 1:11
    else
        echo $ip
        tc filter add dev $devDL protocol all prio 1 parent 1:0 u32 match ip6 dst $ip flowid 1:11
    fi
    done
    tc filter add dev $devDL protocol all prio 1 parent 1:11 handle 11 flow hash keys dst divisor $divisor baseclass 1:11
fi

tc filter add dev $devDL protocol all prio 2 parent 1:0 u32 match ip dst 0/0 flowid 1:12
tc filter add dev $devDL protocol all prio 2 parent 1:0 u32 match ip6 dst ::/0 flowid 1:12
tc filter add dev $devDL protocol all prio 2 parent 1:12 handle 12 flow hash keys dst divisor $divisor baseclass 1:12

HTB 规则运行良好,但 sfq 外部分类器无法按预期工作。运行 torrent 客户端的两台同级主机无法平等共享带宽。一个客户端可以占用更多共享带宽。

tc filter add dev $devDL protocol all prio 2 parent 1:12 handle 12 flow hash keys dst divisor $divisor baseclass 1:12

我的错误在哪里?

答案1

我在配置中犯了一些错误。这是更正后的版本:

# Add disciplines for DL device
tc qdisc add dev $devDL root handle 1: htb default 12

# Add classes for DL device
tc class add dev $devDL parent 1: classid 1:1 htb rate $bwDL ceil $bwDL quantum $quantum
tc class add dev $devDL parent 1:1 classid 1:11 htb prio 1 rate $bwPrivateDL ceil $bwDL quantum $quantum
tc class add dev $devDL parent 1:1 classid 1:12 htb prio 2 rate $bwPublicDL ceil $bwPublicDL quantum $quantum

tc qdisc add dev $devDL parent 1:11 handle 11: sfq divisor $divisor perturb $perturb
tc qdisc add dev $devDL parent 1:12 handle 12: sfq divisor $divisor perturb $perturb

tc filter add dev $devDL protocol all prio 1 parent 11: handle 11 flow hash keys dst divisor $divisor baseclass 1:11
tc filter add dev $devDL protocol all prio 2 parent 12: handle 12 flow hash keys dst divisor $divisor baseclass 1:12

# Add filters for DL device
if [ -s $filePrivate ]; then
    for ip in `grep -v "#" $filePrivate`; do
    if [ `expr index $ip :` = 0 ]; then
        tc filter add dev $devDL protocol all prio 1 parent 1: u32 match ip dst $ip flowid 1:11
    else
        echo $ip
        tc filter add dev $devDL protocol all prio 1 parent 1: u32 match ip6 dst $ip flowid 1:11
    fi
    done
fi

tc filter add dev $devDL protocol all prio 2 parent 1: u32 match ip dst 0/0 flowid 1:12
tc filter add dev $devDL protocol all prio 2 parent 1: u32 match ip6 dst ::/0 flowid 1:12

SFQ qdisc 必须有一个句柄,SFQ 外部分类器必须使用此句柄链接到它。Shaper 现在可以按需要工作。

相关内容