QoS Traffic Shaping Explained

Shaping is a QoS (Quality of Service) technique that we can use to enforce lower bitrates than what the physical interface is capable of. Most ISPs will use shaping or policing to enforce “traffic contracts” with their customers. When we use shaping we will buffer the traffic to a certain bitrate, policing will drop the traffic when it exceeds a certain bitrate. Let’s discuss an example why you want to use shaping:

Your ISP sold you a fibre connection with a traffic contract and a guaranteed bandwidth of 10 Mbit, the fibre interface however is capable of sending 100 Mbit per second. Most ISPs will configure policing to drop all traffic above 10 Mbit so that you can’t get more bandwidth than what you are paying for. It’s also possible that they shape it down to 10 Mbit but shaping means they have to buffer data while policing means they can just throw it away. The 10 Mbit that we pay for is called the CIR (Commited Information Rate).

There are two reasons why you might want to configure shaping:

Instead of waiting for the policer of the ISP to drop your traffic, you might want to shape your outgoing traffic towards the ISP so that they don’t drop it.

To prevent egress blocking. When you go from a high speed interface to a low speed interface you might get packet loss (tail drop) in your outgoing queue. We can use shaping to make sure everything will be sent (until its buffer is full).

In short, we configure shaping when we want to use a “lower bitrate” than what the physical interface is capable of.

Routers are only able to send bits at the physical clock rate. As network engineers we think we can do pretty much anything but it’s impossible to make an electrical or optical signal crawl slower through the cable just because we want to. If we want to get a lower bitrate we will have to send some packets, pause for a moment, send some packets, pause for a moment…and so on.

For example let’s say we have a serial link with a bandwidth of 128 kbps. Imagine we want to shape it to 64 kbps. If we want to achieve this we need to make sure that 50% of the time we are sending packets and 50% of the time we are pausing. 50% of 128 kbps = an effective CIR of 64 kbps.

Another example, let’s say we have the same 128 kbps link but the CIR rate is 96 kbps. This means we will send 75% of the time and pause 25% of the time (96 / 128 = 0.75).

Now you have a basic idea of what shaping is, let’s take a look at a shaping example so I can explain some terminology:

Above we see an interface with a physical bitrate of 128 kbps that has been configured to shape to 64 kbps. On the vertical line you can see the physical bitrate of 128 kbps. Horizontally you can see the time from 0 to 1000 milliseconds. The green line indicates when we send traffic and when we are pausing traffic. The first 62.5 ms we are sending traffic at 128 kbps and the second 62.5 ms we are pausing. This first interval takes 125 ms (62.5 + 62.5 = 125 ms) and we call this interval the Tc (Time Interval).

In total there are 8 time intervals of 125 ms each. 8x 125 ms = 1000 ms. Most Cisco routers have a Tcdefault value of 125 ms. With the example above we are sending traffic 50% of the time and pausing 50% of the time. 50% of 128 kbps = shaping rate of 64 kbps.

Our Cisco router will calculate how many bits it can send each Tc so that it will reach the targetted shaping rate. This value is called the Bc (committed burst).

In the example above the Bc is 8.000 bits. Each Tc (125 ms) it will send 8.000 bits and when it’s done it will wait until the Tc expires. In total we have 1.000 ms of time. When we divide 1.000 ms by 125 ms we have 8 Tcs. 8000 bits x 8 Tcs = shaping rate of 64 kbps.

To sum things up, this is what you have learned so far:

Tc (time interval) is the time in milliseconds over which we can send the Bc (committed burst).

Bc (committed burst) is the amount of traffic that we can send during the Tc (time interval) and is measured in bits.

CIR (committed information rate) is the bitrate that is defined in the “traffic contract” that we received from the ISP.

There are a number of formulas that we can use to calculate the values above:

Bc value:

Bc = Tc * CIR

In the example above we have a Tc of 125 ms and we are shaping to 64 kbps (that’s the CIR) so the formula will be:

125 ms * 64 kbps = 8.000 bits.

Tc value:

Tc = Bc / CIR

We just calculated the Bc (8.000 bits) and the CIR rate is 64 kbps, the formula will be:

