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.

Procedure

  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 a sample configuration for traffic shaping using 200000 packets per second:


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
    shape pps 200000		
    bandwidth percent 50
  class type queuing class-default
    bandwidth percent 50
class-map type network-qos cn
  match qos-group 2
policy-map type network-qos pn
  class type network-qos cn
    congestion-control random-detect
  class type network-qos class-default
system qos
  service-policy type network-qos pn
  service-policy type queuing output pqu
  service-policy type qos input pq