# QoS - Assured Forwarding PHB values

When implementing QoS, traffic can be classified using the values of the DS field of the IPv4 packet. Assured Forwarding Per Hop Behavior (PHB) is used to define specific classes and drop probabilities based on those values. The following table indicates these AF markings:

#DropClass 1Class 2Class 3Class 4
1Low001010 (AF11)010010 (AF21)011010 (AF32)100010 (AF41)
2Medium001100 (AF12)010100 (AF22)011100 (AF32)100100 (AF42)
3High001110 (AF13)010110 (AF23)011110 (AF33)100110 (AF43)

Notice also that we've added row numbers on the left for Low, Medium, and High drop probability.

How are the AFXY labels determined? Let's take AF31 as an example. AF31 is equal to 011 010 in the DS field. However, the value of 31 in the name AF31 does not come from the value of the bits, but from the class and drop probability, where X is the class and Y is the drop probability.

Some examples:

• AF11 is in class 1 and row 1 (low), therefore, it is AF11
• AF12 is in class 1 and row 2 (medium), therefore, it is AF12
• AF31 is in class 3 and row 1 (low), therefore, it is AF31
• AF23 is in class 2 and row 3 (high), therefore, it is AF23

Let's take a deeper look.

Take a look at the structure of the DS field and the subfields it contains: Now notice the following:

Classes range from 1 to 4 with the following possible values of the class bits:

• Class 1: 001 (1 in decimal)
• Class 2: 010 (2 in decimal)
• Class 3: 011 (3 in decimal)
• Class 4: 100 (4 in decimal)

Drop probability ranges from 1 to 3 with the three drop probability bits having these possible values:

• Low: 010 (2 in decimal)
• Medium: 100 (4 in decimal)
• High: 110 (6 in decimal)

Now when the AF notation is used, we have AFXY, where X is the class and Y is the drop probability. However, the value used for X and Y is not intuitive. The values for X range from 1 to 4 which are the decimal values of the three-bit class field. However, the values for Y range from 1 to 3, where we use 1 for Low, 2 for Medium, and 3 for High. But these values are not the actual decimal values represented by the bits which we see to be 2, 4, and 6.

For this reason, we can use the 8x + 2y formula to determine the decimal value of each AF combination.

The 8x + 2y formula works because the “y” value is not the value in decimal, but the value that corresponds to Low, Medium, and High in the AF notation. That’s why we need the “2” there. The final bit is always 0 as you can see from the table in the lesson. And we have the number 8 there because the Class portion of the DS field begins at the bit representing the number 8.