Hands-On Lab: Configuring Traffic Shaping and Policing

This hands-on lab configures both traffic shaping and traffic policing on separate interfaces, comparing how each mechanism handles traffic exceeding its configured rate — shaping by buffering and delaying, policing by dropping or remarking outright.

Traffic Shaping ConfigurationTraffic Policing ConfigurationShape vs Police Behavioral Difference

~4 دقیقه مطالعه · آخرین به‌روزرسانی ۴ مهر ۱۴۰۵

Lab Objective

Configure traffic shaping on one interface limiting outbound rate by buffering excess traffic, configure traffic policing on a separate interface limiting rate by dropping excess traffic outright, and generate traffic exceeding each configured rate to directly observe the behavioral difference between the two mechanisms.

Lab Purpose

The QoS lab covered earlier in this series configured priority queuing for voice traffic but did not address the two primary mechanisms for enforcing a maximum rate on non-priority traffic. Shaping and policing both limit throughput to a configured rate, but their fundamentally different handling of excess traffic — buffer versus drop — makes them suited to different scenarios.

Lab Topology

R1
  Gi0/1 (shaped, toward WAN link A)
  Gi0/2 (policed, toward WAN link B)

Both links have an actual physical
bandwidth of 100 Mbps, but the contracted
rate with the provider is 10 Mbps on each

Task 1: Configure Traffic Shaping on Gi0/1

Configure class-based shaping limiting outbound traffic on Gi0/1 to 10 Mbps.

Task 2: Configure Traffic Policing on Gi0/2

Configure class-based policing limiting outbound traffic on Gi0/2 to 10 Mbps, dropping traffic exceeding this rate.

Task 3: Generate Traffic Exceeding the Rate on Gi0/1

Generate a burst of traffic exceeding 10 Mbps toward Gi0/1 and observe the resulting behavior.

Task 4: Generate Traffic Exceeding the Rate on Gi0/2

Generate the identical burst toward Gi0/2 and observe the resulting behavior.

Task 5: Compare Latency and Loss Between the Two Approaches

Measure and compare the latency and packet loss characteristics of the shaped versus policed traffic during the burst.

Solution and Verification

R1(config)# class-map match-all ALL-TRAFFIC
R1(config-cmap)# match any

R1(config)# policy-map SHAPE-POLICY
R1(config-pmap)# class ALL-TRAFFIC
R1(config-pmap-c)# shape average 10000000

-- Shaping smooths traffic to the configured
-- rate by holding excess traffic in a
-- buffer/queue and releasing it later,
-- rather than discarding it immediately

R1(config)# interface gigabitethernet0/1
R1(config-if)# service-policy output SHAPE-POLICY

R1(config)# policy-map POLICE-POLICY
R1(config-pmap)# class ALL-TRAFFIC
R1(config-pmap-c)# police 10000000 conform-action transmit exceed-action drop

-- Policing enforces a hard rate limit --
-- traffic exceeding it is dropped
-- immediately, with no buffering at all

R1(config)# interface gigabitethernet0/2
R1(config-if)# service-policy output POLICE-POLICY

TrafficGen> [generates a burst of 20 Mbps
             toward Gi0/1 for 10 seconds]

R1# show policy-map interface gigabitethernet0/1

  Service-policy output: SHAPE-POLICY
    Class-map: ALL-TRAFFIC
      Queueing
      queue limit 64 packets
      (queue depth/total drops/no-buffer drops) 12/0/0
      shape (average) cir 10000000, bc 40000, be 40000
-- Traffic queued (depth 12) rather than
-- dropped -- the burst is smoothed out
-- over a slightly longer period, at the
-- cost of added latency for the delayed
-- packets, but with ZERO drops

TrafficGen> [generates the identical burst
             toward Gi0/2]

R1# show policy-map interface gigabitethernet0/2

  Service-policy output: POLICE-POLICY
    Class-map: ALL-TRAFFIC
      police:
        cir 10000000 bps
        conformed 1250000 bytes; actions:
          transmit
        exceeded 1250000 bytes; actions:
          drop
-- Roughly half the traffic (the portion
-- exceeding 10 Mbps) was dropped
-- immediately -- no queuing delay was
-- introduced, but real data loss occurred

-- Latency/loss comparison:

Gi0/1 (shaped):  0% packet loss, increased
                 latency during the burst
                 (buffered packets delayed)

Gi0/2 (policed): ~50% packet loss during
                 the burst, but no added
                 latency for packets that
                 did get through

Key Takeaway

Shaping trades increased latency for zero loss by buffering excess traffic and releasing it later, making it well-suited to traffic that tolerates delay but not loss (bulk data transfers, for instance), while policing trades occasional loss for consistent, unbuffered latency by dropping excess traffic outright — the correct choice between them depends entirely on whether the specific traffic being managed is more sensitive to delay or to loss, a distinction with no universally correct answer across every traffic type.

نوشته و پژوهش‌شده توسط دکتر شاهین صیامی

مقالات مرتبط

Hands-On Lab: Final Comprehensive CCNP Troubleshooting Challenge (BGP, DMVPN, and QoS Integration)

This hands-on lab presents a complex multi-layer failure across an integrated BGP-over-DMVPN topology combined with QoS marking, requiring systematic diagnosis of a route reflector misconfiguration, an NHRP registration failure, and an incorrectly applied QoS policy simultaneously affecting the same network.

ادامه

Hands-On Lab: Configuring BGP over DMVPN

This hands-on lab runs iBGP as the routing protocol across the same DMVPN hub-and-spoke topology used in the two previous labs, configuring the hub as a route reflector so spokes learn each other's routes without a full iBGP mesh, combining two previously separate concepts into one integrated design.

ادامه

Hands-On Lab: Configuring OSPF over DMVPN

This hands-on lab runs OSPF as the dynamic routing protocol across the same DMVPN hub-and-spoke topology, configuring the tunnel interface as an OSPF point-to-multipoint network type to correctly handle the hub-and-spoke adjacency pattern without requiring the broadcast network type's DR/BDR election.

ادامه

Hands-On Lab: Configuring EIGRP over DMVPN

This hands-on lab runs EIGRP as the dynamic routing protocol across the DMVPN hub-and-spoke topology built in earlier labs, verifying neighbor relationships form correctly across the multipoint tunnel and routes propagate without requiring per-spoke static configuration on the hub.

ادامه

Hands-On Lab: Configuring HSRP MD5 Authentication

This hands-on lab configures MD5 authentication on an HSRP group, verifying two routers with matching authentication strings form a normal active/standby relationship while a router with a mismatched string is excluded from the group entirely.

ادامه

Hands-On Lab: Configuring Cisco Umbrella-Style DNS Security via DNS Forwarding Redirection

This hands-on lab configures a router to redirect all client DNS queries toward a security-focused DNS resolver using DNS forwarding interception, approximating cloud-delivered DNS security enforcement without requiring per-client configuration changes.

ادامه