Re: Convert IP Precedence to TOS byte

From: Ruhann <groupstudy_at_ru.co.za>
Date: Thu, 2 Apr 2009 18:16:40 +0200

The TOS-Byte/DS-field in the IP header is 8-bits long.

IPP is the first 3 bit (0-2) in the TOS-Byte, the other 5 bits are not
really used today.
3 binary values give 8 possible values, 2^n

0 1 2 3 4 5 6 7
|_____|
  IPP

So the calculation is easy. 4 in binary is 100,
You need the get the decimal value for the TOS-byte (8 bits),
 IPP4 is represented in the 3 bits as 100, and followed by 5 zero's since
those bits are not used.
  Thus would give you a TOS-BYTE = 10000000 in decimal is 128

But that is really old terminology.
The DS-field has taken on a new structure, to try and use more of the wasted
bits in the TOS-Byte and give us more to play with.

0 1 2 3 4 5 6 7
|_____:_____|

The DS-Field contains 6 DSCP and 2 ECN bits.
The DSCP field was designed to be backwards compatible with the IP
Precedence,
 - The 1st three bits of the DSCP field carry the same value as the IPP in
the TOS-BYTE Format.
  - In DSCP terminology this is just called the Class-Selector , ie CS0 -
CS7 = IPP0 - IPP7
 - The 2nd three bits are the Drop-Probability bits, the higher the value
the more likely to be drop with the class

You can really read alot more about the AF values and the diffserv model,
but long story short,
if you have CS4 (IPP4) what would the TOS-Byte decimal value be? same as
above, 100 with five zero's = 128. Obviously :)

But what if you have AF22 (DSCP decimal 20), what would the TOS-Byte decimal
value be then?
Well, the 20 is a decimal value that maps the 6 bit DSCP field, that is in
binary 010100
and you need the 8-bit TOS-Byte value, so knowing the field structure you
add two zero at the end (the ECN field)

01010000 = the full 8 bits of the TOS-Byte,
Convert that to decimal and ta-da you have a TOS-Byte value of 80 that you
can use in your pings.

HTH

On Sat, Mar 28, 2009 at 11:18 AM, Sergei Udovenko <udovenko_at_gmail.com>wrote:

> Hello!
> Working on some tasks I need to make telnet session with different IP
> Precedence values. How do I convert let's say IPP4 to TOS byte in extended
> ping command.
>
> Thanks!
> --------------------
> Best regards,
> Sergei
>
>
> Blogs and organic groups at http://www.ccie.net
>
> _______________________________________________________________________
> Subscription information may be found at:
> http://www.groupstudy.com/list/CCIELab.html
>
>
>
>
>
>
>
>

-- 
<ruhann>
Blogs and organic groups at http://www.ccie.net
Received on Thu Apr 02 2009 - 18:16:40 ART

This archive was generated by hypermail 2.2.0 : Mon May 04 2009 - 07:39:11 ART