Tuesday, March 16, 2010

Shaping Calculations

Small post here on traffic shaping calculations. I am thinking of taking the 642-642 QoS test next Tuesday, so I am really trying to re-read the book, and drive the topics home with some note-taking and lab exercises. Basically I have a topology that looks like this (sorry for the lack of visio!):

Host1(client)---R1---R2----Server1 (HTTP/FTP)

The access rate of the link (i.e. clock rate is 128000bps), the CIR given by the ISP is 64kbps. So we need to configure shaping so that our ISP does not drop our traffic. This is a REALLY basic example guys. Here is the config on R2 to shape traffic back to R1:

``` policy-map shape_all class class-default shape average 64000 ! interface Serial0/1 bandwidth 64 ip address 172.16.12.2 255.255.255.0 service-policy output shape_all ```

I then initiated a huge file download using both FTP and HTTP to engage the shaper. Here is the output of my show policy-map interface serial 0/1:

This, needs a bit of explaining. You can clearly see that the offered rate is at or below our configured shaping rate (63,000 bps at the top). Our target rate is what we configured, 64000. The "byte limit" is correct at 2000 bytes because it equals Bc + Be (8000+8000/8). This is how much the router can send per time interval (125ms). So every 125ms the router will send 2000 bytes in order to conform the traffic to 64kpbs. The Bc bucket is 8000 bits, and by default the Be bucket is = Bc bucket. These values were derived from the shaping rule (if shaping rate is < 320kbps then Bc = 8000; if it is greater than 320kbps then Tc defaults to .025 and Bc can be calculated by the formula Bc = Tc*CIR). The last item is the Increment bytes. Tokens are replenished at Bc per Tc. So every 125ms, Bc (or 1000 bytes) will be put back into the buckets.