Sunday, February 19, 2012

QOS TRAFFIC SHAPING AND POLICING

Traffic Shaping and Policing

  • Shaping can only done outbound as it is queing mechanism
  • can be used for smoother flow and adhering to bw limits set by provider
  • it can also be used to avoid over subscription i.e high bandwidth link in main office is transmitting to fast for low bandwith link in branch office
  • Time commited = TC .
  • 1 second is too long an interval too look at for shaping the reason being traffic has to be sent at the physical link speed. What shaping does is that it averages out the traffic to your desired transmission rate.
  • so for example  physicalyl have  1mbs line but agreed a 250kb rate with your provider. Given that the shaping rate then is 250 kb a second and we have to transmit at line speed of 1mbs the transmission would be complete in 1/4 of second leaving excess traffic been buffered waiting to be sent in the next second 3/4 of second is a long wait for delay sensitive traffic for example voice needs or recommended even less than 150 ms in one direction so 3/4 second is huge amount of time to wait.
  • In order to get around this we break the second into intervals so say we have 8 intervals of 125 ms. The tc is the amount of time in an interval so 125 ms in this case
  • So it important is not the number of intervals but rather lenght of an interval
  • We control the amount of data that can be sent in an interval with a token based algorithm. The idea being it is like a piggy bank we take tokens if there is no more we buffer and wait till the next interval till we get paid again with more tokens.
  • 3 important values in token bucket are bc and be + CIR
  • BC is the size of token bucket how many tokens can be stored in the bucket
  • BE is the amount you will allow the bc to be transmitted we can save up tokens to allow excess traffic to be transmitted in another interval in actual fact it allows whether there is saved up tokens or not but the router keeps track average out over the 1 sec to ensure we never go over our set rate
  • CIR is the fill rate of the token bucket
  • 1 token = 1 byte= 8 bits
Formulas

CIR  = BC/TC
TC = BC/CIR
TN - CIR/BC
TC - 1/TN
** tn i added which is the number of intervals to decipher it from tc which is the lenght of the interval

SHAPE AVERAGE VS SHAPE PEAK
  • . Some providers may say to you we will provide you with a certain speed line which we will guarantee x speed but you may go over to y speed but only x is guaranteed to be sent the differnce between x and y will be best effort
  • SO say 128Kbit is guaranteed to be sent but you can go over to 256 kilobits but we will only guarantee 128 kbit will be sent but will try our best for the other 128 kbit depending on how busy the service provider network is. CIR = 128 KBIT PIR= 256 KBIT
  • In this case we will for our critical delay sensitive traffic we will shape average this will shape to the CIR of 128 it will not use the BC+BE
  • For our non critical delay tolerable traffic we will send at BC + BE every timing interval if neccessary on the understanding that could be potential dropped as we are going over our CIR 
Commands

Policing

  • Policing uses similar concept to shaping. In that it does use a token bucket but it will not buffer traffic that goes over the rate specfied it will take an action of either drop or mark depending on the config.
  • Can be used inbound or outbound tends to be used inbound
  • The service provider may use this to rate limit the traffic.
When traffic is recieved faster than the rate desired in policing we can drop the exessive
traffic we could also not drop but remark.We may want to remark to mark it as best effort
So policing is the more stern option it does not buffer and eventually send like shaping does
it is more agreesive way of achieving a Desired speed rate.
Policing introduces a few new terms to shaping
conform- packets that keep to the speed limit and use BC tokens to trasmit
Exceed - packets that exceed  and use BE tokens
Violate - When traffic exceeds both BC and BE

 

LAB
----
OK for the LAB R4 will shape to 512 going out and R5 will police coming in to 512. Typical
scenerio of a r4 customer site connecting to service provider site
I will start doing a standard shaping config on r4 we will just do it for the class default
if we had other classes defined we could do it for them also

So we are just using class class-default which is predefined so we can move straight
to the policy map. The main thing to remeber is that it is bits not bytes the shape
command

r4(config)#policy-map SHAPE
r4(config-pmap)#class class-default
r4(config-pmap-c)#shape average ?
  <8000-154400000>  Target Bit Rate (bits per second), the value needs to be
                    multiple of 8000
  percent           % of interface bandwidth for Committed information rate
r4(config-pmap-c)#shape average 512000

so now as typically with mqc we apply to the interface

if we try to apply input
r4(config-if)#int s0/1/0
r4(config-if)#service-policy input ?
  WORD  policy-map name
r4(config-if)#service-policy input SHAPE
 GTS : Can be enabled as an output feature only
r4(config-if)#

we get an error as shaping is only an output feature
r4(config)#int s0/1/0
r4(config-if)#service-policy output SHAPE
r4(config-if)#

