Home Support Blog

Leaky Bucket vs Token Bucket: What the QoS Knob Does

Release date:2026-12-01

Leaky bucket vs token bucket is really a choice between a constant output rate that adds queueing delay and a controlled burst that can be metered with no queue at all. Both live in the QoS block of a switch port, both are drawn as a bucket, and both are routinely confused with each other in a configuration guide. One paces packets out; the other decides whether a packet conforms. As of November 2026 that distinction matters more than ever, because TSN has turned shaping from a bandwidth tool into a latency tool. This article stays on the switch queue and does not cover PON-side bandwidth profiles or subscriber rate limits.

Rayin (Shenzhen Rayin Technology) is a manufacturer of GPON OLTs and industrial Ethernet switches.

KEY TAKEAWAYS
  • The leaky bucket emits at a constant rate and adds queueing delay; the token bucket admits bounded bursts and can police with zero queueing.

  • The leaky bucket comes from Turner 1986 and the ATM GCRA, not an IETF RFC; RFC 2697 srTCM, RFC 2698 trTCM and RFC 2212 describe token-bucket metering.

  • A token bucket is not a shaper; IEEE 802.1Qav, 802.1Qbv and the P60802 profile (in development) turn shaping into a latency tool.

Where do the two algorithms actually come from?

They do not share a standard, and that is the first thing a specification should get right. The leaky bucket traces to Turner 1986 and the ATM Generic Cell Rate Algorithm, or GCRA; it is not an IETF RFC. It models a queue that drains at a fixed rate, so whatever arrives too fast waits in the buffer and leaves evenly spaced. The token-bucket family, by contrast, is written down in IETF documents about metering: RFC 2697 srTCM (a single rate, three colour marker, published 1999-09), RFC 2698 trTCM (two rates, three colours) and RFC 2212, whose TSpec describes a flow with a token bucket plus a peak rate.

transport

AlgorithmOriginWhat it models
Leaky bucketTurner 1986 / ATM GCRAA queue draining at a fixed rate
Token bucket (srTCM)RFC 2697CIR with CBS and EBS, green / yellow / red
Token bucket (trTCM)RFC 2698CIR + PIR with CBS + PBS
Flow descriptorRFC 2212 TSpecToken bucket plus peak rate

So the two buckets have different pedigrees: one is a queueing model from ATM traffic control, the other a conformance meter from IP QoS. Mixing them up is not a wording quibble; it changes whether you expect delay or expect a colour mark.

What does traffic shaping actually do to a queue?

Traffic shaping is the leaky-bucket behaviour. A shaper holds packets in a queue and releases them at a constant rate, so a bursty input becomes a smooth output. The cost is explicit: a packet that arrives early waits, and that wait is queueing delay. Nothing is discarded simply for being early — the buffer absorbs it, up to its depth. This is why a shaper is the right tool when the downstream device wants an even stream, and the wrong tool when a control loop cannot tolerate added latency.

PropertyLeaky bucketToken bucket
OutputConstant rateBursty, bounded
QueueingYes, adds delayNone when policing
Burst handlingSmoothed awayBounded by bucket depth
Typical usetraffic shapingqos policing
Delay addedQueueing delayNear zero

The table is the whole mental model. If the knob you turned adds delay, you are shaping; if it marks or drops without holding packets, you are policing. For how real ports behave under short bursts, see QoS and packet buffer microbursts, which covers the buffer side of the same congestion event.

Why is qos policing a different knob?

QoS policing is the token-bucket behaviour, and the difference is that a policer does not wait. Tokens accumulate in a bucket at a committed rate; a packet of a given size either finds enough tokens and passes, or is marked down or dropped. Because there is no queue, a policer adds essentially no delay — it just decides conformance. This is the second common error in a datasheet: a token bucket is a meter, not a shaper. It can feed a shaper, it can feed a dropper, but on its own it never paces anything out. RFC 2697 srTCM and RFC 2698 trTCM are exactly such meters, classifying traffic into colours rather than scheduling it.

A useful way to say it out loud: shaping manages time, policing manages permission. As of November 2026, a switch port can run either, but the two answer different questions and produce different measurements at acceptance.

How much burst tolerance does a token bucket grant?

Burst tolerance is the entire reason to choose a token bucket over a strict rate. The bucket depth, expressed as CBS and optionally EBS in RFC 2697 srTCM, lets a flow send a short burst above its committed rate without being marked, as long as tokens are available. RFC 2697 srTCM uses one rate and two bucket depths (CBS, EBS) to produce green, yellow and red. RFC 2698 trTCM adds a peak information rate with its own PBS, so the peak is constrained separately from the committed rate. RFC 2212 TSpec carries the same idea — token bucket plus peak rate — into an IntServ flow descriptor.

MeterReferenceParametersResult
Single rate, three colourRFC 2697 srTCMCIR, CBS, EBSGreen / yellow / red
Two rate, three colourRFC 2698 trTCMCIR + PIR, CBS + PBSPeak rate bounded separately
IntServ flow descriptorRFC 2212 TSpecToken bucket + peak rateReservation descriptor

