News Update :

Linux QoS

Linux provides a powerful and feature-rich subsystem for traffic control (traffic shaping, queuing disciplines, classification, prioritizing, sharing, filter chains), of both ingress and egress traffic. You configure such by having multiple sets of routing tables (iproute2) and by using the tc tool.

The main application of realms is in conjunction with the tc route classifier, where they help assign packets to traffic classes for accounting, policing, and scheduling. The tc tool handles these tasks:

  • Setup of queuing disciplines (QDISC) such as CBQ, RED, and SFQ

  • Setup of parent and child classes for classful queuing

  • Flexible filtering of classful queuing disciplines

  • Combinations of all these features

You also can shape inbound via the ingress option of the tc utility. It is up to you to decide whether inbound policing makes sense. Examples 13-6 through 13-10 demonstrate classless QDISCs.

Note that Example 13-6 facilitates a simple token-bucket filter (TBF) applied to interface eth0 (highlighted text), with certain parameters that influence shaping and allow short bursts while reacting with delays and drops to lasting overload conditions. In the current implementation, tokens correspond to bytes, not packets. A similar effect is achieved via a shaper device attached to eth0 in Example 13-7.

NOTE

For more details on TBF and an in-depth discussion of classful and classless queuing disciplines, see the "Linux Advanced Routing & Traffic Control HOWTO," especially for generic RED, weighted RED, and weighted round-robin (WRR).


