647 Words. Plan about 4 minute(s) to read this.
Traffic-shaping is the idea of delaying a flow of traffic such that it does not exceed a specified bandwidth. In observing an graph of bandwidth utilization of unshaped flow of traffic versus shaped traffic, you might see an irregular utilization of spikes up and down for the unshaped traffic, and an even plateau for shaped traffic.
Traffic-shaping is largely targeted at preventing a high-bandwidth interface from overwhelming a lower bandwidth interface downstream. This can manifest itself in a couple of ways:
- A service provider may discard traffic in excess of the committed information rate. While TCP conversations may recover from such a thing, a more graceful solution to avoiding the packet drops within the provider cloud is to shape the traffic at the router before it hits the cloud.
- Another situation known as “egress blocking” is when a frame or ATM switch must queue traffic sent in from a high bandwidth site before forwarding to a lower bandwidth site. Or conversely, when an aggregate of low bandwidth sites sending at once overwhelm an upstream link. By shaping on the router, you leave control over the traffic flow with your queuing tools, rather than in the hand of an egress queue you might not manage.
A Cisco router shapes by determining, in accordance with the interface clock signal, how often it can transmit how many bits. To use half of a 256Kbps link, the router would send traffic one clock cycle, and send nothing the next.
- Tc = Time interval in milliseconds during which the committed burst rate (Bc) can be sent. This is often the formula Tc = Bc/CIR.
- Bc = Committed burst size in bits. This is the amount of traffic that can be send during Tc, and is usually defined in the “traffic contract”.
- CIR = committed information rate in bits per second. This is the rate of a virtual circuit.
- Shaped rate = the rate in bits per second that traffic is to be shaped to. It is often, but does not have to be, the same as the CIR.
- Be = excess burst size in bits. This defines how many bits over and above that of Bc that can be sent during inactivity. Inactivity is the idea of an interface sending a small amount of data when compared to the CIR.
A base formula to understand when dealing with traffic shaping is Tc = Bc/shaping rate. This simple formula can be rewritten as Bc = Tc * shaping rate. You can use whatever values are known to compute the unknown.
When traffic-shaping is enabled, a router uses a token bucket to determine whether he can send more traffic or not. Think of a token as cash, where each token gives the router the right to send a bit. Let’s assume we aren’t using Be. Then at the end of each Tc, enough tokens are placed in the bucket for the router to send Bc worth of data. If there were tokens left from the last cycle, tokens added during this Tc are lost – the router will never have more tokens in the bucket than Bc. Now, let’s say we do have Be enabled. In that case, the bucket is bigger than Tc. So you can accumulate spare tokens to allow you to send burst data during the next cycle.
In frame-relay networks, the traffic-shaping rate can fluctuate dynamically in relation to backward explicit congestion notification (BECN) messages or receiving a Cisco-proprietary “foresight” congestion message. The rate can go as low as the configured “minimum information rate” (MIR or mincir) which defaults to 50% of the shaped rate. When a frame router gets a BECN, the shaper will drop the transmission rate by 25% of the max. This will continue for each BECN until mincir is reached. If after 16 consecutive Tc values, there are no BECNs, the rate will grow by a sixteenth per Tc until the max rate is again reached.