]>
Commit | Line | Data |
---|---|---|
aba5acdf SH |
1 | iproute2+tc* |
2 | ||
3 | It's the first release of Linux traffic control engine. | |
4 | ||
5 | ||
6 | NOTES. | |
7 | * csz scheduler is inoperational at the moment, and probably | |
8 | never will be repaired but replaced with h-pfq scheduler. | |
9 | * To use "fw" classifier you will need ipfwchains patch. | |
10 | * No manual available. Ask me, if you have problems (only try to guess | |
11 | answer yourself at first 8)). | |
12 | ||
13 | ||
14 | Micro-manual how to start it the first time | |
15 | ------------------------------------------- | |
16 | ||
17 | A. Attach CBQ to eth1: | |
18 | ||
19 | tc qdisc add dev eth1 root handle 1: cbq bandwidth 10Mbit allot 1514 cell 8 \ | |
20 | avpkt 1000 mpu 64 | |
21 | ||
22 | B. Add root class: | |
23 | ||
24 | tc class add dev eth1 parent 1:0 classid 1:1 cbq bandwidth 10Mbit rate 10Mbit \ | |
25 | allot 1514 cell 8 weight 1Mbit prio 8 maxburst 20 avpkt 1000 | |
26 | ||
27 | C. Add default interactive class: | |
28 | ||
29 | tc class add dev eth1 parent 1:1 classid 1:2 cbq bandwidth 10Mbit rate 1Mbit \ | |
30 | allot 1514 cell 8 weight 100Kbit prio 3 maxburst 20 avpkt 1000 split 1:0 \ | |
31 | defmap c0 | |
32 | ||
33 | D. Add default class: | |
34 | ||
35 | tc class add dev eth1 parent 1:1 classid 1:3 cbq bandwidth 10Mbit rate 8Mbit \ | |
36 | allot 1514 cell 8 weight 800Kbit prio 7 maxburst 20 avpkt 1000 split 1:0 \ | |
37 | defmap 3f | |
38 | ||
39 | etc. etc. etc. Well, it is enough to start 8) The rest can be guessed 8) | |
40 | Look also at more elaborated example, ready to start rsvpd, | |
41 | in rsvp/cbqinit.eth1. | |
42 | ||
43 | ||
44 | Terminology and advices about setting CBQ parameters may be found in Sally Floyd | |
45 | papers. | |
46 | ||
47 | ||
48 | Pairs X:Y are class handles, X:0 are qdisc heandles. | |
49 | weight should be proportional to rate for leaf classes | |
50 | (I choosed it ten times less, but it is not necessary) | |
51 | ||
52 | defmap is bitmap of logical priorities served by this class. | |
53 | ||
54 | E. Another qdiscs are simpler. F.e. let's join TBF on class 1:2 | |
55 | ||
56 | tc qdisc add dev eth1 parent 1:2 tbf rate 64Kbit buffer 5Kb/8 limit 10Kb | |
57 | ||
58 | F. Look at all that we created: | |
59 | ||
60 | tc qdisc ls dev eth1 | |
61 | tc class ls dev eth1 | |
62 | ||
63 | G. Install "route" classifier on root of cbq and map destination from realm | |
64 | 1 to class 1:2 | |
65 | ||
66 | tc filter add dev eth1 parent 1:0 protocol ip prio 100 route to 1 classid 1:2 | |
67 | ||
68 | H. Assign routes to 10.11.12.0/24 to realm 1 | |
69 | ||
70 | ip route add 10.11.12.0/24 dev eth1 via whatever realm 1 | |
71 | ||
72 | etc. The same thing can be made with rules. | |
73 | I still did not test ipchains, but they should work too. | |
74 | ||
75 | Setup of rsvp and u32 classifiers is more hairy. | |
76 | If you read RSVP specs, you will understand how rsvp classifier | |
77 | works easily. What's about u32... That's example: | |
78 | ||
79 | ||
80 | ||
81 | #! /bin/sh | |
82 | ||
83 | TC=/home/root/tc | |
84 | ||
85 | # Setup classifier root on eth1 root (it is cbq) | |
86 | $TC filter add dev eth1 parent 1:0 prio 5 protocol ip u32 | |
87 | ||
88 | # Create hash table of 256 slots with ID 1: | |
89 | $TC filter add dev eth1 parent 1:0 prio 5 handle 1: u32 divisor 256 | |
90 | ||
91 | # Add to 6th slot of hash table rule to select tcp/telnet to 193.233.7.75 | |
92 | # direct it to class 1:4 and prescribe to fall to best effort, | |
93 | # if traffic violate TBF (32kbit,5K) | |
94 | $TC filter add dev eth1 parent 1:0 prio 5 u32 ht 1:6: \ | |
95 | match ip dst 193.233.7.75 \ | |
96 | match tcp dst 0x17 0xffff \ | |
97 | flowid 1:4 \ | |
98 | police rate 32kbit buffer 5kb/8 mpu 64 mtu 1514 index 1 | |
99 | ||
100 | # Add to 1th slot of hash table rule to select icmp to 193.233.7.75 | |
101 | # direct it to class 1:4 and prescribe to fall to best effort, | |
102 | # if traffic violate TBF (10kbit,5K) | |
103 | $TC filter add dev eth1 parent 1:0 prio 5 u32 ht 1:: \ | |
104 | sample ip protocol 1 0xff \ | |
105 | match ip dst 193.233.7.75 \ | |
106 | flowid 1:4 \ | |
107 | police rate 10kbit buffer 5kb/8 mpu 64 mtu 1514 index 2 | |
108 | ||
109 | # Lookup hash table, if it is not fragmented frame | |
110 | # Use protocol as hash key | |
111 | $TC filter add dev eth1 parent 1:0 prio 5 handle ::1 u32 ht 800:: \ | |
112 | match ip nofrag \ | |
113 | offset mask 0x0F00 shift 6 \ | |
114 | hashkey mask 0x00ff0000 at 8 \ | |
115 | link 1: | |
116 | ||
117 | ||
118 | Alexey Kuznetsov | |
119 | kuznet@ms2.inr.ac.ru |