Example 13-6. Interface Shaping with a TBF
[root@callisto:~#] tc qdisc add dev eth0 root tbf rate 220kbit latency 50ms burst 1540



[root@callisto:~#] tc -d qdisc

qdisc tbf 8001: dev eth0 rate 220Kbit burst 1539b/8 mpu 0b lat 61.0ms



[root@callisto:~#] tc -s qdisc

qdisc tbf 8001: dev eth0 rate 220Kbit burst 1539b lat 61.0ms

Sent 425 bytes 5 pkts (dropped 0, overlimits 0)


Example 13-7. Alternative Interface Shaping with the Shaper Device
[root@callisto:~#] insmod shaper

Using /lib/modules/2.4.21/kernel/drivers/net/shaper.o



[root@callisto:~#] shapecfg -?

shapecfg attach

shapecfg speed



[root@callisto:~#] shapecfg attach shaper0 eth0



[root@callisto:~#] shapecfg speed shaper0 2000000



[root@callisto:~#] ifconfig shaper0 192.168.80.1 netmask 255.255.255.0 up



[root@callisto:~#] ifconfig -a

eth0 Link encap:Ethernet HWaddr 00:10:5A:D7:93:60

inet addr:192.168.14.1 Bcast:192.168.14.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:476 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:100

RX bytes:0 (0.0 b) TX bytes:53487 (52.2 Kb)

Interrupt:5 Base address:0xd800



eth1 Link encap:Ethernet HWaddr 52:54:05:E3:51:87

inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:19895 errors:0 dropped:0 overruns:0 frame:0

TX packets:14777 errors:0 dropped:0 overruns:0 carrier:0

collisions:43 txqueuelen:100

RX bytes:5879639 (5.6 Mb) TX bytes:1302730 (1.2 Mb)

Interrupt:9 Base address:0xd400



eth1:1 Link encap:Ethernet HWaddr 52:54:05:E3:51:87

inet addr:192.168.45.253 Bcast:192.168.45.255 Mask:255.255.255.0

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

Interrupt:9 Base address:0xd400



lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:72 errors:0 dropped:0 overruns:0 frame:0

TX packets:72 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:5416 (5.2 Kb) TX bytes:5416 (5.2 Kb)



shaper0 Link encap:Ethernet HWaddr 00:00:00:00:00:00

inet addr:192.168.80.1 Mask:255.255.255.0

UP RUNNING MTU:1500 Metric:1

RX packets:0 errors:0 dropped:0 overruns:0 frame:0

TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:10

RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)


Stochastic fair queuing (SFQ), as shown in Example 13-8, represents an "almost" fair queuing mechanism with reduced calculation burden. It helps on saturated links to distribute utilization in a fair way among sessions.

Example 13-8. Stochastic Fair Queuing
[root@callisto:~#] tc qdisc add dev eth0 root sfq perturb 10 quantum 2



[root@callisto:~#] tc -s -d qdisc list

qdisc sfq 8003: dev eth0 quantum 2b limit 128p flows 128/1024 perturb 10sec

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)


Example 13-9. pFIFO-Fast
[root@callisto:~#] tc qdisc add dev eth0 root pfifo limit 200k



[root@callisto:~#] tc -s -d qdisc list

qdisc pfifo 8004: dev eth0 limit 204800p

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)


Example 13-10. Random Early Detect/Discard with Explicit Congestion Notification
[root@callisto:~#] tc qdisc add dev eth0 root red limit 100 min 80 max 90 avpkt 10 burst

graphics/ccc.gif 10 probability 1 bandwidth 200 ecn




[root@callisto:~#] tc -s -d qdisc list

qdisc red 8006: dev eth0 limit 100b min 80b max 90b ecn ewma 2 Plog 4 Scell_log 17

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)

marked 0 early 0 pdrop 0 other 0


In contrast to the previous examples, Example 13-11 offers a variant of classful queuing (priority queuing) in combination with filter chains. Class-based queuing (CBQ) is a huge field that is covered exhaustively in the HOWTO.

Example 13-11. Priority Queuing (PRIQ)
[root@callisto:~#] tc qdisc add dev eth0 root handle 1: prio



[root@callisto:~#] tc -s -d qdisc

qdisc prio 1: dev eth0 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

Sent 1097 bytes 5 pkts (dropped 0, overlimits 0)



[root@callisto:~#] tc qdisc add dev eth0 parent 1:1 handle 10: sfq



[root@callisto:~#] tc qdisc add dev eth0 parent 1:2 handle 20: tbf rate 20kbit buffer 1600

graphics/ccc.gif limit 3000




[root@callisto:~#] tc qdisc add dev eth0 parent 1:3 handle 30: sfq



[root@callisto:~#] tc -s -d qdisc

qdisc sfq 30: dev eth0 quantum 1514b limit 128p flows 128/1024

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)

qdisc tbf 20: dev eth0 rate 20Kbit burst 1599b/8 mpu 0b lat 667.6ms

Sent 85 bytes 1 pkts (dropped 0, overlimits 0)



qdisc sfq 10: dev eth0 quantum 1514b limit 128p flows 128/1024

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)



qdisc prio 1: dev eth0 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

Sent 1182 bytes 6 pkts (dropped 0, overlimits 0)



[root@callisto:~#] tc -s -d qdisc list dev eth0

qdisc sfq 30: quantum 1514b limit 128p flows 128/1024

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)



qdisc tbf 20: rate 20Kbit burst 1599b/8 mpu 0b lat 667.6ms

Sent 85 bytes 1 pkts (dropped 0, overlimits 0)



qdisc sfq 10: quantum 1514b limit 128p flows 128/1024

Sent 0 bytes 0 pkts (dropped 0, overlimits 0)



qdisc prio 1: bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1

Sent 1182 bytes 6 pkts (dropped 0, overlimits 0)



[root@callisto:~#] tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip dport

graphics/ccc.gif 22 0xffff flowid 1:1




[root@callisto:~#] tc filter add dev eth0 protocol ip parent 1: prio 1 u32 match ip sport

graphics/ccc.gif 80 0xffff flowid 1:1


[root@callisto:~#] tc -s -d filter list dev eth0

filter parent 1: protocol ip pref 1 u32

filter parent 1: protocol ip pref 1 u32 fh 800: ht divisor 1

filter parent 1: protocol ip pref 1 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1

graphics/ccc.gif:1 match 00000016/0000ffff at 20

filter parent 1: protocol ip pref 1 u32 fh 800::801 order 2049 key ht 800 bkt 0 flowid 1

graphics/ccc.gif:1 match 00500000/ffff0000 at 20
Share this Article on :

0 comments:

Post a Comment

 

© Copyright Cisco elearning 2010 -2011 | Design by Herdiansyah Hamzah | Published by Borneo Templates | Powered by Blogger.com.