While writing an article about QoS, I realized that i needed at clarify some of the terminology used. In particular I want to discuss first about the different ways to control the amount of traffic we send out or receive in a particular interface, especially in the case when the CIR we contracted is less than the physical speed of our interface. I’m talking about Shaping and Policing.
Shaping and policing are two very different approaches and are configured also in a very different way even though they use similar terminology. In this article I will be focusing on the first of the two methods, traffic shaping.
With traffic shaping we prevent the router to ensure that the bit rate of packets leaving an interface will not exceed the configured value. When the configured value is exceeded, the exceeding packets are queued in the shaping queue and forwarded on a later time. Therefore, traffic shaping can only be applied outbound.
Every device can send traffic out of a particular interface only at the serialization speed of the interface. For example, on a Serial interface that will be 1.544 Mbps, on a Ethernet will be 10 Mbps, on a FastEthernet 100 Mbps and so on. For this reason, the only way to limit the bit rate of an interface, is to interleave periods when traffic is sent at the serialization speed of the link, with periods of silence.
Let’s make an example. We want to limit an Ethernet link at 5 Mbps. Since the serialization on an Ethernet interface is 10 Mbps, to achieve only 5 Mbps we will need to send traffic for half second, and be quite for the other half. That, in average, will result on 5 Mbps since 10 Mbps * 0.5 s = 5 Mbps. The routers won’t be thinking in seconds, as a second is too big, instead they will think in a much smaller unit, the milliseconds (ms). Obviously, thinking in ms, we will have more than one interval within a seconds; those time intervals are called Tc.
Assuming for simplicity a Tc of 125 ms, we will have 8 intervals within a second (125 * 8 = 1000 ms = 1s). Within each interval, the router will send traffic at the maximum speed allowed by the interface and be silent so that, as explained before, the average over time, will be the configured shaped rate.
The Bc instead, is the amount of traffic (in bits) that can be sent out of the interface for every interval. The relation between Tc, Bc and Shaped rate is: Shaped rate = Bc / Tc. Most of the times we configure the CIR as the shaped rate, this will make the formula easier to read as : CIR = Bc / Tc. Particular attention needs to be placed on the units we use, as the CIR is usually in Kbps or Mbps, the Bc is in bps an the Tc in ms.
The following picture should be more explanatory (click on it to zoom it) :
All this considerations are perfect when the link is utilized above the shaping rate. The router, working as described before, is able to reduce the amount of traffic sent out the interface.
We know that most of the traffic, is usually not so uniform, we deal with moments of high utilization and moment of lower utilization. In this condition, traffic shaping, is able to queue excess packets, and transmit them later during an interval of low utilization. The maximum amount of traffic that can be sent during a low utilization interval is calledBe.
The result of applying traffic shaping is a quite uniform distribution of the outgoing traffic as the picture below is showing:
The configuration of traffic shaping, in regards of Class Based (CB) is quite simple. Let see just a couple of examples and verifications. In the following examples we want to shape a FastEthernet link at 60 Mbps.
When the shaping rate is configured as an absolute value, we need to specify what this value is in bits per second. We can use the key letters k , m, g for Kbps, Mbps, Gbps respectively, but the value will be automatically converted in bits in the configuration.
Also, is to be noted, that the shaping rate is the only required and IOS actually explicitly recommends not to configure Bc and Be values.
To apply the shaping, we need to go at the interface level, and apply the service policy in the outbound direction. Verification is done using the show service-policy interface command. We can there verify the Shaping rate as well the Be and Bc that have been automatically calculated by the router as per output below:
Since Bc is 240000 bits and the CIR is 60000000, the Tc considered can be calculated and in this example is equal to 4ms
Shaping can also be configured as a relative percentage of the configured interface bandwidth. If the configured bandwidth changes, the policy-map will automatically adjust to the new relative shaping rate as per example below: