Configuring Traffic Shaping

This chapter contains the following sections:

Information 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. Thus, traffic adhering to a particular profile can be shaped to meet downstream requirements, thereby eliminating 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 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), thereby providing 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 sent traffic exceeds the access speed of its remote, target interface. For example, you can control access to 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 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, since it falls back to store-and-forward mode when packets get queued.
  • Traffic shaping is supported only for unicast traffic. There is no traffic shaping support for multicast and broadcast traffic.

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 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 {pps | kbps } value 

    Configures the packet shaping in either packets per second (pps) or Kilobytes per second (Kbps).

     
    Step 5 switch(config-pmap-que)# exit 

    Exits the current configuration mode.

     
    Step 6 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.

     

    The following 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, enter one of the following show commands:

    Command Purpose

    show queuing interface slot/port

    Displays the queuing information configured on the specified interface.

    show hardware internal buffer info pkt-stats

    Shows the egress per-port per-queue occupancy in the running system.

    show interface slot/port

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

    Sample Configuration 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