info > CBQ

CBQ(8) Linux CBQ(8)

📛 NAME

CBQ - Class Based Queueing

🚀 Quick Reference

Use CaseCommandDescription
Create root CBQ qdisctc qdisc add dev eth0 root handle 1: cbq bandwidth 100mbit avpkt 1000Set up CBQ as root qdisc on an interface
Create a rate-limited classtc class add dev eth0 parent 1: classid 1:1 cbq rate 10mbit allot 1514 prio 5 avpkt 1000Create a class with bandwidth cap
Classify by priority with defmaptc class add dev eth0 parent 1:0 classid 1:1 cbq split 1:0 defmap c0Send priority 6/7 traffic to class 1:1
Attach a leaf classtc class add dev eth0 parent 1:1 classid 1:10 cbq rate 5mbit allot 1514 prio 5 avpkt 1000Add leaf class under parent 1:1

📋 SYNOPSIS

tc  qdisc  ...  dev  dev ( parent classid | root) [ handle major: ] cbq
avpkt bytes bandwidth rate [ cell bytes ] [ ewma log ] [ mpu bytes ]

tc class ... dev dev parent major:[minor] [ classid major:minor  ]  cbq
allot  bytes  [  bandwidth  rate ] [ rate rate ] prio priority [ weight
weight ] [ minburst packets ] [ maxburst packets ] [ ewma log ] [  cell
bytes ] avpkt bytes [ mpu bytes ] [ bounded isolated ] [ split handle &
defmap defmap ] [ estimator interval timeconstant ]

📖 DESCRIPTION

Class Based Queueing is a classful qdisc that 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 the timing of dequeue events and underlying link bandwidth.

⚙️ SHAPING ALGORITHM

Shaping is done using link idle time calculations, and actions taken if these calculations deviate from set limits.

When shaping a 10mbit/s connection to 1mbit/s, the link will be idle 90% of the time. If it isn't, it needs to be throttled so that it IS idle 90% of the time.

From the kernel's perspective, this is hard to measure, so CBQ instead derives the idle time from the number of microseconds (in fact, jiffies) that elapse between requests from the device driver for more data. Combined with the knowledge of packet sizes, this is used to approximate how full or empty the link is.

This is rather circumspect and doesn't always arrive at proper results. For example, what is the actual link speed of an interface that is not really able to transmit the full 100mbit/s of data, perhaps because of a badly implemented driver? A PCMCIA network card will also never achieve 100mbit/s because of the way the bus is designed - again, how do we calculate the idle time?

The physical link bandwidth may be ill defined in case of not-quite-real network devices like PPP over Ethernet or PPTP over TCP/IP. The effective bandwidth in that case is probably determined by the efficiency of pipes to userspace - which not defined.

During operations, the effective idletime is measured using an exponential weighted moving average (EWMA), which considers recent packets to be exponentially more important than past ones. The Unix loadaverage is calculated in the same way.

The calculated idle time is subtracted from the EWMA measured one, the resulting number is called 'avgidle'. A perfectly loaded link has an avgidle of zero: packets arrive exactly at the calculated interval.

An overloaded link has a negative avgidle and if it gets too negative, CBQ throttles and is then 'overlimit'.

Conversely, an idle link might amass a huge avgidle, which would then allow infinite bandwidths after a few hours of silence. To prevent this, avgidle is capped at maxidle.

If overlimit, in theory, the CBQ could throttle itself for exactly the amount of time that was calculated to pass between packets, and then pass one packet, and throttle again. Due to timer resolution constraints, this may not be feasible, see the minburst parameter below.

🏷️ CLASSIFICATION

Within the one CBQ instance many classes may exist. Each of these classes contains another qdisc, by default tc-pfifo(8).

When enqueueing a packet, CBQ starts at the root and uses various methods to determine which class should receive the data. If a verdict is reached, this process is repeated for the recipient class which might have further means of classifying traffic to its children, if any.

CBQ has the following methods available to classify a packet to any child classes.

Each class also has a level. Leaf nodes, attached to the bottom of the class hierarchy, have a level of 0.

🔍 CLASSIFICATION ALGORITHM

