blob: 4e99dcad5b1dab72256919302215c03a05962841 [file] [log] [blame]
.TH TC 8 "16 December 2001" "iproute2" "Linux"
tc \- show / manipulate traffic control settings
.B tc
.RI "[ " OPTIONS " ]"
.B qdisc [ add | change | replace | link | delete ] dev
[ parent
.B | root ]
.B [ handle
qdisc-id ] qdisc
[ qdisc specific parameters ]
.B tc
.RI "[ " OPTIONS " ]"
.B class [ add | change | replace | delete ] dev
.B parent
.B [ classid
class-id ] qdisc
[ qdisc specific parameters ]
.B tc
.RI "[ " OPTIONS " ]"
.B filter [ add | change | replace | delete ] dev
.B [ parent
.B | root ] protocol
.B prio
priority filtertype
[ filtertype specific parameters ]
.B flowid
.B tc
.RI "[ " OPTIONS " ]"
.RI "[ " FORMAT " ]"
.B qdisc show [ dev
.B ]
.B tc
.RI "[ " OPTIONS " ]"
.RI "[ " FORMAT " ]"
.B class show dev
.B tc
.RI "[ " OPTIONS " ]"
.B filter show dev
.ti 8
.IR OPTIONS " := {"
\fB[ -force ] -b\fR[\fIatch\fR] \fB[ filename ] \fR|
\fB[ \fB-n\fR[\fIetns\fR] name \fB] \fR|
\fB[ \fB-nm \fR| \fB-nam\fR[\fIes\fR] \fB] \fR|
\fB[ \fR{ \fB-cf \fR| \fB-c\fR[\fIonf\fR] \fR} \fB[ filename ] \fB] \fR}
.ti 8
.IR FORMAT " := {"
\fB\-s\fR[\fItatistics\fR] |
\fB\-d\fR[\fIetails\fR] |
\fB\-r\fR[\fIaw\fR] |
\fB\-p\fR[\fIretty\fR] |
\fB\-i\fR[\fIec\fR] |
\fB\-g\fR[\fIraph\fR] }
.B Tc
is used to configure Traffic Control in the Linux kernel. Traffic Control consists
of the following:
When traffic is shaped, its rate of transmission is under control. Shaping may
be more than lowering the available bandwidth - it is also used to smooth out
bursts in traffic for better network behaviour. Shaping occurs on egress.
By scheduling the transmission of packets it is possible to improve interactivity
for traffic that needs it while still guaranteeing bandwidth to bulk transfers. Reordering
is also called prioritizing, and happens only on egress.
Whereas shaping deals with transmission of traffic, policing pertains to traffic
arriving. Policing thus occurs on ingress.
Traffic exceeding a set bandwidth may also be dropped forthwith, both on
ingress and on egress.
Processing of traffic is controlled by three kinds of objects: qdiscs,
classes and filters.
.B qdisc
is short for 'queueing discipline' and it is elementary to
understanding traffic control. Whenever the kernel needs to send a
packet to an interface, it is
.B enqueued
to the qdisc configured for that interface. Immediately afterwards, the kernel
tries to get as many packets as possible from the qdisc, for giving them
to the network adaptor driver.
A simple QDISC is the 'pfifo' one, which does no processing at all and is a pure
First In, First Out queue. It does however store traffic when the network interface
can't handle it momentarily.
Some qdiscs can contain classes, which contain further qdiscs - traffic may
then be enqueued in any of the inner qdiscs, which are within the
.B classes.
When the kernel tries to dequeue a packet from such a
.B classful qdisc
it can come from any of the classes. A qdisc may for example prioritize
certain kinds of traffic by trying to dequeue from certain classes
before others.
.B filter
is used by a classful qdisc to determine in which class a packet will
be enqueued. Whenever traffic arrives at a class with subclasses, it needs
to be classified. Various methods may be employed to do so, one of these
are the filters. All filters attached to the class are called, until one of
them returns with a verdict. If no verdict was made, other criteria may be
available. This differs per qdisc.
It is important to notice that filters reside
.B within
qdiscs - they are not masters of what happens.
The available filters are:
Filter packets based on an ematch expression. See
.BR tc-ematch (8)
for details.
Filter packets using (e)BPF, see
.BR tc-bpf (8)
for details.
Filter packets based on the control group of their process. See
. BR tc-cgroup (8)
for details.
flow, flower
Flow-based classifiers, filtering packets based on their flow (identified by selectable keys). See
.BR tc-flow "(8) and"
.BR tc-flower (8)
for details.
Filter based on fwmark. Directly maps fwmark value to traffic class. See
.BR tc-fw (8).
Filter packets based on routing table. See
.BR tc-route (8)
for details.
Match Resource Reservation Protocol (RSVP) packets.
Filter packets based on traffic control index. See
.BR tc-tcindex (8).
Generic filtering on arbitrary packet data, assisted by syntax to abstract common operations. See
.BR tc-u32 (8)
for details.
The classless qdiscs are:
CHOKe (CHOose and Keep for responsive flows, CHOose and Kill for unresponsive
flows) is a classless qdisc designed to both identify and penalize flows that
monopolize the queue. CHOKe is a variation of RED, and the configuration is
similar to RED.
CoDel (pronounced "coddle") is an adaptive "no-knobs" active queue management
algorithm (AQM) scheme that was developed to address the shortcomings of
RED and its variants.
Simplest usable qdisc, pure First In, First Out behaviour. Limited in
packets or in bytes.
Fair Queue Scheduler realises TCP pacing and scales to millions of concurrent
flows per qdisc.
Fair Queuing Controlled Delay is queuing discipline that combines Fair
Queuing with the CoDel AQM scheme. FQ_Codel uses a stochastic model to classify
incoming packets into different flows and is used to provide a fair share of the
bandwidth to all the flows using the queue. Each such flow is managed by the
CoDel queuing discipline. Reordering within a flow is avoided since Codel
internally uses a FIFO queue.
Generalized Random Early Detection combines multiple RED queues in order to
achieve multiple drop priorities. This is required to realize Assured
Forwarding (RFC 2597).
Heavy-Hitter Filter differentiates between small flows and the opposite,
heavy-hitters. The goal is to catch the heavy-hitters and move them to a
separate queue with less priority so that bulk traffic does not affect the
latency of critical traffic.
This is a special qdisc as it applies to incoming traffic on an interface, allowing for it to be filtered and policed.
The Multiqueue Priority Qdisc is a simple queuing discipline that allows
mapping traffic flows to hardware queue ranges using priorities and a
configurable priority to traffic class mapping. A traffic class in this context
is a set of contiguous qdisc classes which map 1:1 to a set of hardware exposed
Multiqueue is a qdisc optimized for devices with multiple Tx queues. It has
been added for hardware that wishes to avoid head-of-line blocking. It will
cycle though the bands and verify that the hardware queue associated with the
band is not stopped prior to dequeuing a packet.
Network Emulator is an enhancement of the Linux traffic control facilities that
allow to add delay, packet loss, duplication and more other characteristics to
packets outgoing from a selected network interface.
Standard qdisc for 'Advanced Router' enabled kernels. Consists of a three-band
queue which honors Type of Service flags, as well as the priority that may be
assigned to a packet.
Proportional Integral controller-Enhanced (PIE) is a control theoretic active
queue management scheme. It is based on the proportional integral controller but
aims to control delay.
Random Early Detection simulates physical congestion by randomly dropping
packets when nearing configured bandwidth allocation. Well suited to very
large bandwidth applications.
Round-Robin qdisc with support for multiqueue network devices. Removed from
Linux since kernel version 2.6.27.
Stochastic Fair Blue is a classless qdisc to manage congestion based on
packet loss and link utilization history while trying to prevent
non-responsive flows (i.e. flows that do not react to congestion marking
or dropped packets) from impacting performance of responsive flows.
Unlike RED, where the marking probability has to be configured, BLUE
tries to determine the ideal marking probability automatically.
Stochastic Fairness Queueing reorders queued traffic so each 'session'
gets to send a packet in turn.
The Token Bucket Filter is suited for slowing traffic down to a precisely
configured rate. Scales well to large bandwidths.
In the absence of classful qdiscs, classless qdiscs can only be attached at
the root of a device. Full syntax:
.B tc qdisc add dev
.B root
To remove, issue
.B tc qdisc del dev
.B root
.B pfifo_fast
qdisc is the automatic default in the absence of a configured qdisc.
The classful qdiscs are:
Map flows to virtual circuits of an underlying asynchronous transfer mode
Class Based Queueing implements a rich linksharing hierarchy of classes.
It contains shaping elements as well as prioritizing capabilities. Shaping is
performed using link idle time calculations based on average packet size and
underlying link bandwidth. The latter may be ill-defined for some interfaces.
The Deficit Round Robin Scheduler is a more flexible replacement for Stochastic
Fairness Queuing. Unlike SFQ, there are no built-in queues \-\- you need to add
classes and then set up filters to classify packets accordingly. This can be
useful e.g. for using RED qdiscs with different settings for particular
traffic. There is no default class \-\- if a packet cannot be classified, it is
Classify packets based on TOS field, change TOS field of packets based on
Hierarchical Fair Service Curve guarantees precise bandwidth and delay allocation for leaf classes and allocates excess bandwidth fairly. Unlike HTB, it makes use of packet dropping to achieve low delays which interactive sessions benefit from.
The Hierarchy Token Bucket implements a rich linksharing hierarchy of
classes with an emphasis on conforming to existing practices. HTB facilitates
guaranteeing bandwidth to classes, while also allowing specification of upper
limits to inter-class sharing. It contains shaping elements, based on TBF and
can prioritize classes.
The PRIO qdisc is a non-shaping container for a configurable number of
classes which are dequeued in order. This allows for easy prioritization
of traffic, where lower classes are only able to send if higher ones have
no packets available. To facilitate configuration, Type Of Service bits are
honored by default.
Quick Fair Queueing is an O(1) scheduler that provides near-optimal guarantees,
and is the first to achieve that goal with a constant cost also with respect to
the number of groups and the packet length. The QFQ algorithm has no loops, and
uses very simple instructions and data structures that lend themselves very
well to a hardware implementation.
Classes form a tree, where each class has a single parent.
A class may have multiple children. Some qdiscs allow for runtime addition
of classes (CBQ, HTB) while others (PRIO) are created with a static number of
Qdiscs which allow dynamic addition of classes can have zero or more
subclasses to which traffic may be enqueued.
Furthermore, each class contains a
.B leaf qdisc
which by default has
.B pfifo
behaviour, although another qdisc can be attached in place. This qdisc may again
contain classes, but each class can have only one leaf qdisc.
When a packet enters a classful qdisc it can be
.B classified
to one of the classes within. Three criteria are available, although not all
qdiscs will use all three:
tc filters
If tc filters are attached to a class, they are consulted first
for relevant instructions. Filters can match on all fields of a packet header,
as well as on the firewall mark applied by ipchains or iptables.
Type of Service
Some qdiscs have built in rules for classifying packets based on the TOS field.
Userspace programs can encode a class-id in the 'skb->priority' field using
the SO_PRIORITY option.
Each node within the tree can have its own filters but higher level filters
may also point directly to lower classes.
If classification did not succeed, packets are enqueued to the leaf qdisc
attached to that class. Check qdisc specific manpages for details, however.
All qdiscs, classes and filters have IDs, which can either be specified
or be automatically assigned.
IDs consist of a
.BR major " number and a " minor
number, separated by a colon -
.BR major ":" minor "."
.BR major " and " minor
are hexadecimal numbers and are limited to 16 bits. There are two special
values: root is signified by
.BR major " and " minor
of all ones, and unspecified is all zeros.
A qdisc, which potentially can have children, gets assigned a
.B major
number, called a 'handle', leaving the
.B minor
number namespace available for classes. The handle is expressed as '10:'.
It is customary to explicitly assign a handle to qdiscs expected to have children.
Classes residing under a qdisc share their qdisc
.B major
number, but each have a separate
.B minor
number called a 'classid' that has no relation to their
parent classes, only to their parent qdisc. The same naming custom as for
qdiscs applies.
Filters have a three part ID, which is only needed when using a hashed
filter hierarchy.
The following parameters are widely used in TC. For other parameters,
see the man pages for individual qdiscs.
Bandwidths or rates.
These parameters accept a floating point number, possibly followed by
a unit (both SI and IEC units supported).
bit or a bare number
Bits per second
Kilobits per second
Megabits per second
Gigabits per second
Terabits per second
Bytes per second
Kilobytes per second
Megabytes per second
Gigabytes per second
Terabytes per second
To specify in IEC units, replace the SI prefix (k-, m-, g-, t-) with
IEC prefix (ki-, mi-, gi- and ti-) respectively.
TC store rates as a 32-bit unsigned integer in bps internally,
so we can specify a max rate of 4294967295 bps.
Length of time. Can be specified as a floating point number
followed by an optional unit:
s, sec or secs
Whole seconds
ms, msec or msecs
us, usec, usecs or a bare number
TC defined its own time unit (equal to microsecond) and stores
time values as 32-bit unsigned integer, thus we can specify a max time value
of 4294967295 usecs.
Amounts of data. Can be specified as a floating point number
followed by an optional unit:
b or a bare number
kb or k
mb or m
gb or g
TC stores sizes internally as 32-bit unsigned integer in byte,
so we can specify a max size of 4294967295 bytes.
Other values without a unit.
These parameters are interpreted as decimal by default, but you can
indicate TC to interpret them as octal and hexadecimal by adding a '0'
or '0x' prefix respectively.
The following commands are available for qdiscs, classes and filter:
Add a qdisc, class or filter to a node. For all entities, a
.B parent
must be passed, either by passing its ID or by attaching directly to the root of a device.
When creating a qdisc or a filter, it can be named with the
.B handle
parameter. A class is named with the
.B classid
A qdisc can be deleted by specifying its handle, which may also be 'root'. All subclasses and their leaf qdiscs
are automatically deleted, as well as any filters attached to them.
Some entities can be modified 'in place'. Shares the syntax of 'add', with the exception
that the handle cannot be changed and neither can the parent. In other words,
cannot move a node.
Performs a nearly atomic remove/add on an existing node id. If the node does not exist yet
it is created.
Only available for qdiscs and performs a replace where the node
must exist already.
.BR "\-b", " \-b filename", " \-batch", " \-batch filename"
read commands from provided file or standard input and invoke them.
First failure will cause termination of tc.
.BR "\-force"
don't terminate tc on errors in batch mode.
If there were any errors during execution of the commands, the application return code will be non zero.
.BR "\-n" , " \-net" , " \-netns " <NETNS>
.B tc
to the specified network namespace
Actually it just simplifies executing of:
.B ip netns exec
.B tc
.RI "[ " OPTIONS " ] " OBJECT " { " COMMAND " | "
.BR help " }"
.B tc
.RI "-n[etns] " NETNS " [ " OPTIONS " ] " OBJECT " { " COMMAND " | "
.BR help " }"
.BR "\-cf" , " \-conf " <FILENAME>
specifies path to the config file. This option is used in conjunction with other options (e.g.
.BR -nm ")."
The show command has additional formatting options:
.BR "\-s" , " \-stats", " \-statistics"
output more statistics about packet usage.
.BR "\-d", " \-details"
output more detailed information about rates and cell sizes.
.BR "\-r", " \-raw"
output raw hex values for handles.
.BR "\-p", " \-pretty"
decode filter offset and mask values to equivalent filter commands based on TCP/IP.
.BR "\-iec"
print rates in IEC units (ie. 1K = 1024).
.BR "\-g", " \-graph"
shows classes as ASCII graph. Prints generic stats info under each class if
.BR "-s"
option was specified. Classes can be filtered only by
.BR "dev"
.BR "\-nm" , " \-name"
resolve class name from
.B /etc/iproute2/tc_cls
file or from file specified by
.B -cf
option. This file is just a mapping of
.B classid
to class name:
.RS 10
# Here is comment
.RS 10
1:40 voip # Here is another comment
.RS 10
1:50 web
.RS 10
1:60 ftp
.RS 10
1:2 home
.B tc
will not fail if
.B -nm
was specified without
.B -cf
option but
.B /etc/iproute2/tc_cls
file does not exist, which makes it possible to pass
.B -nm
option for creating
.B tc
tc -g class show dev eth0
.RS 4
Shows classes as ASCII graph on eth0 interface.
tc -g -s class show dev eth0
.RS 4
Shows classes as ASCII graph with stats info under each class.
.B tc
was written by Alexey N. Kuznetsov and added in Linux 2.2.
.BR tc-basic (8),
.BR tc-bfifo (8),
.BR tc-bpf (8),
.BR tc-cbq (8),
.BR tc-cgroup (8),
.BR tc-choke (8),
.BR tc-codel (8),
.BR tc-drr (8),
.BR tc-ematch (8),
.BR tc-flow (8),
.BR tc-flower (8),
.BR tc-fq (8),
.BR tc-fq_codel (8),
.BR tc-fw (8),
.BR tc-hfsc (7),
.BR tc-hfsc (8),
.BR tc-htb (8),
.BR tc-mqprio (8),
.BR tc-pfifo (8),
.BR tc-pfifo_fast (8),
.BR tc-red (8),
.BR tc-route (8),
.BR tc-sfb (8),
.BR tc-sfq (8),
.BR tc-stab (8),
.BR tc-tbf (8),
.BR tc-tcindex (8),
.BR tc-u32 (8),
.RB "User documentation at " ", but please direct bugreports and patches to: " <>
Manpage maintained by bert hubert (