Search This Blog

Showing posts with label DSCP. Show all posts
Showing posts with label DSCP. Show all posts

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


Friday, November 29, 2013

How to convert TOS / AF / DSCP / IP Precedence




How to convert AF to DSCP

Explanation:

Take the first (AF) number and multiply it by 8, take the second (AF) number and multiply it by 2, add both results.

Formula: 

(8*x) + (2*y)

Example:

AF31 = (8*3) + (2*1) = 26 = DSCP 26

How to convert TOS to DSCP/IP Precedence

Explanation:

TOS stands for Type of Service and it’s an 8 bit filed in the IP header, IP Precedence uses only the 3 leftmost bits while DSCP uses the 6 leftmost bits.
 
 
(Taken from http://bogpeople.com/networking/dscp.shtml)

In order to convert TOS to DSCP/IP Precedence all we have to do is translate from binary to decimal.

Example:

TOS 160 = for having TOS 160 we need to put “1” (binary 0 or 1) on the 7th and 5th bits which will result in 128 (2^7) and 32 (2^5) = 160
Now because IP Precedence uses only the 3 leftmost bits (7, 6 and 5) and only the 1st (5) and the 3rd (7) bits are “1” the result will be 5.
The same manner for DSCP but this time with 6 bits calculation, where only the 6th and the 4th bits are “1” the result will be 40

Another example:

TOS 96 = the 6th and 5th bits are “1”

IP Precedence = because in TOS the 6th and 5th bits are “1” in IP Precedence its 1st and 2nd bits which result in (2^2) + (2^1) = 2 + 1 = 3

DSCP = because in TOS the 6th and 5th bits are “1” in DSCP its 4th and 5th bits which result in (2^5) + (2^4) = 16 + 8 = 24

Monday, June 25, 2012

How to mark DSCP on Check Point R7x

    The following post will show how to mark IP packets with DSCP, in Check Point R7x platform (in my case SPLAT R75.4). DSCP marking will allow us to use PHB QoS and to apply congestion avoidance.

 
      1.       Create Class of service under Manage (A) ->QoS (B) ->QoS Classes (C)
 

      2.       On the opened window press New… and choose DiffServ Class of Service

      3.       Type in a desired name for the class of service, enter comment and choose color then select the type of the service

      4.       Click on Close to close the window

      5.       Click the QoS tab (A) then right click on Default (B) and choose Add Class of Service->Above (C)

      6.       Choose the Class of Service we have just created at step 3

      7.       Right click on the new Class of Service (A) and choose Add Rule Below (B)

      8.       Give the rule a name

      9.       Create rules like and other firewall rules

      10.  Install the policy