2010年5月12日 星期三

Linux flow control

1:create the root qdisc and assign the default class
# $TC qdisc add dev eth0 root handle 1: htb default $D_CLASS
2:create the class you want to have
# $TC class add dev eth0 parent 1: classid 1:1 htb rate 10mbit
# $TC class add dev eth0 parent 1: classid 1:1000 htb rate 1000mbit
child class of 1:1000 -- 20mbit of 1000mbit
# $TC class add dev eth0 parent 1:1000 classid 1:20 htb rate 20mbit
3:speed control parameter in class creation -- rate for guarantee bandwidth and ceil for maximum bandwidth
4:define your rule.
U32="$TC filter add dev $IF protocol ip parent 1:0 prio 1 u32"
by IP
$U32 match ip dst xxx.xxx.xxx.xxx/32 flowid $CLASS
by port
$U32 match ip sport port_number 0xffff flowid $CLASS
Nested rule
$U32 match ip dport port_number 0xffff match ip dst xxx.xxx.xxx.xxx/32 flowid $CLASS

tc class|qdisc|filer add|change|replace dev $IF args
tc -s class|qdisc|filter ls dev eth0

tc filter del dev eth0 parent CLASS:CLASS prio 10 handle HANDLE::HANDLE u32

refer to http://blog.edseek.com/~jasonb/articles/traffic_shaping/classflows.html#iptu32
refer to http://www.gentoo-wiki.info/QoS

沒有留言: