Search This Blog

Thursday, July 2, 2015

DSCP and IP Precedence conversion

IP Precedence conversion table:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

DSCP conversion table:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

IP Precedence use only the 3 left-most bits, hence we will start calculate only from bit 5 up to bit 7, Were DSCP uses only the 6 left-most bits, so calculation starts from bit 2 up to bit 7.

Example #1: DSCP to decimal

Let’s say we have AF41, first we will need to translate it to decimal using the following formula:

(8 x X) + (2 x Y) - where X is the first number and Y is the second number.

(8 x 4) + (2 x 1) = 32 + 2 = 34

So AF41 equals, in decimal, to 34

Now let’s use the conversion table to convert it to binary:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

We need to use the 7th bit and the 3nd bit to get 34, so in binary it will be:
10001000

Example #2: IP Precedence to decimal

Let’s say we got CS3, since IPPrec is using only 3 bits, CS3 in binary is 011

Now let’s put this value on the IPPrec table:

7
6
5
4
3
2
1
0
2^5
2^4
2^3
2^2
2^1
2^0
x
x
32
16
8
4
2
1
x
x

We got 16 + 8 which equals to 24 in decimal

ToS Conversion

In order to convert any DSCP/IPPrec decimal to ToS value just multiple it in 4.
So AF41 equals to 34, 34 x 4 = 136
CS3 equals to 24, 24 x 4 = 96


No comments:

Post a Comment