Home > Articles

  • Print
  • + Share This
This chapter is from the book

Traffic Conditioners

QoS mechanisms can not only provide for the allocation of a minimum amount of bandwidth for specific traffic but also limit the amount of bandwidth made available to that traffic. This section discusses how policing and shaping mechanisms limit traffic rates.

Policing Versus Shaping

Instead of allocating bandwidth for applications, in some instances, you might want to restrict the amount of bandwidth that is available for specific traffic. For example, you might want to set a “speed limit” for users on the network who are downloading music files from the Internet.

QoS mechanisms that limit bandwidth are called traffic conditioners. The two categories of traffic conditioners are policing and shaping. Although both of these approaches limit bandwidth, they have different characteristics, as follows:

  • Policing—Policing typically limits bandwidth by discarding traffic that exceeds a specified rate. However, policing also can remark traffic that exceeds the specified rate and attempt to send the traffic anyway. Because policing’s drop behavior causes TCP retransmits, it is recommended for use on higher-speed interfaces. Also, note that policing can be applied inbound or outbound on an interface.

  • Shaping—Shaping limits excess traffic, not by dropping it but by buffering it. This buffering of excess traffic can lead to delay. Because of this delay, shaping is recommended for slower-speed interfaces. Unlike policing, shaping cannot remark traffic. As a final contrast, shaping can be applied only in the outbound direction on an interface.

The question becomes this: How do you send traffic out of an interface at a rate that is less than the physical clock rate of the interface? It is impossible for an interface to send at a rate that is slower than the line rate. However, you can send at an “average” rate that is less than the clock rate by using policing or shaping tools that do not transmit all the time. Specifically, these tools send a certain number of bits or bytes at line rate, and then they stop sending until a specific timing interval (for example, 1/8 of a second) is reached. When the timing interval is reached, the interface again sends a specific amount of traffic at line rate, it stops, and then it waits for the next timing interval to occur. This process continually repeats, allowing an interface to send an average bandwidth that can be below the physical speed of the interface. This average bandwidth is called the Committed Information Rate (CIR). The number of bits (the unit of measure that is used with shaping tools) or bytes (the unit of measure that is used with policing tools) that is sent during a timing interval is called the Committed Burst (Bc). The timing interval is written as Tc.

For example, consider that you have a physical line rate of 128 kbps, but the CIR is only 64 kbps. Also consider that there are eight timing intervals in a second (that is, Tc = 1/8 of a second = 125 ms), and during each of those timing intervals, 8000 bits (that is, the committed burst parameter) are sent at line rate. Therefore, over the period of a second, 8000 bits were sent (at line rate) eight times, for a grand total of 64,000 bits per second, which is the CIR.

Figure 25Figure 25

However, if all the Bc bits (or bytes) were not sent during a timing interval, you have an option to “bank” those bits and use them during a future timing interval. The parameter that allows this storing of unused potential bandwidth is called the Excess Burst (Be) parameter. The Be parameter in a shaping configuration specifies the maximum number of bits or bytes that can be sent in excess of the Bc during a timing interval, if those bits are indeed available. For those bits or bytes to be available, they must have gone unused during previous timing intervals. Policing tools, however, use the Be parameter to specify the maximum number of bytes that can be sent during a timing interval. Therefore, in a policing configuration, if the Bc equals the Be, no excess bursting occurs. If excess bursting does occur, policing tools consider this excess traffic as exceeding traffic. Traffic that conforms to (that is, does not exceed) the specified CIR is considered by a policing tool to be conforming traffic. As part of your policing configuration, you can specify what action to take when traffic conforms to the CIR and what other action to take when the traffic exceeds the CIR.

The relationship between the Tc, Bc, and CIR is given with the following formula:

CIR = Bc / Tc

Alternatively, the formula can be written as follows:

Tc = Bc / CIR

Therefore, if you want a smaller timing interval, you could configure a smaller Bc.

To illustrate the operation of traffic conditioners, Cisco allows the metaphor of a “token bucket,” where you place Bc tokens in the bucket during each timing interval. Also, the bucket can hold a total of Be tokens. In a policing configuration, traffic that requires no more than the Bc number of bits or bytes to be transmitted is called conforming traffic. Traffic that requires more than the Bc number of bits or bytes is said to be exceeding traffic.

Consider a policing example, where 500 bytes are currently in the token bucket. A packet comes through requiring 300 bytes. The bytes are removed from the bucket, and the packet is sent. Then, before the bucket has been replenished with more tokens, another 300-byte packet comes along. Because only 200 bytes remain in the bucket, the packet cannot be sent and is discarded.

