Shaping is actually done by queuing the traffic and policing is dropping / discarding traffic which exceeds the configured.
Shaping is Queuing
Policing is Dropping
Actually there are 2 types of shaping supported by Cisco IOS.
1. Average Shaping
2. Peak Shaping
Average Shaping & CIR (Committed Information Rate)
Let's say we have bought a link from an ISP with a bit rate of 5 Mbps and the physical link is an Ethernet link of 10 Mbps. This 5 Mbps is called the CIR and shaping to CIR is called average shaping.
As an example if we have a link of 10 Mbps and we need to send it out 5 Mbps bit rate, we have to send some bits for half a second and pause sending bits for the other half of the second so that as an average it counts as 5 Mbits per second.
Following is a bit-rate by time graph of a 10 Mbps interface where shaping is not configured.
Most Cisco routers has the time interval of 125 ms by default. So within a 1 second, there are 8 time intervals.
If shaping to 8 Mbps is required out of a 10 Mbps link, following is the graph for that;
Bc = CIR x Tc
Tc = Time interval over which the committed burst can be sent.
Bc is the amount of bits sent within a time interval. For the above example, CIR = 8 Mbps & Tc = 125 ms, so the Bc = 1 M bits
What router actually does is that it will send 1 M bits and wait for another Time interval to start.
To visualize this decision making process of the router, Cisco uses a concept of a token bucket.
Imagine a bucket which can be filled using tokens in which a 1 token equals to a 1 bit and this bucket can be filled with tokens equal to Bc.
Also this bucket is filled at the beginning of every time interval and can spend tokens only within that time interval.
When 1 bit of data is transmitted, 1 token is taken out and when there is no tokens left, the traffic is buffered until the next time interval comes where the bucket is refilled with Bc amount of tokens.
Delay
The actual time period which it spend to send this Bc is called the Delay.
When we configure the router to shape the traffic to a certain bit rate, it should calculate this "Delay" which is stated in the graph by the simple "d" in red color. Let's continue the example to find the delay..
So within 8 intervals, total of 8 M bits (1 M x 8) will be sent.
Delay = Bc/(Physical bit rate)
Now as per the above example,
Delay = 1M/10Mbps
= 100 ms
So the router will send data for 100 ms and wait for 25 ms and send data for 100 ms again and it will continue this behavior to achieve the shaping bit rate.
So there can be 25 ms of maximum time gap between 2 packets which are the last packet of a time interval and the 1st packet of the next time interval. So the packet after the last packet of a time interval can be delayed for 25 ms.
Concept of Bursting & Be (Burst Excess)
This concept allows the router to send more bits than the Bc within a time interval after a period of inactivity where it has some data which could not be sent during the last interval because of the limitation of the fixed Bc.
Now the token bucket is larger but at the beginning of every regular time interval it will only be refilled with tokens equal to the amount of Bc. But at the time intervals where the router does not send full amount of Bc, the bucket is filled more than Bc (up to the Be) so that it can spend more tokens (send more bits) during the next interval.
Imagine a situation where the router has 2 packets to send and one packet contains 700 bits and the next packet has 500 bits. Let's say the Bc is 1 M. What happens is now after the 1st packet is sent, only a packet of 300 bits or a lesser can be sent because unless otherwise it will exceed the Bc.
If Be is configured to 250 kilo bits as an example, during next time interval it will send the 500 bit packet with the next coming packets which will exceed the Bc as a total within a single Tc. But when the average is calculated per second, the shaping rate (CIR) is not exceeded.
The graph will be something like the following..
Calculate Be to match the burst to physical access rate?
On the above example I have taken the Be to be 250 kilo bits to match the physical access rate of the interface. In a case where we are asked to calculate the Be so that we can configure the shaper to burst up to the physical rate of the interface after a period of inactivity here is how we calculate it.
CIR = 8 Mbps , Tc = 125 ms, Physical Access Rate of the interface = 10 Mbps are given..
Bc = CIR x Tc
= 8 Mbps x 125 ms
= 1 Mbits calculated..
Calculating Bc if we burst up to the Physical Access Rate;
Bc = CIR x Tc
= 10 Mbps x 125 ms
= 1.25 M bits
So the Be should be = 1.25 M - 1 M = 250 kilo bits..
So setting Bc = 1 Mbits and Be = 250 kbits will burst up to the physical access rate..
Peak Shaping & PIR (Peak Information Rate)
According to your agreements, the ISP will give you CIR along with a PIR. CIR is the maximum guaranteed bandwidth and PIR is the maximum non guaranteed bandwidth you can get when there is no congestion in the network. Peak Shaping is that we are configuring the shaper up to the PIR when we have a lot of packets to send and shape up to the CIR when there is not that much traffic to send.
When peak shaping is configured, the router is sending Bc + Be bits every interval so that no need to wait for a period of inactivity which means now the Bc + Be token bucket is filled at the beginning of every time interval and spend all tokens during each interval unless there is a congestion. In a congestion it will spend only the Bc tokens.
This means the Bc+Be should be configured not to match the physical rate but to the given PIR.
For configurations please go here.
No comments:
Post a Comment