8.000 bits / 64.000 = 0.125. So that’s 125 ms.

Let’s look at another example. Imagine we have an interface with a physical bitrate of 256 kbps and we are shaping to 128 kbps. How many bits will we send each Tc?

CIR = 128 kbps
TC = 125 ms (the default)

125 ms x 128 kbps = 16.000 bits

So the Bc is 16.000 bits. Each Tc we will send 16.000 bits.

The shaper will grab 16.000 bits each Tc and send them. Once they are sent it will wait until the Tc has expired and a new Tc will start.

The cool thing about shaping is that all traffic will be sent since we are buffering it. The downside of buffering traffic is that it introduces delay and jitter. Let me show you an example:

Above we have the same interface with a physical bitrate of 128 kbps and the Tc is 125 ms. Shaping has been configured for 64 kbps. You can see that each Tc it takes 62 ms to send the Bc. How did I come up with this number? Let me walk you through it:

125 ms * 64 kbps = 8.000 bits.

Now we know the Bc we can calculate how long it takes for a 128 kbps interface to send these 8000 bits. This is how you do it:

Delay value:

Delay = Bc / physical bitrate

Let’s try this formula to find out how long it takes for our 128kbps interface to send 8.000 bits:

8.000 / 128.000 = 0.0625

So it takes 62.5 ms to send 8000 bits through a 128 kbps interface. If we have a fast interface the delay will of course be a lot lower, let’s say we have a T1 interface (1.54 Mbit):

8.000 / 1.540.000 = 0.0051

It only takes 5 ms to send 8000 bits through a T1 interface.

The default Tc of 125 ms is maybe not a very good idea when you are working with Voice over IP. Imagine that we are sending a data packet that is exactly 8.000 bits over this T1 link. It will only take 5 ms but that means that we are waiting 120 ms ( 125 ms – 5 ms) before the Tc expires and we can send the next 8.000 bits . If this next packet is a VoIP packet then it will at least be delayed by 120 ms.

Cisco recommends a one way delay of 150 to 200 ms for realtime traffic like VoIP so wasting 120 ms just waiting isn’t a very good idea. When you have realtime traffic like voice, Cisco recommends to set your Tc to 10ms to keep the delay to a minimum.

So if we set our Tc to 10 ms instead of the default 125 ms…what will our Bc be? In other words how many bits can we send during the Tc of 10 ms?

Let’s get back to our 128 kbps interface that is configured to shape to 64 kbps to calculate this:

We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.

Try for Just $1. The Best Dollar You've Ever Spent on Your Cisco Career!

Both policing and shaping have a common goal: to “rate-limit” exceeding traffic.

How they do it is different though. A shaper will “buffer” the traffic while a policer “drops” the traffic.

A practical example could be an ISP router that is connected to multiple customer routers. Let’s say that the routers are connected with GigabitEthernet links but the customers are only paying for a 100/100 Mbit connection.

The ISP will then use a policer to drop all incoming traffic that exceeds 100 Mbit.

Yes indeed this can be the case. You must coordinate with the ISP so that your shaping policy on the edge of your network doesn’t send more traffic than the ISP is configured to handle especially if the ISP implements a more strict policy than your edge router. Otherwise, as you describe in your post, traffic can and will be dropped by the ISP.

There’s no single answer to your question. You are correct in that the Bc that you will use will depend on the traffic that you want to shape. As mentioned in the lesson, Bc depends upon the Tc and upon the actual Committed Information Rate or the required shaped speed of the link, like so:

Bc = Tc * CIR

And Tc will depend on the kind of traffic that will be shaped. If you’re shaping voice, Tc should be around 10 ms. So Bc = 10 ms * CIR. Now if your CIR is very large like 5Mbps, then Bc will be 50 kilobits, but if your CIR is relatively small li

New Lessons

Testimonials

Great Troubleshooting Resource

I cannot be more grateful to have found NetworkLessons.com to prepare for my CCIE journal. Rene really makes these topics very easy to understand and using real life examples, giving us proof of concept how different networking technologies work.

Jose AndaNetwork EngineerMay 9, 2016

