Configuring Traffic Shaping

This chapter contains the following sections:

About Traffic Shaping

Traffic shaping allows you to control the traffic going out an interface in order to match its flow to the speed of the remote target interface and to ensure that the traffic conforms to policies contracted for it. Traffic that is adhering to a particular profile can be shaped to meet downstream requirements, which eliminates bottlenecks in topologies with data-rate mismatches.

Traffic shaping regulates and smooths out the packet flow by imposing a maximum traffic rate for each port's egress queue. Packets that exceed the threshold are placed in the queue and are transmitted later. This process is similar to traffic policing; however, the packets are not dropped. Because packets are buffered, traffic shaping minimizes packet loss (based on the queue length), which provides a better traffic behavior for TCP traffic.

Using traffic shaping, you can control access to available bandwidth, ensure that traffic conforms to the policies established for it, and regulate the flow of traffic in order to avoid congestion that can occur when the egress traffic exceeds the access speed of its remote, target interface. For example, you can control access to the bandwidth when policy dictates that the rate of a given interface should not, on average, exceed a certain rate even though the access rate exceeds the speed.

The traffic shaping rate can be configured in kilobits per second (kbps) or packets per second (PPS) and is applied to unicast queues. Queue length thresholds are configured using weighted randam early detection (WRED) configuration.

Traffic shaping can be configured at the system level or the interface level. System level queuing policies can be overridden by interface queuing policies.

Guidelines and Limitations for Traffic Shaping

  • Traffic shaping might increase the latency of packets due to queuing, because it falls back to store-and-forward mode when packets get queued.

  • For traffic shaping to function properly, the store and forwarding switching mode needs to be enabled.

Configuring Traffic Shaping

You can configure a maximum traffic rate to regulate traffic flow.

Before you begin

Configure random-detect minimum and maximum thresholds for packets.

Configure congestion control random detection on the network QoS class map by using the congestion-control random detect command under the network-qos class-map.

Both QoS and network QoS policies must be applied for queuing to work. This prerequisite exists for configuring any queuing policy.

SUMMARY STEPS

  1. switch# configure terminal
  2. switch(config)# policy-map type queuing policy-name
  3. switch(config-pmap-que)# class type queuing class-name
  4. switch(config-pmap-que)# shape {kbps | mbps | gbps} burst size min minimum bandwidth
  5. switch(config-pmap-que)# exit
  6. (Optional) switch(config)# copy running-config startup-config

DETAILED STEPS

  Command or Action Purpose

Step 1

switch# configure terminal

Enters global configuration mode.

Step 2

switch(config)# policy-map type queuing policy-name

Creates a named object that represents a set of policies that are to be applied to a set of traffic classes. Policy-map names can contain alphabetic, hyphen, or underscore characters, are case sensitive, and can be up to 40 characters.

Step 3

switch(config-pmap-que)# class type queuing class-name

Associates a class map with the policy map and enters configuration mode for the specified system class.

Step 4

switch(config-pmap-que)# shape {kbps | mbps | gbps} burst size min minimum bandwidth

Specifies the burst size and minimum guaranteed bandwidth for this queue.

Step 5

switch(config-pmap-que)# exit

Exits the current configuration mode.

Step 6

(Optional) switch(config)# copy running-config startup-config

(Optional)

Saves the change persistently through reboots and restarts by copying the running configuration to the startup configuration.

Example

This example shows how to configuring packet shaping using 200000 packets per second (pps):


switch# configuration terminal
class-map type qos match-all cq
  match access-group name test
class-map type queuing cqu
  match qos-group 2
policy-map type qos pq
  class cq
    set qos-group 2
policy-map type queuing pqu
  class type queuing cqu
    random-detect minimum-threshold 100 packets maximum-threshold 350 packets   
switch(config)# policy-map type queuing pqu
switch(config-pmap-que)# class type queuing cqu
switch(config-pmap-que)# shape pps 200000
switch(config-pmap-que)# exit
switch(config)# copy running-config startup-config

Verifying Traffic Shaping

To display traffic shaping configuration information, perform one of the following tasks:

Command Purpose
show queuing

Displays the queuing information configured for all interfaces. It includes shaper configuration information for each class, the control queue Tx and drop statistics for each port, and WRED drop packet counts.

show queuing interface slot/port

Displays the queuing information configured on the specified interface.

show interface slot/port

Shows the aggregated output traffic rate on all egress queues of the specified interface.

Configuration Example for Traffic Shaping

The following example shows sample configuration for the following tasks:

  • Defining an ACL that matches a range of IP flows named test-qos-acl

  • Marking traffic matching the test-qos-acl that ingresses on eth1/97 and eth1/99 to q2 (qos-group 2)

  • Traffic shaping all traffic on q2 (qos-group 2) to a maximum of 200 mbps on egress interface eth1/100

  • Applying the service-policy for qos and queuing to the respective ingress and egress interface(s)

ip access-list test-qos-acl
  10 permit ip 10.1.1.0/24 any
  20 permit ip 10.2.2.0/24 any
  30 permit ip 10.3.3.0/24 any

class-map type qos match-all cq
  match access-group name test-qos-acl

policy-map type qos set-queue-2
  class cq
    set qos-group 2

policy-map type queuing custom-shaper-policy
  class type queuing c-out-8q-q3
    bandwidth percent 20
  class type queuing c-out-8q-q2
    bandwidth percent 30
    shape min 200 mbps max 200 mbps
  class type queuing c-out-8q-q-default
    bandwidth percent 50
  class type queuing c-out-8q-q1
    bandwidth percent 0
  class type queuing c-out-8q-q4
    bandwidth percent 0
  class type queuing c-out-8q-q5
    bandwidth percent 0
  class type queuing c-out-8q-q6
    bandwidth percent 0
  class type queuing c-out-8q-q7
    bandwidth percent 0

interface Ethernet1/97
  service-policy type qos input set-queue-2

interface Ethernet1/99
  service-policy type qos input set-queue-2

interface Ethernet1/100
  service-policy type queuing output custom-shaper-policy