The ability to divvy up bandwidth owned by a service provider for QoS is referred to as “bandwidth management”. TOS, RSVP, diffserv are the different type of bandwidth management techniques available.
Linux can do transmission control for outgoing packets.
The following modules enable QoS support in Linux:
Networking options -> Netlink device emulation
Networking options -> Network packet filtering
Networking options -> Qos and/or fair queueing -> CBQ packet scheduler
Networking options -> Qos and/or fair queueing -> HTB packet scheduler
Networking options -> Qos and/or fair queueing -> ***
Qdisc - queueing discipline. These are used to give traffic classes different behaviour. (CBQ, PRIORITY, CSZ).
Class - some qdiscs are classful and can have a hierarchy - sort of a tree under them. These trees compose of classes. (FIFO, SFQ, HTB).
Filter - a filter examines a packet and sends it somewhere down the hierarchy (i.e. to classes). (RSVP classifier, u32 classifier).
Each interface has a root qdisc, and the packets pass through the qdisc. Filters attached to qdisc decide to which class the packet should send. The queue attached to the leaf class does the packet scheduling.
The root qdisc gets dequeued by the kernel. The request passes through the entire tree and the scheduling happens at the leaf node. The upshot of this is that classes never get dequeued faster than their parents allow.
Inbound Shaping
tc qdisc add dev imq0 root handle 1: htb default 2
tc class add dev imq0 parent 1: classid 1:1 htb rate 1000000kbit ceil 1000000kbit prio 0 quantum 57000
tc class add dev imq0 parent 1:1 classid 1:2 htb rate 1000000kbit ceil 1000000kbit prio 1 quantum 57000
tc qdisc add dev imq0 parent 1:2 handle 2: sfq perturb 10
iptables -t mangle -A PREROUTING -i eth0 -j IMQ --todev 0
iptables -t mangle -A POSTROUTING -o eth0 -j IMQ --todev 0
tc class add dev imq0 parent 1:1 classid 1:65 htb rate 9000kbit ceil 9000kbit prio 2 quantum 57000
tc qdisc add dev imq0 parent 1:65 handle 65: sfq perturb 10
tc class change dev imq0 parent 1:1 classid 1:2 htb rate 991000kbit ceil 1000000kbit prio 0 quantum 57000
tc filter add dev imq0 parent 1: protocol ip prio 2 handle 0x65 u32 match ip dst 192.168.10.160 flowid 1:65
tc filter add dev imq0 parent 1: protocol ip prio 2 handle 0x65 u32 match ip src 192.168.10.160 flowid 1:65
1: root qdisc
|
1:1 child class
/ | \
/ | \
/ | \
/ | \
1:2 1:65 1:66 child classes
| | |
| | |
| | |
2: 65: 66: qdisc
All the packets reaching eth0 after PREROUTING and all the packets leaving eth0 after POSTROUTING are forwarded to imq0, using iptables command.
A tc filter is configured to forward all IP packets to/from 192.168.10.160 to class 1:65.
The class 1:65 is configured to limit the transmission rate.
Reference:
http://www.linuxexposed.com/content/view/105/1
http://tldp.org/HOWTO/html_single/Traffic-Control-HOWTO
No comments:
Post a Comment