Great Source of Information

I had the classroom training for CCNP Routing & Switching and failed the test afterward. That was the reason why I searched for more and better information and found it here. NetworkLessons.com is great. Easy to follow explanations and videos. It covers all topics of the actual test. With the material from NetworkLessons.com, I passed ROUTE (with a 94% score!) and SWITCH (an 88%!) and have 1 more to go (TSHOOT). I am very confident to pass this as well. Thank you very much, Rene!

Christian RichterNetwork EngineerMay 8, 2017

Taking Network Technologies to the Street

The lead instructor Rene has the ability to explain the most complex concept into very straightforward and easy to understand units. Studying with NetworkLessons.com has changed the course of my career for the best and I will never stop recommending his lessons, books, website and videos. Thank you Rene (and your crew), for your great work!

Wandjlaye GodweNetwork EngineerJanuary 7, 2017

Clarity, Pedagogy & Useful

I'm working to obtain the Cisco CCNP R&S certification and NetworkLessons.com makes me more understandable Cisco's technologies. Thanks a lot Renee for the quality of your lessons!

Cyril CamardNetwork EngineerOctober 8, 2015

A Fantastic Teacher

NetworkLessons.com is a fantastic teaching platform. Every lesson is set up in a way that makes learning interesting and fun. Rene is an expert and doesn't try to impress his readers on how much he knows. He has a genuine desired to help others to grasp all network concepts. The one aspect I enjoy the most are the live demonstrations he includes with each lesson. The labs presented in his lessons are easily reproducible in GNS3 which has allowed me to hone my skills. NetworkLessons.com is very affordable and should be a part of anyone's Network Training Library.

Paul LagattaNetwork EngineerSeptember 1, 2016

Educationally Rewarding

NetworkLessons.com is one of the best educational websites out there! The ease of finding content, the concise breakdown of complex topics in an easy to understand manner and great staff who will assist in answering questions. What more can you ask for!? If you want to learn networking and grow your skills this is the environment you want to be a part of. I truly love NetworkLessons.com and respect & appreciate the staff. A great investment helping me to achieve my CCNA and now working on my CCNP!

Brian CatlinSystem AdministratorJune 26, 2017

Amazing Site

NetworkLessons.com explains complex and hard to understand networking concepts in just plain English. It's hard to miss the concepts. Thank you for all of your hard work. It did help me, and will definitely help somebody else.

Meheretab MengistuNetwork EngineerJanuary 10, 2017

Can’t Miss for a Day

NetworkLessons.com makes labs look easy and understandable. I seriously can't miss a single day without being a member of their website. NetworkLessons.com is a fantastic and very helpful e-learning site. They provide you the best and the most important knowledge that you need to get any networking job done. Thank you!

Jean CasimirSr Network EngineerAugust 14, 2017

Improve Your Network Skills

NetworkLessons.com is very useful if you want to improve your Cisco and network skills. Their website is very interesting because the topics are very well explained even the most complex ones. I can recommend it highly because it is very rich in great information and lessons!

Networklessons.com is a very nice compilation of all Networking Route and Switch Technologies. Very good and interactive explanation of technologies which are easier to simulate on own's lab environment after reading on Networklessons.com.

Abhijeet AgarwalNetwork EngineerOctober 30, 2015

Awesome R&S Tour Guide

Climbing the Cisco R&S 'mountain' with NetworkLessons.com as your ultimate 'travel tour guide'! Everyone who strives to become a (better) networking/R&S professional and uses NetworkLessons.com as a daily resource is right on target! We 'strivers' need the best to guide us to the top of the network/R&S mountain! We all know how hard and demanding this IT/R&S journey is! To us, the Cisco R&S pyramid is perfect and pretty. Networking technologies, routing & switching is full of pitfalls. NetworkLessons.com provides truly one of the best guides. Rene inspired me greatly over the years, presenting his wealth of knowledge on GNS3Vault.com and Networklessons.com and I have watched, listened and learned a heck of a lot. He has inspired me to reach my goals and I don't see myself slowing down. Thank you Rene and team! It's truly a great journey!