Figure 26Figure 26

This illustration describes how policing functions with a single token bucket; however Cisco supports a dual token bucket.

With a dual token bucket, two buckets exist. The first bucket has a depth of Bc, and the second bucket has a depth of Be. If a packet can be forwarded using bytes in the Bc bucket, it is said to be conforming. If the packet cannot be forwarded using the bytes in the Bc bucket, but it can be forwarded using the bytes in the Be bucket, it is said to be exceeding. If the packet cannot be forwarded using either of the buckets individually, it is said to be violating. Realize, however, that a violating packet can still be transmitted if it can be forwarded using the combined bytes in both the Bc and Be buckets.

Figure 27Figure 27

Instead of policing traffic to a single rate, Cisco also supports dual-rate policing. With dual-rate policing, you still have two token buckets. The first bucket is the Committed Information Rate (CIR) bucket, and the second bucket is the Peak Information Rate (PIR) bucket. These buckets are replenished with tokens at different rates, with the PIR bucket being filled at a faster rate.

When a packet arrives, the dual-rate policer checks to see whether the PIR bucket has enough tokens (that is, bytes) to send the packet. If there are not sufficient tokens, the packet is said to be violating, and it is discarded. Otherwise, the policer checks to see whether the CIR bucket has enough tokens to forward the packet. If the packet can be sent using the CIR bucket’s tokens, the packet is conforming. If the CIR bucket’s tokens are not sufficient, but the PIR bucket’s tokens are sufficient, the packet is said to be exceeding, and the exceed action (for example, transmit with a DSCP value of AF11) is applied.

Figure 28Figure 28

With a policing mechanism, you can specify various actions to perform based on whether a packet is conforming, exceeding, or violating. Examples of these actions are as follows:

  • Transmit—Send the packet on to the scheduler.

  • Drop—Discard the packet.

  • Mark—Set priority bits for the packet.

  • Multiaction—Perform more than one action, such as mark the packet with a DSCP value of AF12 and set the CLP bit to a 1.

CB-Policing Configuration

First, consider the configuration of Class-Based Policing (CB-Policing) for a single rate. You can configure CB-Policing with the following command:

Router(config-pmap-c)#police cir [bc [be]] [conform-action action] [exceed-action action] [violate-action action]

Note that you do not have to specify the Bc or Be values. If you specify only the CIR, the IOS calculates Bc as CIR/32 or 1500 (whichever is higher). Also, the default Be value equals Bc, meaning that the token bucket never holds more than Bc bytes.

In the following example, you want to limit web traffic to 100 kbps and Telnet traffic to 50 kbps on interface Ethernet 0/0.

Figure 29Figure 29

RouterA(config)#class-map WEB
RouterA(config-cmap)#match protocol http
RouterA(config-cmap)#exit
RouterA(config)#class-map TELNET
RouterA(config-cmap)#match protocol telnet
RouterA(config-cmap)#exit
RouterA(config)#policy-map POLICING_EXAMPLE
RouterA(config-pmap)#class WEB
RouterA(config-pmap-c)#police 100000
RouterA(config-pmap-c)#exit
RouterA(config-pmap)#class-map TELNET
RouterA(config-pmap-c)#police 50000
RouterA(config-pmap-c)#exit
RouterA(config-pmap-c)#exit
RouterA(config-pmap)#exit
RouterA(config)#interface Ethernet 0/0
RouterA(config-if)#service-policy output POLICING_EXAMPLE

As mentioned earlier, you can configure dual-rate CB-Policing, where you police to two distinct rates: the CIR and PIR. The following command configures dual-rate CB-Policing:

Router(config-pmap-c)#police cir cir [bc bc] [pir pir] [be be] [conform-action action] [exceed-action action] [violate-action action]

Similar to CB-WFQ and LLQ, dual-rate CB-Policing allows you to limit the bandwidth of specific traffic by a percentage of an interface’s bandwidth. This can be accomplished with the following command:

Router(config-pmap-c)#police cir percent percent [bc bc] [pir percent percent] [be be] [conform-action action] [exceed-action action] [violate-action action]

CB-Shaping Configuration

One of two approaches can be used when configuring Class-Based Shaping (CB-Shaping): shaping to average and shaping to peak. When you configure CB-Shaping to shape to average, you only want to send traffic at the CIR. However, if you configure shaping to peak, you are attempting to send above the CIR, if bandwidth is available. Specifically, when you shape to peak, instead of just adding Bc bits to the token bucket during each timing interval, you are adding Bc + Be bits to the token bucket. The peak rate is given by the following formula:

