traffic shaping and policing

term

networkingISP & telecom

Kept in this browser · My desk

The two ways a network enforces a rate on traffic: shaping holds excess packets in a buffer and sends them later, adding delay; policing drops or re-marks them at once, adding loss.

Both are routine on access links, where they enforce the speed a subscriber buys, and both are measured with token buckets. They raise no neutrality issue when applied to a whole connection; they become 'throttling' when aimed at particular content or applications. The best documented change from one to the other is Comcast's: after the 2007 dispute over its interference with peer-to-peer traffic, it published in RFC 6057 a protocol-agnostic system that lowers the priority of the heaviest users on a congested segment, whatever applications they use.

Definitions. RFC (Request for Comments) 2475, the Differentiated Services architecture of December 1998, defines shaping as delaying packets within a stream so that it conforms to a traffic profile, and policing as discarding packets, by a dropper, according to the state of a meter enforcing a profile; it notes that a dropper is a shaper whose buffer holds zero or a few packets. A shaper smooths bursts at the cost of delay; a policer keeps latency low at the cost of loss, which TCP interprets as congestion and answers by slowing down. Cisco's technical note 19645 (revised July 2026) adds the practical differences: shaping works on outbound traffic only and never re-marks; policing works in either direction, can re-mark a packet instead of dropping it, and gives a saw-tooth rate because its drops throttle TCP windows. Neither guarantees a minimum rate under congestion.

The arithmetic. RFC 3290 (May 2002) reduces every bucket to a rate R, a burst B and an interval t, with R = B/t: 1.2 megabits per second with a 1,500-byte burst means a 12,000-bit burst every 10 milliseconds, 100 bursts a second at worst. A stream conforms to a bucket (R, B) if in any interval t it delivers no more than R x t + B. The RFC separates two ideas often confused: a leaky bucket shapes traffic leaving an interface at as constant a rate as possible, while a token bucket measures arriving traffic to decide whether it still conforms.

Three colours. RFC 2697 (September 1999), by Juha Heinanen of Telia Finland and Roch Guerin of the University of Pennsylvania, specifies the Single Rate Three Color Marker: a Committed Information Rate (CIR) in bytes per second refills two buckets, sized by the Committed Burst Size (CBS) and the Excess Burst Size (EBS), and each packet is green, yellow or red according to which bucket can pay for it. With a CIR of 125,000 bytes per second and both burst sizes at 15,000 bytes, a burst of 25 packets of 1,500 bytes yields ten green, ten yellow and five red packets; a shaper at the same rate would instead release all 25 over 300 milliseconds. The companion RFC 2698 adds a Peak Information Rate (PIR), never below the CIR, with its own Peak Burst Size (PBS): what the peak bucket cannot pay for is red, what only the committed bucket cannot pay for is yellow; its example service discards red, forwards yellow as best effort and protects green. RFC 4115 (July 2005, Nortel Networks) documents the two-rate marker of Frame Relay services, with an Excess Information Rate (EIR) of its own. All three are Informational RFCs, not standards.

A worked example. Cisco gives the shaper's interval as Tc = Bc/CIR, where Bc is the committed burst in bits, with Tc between 10 and 125 milliseconds on most platforms. Shaping to 8 Mbit/s with a Bc of 80,000 bits gives Tc = 80,000 / 8,000,000 = 0.01 seconds: at most 80,000 bits leave in each of 100 intervals a second, and the rest waits in the queue. A policer at the same rate refills by elapsed time, ((t - t1) x rate) / 8 bytes: a packet arriving 1.5 milliseconds after the previous one finds 0.0015 x 8,000,000 / 8 = 1,500 bytes of new tokens, exactly one full-size packet, and anything faster once the bucket is empty is dropped or re-marked.

