HTB分层令牌桶(Hierarchical Token Bucket)

http://luxik.cdi.cz/~devik/qos/htb/    主站

tc qdisc del dev eth1 root  //清空队列
    设定队列
tc qdisc add dev eth1 root handle 1: htb default 40
                                                                          1:40
tc class add dev eth1 parent 1: classid 1:3 htb rate 2048kbit ceil 2048kbit
   新建一个子类           继承自根类   子类的编号      限定速率           可以借用到的速率
tc class add dev eth1 parent 1:3 classid 3:10 htb rate 128kbit ceil 256kbit
tc class add dev eth1 parent 1:3 classid 3:20 htb rate 512kbit ceil 1024kbit
tc class add dev eth1 parent 1:3 classid 3:30 htb rate 1536kbit ceil 1536kbit
tc class add dev eth1 parent 1: classid 1:40 htb rate 1024kbit ceil 1024kbit

tc qdisc add dev eth1 parent 3:1 handle 10: sfq perturb 10
tc qdisc add dev eth1 parent 3:2 handle 20: sfq perturb 10
tc qdisc add dev eth1 parent 3:3 handle 30: sfq perturb 10
tc qdisc add dev eth1 parent 3:4 handle 40: sfq perturb 10

tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dst 192.168.1.0/24  flowid 3:1
tc filter add dev eth1 protocol ip parent 1:0 prio 1 u32 match ip dport 80 0xffff flowid 3:2
tc filter add dev eth1 protocol ip parent 1:0 prio 1 handle 6 fw flowid 3:3
  ///////  iptables -A PREROUTING -t mangle -i eth0 -j MARK --set-mark 6 //////
tc filter add dev eth1 protocol ip parent 1:0 prio 10 flowid 3:4

classes with higher priority are offered excess bandwidth first   (prio值越低会得到更为优先的服务   prio=0 的类将会比prio=1的类优先获得数据包的发送权)

The burst and cburst parameters control the amount of data that can be sent at the maximum (hardware) speed without trying to serve another class.   (burst和cburst参数控制网络接口为一个进程送多少数据包后在为下个进程传送)

建议在每个子类中加入一个sfq队列,已保证经过该类的数据包能被随机平均的发送。

tc qdisc add dev eth1 parent 1:1 handle 11: sfq perturb 20  // perturb: 多少秒后重置一次散列算法,默认10s

使用tc限制下行速率
tc qdisc add dev eth1 handle ffff: ingress 
tc filter add dev eth1 parent ffff: protocol ip prio 50 handle 8 fw police rate 1024kbit burst 10k drop flowid :8

你可能感兴趣的:(职场,休闲)