Search This Blog

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

No comments:

Post a Comment