Configuring Traffic Shaping
This chapter contains the following sections:
- Information About Traffic Shaping
- Guidelines and Limitations for Traffic Shaping
- Configuring Traffic Shaping
- Verifying Traffic Shaping
- Sample Configuration for Traffic Shaping
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
Configuring Traffic Shaping
You can configure a maximum traffic rate to regulate traffic flow.
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.
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