]> git.proxmox.com Git - mirror_iproute2.git/blob - man/man8/tc.8
tc: Allow to easy change network namespace
[mirror_iproute2.git] / man / man8 / tc.8
1 .TH TC 8 "16 December 2001" "iproute2" "Linux"
2 .SH NAME
3 tc \- show / manipulate traffic control settings
4 .SH SYNOPSIS
5 .B tc
6 .RI "[ " OPTIONS " ]"
7 .B qdisc [ add | change | replace | link | delete ] dev
8 DEV
9 .B
10 [ parent
11 qdisc-id
12 .B | root ]
13 .B [ handle
14 qdisc-id ] qdisc
15 [ qdisc specific parameters ]
16 .P
17
18 .B tc
19 .RI "[ " OPTIONS " ]"
20 .B class [ add | change | replace | delete ] dev
21 DEV
22 .B parent
23 qdisc-id
24 .B [ classid
25 class-id ] qdisc
26 [ qdisc specific parameters ]
27 .P
28
29 .B tc
30 .RI "[ " OPTIONS " ]"
31 .B filter [ add | change | replace | delete ] dev
32 DEV
33 .B [ parent
34 qdisc-id
35 .B | root ] protocol
36 protocol
37 .B prio
38 priority filtertype
39 [ filtertype specific parameters ]
40 .B flowid
41 flow-id
42
43 .B tc
44 .RI "[ " OPTIONS " ]"
45 .RI "[ " FORMAT " ]"
46 .B qdisc show [ dev
47 DEV
48 .B ]
49 .P
50 .B tc
51 .RI "[ " OPTIONS " ]"
52 .RI "[ " FORMAT " ]"
53 .B class show dev
54 DEV
55 .P
56 .B tc
57 .RI "[ " OPTIONS " ]"
58 .B filter show dev
59 DEV
60
61 .P
62 .ti 8
63 .IR OPTIONS " := {"
64 \fB[ -force ] -b\fR[\fIatch\fR] \fB[ filename ] \fR|
65 \fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR}
66
67 .ti 8
68 .IR FORMAT " := {"
69 \fB\-s\fR[\fItatistics\fR] |
70 \fB\-d\fR[\fIetails\fR] |
71 \fB\-r\fR[\fIaw\fR] |
72 \fB\-p\fR[\fIretty\fR] |
73 \fB\-i\fR[\fIec\fR] }
74
75 .SH DESCRIPTION
76 .B Tc
77 is used to configure Traffic Control in the Linux kernel. Traffic Control consists
78 of the following:
79
80 .TP
81 SHAPING
82 When traffic is shaped, its rate of transmission is under control. Shaping may
83 be more than lowering the available bandwidth - it is also used to smooth out
84 bursts in traffic for better network behaviour. Shaping occurs on egress.
85
86 .TP
87 SCHEDULING
88 By scheduling the transmission of packets it is possible to improve interactivity
89 for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering
90 is also called prioritizing, and happens only on egress.
91
92 .TP
93 POLICING
94 Whereas shaping deals with transmission of traffic, policing pertains to traffic
95 arriving. Policing thus occurs on ingress.
96
97 .TP
98 DROPPING
99 Traffic exceeding a set bandwidth may also be dropped forthwith, both on
100 ingress and on egress.
101
102 .P
103 Processing of traffic is controlled by three kinds of objects: qdiscs,
104 classes and filters.
105
106 .SH QDISCS
107 .B qdisc
108 is short for 'queueing discipline' and it is elementary to
109 understanding traffic control. Whenever the kernel needs to send a
110 packet to an interface, it is
111 .B enqueued
112 to the qdisc configured for that interface. Immediately afterwards, the kernel
113 tries to get as many packets as possible from the qdisc, for giving them
114 to the network adaptor driver.
115
116 A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure
117 First In, First Out queue. It does however store traffic when the network interface
118 can't handle it momentarily.
119
120 .SH CLASSES
121 Some qdiscs can contain classes, which contain further qdiscs - traffic may
122 then be enqueued in any of the inner qdiscs, which are within the
123 .B classes.
124 When the kernel tries to dequeue a packet from such a
125 .B classful qdisc
126 it can come from any of the classes. A qdisc may for example prioritize
127 certain kinds of traffic by trying to dequeue from certain classes
128 before others.
129
130 .SH FILTERS
131 A
132 .B filter
133 is used by a classful qdisc to determine in which class a packet will
134 be enqueued. Whenever traffic arrives at a class with subclasses, it needs
135 to be classified. Various methods may be employed to do so, one of these
136 are the filters. All filters attached to the class are called, until one of
137 them returns with a verdict. If no verdict was made, other criteria may be
138 available. This differs per qdisc.
139
140 It is important to notice that filters reside
141 .B within
142 qdiscs - they are not masters of what happens.
143
144 .SH CLASSLESS QDISCS
145 The classless qdiscs are:
146 .TP
147 [p|b]fifo
148 Simplest usable qdisc, pure First In, First Out behaviour. Limited in
149 packets or in bytes.
150 .TP
151 pfifo_fast
152 Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
153 queue which honors Type of Service flags, as well as the priority that may be
154 assigned to a packet.
155 .TP
156 red
157 Random Early Detection simulates physical congestion by randomly dropping
158 packets when nearing configured bandwidth allocation. Well suited to very
159 large bandwidth applications.
160 .TP
161 sfq
162 Stochastic Fairness Queueing reorders queued traffic so each 'session'
163 gets to send a packet in turn.
164 .TP
165 tbf
166 The Token Bucket Filter is suited for slowing traffic down to a precisely
167 configured rate. Scales well to large bandwidths.
168 .SH CONFIGURING CLASSLESS QDISCS
169 In the absence of classful qdiscs, classless qdiscs can only be attached at
170 the root of a device. Full syntax:
171 .P
172 .B tc qdisc add dev
173 DEV
174 .B root
175 QDISC QDISC-PARAMETERS
176
177 To remove, issue
178 .P
179 .B tc qdisc del dev
180 DEV
181 .B root
182
183 The
184 .B pfifo_fast
185 qdisc is the automatic default in the absence of a configured qdisc.
186
187 .SH CLASSFUL QDISCS
188 The classful qdiscs are:
189 .TP
190 CBQ
191 Class Based Queueing implements a rich linksharing hierarchy of classes.
192 It contains shaping elements as well as prioritizing capabilities. Shaping is
193 performed using link idle time calculations based on average packet size and
194 underlying link bandwidth. The latter may be ill-defined for some interfaces.
195 .TP
196 HTB
197 The Hierarchy Token Bucket implements a rich linksharing hierarchy of
198 classes with an emphasis on conforming to existing practices. HTB facilitates
199 guaranteeing bandwidth to classes, while also allowing specification of upper
200 limits to inter-class sharing. It contains shaping elements, based on TBF and
201 can prioritize classes.
202 .TP
203 PRIO
204 The PRIO qdisc is a non-shaping container for a configurable number of
205 classes which are dequeued in order. This allows for easy prioritization
206 of traffic, where lower classes are only able to send if higher ones have
207 no packets available. To facilitate configuration, Type Of Service bits are
208 honored by default.
209 .SH THEORY OF OPERATION
210 Classes form a tree, where each class has a single parent.
211 A class may have multiple children. Some qdiscs allow for runtime addition
212 of classes (CBQ, HTB) while others (PRIO) are created with a static number of
213 children.
214
215 Qdiscs which allow dynamic addition of classes can have zero or more
216 subclasses to which traffic may be enqueued.
217
218 Furthermore, each class contains a
219 .B leaf qdisc
220 which by default has
221 .B pfifo
222 behaviour, although another qdisc can be attached in place. This qdisc may again
223 contain classes, but each class can have only one leaf qdisc.
224
225 When a packet enters a classful qdisc it can be
226 .B classified
227 to one of the classes within. Three criteria are available, although not all
228 qdiscs will use all three:
229 .TP
230 tc filters
231 If tc filters are attached to a class, they are consulted first
232 for relevant instructions. Filters can match on all fields of a packet header,
233 as well as on the firewall mark applied by ipchains or iptables.
234 .TP
235 Type of Service
236 Some qdiscs have built in rules for classifying packets based on the TOS field.
237 .TP
238 skb->priority
239 Userspace programs can encode a class-id in the 'skb->priority' field using
240 the SO_PRIORITY option.
241 .P
242 Each node within the tree can have its own filters but higher level filters
243 may also point directly to lower classes.
244
245 If classification did not succeed, packets are enqueued to the leaf qdisc
246 attached to that class. Check qdisc specific manpages for details, however.
247
248 .SH NAMING
249 All qdiscs, classes and filters have IDs, which can either be specified
250 or be automatically assigned.
251
252 IDs consist of a major number and a minor number, separated by a colon.
253 Both major and minor number are limited to 16 bits. There are two special
254 values: root is signified by major and minor of all ones, and unspecified
255 is all zeros.
256
257 .TP
258 QDISCS
259 A qdisc, which potentially can have children,
260 gets assigned a major number, called a 'handle', leaving the minor
261 number namespace available for classes. The handle is expressed as '10:'.
262 It is customary to explicitly assign a handle to qdiscs expected to have
263 children.
264
265 .TP
266 CLASSES
267 Classes residing under a qdisc share their qdisc major number, but each have
268 a separate minor number called a 'classid' that has no relation to their
269 parent classes, only to their parent qdisc. The same naming custom as for
270 qdiscs applies.
271
272 .TP
273 FILTERS
274 Filters have a three part ID, which is only needed when using a hashed
275 filter hierarchy.
276
277 .SH PARAMETERS
278 The following parameters are widely used in TC. For other parameters,
279 see the man pages for individual qdiscs.
280
281 .TP
282 RATES
283 Bandwidths or rates.
284 These parameters accept a floating point number, possibly followed by
285 a unit (both SI and IEC units supported).
286 .RS
287 .TP
288 bit or a bare number
289 Bits per second
290 .TP
291 kbit
292 Kilobits per second
293 .TP
294 mbit
295 Megabits per second
296 .TP
297 gbit
298 Gigabits per second
299 .TP
300 tbit
301 Terabits per second
302 .TP
303 bps
304 Bytes per second
305 .TP
306 kbps
307 Kilobytes per second
308 .TP
309 mbps
310 Megabytes per second
311 .TP
312 gbps
313 Gigabytes per second
314 .TP
315 tbps
316 Terabytes per second
317
318 .P
319 To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with
320 IEC prefix (ki-, mi-, gi- and ti-) respectively.
321
322 .P
323 TC store rates as a 32-bit unsigned integer in bps internally,
324 so we can specify a max rate of 4294967295 bps.
325 .RE
326
327 .TP
328 TIMES
329 Length of time. Can be specified as a floating point number
330 followed by an optional unit:
331 .RS
332 .TP
333 s, sec or secs
334 Whole seconds
335 .TP
336 ms, msec or msecs
337 Milliseconds
338 .TP
339 us, usec, usecs or a bare number
340 Microseconds.
341
342 .P
343 TC defined its own time unit (equal to microsecond) and stores
344 time values as 32-bit unsigned integer, thus we can specify a max time value
345 of 4294967295 usecs.
346 .RE
347
348 .TP
349 SIZES
350 Amounts of data. Can be specified as a floating point number
351 followed by an optional unit:
352 .RS
353 .TP
354 b or a bare number
355 Bytes.
356 .TP
357 kbit
358 Kilobits
359 .TP
360 kb or k
361 Kilobytes
362 .TP
363 mbit
364 Megabits
365 .TP
366 mb or m
367 Megabytes
368 .TP
369 gbit
370 Gigabits
371 .TP
372 gb or g
373 Gigabytes
374
375 .P
376 TC stores sizes internally as 32-bit unsigned integer in byte,
377 so we can specify a max size of 4294967295 bytes.
378 .RE
379
380 .TP
381 VALUES
382 Other values without a unit.
383 These parameters are interpreted as decimal by default, but you can
384 indicate TC to interpret them as octal and hexadecimal by adding a '0'
385 or '0x' prefix respectively.
386
387 .SH TC COMMANDS
388 The following commands are available for qdiscs, classes and filter:
389 .TP
390 add
391 Add a qdisc, class or filter to a node. For all entities, a
392 .B parent
393 must be passed, either by passing its ID or by attaching directly to the root of a device.
394 When creating a qdisc or a filter, it can be named with the
395 .B handle
396 parameter. A class is named with the
397 .B classid
398 parameter.
399
400 .TP
401 delete
402 A qdisc can be deleted by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs
403 are automatically deleted, as well as any filters attached to them.
404
405 .TP
406 change
407 Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
408 that the handle cannot be changed and neither can the parent. In other words,
409 .B
410 change
411 cannot move a node.
412
413 .TP
414 replace
415 Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
416 it is created.
417
418 .TP
419 link
420 Only available for qdiscs and performs a replace where the node
421 must exist already.
422
423 .SH OPTIONS
424
425 .TP
426 .BR "\-b", " \-b filename", " \-batch", " \-batch filename"
427 read commands from provided file or standard input and invoke them.
428 First failure will cause termination of tc.
429
430 .TP
431 .BR "\-force"
432 don't terminate tc on errors in batch mode.
433 If there were any errors during execution of the commands, the application return code will be non zero.
434
435 .TP
436 .BR "\-n" , " \-net" , " \-netns " <NETNS>
437 switches
438 .B tc
439 to the specified network namespace
440 .IR NETNS .
441 Actually it just simplifies executing of:
442
443 .B ip netns exec
444 .IR NETNS
445 .B tc
446 .RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
447 .BR help " }"
448
449 to
450
451 .B tc
452 .RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
453 .BR help " }"
454
455 .SH FORMAT
456 The show command has additional formatting options:
457
458 .TP
459 .BR "\-s" , " \-stats", " \-statistics"
460 output more statistics about packet usage.
461
462 .TP
463 .BR "\-d", " \-details"
464 output more detailed information about rates and cell sizes.
465
466 .TP
467 .BR "\-r", " \-raw"
468 output raw hex values for handles.
469
470 .TP
471 .BR "\-p", " \-pretty"
472 decode filter offset and mask values to equivalent filter commands based on TCP/IP.
473
474 .TP
475 .BR "\-iec"
476 print rates in IEC units (ie. 1K = 1024).
477
478 .SH HISTORY
479 .B tc
480 was written by Alexey N. Kuznetsov and added in Linux 2.2.
481 .SH SEE ALSO
482 .BR tc-bfifo (8),
483 .BR tc-cbq (8),
484 .BR tc-choke (8),
485 .BR tc-codel (8),
486 .BR tc-drr (8),
487 .BR tc-ematch (8),
488 .BR tc-fq_codel (8),
489 .BR tc-hfsc (7),
490 .BR tc-hfsc (8),
491 .BR tc-htb (8),
492 .BR tc-mqprio (8),
493 .BR tc-pfifo (8),
494 .BR tc-pfifo_fast (8),
495 .BR tc-red (8),
496 .BR tc-sfb (8),
497 .BR tc-sfq (8),
498 .BR tc-stab (8),
499 .BR tc-tbf (8),
500 .br
501 .RB "User documentation at " http://lartc.org/ ", but please direct bugreports and patches to: " <netdev@vger.kernel.org>
502
503 .SH AUTHOR
504 Manpage maintained by bert hubert (ahu@ds9a.nl)
505