# Shaping rate calculation and adjustment on IQ2 PIC for M/T series platforms

The IFL shaping granularity level changes depending on the configured and base rate of the IQ2 PIC. The shaping rate (CIR and PIR values) must be a multiple of the base rate. The base rate for the Level 3 service on the IQ2 is 2000 bytes/sec.

Traffic drop is reported by a customer connected on interface xe-7/3/0.9 (1x10GE (LAN/WAN) IQ2).

Customer has a video stream running at ~1M and then downloads a file (ftp/scp) and traffic reaches 160M+ when downloading (default). The packet loss is happening on the video stream (CLASS_B_OUTPUT) at times when the 100M Ethernet circuit is congested, but the amount of video traffic being sent is well below contracted values.

While we expect to see packet loss during congestion, we also expect that Layer 3 QoS will protect video traffic up to the contracted bandwidth level whether the link is congested or not.

IFL shaper applied on xe-7/3/0.9 is 100M. The following are the scheduler attributes for this IFL:

View the following:

When the shaping rate is configured, the actual rate that is being used would be an adjusted version of it.
We see the following for 100M shaping rate configured:

The adjusted shaping rate/base rate multiplier has to be as follows:

0-256 in multiples of 1
256-1K in multiples of 4
1K -4K in multiples of 16
>4K in multiples of 256

If you configure 100 Mbps, the multiple in terms of 2000 bytes/sec is:

100* 10^6/(8*2000) = 6250

6250 is in the > 4K range so it has to be a multiple of 256 (adj_rate_mult).
We always round to the next higher value, so the multiplier is chosen to be 6400. This will correspond to the configured rate of 100 Mbps.
First, we have to round it up to the multiple of base rate. So, it becomes:

Roundup(100Mbps / 8 / level3_base_rate) = 6250

Since it is in the [255*16,255*256] range, the adj_rate_mult becomes:

[ 6250 + 150 ] / 256 * 256 = 6400