Shaping, policing and congestion
Control the traffic contract
A traffic contract specifies a rate and often an allowed burst. A meter checks whether incoming traffic conforms; a policer may discard or remark excess traffic, while a shaper delays traffic to fit a configured profile, subject to finite buffering. Neither creates additional downstream capacity. Choose based on whether excess traffic can wait, and what the next network expects.
Read a token bucket
In a simple single-bucket teaching model, tokens accrue at a fixed byte rate up to capacity B. A packet of N bytes conforms if at least N tokens are available; consume N for a conforming packet. Here nonconforming packets are dropped without consuming tokens. Assume B=3,000 bytes, refill=1,000 bytes/s, initially full. Two simultaneous 2,000-byte packets: the first passes, the second fails. After one second the balance is 2,000 and a third 2,000-byte packet passes. Actual multi-color meters may use multiple buckets and different actions; RFC 2697 is not identical to this toy algorithm.
t=0: start 3000; packet 2000 -> pass, balance 1000t=0: packet 2000 -> drop, balance 1000t=1s: refill 1000; packet 2000 -> pass, balance 0Compare rate and backlog
For a one-second fluid model, offer 12 Mbit/s to a 10 Mbit/s service, starting with an empty buffer and no burst allowance in the calculation. A drop-only policer admits 10 Mbit and discards 2 Mbit. A shaper sends 10 Mbit and retains 2 Mbit if its buffer can hold that much. If arrivals stop, draining that backlog takes 0.2 s. If the buffer holds only 1 Mbit, the simplified shaper drops 1 Mbit. Persistent overload cannot be solved by an ever-growing queue. These are aggregate calculations, not packet timing predictions.
Manage congestion and bufferbloat
Tail drop discards packets when a queue is full. Large persistent queues can create bufferbloat: high latency even when throughput looks healthy. Active queue management (AQM), such as CoDel or RED, signals congestion by dropping packets or marking ECN-capable packets where supported, before relying only on a full buffer. ECN requires compatible endpoints and network behavior; unresponsive senders may still require policing. AQM manages queues; scheduling selects which queue to serve.
Measure before changing limits
Use identical bounded arrival traces for a baseline and candidate policy. Record admitted bits, transmitted bits, drops and remaining backlog separately, plus queue delay. A lower drop count may come with worse delay; a larger buffer is not automatically better. Practice with 15 Mbit offered over one second, 10 Mbit service and 3 Mbit buffer: predict transmitted, queued and discarded quantities. Next, connect queue treatment to application quality.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Shaping, policing and congestion Quiz
Apply QoS concepts to synthetic offline scenarios.
Which treatment can delay excess traffic to conform?
A full 3,000-byte bucket accepts a 2,000-byte packet. How many tokens remain?
With 15 Mbit arrivals and 10 Mbit service over one second, empty 3 Mbit buffer, what is discarded in the fluid model?
A 2 Mbit backlog drains at 10 Mbit/s with no arrivals. How long?
Which observation best suggests bufferbloat?