On Linux. The Token Bucket Filter (TBF, the tc-tbf queueing discipline) is, in its manual's words, a pure shaper. Every packet costs tokens however small it is; packets wait for tokens up to a limit in bytes or a latency in milliseconds; and the burst must be at least the rate divided by the kernel timer frequency, HZ, or packets are dropped because more tokens arrive per tick than fit in the bucket (the manual asks for 10 kilobytes at 10 Mbit/s). Its example, tc qdisc add dev eth0 handle 10: root tbf rate 0.5mbit burst 5kb latency 70ms peakrate 1mbit minburst 1540, holds the average to 0.5 Mbit/s, the bursts to 1 Mbit/s and the wait to 70 milliseconds.

On firewalls and web servers. In FortiOS 8.0 a shared shaper sets a priority, a guaranteed bandwidth and a maximum bandwidth of 1 to 16,776,000 kbit/s for a traffic shaping policy, in the policy's direction (from the local area network to the wide area network it limits the upload; a reverse shaper limits the download), while a per-IP shaper gives each address its own allowance and can cap its sessions; Fortinet warns that a guarantee close to the interface's capacity starves everything else. NGINX's limit_req module (since version 0.7.21) applies the 'leaky bucket' to requests: rate=1r/s with burst=5 allows one request a second per client address with bursts of up to five, delays the excess (shaping) unless nodelay is set, and refuses requests beyond the burst (policing) with status 503 by default.

From Comcast to RFC 6057. In 2007 Comcast was found interfering with its subscribers' peer-to-peer applications; the Federal Communications Commission (FCC) ruled against the practice in 2008, and the Court of Appeals for the District of Columbia Circuit vacated that order on 6 April 2010 for want of authority. The system Comcast adopted instead, published as RFC 6057 (2010), illustrates the agnostic approach: a cable port is near congestion when average use over about 15 minutes exceeds 70% of upstream or 80% of downstream capacity, and on such a port a subscriber who has used 70% of the provisioned bandwidth for 15 minutes is given lower priority, which matters only while the port is actually congested.

The neutrality line. Regulators judge what is shaped, not whether. The 2022 guidelines of BEREC (Body of European Regulators for Electronic Communications) accept management that differentiates categories with objectively different technical requirements (latency, jitter, loss, bandwidth) and mechanisms that are agnostic to applications, while forbidding slowing down specific content or applications beyond the regulation's exceptions; management must be transparent, proportionate, free of commercial motives and no longer than necessary, throttling should stay within the congested section where feasible, and recurrent congestion calls for capacity. Brazil's Decree 8.771 limits discrimination to indispensable technical requirements, such as security and exceptional congestion, and requires measures compatible with international standards and the publication of each practice, its effect on users' quality of experience and its reasons; the Marco Civil guarantees the contracted quality (article 7, V).

What goes wrong. A shaper with a deep queue turns excess into delay, which is why tc-tbf takes a latency bound. The preferred tools of the IETF (Internet Engineering Task Force) today are active queue management (AQM), recommended by RFC 7567 (July 2015), and flow queuing, which keep queues short for every application: FQ-CoDel (Flow Queue Controlled Delay, RFC 8290, January 2018) runs 1,024 queues by default against a 5-millisecond delay target over a 100-millisecond interval. Throttling aimed at applications can be measured from outside: a study presented at SIGCOMM 2019, the data communication conference of the Association for Computing Machinery, and built on the Wehe app (1,045,413 tests by 126,249 users) found content-based differentiation by 30 internet service providers in 7 countries, including T-Mobile video starting at up to 20 Mbit/s and dropping to 1.5 Mbit/s after a few seconds.

Neighbours. Shaping and policing are the enforcement half of quality of service (QoS): classification, sometimes by deep packet inspection (DPI), chooses the traffic; throttling is shaping aimed at particular content; rate limiting applies the same arithmetic to requests; bufferbloat is what an oversized shaping queue causes.

Also known as: traffic shaping, shaping, traffic policing, policing, token bucket, srtcm, single rate three color marker, shaper, policer

Sources

← Back to T Back to the glossary