Blame man/man8/tc-cbq.8

Packit Service 3880ab
.TH CBQ 8 "16 December 2001" "iproute2" "Linux"
Packit Service 3880ab
.SH NAME
Packit Service 3880ab
CBQ \- Class Based Queueing
Packit Service 3880ab
.SH SYNOPSIS
Packit Service 3880ab
.B tc qdisc ... dev
Packit Service 3880ab
dev
Packit Service 3880ab
.B  ( parent
Packit Service 3880ab
classid
Packit Service 3880ab
.B | root) [ handle
Packit Service 3880ab
major:
Packit Service 3880ab
.B ] cbq [ allot
Packit Service 3880ab
bytes
Packit Service 3880ab
.B ] avpkt
Packit Service 3880ab
bytes
Packit Service 3880ab
.B bandwidth
Packit Service 3880ab
rate
Packit Service 3880ab
.B [ cell
Packit Service 3880ab
bytes
Packit Service 3880ab
.B ] [ ewma
Packit Service 3880ab
log
Packit Service 3880ab
.B ] [ mpu
Packit Service 3880ab
bytes
Packit Service 3880ab
.B ]
Packit Service 3880ab
Packit Service 3880ab
.B tc class ... dev
Packit Service 3880ab
dev
Packit Service 3880ab
.B parent
Packit Service 3880ab
major:[minor]
Packit Service 3880ab
.B [ classid
Packit Service 3880ab
major:minor
Packit Service 3880ab
.B ] cbq allot
Packit Service 3880ab
bytes
Packit Service 3880ab
.B [ bandwidth
Packit Service 3880ab
rate
Packit Service 3880ab
.B ] [ rate
Packit Service 3880ab
rate
Packit Service 3880ab
.B ] prio
Packit Service 3880ab
priority
Packit Service 3880ab
.B [ weight
Packit Service 3880ab
weight
Packit Service 3880ab
.B ] [ minburst
Packit Service 3880ab
packets
Packit Service 3880ab
.B ] [ maxburst
Packit Service 3880ab
packets
Packit Service 3880ab
.B ] [ ewma
Packit Service 3880ab
log
Packit Service 3880ab
.B ] [ cell
Packit Service 3880ab
bytes
Packit Service 3880ab
.B ] avpkt
Packit Service 3880ab
bytes
Packit Service 3880ab
.B [ mpu
Packit Service 3880ab
bytes
Packit Service 3880ab
.B ] [ bounded isolated ] [ split
Packit Service 3880ab
handle
Packit Service 3880ab
.B & defmap
Packit Service 3880ab
defmap
Packit Service 3880ab
.B ] [ estimator
Packit Service 3880ab
interval timeconstant
Packit Service 3880ab
.B ]
Packit Service 3880ab
Packit Service 3880ab
.SH DESCRIPTION
Packit Service 3880ab
Class Based Queueing is a classful qdisc that implements a rich
Packit Service 3880ab
linksharing hierarchy of classes. It contains shaping elements as
Packit Service 3880ab
well as prioritizing capabilities. Shaping is performed using link
Packit Service 3880ab
idle time calculations based on the timing of dequeue events and
Packit Service 3880ab
underlying link bandwidth.
Packit Service 3880ab
Packit Service 3880ab
.SH SHAPING ALGORITHM
Packit Service 3880ab
When shaping a 10mbit/s connection to 1mbit/s, the link will
Packit Service 3880ab
be idle 90% of the time. If it isn't, it needs to be throttled so that it
Packit Service 3880ab
IS idle 90% of the time.
Packit Service 3880ab
Packit Service 3880ab
During operations, the effective idletime is measured using an
Packit Service 3880ab
exponential weighted moving average (EWMA), which considers recent
Packit Service 3880ab
packets to be exponentially more important than past ones. The Unix
Packit Service 3880ab
loadaverage is calculated in the same way.
Packit Service 3880ab
Packit Service 3880ab
The calculated idle time is subtracted from the EWMA measured one,
Packit Service 3880ab
the resulting number is called 'avgidle'. A perfectly loaded link has
Packit Service 3880ab
an avgidle of zero: packets arrive exactly at the calculated
Packit Service 3880ab
interval.
Packit Service 3880ab
Packit Service 3880ab
An overloaded link has a negative avgidle and if it gets too negative,
Packit Service 3880ab
CBQ throttles and is then 'overlimit'.
Packit Service 3880ab
Packit Service 3880ab
Conversely, an idle link might amass a huge avgidle, which would then
Packit Service 3880ab
allow infinite bandwidths after a few hours of silence. To prevent
Packit Service 3880ab
this, avgidle is capped at
Packit Service 3880ab
.B maxidle.
Packit Service 3880ab
Packit Service 3880ab
If overlimit, in theory, the CBQ could throttle itself for exactly the
Packit Service 3880ab
amount of time that was calculated to pass between packets, and then
Packit Service 3880ab
pass one packet, and throttle again. Due to timer resolution constraints,
Packit Service 3880ab
this may not be feasible, see the
Packit Service 3880ab
.B minburst
Packit Service 3880ab
parameter below.
Packit Service 3880ab
Packit Service 3880ab
.SH CLASSIFICATION
Packit Service 3880ab
Within the one CBQ instance many classes may exist. Each of these classes
Packit Service 3880ab
contains another qdisc, by default
Packit Service 3880ab
.BR tc-pfifo (8).
Packit Service 3880ab
Packit Service 3880ab
When enqueueing a packet, CBQ starts at the root and uses various methods to
Packit Service 3880ab
determine which class should receive the data.
Packit Service 3880ab
Packit Service 3880ab
In the absence of uncommon configuration options, the process is rather easy.
Packit Service 3880ab
At each node we look for an instruction, and then go to the class the
Packit Service 3880ab
instruction refers us to. If the class found is a barren leaf-node (without
Packit Service 3880ab
children), we enqueue the packet there. If it is not yet a leaf node, we do
Packit Service 3880ab
the whole thing over again starting from that node.
Packit Service 3880ab
Packit Service 3880ab
The following actions are performed, in order at each node we visit, until one
Packit Service 3880ab
sends us to another node, or terminates the process.
Packit Service 3880ab
.TP
Packit Service 3880ab
(i)
Packit Service 3880ab
Consult filters attached to the class. If sent to a leafnode, we are done.
Packit Service 3880ab
Otherwise, restart.
Packit Service 3880ab
.TP
Packit Service 3880ab
(ii)
Packit Service 3880ab
Consult the defmap for the priority assigned to this packet, which depends
Packit Service 3880ab
on the TOS bits. Check if the referral is leafless, otherwise restart.
Packit Service 3880ab
.TP
Packit Service 3880ab
(iii)
Packit Service 3880ab
Ask the defmap for instructions for the 'best effort' priority. Check the
Packit Service 3880ab
answer for leafness, otherwise restart.
Packit Service 3880ab
.TP
Packit Service 3880ab
(iv)
Packit Service 3880ab
If none of the above returned with an instruction, enqueue at this node.
Packit Service 3880ab
.P
Packit Service 3880ab
This algorithm makes sure that a packet always ends up somewhere, even while
Packit Service 3880ab
you are busy building your configuration.
Packit Service 3880ab
Packit Service 3880ab
For more details, see
Packit Service 3880ab
.BR tc-cbq-details(8).
Packit Service 3880ab
Packit Service 3880ab
.SH LINK SHARING ALGORITHM
Packit Service 3880ab
When dequeuing for sending to the network device, CBQ decides which of its
Packit Service 3880ab
classes will be allowed to send. It does so with a Weighted Round Robin process
Packit Service 3880ab
in which each class with packets gets a chance to send in turn. The WRR process
Packit Service 3880ab
starts by asking the highest priority classes (lowest numerically -
Packit Service 3880ab
highest semantically) for packets, and will continue to do so until they
Packit Service 3880ab
have no more data to offer, in which case the process repeats for lower
Packit Service 3880ab
priorities.
Packit Service 3880ab
Packit Service 3880ab
Classes by default borrow bandwidth from their siblings. A class can be
Packit Service 3880ab
prevented from doing so by declaring it 'bounded'. A class can also indicate
Packit Service 3880ab
its unwillingness to lend out bandwidth by being 'isolated'.
Packit Service 3880ab
Packit Service 3880ab
.SH QDISC
Packit Service 3880ab
The root of a CBQ qdisc class tree has the following parameters:
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
parent major:minor | root
Packit Service 3880ab
This mandatory parameter determines the place of the CBQ instance, either at the
Packit Service 3880ab
.B root
Packit Service 3880ab
of an interface or within an existing class.
Packit Service 3880ab
.TP
Packit Service 3880ab
handle major:
Packit Service 3880ab
Like all other qdiscs, the CBQ can be assigned a handle. Should consist only
Packit Service 3880ab
of a major number, followed by a colon. Optional, but very useful if classes
Packit Service 3880ab
will be generated within this qdisc.
Packit Service 3880ab
.TP
Packit Service 3880ab
allot bytes
Packit Service 3880ab
This allotment is the 'chunkiness' of link sharing and is used for determining packet
Packit Service 3880ab
transmission time tables. The qdisc allot differs slightly from the class allot discussed
Packit Service 3880ab
below. Optional. Defaults to a reasonable value, related to avpkt.
Packit Service 3880ab
.TP
Packit Service 3880ab
avpkt bytes
Packit Service 3880ab
The average size of a packet is needed for calculating maxidle, and is also used
Packit Service 3880ab
for making sure 'allot' has a safe value. Mandatory.
Packit Service 3880ab
.TP
Packit Service 3880ab
bandwidth rate
Packit Service 3880ab
To determine the idle time, CBQ must know the bandwidth of your underlying
Packit Service 3880ab
physical interface, or parent qdisc. This is a vital parameter, more about it
Packit Service 3880ab
later. Mandatory.
Packit Service 3880ab
.TP
Packit Service 3880ab
cell
Packit Service 3880ab
The cell size determines he granularity of packet transmission time calculations. Has a sensible default.
Packit Service 3880ab
.TP
Packit Service 3880ab
mpu
Packit Service 3880ab
A zero sized packet may still take time to transmit. This value is the lower
Packit Service 3880ab
cap for packet transmission time calculations - packets smaller than this value
Packit Service 3880ab
are still deemed to have this size. Defaults to zero.
Packit Service 3880ab
.TP
Packit Service 3880ab
ewma log
Packit Service 3880ab
When CBQ needs to measure the average idle time, it does so using an
Packit Service 3880ab
Exponentially Weighted Moving Average which smooths out measurements into
Packit Service 3880ab
a moving average. The EWMA LOG determines how much smoothing occurs. Lower
Packit Service 3880ab
values imply greater sensitivity. Must be between 0 and 31. Defaults
Packit Service 3880ab
to 5.
Packit Service 3880ab
.P
Packit Service 3880ab
A CBQ qdisc does not shape out of its own accord. It only needs to know certain
Packit Service 3880ab
parameters about the underlying link. Actual shaping is done in classes.
Packit Service 3880ab
Packit Service 3880ab
.SH CLASSES
Packit Service 3880ab
Classes have a host of parameters to configure their operation.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
parent major:minor
Packit Service 3880ab
Place of this class within the hierarchy. If attached directly to a qdisc
Packit Service 3880ab
and not to another class, minor can be omitted. Mandatory.
Packit Service 3880ab
.TP
Packit Service 3880ab
classid major:minor
Packit Service 3880ab
Like qdiscs, classes can be named. The major number must be equal to the
Packit Service 3880ab
major number of the qdisc to which it belongs. Optional, but needed if this
Packit Service 3880ab
class is going to have children.
Packit Service 3880ab
.TP
Packit Service 3880ab
weight weight
Packit Service 3880ab
When dequeuing to the interface, classes are tried for traffic in a
Packit Service 3880ab
round-robin fashion. Classes with a higher configured qdisc will generally
Packit Service 3880ab
have more traffic to offer during each round, so it makes sense to allow
Packit Service 3880ab
it to dequeue more traffic. All weights under a class are normalized, so
Packit Service 3880ab
only the ratios matter. Defaults to the configured rate, unless the priority
Packit Service 3880ab
of this class is maximal, in which case it is set to 1.
Packit Service 3880ab
.TP
Packit Service 3880ab
allot bytes
Packit Service 3880ab
Allot specifies how many bytes a qdisc can dequeue
Packit Service 3880ab
during each round of the process. This parameter is weighted using the
Packit Service 3880ab
renormalized class weight described above. Silently capped at a minimum of
Packit Service 3880ab
3/2 avpkt. Mandatory.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
prio priority
Packit Service 3880ab
In the round-robin process, classes with the lowest priority field are tried
Packit Service 3880ab
for packets first. Mandatory.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
avpkt
Packit Service 3880ab
See the QDISC section.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
rate rate
Packit Service 3880ab
Maximum rate this class and all its children combined can send at. Mandatory.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
bandwidth rate
Packit Service 3880ab
This is different from the bandwidth specified when creating a CBQ disc! Only
Packit Service 3880ab
used to determine maxidle and offtime, which are only calculated when
Packit Service 3880ab
specifying maxburst or minburst. Mandatory if specifying maxburst or minburst.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
maxburst
Packit Service 3880ab
This number of packets is used to calculate maxidle so that when
Packit Service 3880ab
avgidle is at maxidle, this number of average packets can be burst
Packit Service 3880ab
before avgidle drops to 0. Set it higher to be more tolerant of
Packit Service 3880ab
bursts. You can't set maxidle directly, only via this parameter.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
minburst
Packit Service 3880ab
As mentioned before, CBQ needs to throttle in case of
Packit Service 3880ab
overlimit. The ideal solution is to do so for exactly the calculated
Packit Service 3880ab
idle time, and pass 1 packet. However, Unix kernels generally have a
Packit Service 3880ab
hard time scheduling events shorter than 10ms, so it is better to
Packit Service 3880ab
throttle for a longer period, and then pass minburst packets in one
Packit Service 3880ab
go, and then sleep minburst times longer.
Packit Service 3880ab
Packit Service 3880ab
The time to wait is called the offtime. Higher values of minburst lead
Packit Service 3880ab
to more accurate shaping in the long term, but to bigger bursts at
Packit Service 3880ab
millisecond timescales. Optional.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
minidle
Packit Service 3880ab
If avgidle is below 0, we are overlimits and need to wait until
Packit Service 3880ab
avgidle will be big enough to send one packet. To prevent a sudden
Packit Service 3880ab
burst from shutting down the link for a prolonged period of time,
Packit Service 3880ab
avgidle is reset to minidle if it gets too low.
Packit Service 3880ab
Packit Service 3880ab
Minidle is specified in negative microseconds, so 10 means that
Packit Service 3880ab
avgidle is capped at -10us. Optional.
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
bounded
Packit Service 3880ab
Signifies that this class will not borrow bandwidth from its siblings.
Packit Service 3880ab
.TP
Packit Service 3880ab
isolated
Packit Service 3880ab
Means that this class will not borrow bandwidth to its siblings
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
split major:minor & defmap bitmap[/bitmap]
Packit Service 3880ab
If consulting filters attached to a class did not give a verdict,
Packit Service 3880ab
CBQ can also classify based on the packet's priority. There are 16
Packit Service 3880ab
priorities available, numbered from 0 to 15.
Packit Service 3880ab
Packit Service 3880ab
The defmap specifies which priorities this class wants to receive,
Packit Service 3880ab
specified as a bitmap. The Least Significant Bit corresponds to priority
Packit Service 3880ab
zero. The
Packit Service 3880ab
.B split
Packit Service 3880ab
parameter tells CBQ at which class the decision must be made, which should
Packit Service 3880ab
be a (grand)parent of the class you are adding.
Packit Service 3880ab
Packit Service 3880ab
As an example, 'tc class add ... classid 10:1 cbq .. split 10:0 defmap c0'
Packit Service 3880ab
configures class 10:0 to send packets with priorities 6 and 7 to 10:1.
Packit Service 3880ab
Packit Service 3880ab
The complimentary configuration would then
Packit Service 3880ab
be: 'tc class add ... classid 10:2 cbq ... split 10:0 defmap 3f'
Packit Service 3880ab
Which would send all packets 0, 1, 2, 3, 4 and 5 to 10:1.
Packit Service 3880ab
.TP
Packit Service 3880ab
estimator interval timeconstant
Packit Service 3880ab
CBQ can measure how much bandwidth each class is using, which tc filters
Packit Service 3880ab
can use to classify packets with. In order to determine the bandwidth
Packit Service 3880ab
it uses a very simple estimator that measures once every
Packit Service 3880ab
.B interval
Packit Service 3880ab
microseconds how much traffic has passed. This again is a EWMA, for which
Packit Service 3880ab
the time constant can be specified, also in microseconds. The
Packit Service 3880ab
.B time constant
Packit Service 3880ab
corresponds to the sluggishness of the measurement or, conversely, to the
Packit Service 3880ab
sensitivity of the average to short bursts. Higher values mean less
Packit Service 3880ab
sensitivity.
Packit Service 3880ab
Packit Service 3880ab
.SH BUGS
Packit Service 3880ab
The actual bandwidth of the underlying link may not be known, for example
Packit Service 3880ab
in the case of PPoE or PPTP connections which in fact may send over a
Packit Service 3880ab
pipe, instead of over a physical device. CBQ is quite resilient to major
Packit Service 3880ab
errors in the configured bandwidth, probably a the cost of coarser shaping.
Packit Service 3880ab
Packit Service 3880ab
Default kernels rely on coarse timing information for making decisions. These
Packit Service 3880ab
may make shaping precise in the long term, but inaccurate on second long scales.
Packit Service 3880ab
Packit Service 3880ab
See
Packit Service 3880ab
.BR tc-cbq-details(8)
Packit Service 3880ab
for hints on how to improve this.
Packit Service 3880ab
Packit Service 3880ab
.SH SOURCES
Packit Service 3880ab
.TP
Packit Service 3880ab
o
Packit Service 3880ab
Sally Floyd and Van Jacobson, "Link-sharing and Resource
Packit Service 3880ab
Management Models for Packet Networks",
Packit Service 3880ab
IEEE/ACM Transactions on Networking, Vol.3, No.4, 1995
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
o
Packit Service 3880ab
Sally Floyd, "Notes on CBQ and Guaranteed Service", 1995
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
o
Packit Service 3880ab
Sally Floyd, "Notes on Class-Based Queueing: Setting
Packit Service 3880ab
Parameters", 1996
Packit Service 3880ab
Packit Service 3880ab
.TP
Packit Service 3880ab
o
Packit Service 3880ab
Sally Floyd and Michael Speer, "Experimental Results
Packit Service 3880ab
for Class-Based Queueing", 1998, not published.
Packit Service 3880ab
Packit Service 3880ab
Packit Service 3880ab
Packit Service 3880ab
.SH SEE ALSO
Packit Service 3880ab
.BR tc (8)
Packit Service 3880ab
Packit Service 3880ab
.SH AUTHOR
Packit Service 3880ab
Alexey N. Kuznetsov, <kuznet@ms2.inr.ac.ru>. This manpage maintained by
Packit Service 3880ab
bert hubert <ahu@ds9a.nl>