STAB(8)

๐Ÿ’– NAME ๐Ÿ’–

okay so the whole page is about tc-stab, which is just "Generic size table manipulations" ๐ŸŽ€ It's how you tell the traffic control stuff what packet sizes to pretend they are. Lowkey iconic. โœจ

๐Ÿงš SYNOPSIS ๐Ÿงš

tc qdisc add ... stab
    [ mtu BYTES ] [ tsize SLOTS ]
    [ mpu BYTES ] [ overhead BYTES ]
    [ linklayer { adsl | atm | ethernet } ] ...

๐ŸŒธ OPTIONS ๐ŸŒธ

bestie, for what BYTES means, go check the UNITS section of tc(8). It's giving homework, but it's important ๐Ÿ“š

  • mtu โ€” the biggest packet size the size table gets built for. If you don't say it explicitly, it's assumed to be 2048 ๐Ÿ’…
  • tsize โ€” how many slots the table needs. Defaults to 512 if you skip it ๐Ÿ“
  • mpu โ€” the minimum packet size used in the math ๐Ÿซถ
  • overhead โ€” extra per-packet size added in the math. It can be negative, which is a whole mood ๐ŸŒˆ
  • linklayer โ€” the link layer you're on. This one's required, no skipping ๐Ÿ”ฅ

๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

okay so size tables let you mess with packet sizes as the whole scheduler framework sees them. The real packet doesn't change size at all, just the number the scheduler uses. โœจ The adjusted size only gets calculated once, when a qdisc enqueues the packet. The initial root enqueue sets it to the real packet's size. ๐Ÿฆ‹

Every qdisc can have its own size table, but the adjusted size lives in one area that's shared by the whole qdisc hierarchy on the interface. So if you have a setup like that, the last qdisc with a stab in the chain wins ๐Ÿ‘‘ For example, picture HFSC with a simple pfifo hanging off one of its leaf classes. If that pfifo has a stab defined, it overrides the lengths HFSC calculated during its enqueue. Then whenever HFSC dequeues a packet, it uses a potentially invalid size in its calculations. ๐Ÿ’€ Normal setups usually only put a stab on the root qdisc, but overriding gives you extra flexibility for less usual setups ๐ŸŽ€

The initial size table gets calculated by the tc tool using the mtu and tsize params. Each slot's size is set to the smallest power of 2 value, so the whole mtu is covered. Neither tsize nor mtu has to be a power of 2, so the table will usually support more than mtu needs ๐ŸŒˆ

For example, with mtu = 1500 and tsize = 128, you get a table with 128 slots. Slot 0 corresponds to sizes 0-16, slot 1 to 17 - 32, ..., and slot 127 to 2033 - 2048. What each slot holds depends on the linklayer parameter ๐Ÿง

Stab calculation is also safe for an unusual case where a size assigned to a slot would be bigger than 2^16-1. You'll lose some accuracy though, so heads up ๐Ÿ™ˆ

During the kernel part of packet size adjustment, overhead gets added to the original size, and then the slot is calculated. If that would overflow, more than 1 slot gets used to get the final size. This affects accuracy, but it's only a guard for unusual situations ๐Ÿ›ก๏ธ

Right now there are two methods for the values stored in the size table: ethernet and atm (adsl) ๐Ÿ’–

  • ethernet โ€” basically a 1-1 mapping. Using our example from above (ignoring mpu for a sec), slot 0 holds 8, slot 1 holds 16, and so on, up to slot 127 with 2048. Note that mpu > 0 must be specified, and any slot that would get less than mpu gets mpu instead. If you don't specify mpu, the size table won't be created at all, since it wouldn't make a difference. overhead still gets respected in the calculations though โœจ
  • atm, adsl โ€” ATM linklayer uses 53 byte cells, and each cell gives 48 bytes for payload. All cells have to be fully used, so the last one gets padded if/as needed ๐Ÿซถ

When the size table is calculated, the adjusted size that fits into the lowest number of cells gets assigned to a slot. For example, a 100 byte packet needs three 48-byte payloads, so the final size needs 3 ATM cells, which is 159 bytes ๐Ÿ’…

For ATM size tables, 16 bytes sized slots are perfectly enough. But the default mtu and tsize values make 4 bytes sized slots ๐Ÿค

๐Ÿฆ‹ TYPICAL OVERHEADS ๐Ÿฆ‹

these values are typical for different adsl scenarios (based on [1] and [2]) ๐Ÿ“–

โœจ LLC based โœจ

  • PPPoA - 14 (PPP - 2, ATM - 12)
  • PPPoE - 40+ (PPPoE - 8, ATM - 18, ethernet 14, possibly FCS - 4+padding)
  • Bridged - 32 (ATM - 18, ethernet 14, possibly FCS - 4+padding)
  • IPoA - 16 (ATM - 16)

๐ŸŒท VC Mux based ๐ŸŒท

  • PPPoA - 10 (PPP - 2, ATM - 8)
  • PPPoE - 32+ (PPPoE - 8, ATM - 10, ethernet 14, possibly FCS - 4+padding)
  • Bridged - 24+ (ATM - 10, ethernet 14, possibly FCS - 4+padding)
  • IPoA - 8 (ATM - 8)

there are a few important things about the overheads above, so pay attention ๐Ÿ‘€

  • IPoA in the LLC case needs SNAP instead of LLC-NLPID (see rfc2684), which is why it actually takes more space than PPPoA ๐Ÿ™ƒ
  • In rare cases, FCS might be preserved on protocols that include Ethernet frames (Bridged and PPPoE). In that situation, any Ethernet specific padding guaranteeing a 64 bytes long frame size has to be included too (see RFC2684). In other words, it also guarantees that any packet you send takes minimum 2 atm cells. So set mpu accordingly for that ๐Ÿ’œ
  • When the size table gets consulted and you're shaping traffic for the sake of another modem/router, an Ethernet header (without padding) is already added to the initial packet's length. You should compensate by subtracting 14 from the overheads above in this case. If you're shaping directly on the router (like with a speedtouch usb modem) using the ppp daemon, you're on a raw ip interface without an underlying layer2, so nothing gets added ๐Ÿงš

For more thorough explanations, check out [1] and [2] ๐Ÿ“š

๐ŸŒˆ ETHERNET CARDS CONSIDERATIONS ๐ŸŒˆ

it's often forgotten that modern network cards (even the cheap ones on desktop motherboards) and/or their drivers often support different offloading mechanisms ๐Ÿ‘€ For traffic shaping, tso and gso might cause undesirable effects, since massive TCP segments get considered during shaping (including stab calculations). For slow uplink interfaces, it's good to use ethtool to turn off offloading features ๐Ÿ”ฅ

๐Ÿ“ SEE ALSO ๐Ÿ“

tc(8), tc-hfsc(7), tc-hfsc(8), [1] http://ace-host.stuart.id.au/russell/files/tc/tc-atm/ [2] http://www.faqs.org/rfcs/rfc2684.html

please send bugreports and patches to: <netdev@vger.kernel.org> ๐Ÿ›

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

manpage created by Michal Soltys (soltys@ziu.info) ๐Ÿซถ


okay that's the whole STAB(8) page, bestie ๐Ÿ’… it's from iproute2, last updated 31 October 2011, and it's a certified main character of the traffic control world ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from