r4#sh policy-map int
 Serial0/1/0
  Service-policy output: SHAPE
    Class-map: class-default (match-any)
      262 packets, 16892 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any
      Traffic Shaping
           Target/Average   Byte   Sustain   Excess    Interval  Increment
             Rate           Limit  bits/int  bits/int  (ms)      (bytes)
           512000/512000    3200   12800     12800     25        1600
        Adapt  Queue     Packets   Bytes     Packets   Bytes     Shaping
        Active Depth                         Delayed   Delayed   Active
        -      0         191       15188     0         0         no
r4#

so this is standard shaping applied

Lets have a look where we have a scenerio with more classes and we want to do CBWFQ
Also some of the traffic we will shape to PIR

The first issue we face with this config is that we are using CBWFQ how will we get all
classes to shape to the desired speed?? If we specify under each class shape to the CIR or
We will need to use a different approach
PIR that class will shape to the speed not all classes

So first of all we will create our classes
r4(config)#class-map HTTP
r4(config-cmap)#match protocol HTTP
r4(config-cmap)#class-map SQL
r4(config-cmap)#match protocol sqlserver
r4(config)#class-map DNS
r4(config-cmap)#match protocol DNS
r4(config-cmap)#

We will create a policy map matching for weighted for queing
r4(config)#policy-map WFQ
r4(config-pmap)#class HTTP
r4(config-pmap-c)#bandwidth percent 20
r4(config-pmap-c)#class SQL
r4(config-pmap-c)#bandwidth percent 15
r4(config-pmap-c)#class DNS
r4(config-pmap-c)#bandwidth percent 25
r4(config-pmap-c)#

Create a class for SHAPE
r4(config)#class-map SHAPE
r4(config-cmap)#
now we need to create a new policy-map for shaping and nest the WFQ into it

r4(config)#policy-map SHAPE
r4(config-pmap)#class SHAPE
r4(config-pmap-c)#shape average 128000
r4(config-pmap-c)#service-policy WFQ
r4(config-pmap-c)#

we will then apply to the interface
r4(config)#int s0/1/0
r4(config-if)#service-policy out SHAPE

r4#sh policy-map int
 Serial0/1/0
  Service-policy output: SHAPE
    Class-map: SHAPE (match-all)
      0 packets, 0 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: none
      Traffic Shaping
           Target/Average   Byte   Sustain   Excess    Interval  Increment
             Rate           Limit  bits/int  bits/int  (ms)      (bytes)
           128000/128000    1984   7936      7936      62        992
        Adapt  Queue     Packets   Bytes     Packets   Bytes     Shaping
        Active Depth                         Delayed   Delayed   Active
        -      0         0         0         0         0         no
      Service-policy : WFQ
        Class-map: HTTP (match-all)
          0 packets, 0 bytes
          5 minute offered rate 0 bps, drop rate 0 bps
          Match: protocol http
          Queueing
            Output Queue: Conversation 25
            Bandwidth 20 (%)
            Bandwidth 25 (kbps)Max Threshold 64 (packets)
            (pkts matched/bytes matched) 0/0
        (depth/total drops/no-buffer drops) 0/0/0
        Class-map: SQL (match-all)
          0 packets, 0 bytes
          5 minute offered rate 0 bps, drop rate 0 bps
          Match: protocol sqlserver
          Queueing
            Output Queue: Conversation 26
            Bandwidth 15 (%)
            Bandwidth 19 (kbps)Max Threshold 64 (packets)
            (pkts matched/bytes matched) 0/0
        (depth/total drops/no-buffer drops) 0/0/0
        Class-map: DNS (match-all)
          0 packets, 0 bytes
          5 minute offered rate 0 bps, drop rate 0 bps
          Match: protocol dns
          Queueing
            Output Queue: Conversation 27
            Bandwidth 25 (%)
            Bandwidth 32 (kbps)Max Threshold 64 (packets)
            (pkts matched/bytes matched) 0/0
        (depth/total drops/no-buffer drops) 0/0/0
        Class-map: class-default (match-any)
          0 packets, 0 bytes
          5 minute offered rate 0 bps, drop rate 0 bps
          Match: any
    Class-map: class-default (match-any)
      7 packets, 362 bytes
      5 minute offered rate 0 bps, drop rate 0 bps
      Match: any

R5
---

Ok on r5 we will police to 128


r5(config)#do sh run | begin policy-map
policy-map POLICE
 class class-default
  police cir 128000
    conform-action transmit
    exceed-action transmit
    violate-action drop
!

so we are policing to 128 if we conform to the bc we will transmit
if we exceed and use be we will also transmit
if we go over that we will drop

r5(config)#int s0/1/0
r5(config-if)#service-policy input POLICE
r5(config-if)#

No comments:

Post a Comment