Classification is a loop, which terminates when a leaf class is found. At any point the loop may jump to the fallback algorithm.

The loop consists of the following steps:

  1. 🔹 If the packet is generated locally and has a valid classid encoded within its skb->priority, choose it and terminate.
  2. 🔹 Consult the tc filters, if any, attached to this child. If these return a class which is not a leaf class, restart loop from the class returned. If it is a leaf, choose it and terminate.
  3. 🔹 If the tc filters did not return a class, but did return a classid, try to find a class with that id within this qdisc. Check if the found class is of a lower level than the current class. If so, and the returned class is not a leaf node, restart the loop at the found class. If it is a leaf node, terminate. If we found an upward reference to a higher level, enter the fallback algorithm.
  4. 🔹 If the tc filters did not return a class, nor a valid reference to one, consider the minor number of the reference to be the priority. Retrieve a class from the defmap of this class for the priority. If this did not contain a class, consult the defmap of this class for the BEST_EFFORT class. If this is an upward reference, or no BEST_EFFORT class was defined, enter the fallback algorithm. If a valid class was found, and it is not a leaf node, restart the loop at this class. If it is a leaf, choose it and terminate. If neither the priority distilled from the classid, nor the BEST_EFFORT priority yielded a class, enter the fallback algorithm.

The fallback algorithm resides outside of the loop and is as follows.

  1. 🔹 Consult the defmap of the class at which the jump to fallback occurred. If the defmap contains a class for the priority of the class (which is related to the TOS field), choose this class and terminate.
  2. 🔹 Consult the map for a class for the BEST_EFFORT priority. If found, choose it, and terminate.
  3. 🔹 Choose the class at which break out to the fallback algorithm occurred. Terminate.

The packet is enqueued to the class which was chosen when either algorithm terminated. It is therefore possible for a packet to be enqueued *not* at a leaf node, but in the middle of the hierarchy.

🔗 LINK SHARING ALGORITHM

When dequeuing for sending to the network device, CBQ decides which of its classes will be allowed to send. It does so with a Weighted Round Robin process in which each class with packets gets a chance to send in turn. The WRR process starts by asking the highest priority classes (lowest numerically - highest semantically) for packets, and will continue to do so until they have no more data to offer, in which case the process repeats for lower priorities.

CERTAINTY ENDS HERE, ANK PLEASE HELP

Each class is not allowed to send at length though - they can only dequeue a configurable amount of data during each round.

If a class is about to go overlimit, and it is not bounded it will try to borrow avgidle from siblings that are not isolated. This process is repeated from the bottom upwards. If a class is unable to borrow enough avgidle to send a packet, it is throttled and not asked for a packet for enough time for the avgidle to increase above zero.

I REALLY NEED HELP FIGURING THIS OUT. REST OF DOCUMENT IS PRETTY CERTAIN AGAIN.

🎛️ QDISC

The root qdisc of a CBQ class tree has the following parameters:

A CBQ qdisc does not shape out of its own accord. It only needs to know certain parameters about the underlying link. Actual shaping is done in classes.

📦 CLASSES

Classes have a host of parameters to configure their operation.

📚 SOURCES

👁️ SEE ALSO

tc(8)

✍️ AUTHOR

Alexey N. Kuznetsov, <kuznet AT ms2.ru>. This manpage maintained by bert hubert <ahu AT ds9a.nl>

iproute2         8 December 2001         CBQ(8)

CBQ
📛 NAME 🚀 Quick Reference 📋 SYNOPSIS 📖 DESCRIPTION ⚙️ SHAPING ALGORITHM 🏷️ CLASSIFICATION 🔍 CLASSIFICATION ALGORITHM 🔗 LINK SHARING ALGORITHM 🎛️ QDISC 📦 CLASSES 📚 SOURCES 👁️ SEE ALSO ✍️ AUTHOR

Generated by phpman v4.9.26-5-g7740029 Author: Che Dong Under GNU General Public License
2026-08-16 09:27 @2600:1f28:365:80b0:7cb9:fb:26c1:e368
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Valid XHTML 1.0 Transitional!Valid CSS!