Peak Rate = CIR * [1 + (Be/Bc)]

Although shaping to peak can squeeze out some extra bandwidth from a WAN connection, it also can lead to multiple packet drops. Therefore, you should judiciously choose between the average and peak options.

Following is the command to configure CB-Shaping:

Router(config-pmap-c)#shape {average | peak} cir [bc] [be]

Like CB-Policing, CB-Shaping can specify its CIR as a percentage of interface bandwidth, with the following command:

Router(config-pmap-c)#shape {average | peak} percent percent [bc] [be]

Consider the following CB-Shaping example, where you are shaping one class-map to average and another class-map to peak:

Router(config)#class-map AVERAGECLASS
Router(config-cmap)#match protocol telnet
Router(config-cmap)#exit
Router(config)#class-map PEAKCLASS
Router(config-cmap)#match protocol http
Router(config-cmap)#exit
Router(config)#policy-map AVERAGEPOLICY
Router(config-pmap)#class AVERAGECLASS
Router(config-pmap-c)#shape average 64000
Router(config-pmap-c)#exit
Router(config-pmap)#exit
Router(config)#policy-map PEAKPOLICY
Router(config-pmap)#class PEAKCLASS
Router(config-pmap-c)#shape peak 64000

In this example, the AVERAGEPOLICY policy-map is shaping Telnet traffic to average, meaning that Telnet traffic is shaped to the CIR of 64 kbps. However, that is not the case for the PEAKPOLICY policy-map.

The PEAKPOLICY policy-map is shaping traffic to a peak rate of CIR * [1 + (Be/Bc)]. Because you let the IOS calculate the Bc and Be values, they are equal, which means that you are shaping to a rate of 64000 * (1 + 1) = 128 kbps.

Enabling CB-Shaping for Frame Relay Networks

On Frame Relay networks, you might need not only to shape your traffic, but you might also need your router to respond to congestion occurring in the service provider’s cloud, by reducing the CIR to a lower value.

When a service provider becomes congested and needs to discard frames, it first discards frames with their Discard Eligible (DE) bit set to a 1. The service provider also can request that the sending router slow its transmission rate, by marking the Backward Explicit Congestion Notification (BECN) bit to a 1, in a frame going back to the sender. When this occurs, if the router is configured to respond to BECNs, the router reduces its CIR by 25 percent. If the router receives another BECN in the next time interval, it decreases its transmission rate by 25 percent of the current rate. This behavior can continue until the rate drops to the router’s configured minimum CIR.

Figure 30Figure 30

You can, however, encounter a situation in which the vast majority of the traffic is from one router to another router (that is, with little, if any, return traffic). In such a situation, the service provider cannot mark the BECN bit in a frame going back to the sender, because no (or very few) frames are going back to the sender. To remedy this situation, the service provider can mark the Forward Explicit Congestion Notification (FECN) bit in a frame that is destined for the receiver. If the receiver is configured to respond to FECNs, it generates a Q.922 test frame and sends it back to the sender. This test frame gives the service provider the opportunity to mark a frame’s BECN bit, in an attempt to make the sender slow its transmission rate.

Figure 31Figure 31

After a sender has slowed its transmission rate because of BECNs, 16 timing intervals must elapse before the sender begins to increase its transmission rate. When the sender does begin to increase its transmission rate, it does so at a much more cautious rate than when it reduced its rate. Specifically, the sender only increases its transmission rate by (Be + Bc) / 16 bits per timing interval.

Consider the following example, where CB-Shaping is being combined with CB-WFQ to allocate at least one amount of bandwidth, while shaping (that is, limiting the traffic rate) to a higher bandwidth.

Router(config)#policy-map FRAMESHAPE
Router(config-pmap)#class FRAMECLASS
Router(config-pmap-c)#shape average 128000
Router(config-pmap-c)#shape adaptive 96000
Router(config-pmap-c)#bandwidth 96

In this example, traffic classified by the FRAMECLASS class-map is shaped to an average rate of 128 kbps. Also, the shape adaptive mincir command is used to specify the minimum value to which the CIR can drop in the presence of BECNs. In this example, the router can reduce its transmission rate to a CIR of 96 kbps. (Note that the units of measure for the mincir parameter are bits per second.) Also, CB-WFQ specifies that at least 96 kbps of bandwidth is available for this class of traffic. Note that, as shown in the previous example, minimum CIR (as specified by the shape adaptive command) should not be less than the bandwidth that is allocated by CB-WFQ.

  • + Share This
  • 🔖 Save To Your Account