Traffic shaping the 2 Methods.

Traffic shaping allows you to control outgoing traffic on an interface to match the speed of transmission to the speed of the remote interface, and to ensure that the traffic conforms to administrative QoS policies. You can shape traffic adhering to a particular profile to meet downstream requirements, thereby eliminating bottlenecks due to data-rate mismatches.

ok so we have the following stream going

R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 779000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 651000 bps

We can tell from here that R3 is sending 760.742188 Kbps of ICMP Traffic out to R4 Now let’s test the 2 different Traffic Shaping Methods, using class based shaping

1st method

R2#conf ter
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#access-list 106 permit icmp any any
R2(config)# class-map match-all ICMP
R2(config-cmap)#  match access-group 106
R2(config-cmap)#exit
R2(config)#policy-map ICMP
R2(config-pmap)#class ICMP
R2(config-pmap-c)#exit
R2(config-pmap)#int s0/1
R2(config-if)#service-po out ICMP
R2(config-if)#do show policy-map int s0/0 | in Class|rate
    Class-map: ICMP (match-all)
      30 second offered rate 35000 bps
    Class-map: class-default (match-any)
      30 second offered rate 90000 bps, drop rate 0 bps

If we wait for a period of time until the counters are refreshed

R2(config-if)#do show policy-map int s0/0 | in Class|rate
    Class-map: ICMP (match-all)
      30 second offered rate 125000 bps
    Class-map: class-default (match-any)
      30 second offered rate 1000 bps, drop rate 0 bp

Now lets test the shaping to the configured average rate, with this shaping method the average rate forwards up to a committed Burst (BC) traffic at every committed time window (TC) interval, with additional bursting capability when enough tokens are accumulated in the bucket

in other words, BC of tokens are added to the token  bucket at every TC time interval.

the configuration for Shaping Average is ..

R2(config-pmap-c)#shape average ?
    Target Bit Rate (bits per second), the value needs to be
                    multiple of 8000
  percent           % of interface bandwidth for Committed information rate

back to the router.

R2(config-if)# policy-map ICMP
R2(config-pmap)#  class ICMP
R2(config-pmap-c)#shape average 8000
R2(config)#do show policy-map int s0/1
 Serial0/1 

  Service-policy output: ICMP

    Class-map: ICMP (match-all)
      684 packets, 960336 bytes
      30 second offered rate 35000 bps, drop rate 30000 bps
      Match: access-group 106
      Traffic Shaping
           Target/Average   Byte   Sustain   Excess    Interval  Increment
             Rate           Limit  bits/int  bits/int  (ms)      (bytes)
             8000/8000      2000   8000      8000      1000      1000     

        Adapt  Queue     Packets   Bytes     Packets   Bytes     Shaping
        Active Depth                         Delayed   Delayed   Active
        -      10        9         12636     7         9828      yes

    Class-map: class-default (match-any)
      1 packets, 84 bytes
      30 second offered rate 0 bps, drop rate 0 bps
      Match: any

After this Configuration was applied to the interface pointing to R3

we get the following @ R3

R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 45000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 21000 bps
R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 36000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 14000 bps
R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 36000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 14000 bps
R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 36000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 14000 bps
R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 30000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 9000 bps
R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 30000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 9000 bps
R3#

we can determine that the traffic is now “Slowing Down”

after the counter had been refresed on R3

@R2

R2(config)#do show policy-map int s0/1
 Serial0/1 

  Service-policy output: ICMP

    Class-map: ICMP (match-all)
      15106 packets, 21208824 bytes
      30 second offered rate 729000 bps, drop rate 75520000 bps
      Match: access-group 106
      Traffic Shaping
           Target/Average   Byte   Sustain   Excess    Interval  Increment
             Rate           Limit  bits/int  bits/int  (ms)      (bytes)
             8000/8000      2000   8000      8000      1000      1000     

        Adapt  Queue     Packets   Bytes     Packets   Bytes     Shaping
        Active Depth                         Delayed   Delayed   Active
        -      64        93        130572    91        127764    yes

    Class-map: class-default (match-any)
      42 packets, 4216 bytes
      30 second offered rate 0 bps, drop rate 0 bps
      Match: any
R2(config)#

@R3

R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 19000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 0 bps

=============================================1=
=                      19.000 bits per second = 18.5546875 Kbps                     =
===============================================

2nd Method.

Now for the second method Shaping to the peak rate, means that BC + BE of traffic at every TC time interval is sent.  BC+ BE tokens are added to the token bucket at every TC time interval.

The formula related to this method is Average Rate * (1 + Be/Bc)

The same test as in the first method but now for the following configuration:

The configuration for Shape to Peak:

R2(config-pmap-c)#shape peak ?
    Target Bit Rate (bits per second), the value needs to be
                    multiple of 8000
  percent           % of interface bandwidth for Committed information rate

back at the router:

R2(config)# policy-map ICMP
R2(config-pmap)#  class ICMP
R2(config-pmap-c)#no   shape average 8000
R2(config-pmap-c)#shape peak 8000
R2(config-pmap-c)#do show policy-map int s0/1
 Serial0/1 

  Service-policy output: ICMP

    Class-map: ICMP (match-all)
      27783 packets, 39007332 bytes
      30 second offered rate 730000 bps, drop rate -2126850296 bps
      Match: access-group 106
      Traffic Shaping
           Target/Average   Byte   Sustain   Excess    Interval  Increment
             Rate           Limit  bits/int  bits/int  (ms)      (bytes)
            16000/8000      2000   8000      8000      1000      2000     

        Adapt  Queue     Packets   Bytes     Packets   Bytes     Shaping
        Active Depth                         Delayed   Delayed   Active
        -      64        12        16848     10        14040     yes

    Class-map: class-default (match-any)
      73 packets, 7237 bytes
      30 second offered rate 0 bps, drop rate 0 bps
      Match: any
R2(config-pmap-c)#

after counters where refreshed on R3 we can see now we have

R3#show policy-map interface s0/0 | in rate|Class
    Class-map: ICMP (match-all)
      30 second offered rate 38000 bps
    Class-map: class-default (match-any)
      30 second offered rate 0 bps, drop rate 8000 bps

=============================================2=
=                    38.000 bits per second = 37.109375 Kbps                          =
===============================================
as expected,  You can do your Math here:  Be= 8000, Bc= 8000, Average Rate= 8000

In summary, class Based shaping can shape to the configured average rate or to the peak rate for packets Peak Rate = Average Rate * (1 + Be/Bc)

A Networker Blog

Advertisements

2 thoughts on “Traffic shaping the 2 Methods.

  1. In the first code snippet. From the output:
    30 second offered rate 779000 bps
    How can you say that ‘R3 is sending 760.742188 Kbps of ICMP Traffic out to R4’ ?
    How did you make that conversion?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s