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