traffic shaping and policing
termKept 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
- IETF, RFC 2475, An Architecture for Differentiated Services, December 1998 (read 2026-11-23): shaping delays packets to conform to a profile; policing discards them by a dropper according to a meter; a dropper is a shaper with a buffer of zero or a few packets
- IETF, RFC 2697, A Single Rate Three Color Marker, J. Heinanen and R. Guerin, September 1999 (read 2026-11-23): CIR, CBS and EBS; two token buckets; green, yellow and red
- IETF, RFC 6057, Comcast's Protocol-Agnostic Congestion Management System, December 2010 (read 2026-11-23): congestion managed by heavy users, not applications; 70% and 80% port thresholds and 70% user threshold over 15 minutes
- IETF, RFC 7567, IETF Recommendations Regarding Active Queue Management, July 2015 (read 2026-11-23): AQM recommended for widespread deployment
- BEREC, BoR (22) 81, 9 June 2022 (read 2026-11-23): reasonable traffic management by categories with objectively different technical requirements; application-agnostic mechanisms that assist end-point congestion control permitted
- IETF, RFC 2698, A Two Rate Three Color Marker, J. Heinanen and R. Guerin, September 1999 (read 2026-11-23): PIR at least equal to the CIR, PBS and CBS; buckets P and C; red if the peak bucket cannot pay, yellow if the committed one cannot; colour-blind and colour-aware modes; example service discards red and forwards yellow as best effort
- IETF, RFC 4115, A Differentiated Service Two-Rate, Three-Color Marker with Efficient Handling of in-Profile Traffic, O. Aboul-Magd and S. Rabie (Nortel Networks), July 2005 (read 2026-11-23): CIR and EIR filling buckets of CBS and EBS independently; in use for Frame Relay services; no peak-rate shaping needed at the customer edge; IESG note that it is not a candidate for any level of Internet Standard
- IETF, RFC 3290, An Informal Management Model for Diffserv Routers, May 2002 (read 2026-11-23): appendix A, R = B/t with the 1.2 Mbps and 1,500-byte example (12,000 bits, 10 ms); conformance to {R, B} as at most R*t + B; leaky buckets shape outgoing traffic, token buckets measure arriving traffic; clock granularity adds jitter
- tc-tbf(8), Linux manual page, iproute2, man7.org rendering (read 2026-11-23): TBF a pure, non-work-conserving shaper; tokens roughly bytes with a per-packet cost (mpu, 64 bytes on Ethernet); limit or latency, mutually exclusive; minimum burst rate/HZ, 10 kbyte for 10 mbit/s; the 1 mbit/s ceiling of perfect shaping at HZ=100; the rate 0.5mbit, burst 5kb, latency 70ms, peakrate 1mbit example; author Alexey N. Kuznetsov
- Cisco, 'Compare Traffic Policing and Traffic Shaping to Limit Bandwidth', Document ID 19645, revision 6.0 of 21 July 2026, read through WebFetch after curl was refused (read 2026-11-23): shaping queues the excess, outbound only, smooth output; policing does not buffer, can re-mark, saw-tooth output, drops can throttle TCP windows; Tc = Bc/CIR, 10 to 125 ms; Bc + Be; policer tokens ((t - t1) x rate)/8 bytes; shape average and police commands
- Fortinet, FortiOS 8.0.0 Administration Guide, 'Shared traffic shaper' (read 2026-11-23): priority high, medium or low; guaranteed and maximum bandwidth, maximum 1 to 16,776,000 kbps, 0 for unlimited from the CLI; per-policy versus shared among all policies; forward shaper in the policy direction, reverse shaper for the opposite direction; warning on guaranteed bandwidth close to interface capacity
- Fortinet, FortiOS 8.0.0 Administration Guide, 'Per-IP traffic shaper' (read 2026-11-23): a bandwidth limit for each IP address and a maximum of concurrent sessions; per-IP shapers apply to upload and download at once; shared shapers affect upload unless set as reverse shapers
- NGINX, Module ngx_http_limit_req_module (read 2026-11-23): since 0.7.21; the 'leaky bucket' method; rate=1r/s with burst=5 allows one request a second on average and bursts of up to 5; excess delayed unless nodelay; requests beyond the burst rejected, limit_req_status 503 by default
- US Court of Appeals for the D.C. Circuit, Comcast Corp. v. FCC, No. 08-1291, decided 6 April 2010 (read 2026-11-23): Comcast's 2007 interference with peer-to-peer applications reported by the Associated Press on 19 October 2007; Free Press and Public Knowledge complaint of 1 November 2007; the 2008 order; vacated for want of ancillary authority
- IETF, RFC 8290, The Flow Queue CoDel Packet Scheduler and Active Queue Management Algorithm, January 2018 (read 2026-11-23): 1024 queues by default; target 5 ms; interval 100 ms; Linux packet limit 10240
- Li, Akhavan Niaki, Choffnes, Gill and Mislove, 'A Large-Scale Analysis of Deployed Traffic Differentiation Practices', SIGCOMM 2019 (read 2026-11-23): 1,045,413 Wehe measurements by 126,249 users across 2,735 ISPs in 183 countries and regions; differentiation in 30 ISPs in 7 countries; T-Mobile's delayed throttling, rates up to 20 Mbps dropping to 1.5 Mbps
- Presidência da República, Decreto nº 8.771, de 11 de maio de 2016 (read 2026-11-23): art. 5 technical requirements (spam, denial of service, exceptional congestion); art. 6 management only with measures compatible with international standards, Anatel's parameters and CGI.br's guidelines; art. 7 disclosure of each practice, its effect on quality of experience and its reasons
- Presidência da República, Lei nº 12.965, de 23 de abril de 2014 (read 2026-11-23): art. 7, V, maintenance of the contracted quality of the connection