Everyone from your users to your suppliers are telling you that you must have a Quality of Service enabled infrastructure so that you can run converged applications. Whether you need them or not and how you use them are subjects we’ll cover in later articles, but first there’s a lot of terminology and detail to be understood so that you can appreciate the nuts and bolts of QoS mechanisms.

Layer 2 QoS--COS
QoS can be applied at various points of your network, and what it does depends on the capabilities of your network devices. When we talk about QoS at Layer 2, we’re referring to the setting of the Class of Service (COS) bits in an Ethernet frame header.

Within the 802.1Q (VLAN) tag in Ethernet frame, as well as the VLAN tagging information, there are also three bits which are used to carry priority information. This field, known as 802.1p, allows data to be prioritised within Ethernet switches, prior to them being dealt with at an IP level, and this value can be used to associate different types of traffic with different queuing strategies in your LAN. With three bits, eight different priority values can be set. The queuing mechanisms will be covered in another article.

Layer 3 QoS—TOS, IP Precedence and DSCP
At layer 3, the IP layer, you have more options for marking traffic, although they are all based on the same eight bits—the Type of Service (TOS) byte within the IP header. Of this, the three most significant bits are what was historically used to give priority values for IP packets, being known as the IP Precedence value. Like Ethernet COS values, eight possible permutations can be created out of the three bits, giving eight levels of precedence, zero to seven. These are termed, in order of increasing priority: routine, priority, immediate, flash, flash override, critical, internetwork control, and network control. The two control values, six and seven, are reserved for network routing type information, so in effect you have six levels of prioritisation.

It was decided that this was not sufficiently flexible—or complex—to provide enough differentiation between traffic types, hence the adoption of an enhanced marking scheme, known as DSCP.

Differentiated Services Code Point refers to the six most significant bits of the IP TOS field (the last two in the byte being reserved for flow control and currently unused). This now gives 64 possible priority levels that can be assigned to IP packets.

While nobody in their right mind would try to use all 64 options, DSCP, or DiffServ, does give much greater flexibility. But there are a couple of things to watch out for, that, if you don’t get it straight in your head, will cause you all sorts of strange network behaviour if you get your values mixed up.

IP Prec values can be mapped straight to DSCP values, since all that happens is that the three LSBs of the DSCP number are left as zeros. Mapping the other way round, though, does leave room for error.

IP Precedence DSCP 0 0 1 8 2 16 3 24 4 32 5 40 6 48 7 56

DSCP IP Precedence 0-7 0 8-15 1 16-23 2 24-31 3 32-39 4 40-47 5 48-55 6 56-63 7

In addition, there are different types of DSCPs. The ones that map closest to IP Prec, that have their lowest triplet equal to zeros, are called Class Selector DSCP values. However there are specific types, known as Assured Forwarding (AF) and Expedited Forwarding (EF) DSCPs, and it’s these that people often use, particularly in the world of configuring QoS for voice.

Now, pay attention, because this is where it gets complicated.

There are four AF service levels, called AF1x, AF2x, AF3x, AF4x. Each service level has three possible drop ratios—think of the first digit as being the priority of the traffic, and the second indicating, within that priority queue, the relative times at which packets may be dropped.

So taking AF4x, you actually have AF41, AF42 and AF43. These DO NOT equal DSCP 41, 42 and 43. You have to go back to basics and start thinking in binary again here:

AF Binary Class Selector DSCP 31 011 01 0 26 (0+16+8+0+2+0) 32 011 10 0 28 (0+16+8+4+0+0) 33 011 11 0 30 (0+16+8+4+2+0)

You’ll see that the LSB in binary is always zero when translated from AF value, as its not used. This throws the calculation out a bit, as it is counted when calculating the DSCP value.

So to go from AF to DSCP, you need to separate the AF value into its two binary numbers, express both in binary, then shove the string together to turn back into a binary DSCP number.

Setting an IP packet with an EF value in effect means giving it the binary value 101 110. This would be truncated to IP Prec 5, or DSCP Class Selector value 46 (32+0+8+4+2+0).

You will find that people that don’t really understand this will talk about DSCP 32, for instance, when they actually mean AF32, which is DSCP 28, not 32! Hence the confusion, and need to write all this down until you get used to it. If you have to configure DSCP values, be sure you know whether it’s the Class Selector values your network equipment deals in, or AF and EF numbers.

The good news is that at least when you come to IP precedence zero, there is no confusion. There is no AF equivalent, so whether its IP Prec or DSCP, a zero means a zero.