Bigger buckets mean more burst tolerance and a less predictable instantaneous rate; smaller buckets mean a tighter, more rigid stream. Neither setting is a universal "better" — it depends on whether the traffic is file transfers, video or cyclic control frames. What matters is that the number you tune is a bucket depth, not a bandwidth ceiling.

When does shaping become a latency tool rather than a bandwidth tool?

This is the 2026 twist. In classic QoS, a shaper was a bandwidth tool: smooth a fast sender to protect a slow link. In time-sensitive networking, shaping is a latency tool, because scheduling when a queue is allowed to transmit bounds the worst-case delay. IEEE 802.1Qav defines credit-based shaping with a CBS credit per queue; IEEE 802.1Qbv defines time-aware shaping with scheduled gate openings. Both are TSN extensions of the same "hold and release" idea that the leaky bucket introduced, now driven by a clock instead of just a rate.

MechanismStandardRoleStatus as of November 2026
Credit-based shapingIEEE 802.1QavCBS credits per queuePublished TSN extension
Time-aware shapingIEEE 802.1QbvScheduled gate openingsPublished TSN extension
Industrial TSN profileP60802Profile for industrial automationin development

P60802, the IEC/IEEE TSN profile for industrial automation, is listed by the IEEE as in development as of November 2026, so it should be written as a direction, not a shipped feature. The practical point for a buyer is that "shaping" now has two meanings: smoothing a rate, or bounding a delay bound. Ask which one the knob implements.

What should a switch acceptance test actually measure?

Measure the thing the algorithm promises. For a shaper, record the output rate over time and the queueing delay under a burst; for a policer, record conformance marks and confirm there is no queue build-up. Then sweep burst tolerance by changing the bucket depth and watching how many packets pass unmarked. Keep the two axes separate: a test that only checks throughput will pass a policer that is silently dropping, and a test that only checks drops will miss a shaper that added 20 ms of delay.

Access-side subscriber rate profiles are a separate topic covered in OLT bandwidth profiles and DBA; this article stays on the switch queue. Rayin industrial Ethernet switches apply the same standards-based queueing behaviour as any managed switch; the algorithm is not a brand feature. On the product side, the wired items are a mini GPON OLT, a 1-port XPON ONU, an 8+4-port gigabit industrial switch (PoE optional) and the PON optical modules bundled with the OLT; 4/8-port GPON OLTs and the 1-port XGS-PON OLT are in development as of November 2026. Nothing here asserts a specific certification.

rayin ptp switch

FAQs

Is the leaky bucket defined by an IETF RFC?

No. It comes from Turner 1986 and the ATM Generic Cell Rate Algorithm, which is an ATM traffic-control model, not an IETF specification. The IETF documents in this area — RFC 2697, RFC 2698 and RFC 2212 — describe token-bucket metering instead. Keeping the pedigrees apart stops you from expecting RFC-style conformance colours from a queue that simply drains at a fixed rate.

Does a token bucket automatically shape traffic?

No. A token bucket is a meter: it checks whether enough tokens exist for a packet and marks or drops accordingly. Shaping requires a queue that holds packets and releases them on a schedule. As of November 2026, the two are often configured on the same port, but one produces delay and the other produces a colour decision, so they must not be treated as synonyms.

Which RFCs cover the three-colour meters?

RFC 2697 srTCM defines a single-rate three-colour marker using CIR, CBS and EBS, published in 1999-09. RFC 2698 trTCM defines a two-rate version with CIR plus PIR and CBS plus PBS, so the peak rate is bounded on its own. RFC 2212 TSpec carries a token bucket plus peak rate into IntServ. All three are metering descriptions, not queue schedulers.

Does shaping add delay on a switch port?

Yes, by design. A shaper holds early packets in a queue and paces them out at a constant rate, so a burst turns into waiting time. A policer adds almost no delay because it never holds a packet. As of November 2026, an acceptance test should measure both output smoothness and queuing delay, otherwise a port can look compliant while quietly adding latency to a control flow.

Is the industrial TSN profile finished?

Not yet. IEEE 802.1Qav and 802.1Qbv are published TSN extensions, but P60802, the industrial automation profile, is listed as in development as of November 2026. Treat it as a direction for converging IT and OT traffic, not a feature to tick on a datasheet. Rayin, as a manufacturer of GPON OLTs and industrial Ethernet switches, frames these as configuration questions to verify.

Related Reading


How this article was made

The algorithms, RFC numbers and IEEE standards above come from public sources: Turner 1986 and the ATM GCRA for the leaky bucket; RFC 2697 srTCM, RFC 2698 trTCM and RFC 2212 TSpec for token-bucket metering; IEEE 802.1Qav and 802.1Qbv for TSN shaping; and the P60802 industrial profile, listed as in development. Only series, RFC and standard names are cited; no product certification is asserted. The comparison tables and wording are written and checked by Sara against those sources. Anything presented as an industry-typical value is labelled as such; no figure here is a measured Rayin specification.

About the author: Sara — Sara is a Customer Manager at Rayin with over 10 years of experience in the communications field. In her free time, she enjoys badminton and swimming.

Connect with Sara on LinkedIn


About Rayin: Shenzhen Rayin Technology Co., Ltd. — Company Profile

Get A Quote

You have agreed to this website’s《Privacy Policy》