more on commands
[lartc.git] / manpages / tc.8
blob1738b8b41fd13402f9b24c1acc2f8dcfd624dd59
1 .TH TC 8 "8 December 2001" "iproute2" "Linux"
2 .SH NAME
3 tc \- show / manipulate traffic control settings
4 .SH SYNOPSIS
5 .B tc qdisc [ add | change | replace | link ] dev 
6 DEV 
7 .B 
8 [ parent 
9 qdisc-id 
10 .B | root ] 
11 .B [ handle 
12 qdisc-id ] qdisc
13 [ qdisc specific parameters ]
16 .B tc class [ add | change | replace ] dev
17 DEV
18 .B parent 
19 qdisc-id 
20 .B [ classid 
21 class-id ] qdisc
22 [ qdisc specific parameters ]
25 .B tc filter [ add | change | replace ] dev
26 DEV
27 .B  [ parent
28 qdisc-id
29 .B | root ] protocol
30 protocol
31 .B prio
32 priority filtertype
33 [ filtertype specific parameters ]
34 .B flowid
35 flow-id
37 .B tc [-s | -d ] qdisc show [ dev 
38 DEV 
39 .B  ]
41 .B tc [-s | -d ] class show dev 
42 DEV 
44 .B tc filter show dev 
45 DEV 
47 .SH DESCRIPTION
48 .B Tc
49 is used to configure Traffic Control in the Linux kernel. Traffic Control consists 
50 of the following:
52 .TP 
53 SHAPING
54 When traffic is shaped, its rate of transmission is under control. Shaping may 
55 be more than lowering the available bandwidth - it is also used to smooth out 
56 bursts in traffic for better network behaviour.
58 .TP 
59 REORDERING
60 By changing the relative positions of packets it is possible to improve interactivity
61 for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering
62 is also called prioritizing.
64 .TP
65 DROP
66 Traffic exceeding a set bandwidth may also be dropped forthwith.
69 Processing of traffic is controlled by three kinds of objects: qdiscs, 
70 classes and filters. 
72 .SH QDISCS
73 .B qdisc 
74 is short for 'queueing discipline' and it is elementary to 
75 understanding traffic control. Whenever the kernel needs to send a 
76 packet to an interface, it is 
77 .B enqueued
78 to the qdisc configured for that interface. Immediately afterwards, the kernel
79 tries to get as many packets as possible from the qdisc, for giving them
80 to the network adaptor driver.
82 A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure 
83 First In, First Out queue. It does however store traffic when the network interface
84 can't handle it momentarily.
86 .SH CLASSES
87 Some qdiscs can contain further qdiscs - traffic may then be enqueued in any
88 of the inner qdiscs, which are called
89 .B classes.
90 When the kernel tries to dequeue a packet from such a 
91 .B classful qdisc
92 it can come from any of the classes. A qdisc may for example prioritize 
93 certain kinds of traffic by trying to dequeue from certain classes
94 before others.
96 .SH FILTERS
98 .B filter
99 is used by a classful qdisc to determine in which class a packet will
100 be enqueued. Whenever traffic arrives in a classful queueing discipline,
101 it calls all filters attached to it to determine where to send it.
103 It is important to notice that filters reside 
104 .B within
105 qdiscs - they are not masters of what happens.
107 .SH CLASSLESS QDISCS
108 The classless qdiscs are:
109 .TP 
110 [p|b]fifo
111 Simplest usable qdisc, pure First In, First Out behaviour. Limited in 
112 packets or in bytes.
114 pfifo_fast
115 Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
116 queue which honors Type of Service flags by default.
119 Random Early Detection simulates physical congestion by randomly dropping
120 packets when nearing configured bandwidth allocation. Well suited to very
121 large bandwidth applications.
122 .TP 
124 Stochastic Faireness Queueing reorders queued traffic so each 'session'
125 gets to send a packet in turn.
128 The Token Bucket Filter is suited for slowing traffic down to a precisely
129 configured level. Scales well to large bandwidths. 
130 .SH CONFIGURING CLASSLESS QDISCS
131 In the absence of classful qdiscs, classless qdiscs can only be attached at 
132 the root of a device. Full syntax:
134 .B tc qdisc add dev 
135 DEV 
136 .B root 
137 QDISC QDISC-PARAMETERS
139 To remove, issue
141 .B tc qdisc del dev
143 .B root
145 The  
146 .B pfifo_fast
147 qdisc is the automatic default in the absence of a configured qdisc.
149 .SH CLASSFUL QDISCS
150 The classful qdiscs are:
153 Class Based Queueing implements a rich linksharing hierarchy of classes. 
154 It contains shaping elements as well as prioritizing capabilities. Shaping is
155 performed using link idle time calculations based on average packetsize and
156 underlying link bandwidth. The latter may be ill-defined for some interfaces.
159 The Hierarchy Token Bucket implements a rich linksharing hierarchy of 
160 classes with an emphasis on conforming to existing practices. HTB facilitates
161 guaranteeing bandwidth to classes, while also allowing specification of upper
162 limits to inter-class sharing. It contains shaping elements, based on TBF and
163 can prioritize classes. 
164 .TP 
165 PRIO
166 The PRIO qdisc is a non-shaping container for a configurable number of 
167 classes which are dequeued in order. This allows for easy prioritization 
168 of traffic, where lower classes are only able to send if higher ones have 
169 no packets available. To facilitate configuration, Type Of Service bits are 
170 honored by default.
171 .SH THEORY OF OPERATION
172 Classful qdiscs form a tree, where each class has a single parent. 
173 A parent may have multiple children. Some qdiscs allow for runtime addition
174 of classes (CBQ, HTB) while others (PRIO) are created with a static number of 
175 children.
177 Qdiscs which allow dynamic classes can have zero or more subclasses to 
178 which traffic may be enqueued. 
180 Furthermore, each class contains a
181 .B leaf qdisc
182 which by default has 
183 .B pfifo_fast 
184 behaviour though another qdisc can be attached in place. This qdisc may again 
185 contain classes, but each class can have only one leaf qdisc. 
187 When a packet enters a classful qdisc it can be 
188 .B classified
189 to one of the children. Three criteria are available, although not all qdiscs 
190 may use all three:
191 .TP 
192 tc filters
193 If tc filters are attached to a classful qdisc, they are consulted first 
194 for relevant instructions. Filters can match on all fields of a packet header, 
195 as well as on the firewall mark applied by ipchains or iptables. See 
196 .BR tc-filters (8).
198 Type of Service
199 Some qdiscs have built in rules for classifying packets based on the TOS field.
201 skb->prio
202 Userspace programs can encode a class-id in the 'skb->prio' field using 
203 IOCTL commands. 
205 Each node within the tree can have its own filters but higher level filters
206 may also point directly to lower classes.
208 If classification did not succeed, packets are enqueued to the leaf qdisc 
209 attached to that class. Check qdisc specific manpages for details, however.
211 .SH NAMING
212 All qdiscs, classes and filters have IDs, which can either be specified
213 or be automatically assigned. 
215 IDs consist of a major number and a minor number, separated by a colon.
217 .TP 
218 QDISCS
219 A qdisc, which potentially can have children, 
220 gets assigned a major number, called a 'handle', leaving the minor 
221 number namespace available for classes. The handle is expressed as '10:'. 
222 It is customary to explicitly assign a handle to qdiscs expected to have 
223 children.
225 .TP 
226 CLASSES
227 Classes residing under a qdisc share their qdisc major number, but each have
228 a separate minor number called a 'classid' that has no relation to their 
229 parent classes, only to their parent qdisc. The same naming custom as for 
230 qdiscs applies.
232 .TP 
233 FILTERS
234 Filters have a three part ID, which is only needed when using a hashed
235 filter hierarchy, for which see
236 .BR tc-filters (8).
238 .SH TC COMMANDS
239 The following commands are available for qdiscs, classes and filter:
242 Add a qdisc, class or filter to a node. For all entities, a 
243 .B parent
244 must be passed, either by passing its ID or by attaching directly to the root of a device. 
245 When creating a qdisc or a filter, it can be named with the
246 .B handle
247 parameter. A class is named with the
248 .B classid
249 parameter.
252 remove
253 A qdisc can be removed by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs 
254 are automatically deleted, as well as any filters attached to them.
257 change
258 Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
259 that the handle cannot be changed and neither can the parent. In other words, 
261 change 
262 cannot move a node.
265 replace
266 Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
267 it is created.
270 link
271 Only available for qdiscs and performs a replace where the node 
272 must exist already.
275 .SH HISTORY
276 .B tc
277 was written by Alexey N. Kuznetsov and added in Linux 2.2.
278 .SH SEE ALSO
279 .BR tc-cbq (8),
280 .BR tc-htb (8),
281 .BR tc-sfq (8),
282 .BR tc-red (8),
283 .BR tc-tbf (8),
284 .BR tc-pfifo (8),
285 .BR tc-bfifo (8),
286 .BR tc-pfifo_fast (8),
287 .BR tc-filters (8)
289 .SH AUTHOR
290 Manpage maintained by bert hubert (ahu@ds9a.nl)