Watch on Instagram

Network Bytes · Episode 92 · CCNA 4.7

"QoS policing vs shaping"

Policing and shaping both hold traffic to a configured rate. Policing drops or remarks the extra packets right away, while shaping holds them in a buffer and sends them later at a steady rate, so nothing is lost but traffic is delayed.

Posted · About a 1 minute watch, 4 minute read · Take the quiz

Same limit, two ways to enforce it

Both tools enforce a configured rate, such as 10 Mbps. Behind the scenes both measure traffic with a token bucket: tokens drip into a bucket at the configured rate, and a packet can only be sent "within the rate" if there are enough tokens for it. The difference is what happens to a packet that arrives when the bucket is empty.

Picture a theme park ride that boards a fixed number of riders per minute. Too many people arrive at once. The ride can deal with the crowd in two ways.

Policing: the strict gate

A policer is a strict gate: riders over the limit are turned away. For packets, the extra traffic is dropped, or remarked to a lower priority (for example a lower DSCP value) so it is the first to go if the network gets busy later.

Drops have a side effect. TCP notices the lost segments, retransmits them and slows its sending rate. UDP traffic, such as a voice call, has no retransmission, so dropped voice packets are simply lost.

A policer can be applied to traffic coming in to an interface or going out of it.

Shaping: the waiting line

A shaper is the waiting line: extra riders queue and board later. For packets, the extra traffic waits in a buffer and leaves at a steady rate. The output is smooth and evenly spaced.

Nothing is lost, but it is slower: queued packets are delayed, and the delay can vary (jitter). That only holds while the buffer has room; if the queue fills up, a shaper drops packets too. Shaping works on outbound traffic only, because a router can only hold back what it is about to send.

Where each one goes

A common design: a provider sells a 100 Mbps service on a 1 Gbps port and polices what comes in from the customer, dropping anything over 100 Mbps. The customer shapes what it sends to 100 Mbps, so its traffic waits in its own buffer instead of being dropped by the provider. That is a common pattern, not a rule.

Try it yourself

On a lab router (Cisco Modeling Labs or a real IOS router), build a policy-map with shape average 2000000 and apply it outbound with service-policy output <name>. Send a large file across the link and run show policy-map interface <id>: look for the queue depth and the shaped packet counters. Then swap the shaper for police 2000000 and run the same test: the packets now show up in the "exceeded" (dropped) counter instead of a queue.

Good to know

  • CCNA 4.7 lists the QoS per-hop behaviors: classification, marking, queuing, congestion, policing and shaping (EP54 covers classification, marking and queuing).
  • Per Cisco's tech note 19645, both enforce a configured rate measured with a token bucket; policing drops or remarks traffic that exceeds the rate, and shaping queues the excess and sends it later, smoothing the output.
  • Shaping is applied outbound only; policing can be applied inbound or outbound.
  • "Drops make senders resend" refers to TCP; UDP traffic such as voice is simply lost.
  • "Nothing lost, but slower" means added delay and jitter, and assumes the shaping queue is big enough; a full buffer drops packets too.
  • Policers also allow a configured burst size, which the short skips.
  • "Theme park ride" is the analogy. The comment question assumes the shaper has nothing else queued and ignores overhead.

For CCNA learners

CCNA exam topic 4.7 asks you to explain the QoS per-hop behaviors, including policing and shaping. Know that both enforce a rate, that policing drops or remarks the excess while shaping buffers and delays it, and that shaping is outbound only.

Answer to the comment question

3 seconds. The shaper sends at 10 megabits per second, so a 30-megabit burst takes 30 ÷ 10 = 3 seconds to leave (assuming nothing else is queued and ignoring overhead). Nothing is dropped; the burst just waits in the buffer.

Test your knowledge

Quick quiz: "QoS policing vs shaping"

4 multiple-choice questions. Pick one answer for each, then check how you did.

1A packet arrives over the configured rate at a policer. What happens to it?
2What is the main cost of shaping?
3In which direction can a shaper be applied?
4In the theme park ride analogy, what is the waiting line?

Sources

Video transcript

When traffic breaks its speed limit, should the network drop it or make it wait?

Picture a theme park ride that boards a fixed number of riders per minute. Too many arrive at once.

Policing is a strict gate: extra riders are turned away. Extra packets are dropped, or remarked to a lower priority. Drops make senders resend.

Shaping is the waiting line: extra riders queue and board later. Extra packets wait in a buffer and leave at a steady rate. Nothing lost, but slower.

A common pattern: providers police what comes in, so customers shape what they send.

Traffic is shaped to 10 megabits per second. A 30-megabit burst arrives all at once. How many seconds until it's all sent? Comment your answer below!

That's your byte.

More from Network Bytes

All Network Bytes lessons