Sfq flow: Пример использования

Материал из noname.com.ua
Перейти к навигацииПерейти к поиску


Пример использования

#!/bin/bash


INET_SPEED="10mbit"
### module loading
for module in sch_htb cls_fw ; do
    /sbin/modprobe $module 2>&- >&-
done

tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1: htb

tc class add dev eth0 classid 1:1 parent 1: htb rate 100mbit ceil 100mbit
tc class add dev eth0 classid 1:2 parent 1: htb rate ${INET_SPEED} ceil ${INET_SPEED}

tc class add dev eth0 classid 1:3 parent 1:2 htb rate 56kbit ceil ${INET_SPEED} prio 2
tc class add dev eth0 classid 1:4 parent 1:2 htb rate 56kbit ceil ${INET_SPEED} prio 3
tc class add dev eth0 classid 1:5 parent 1:2 htb rate 56kbit ceil ${INET_SPEED} prio 4

tc qdisc add dev eth0 parent 1:3 handle 2: sfq perturb 15
tc qdisc add dev eth0 parent 1:4 handle 3: sfq perturb 15
tc qdisc add dev eth0 parent 1:5 handle 4: sfq perturb 15

#WITHOUT SHAPE
tc filter add dev eth0 parent 1: protocol ip prio 5 u32 match ip dst 192.168.0.111/32 flowid 1:1
tc filter add dev eth0 parent 1: protocol ip prio 5 u32 match ip src 192.168.0.111/32 flowid 1:1
tc filter add dev eth0 parent 1: protocol ip prio 5 u32 match ip dst 192.168.1.1/32 flowid 1:1
tc filter add dev eth0 parent 1: protocol ip prio 160 u32 match ip src 192.168.1.1/32 flowid 1:1

#ICMP
tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip protocol 1 0xff flowid 1:3 police rate 5kbit buffer 25k drop
#VOIP
tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip tos 0x68 0xff match ip protocol 11 0xff flowid 1:4
tc filter add dev eth0 parent 1: protocol ip prio 1 u32 match ip tos 0xb8 0xff match ip protocol 11 0xff flowid 1:4
#TOS
tc filter add dev eth0 parent 1:0 protocol ip prio 10 u32 match ip tos 0x10 0xff flowid 1:4

# To speed up downloads while an upload is going on, put ACK packets in
# the interactive class:
tc filter add dev eth0 parent 1: protocol ip prio 12 u32 match ip protocol 6 0xff match u8 0x05 0x0f at 0 match u16 0x0000 0xffc0 at 2 match u8 0x10 0xff at 33 flowid 1:4
#www
tc filter add dev eth0 parent 1: protocol ip prio 19 u32 match ip sport 80 0xffff flowid 1:5
#dns
tc filter add dev eth0 parent 1: protocol ip prio 19 u32 match ip protocol 17 0xff match ip sport 53 0xffff flowid 1:6

#GRE
tc filter add dev eth0 parent 1: protocol ip prio 150 u32 match ip protocol 47 0xff match ip src 192.168.1.1/32 flowid 1:4
#other
tc filter add dev eth0 parent 1: protocol ip prio 200 u32 match ip dst 192.168.0.0/21 flowid 1:5
tc filter add dev eth0 parent 1: protocol ip prio 201 u32 match ip src 0.0.0.0/0 flowid 1:1

tc filter add dev eth0 pref 1 parent 2: protocol ip handle 2 flow hash keys dst divisor 1024
tc filter add dev eth0 pref 1 parent 3: protocol ip handle 2 flow hash keys dst divisor 1024
tc filter add dev eth0 pref 1 parent 4: protocol ip handle 2 flow hash keys dst divisor 1024