# QoS for IPv6

QoS for IPv6 works almost identically to IPv4. The IPv6 header has a Traffic Class field which is identical to the IPv4 DiffServ Field.



Below, the DSCP value in the IPv6 packet has been set to **EF**. The IPv6 Traffic Class field is 8 bits in length. The first six bits are used for the DSCP value, and the last two bits are used for ECN.

<figure><img src="https://1203572585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgAMH3CMtmYTBkob03NUj%2Fuploads%2F79giXwiPsrFTQDF22Irs%2FUntitled.png?alt=media&#x26;token=e0f77ea1-168a-4374-a829-0d620cbc8517" alt=""><figcaption></figcaption></figure>



This is identical to the IPv4 Differentiated Services Field, shown below for reference:

<figure><img src="https://1203572585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgAMH3CMtmYTBkob03NUj%2Fuploads%2FUbb520YvTi2nB84hU2Rj%2FUntitled%201.png?alt=media&#x26;token=405592ce-1b28-4e77-a698-1975b36ddb42" alt=""><figcaption></figcaption></figure>



### MPLS EXP Mapping <a href="#e2967751-d7f8-45e0-9b41-0a08d237aff2" id="e2967751-d7f8-45e0-9b41-0a08d237aff2"></a>

Just like IPv4 traffic, when an MPLS label stack is imposed on an IPv6 packet, the IPP (first three bits of the DSCP value) are mapped to the EXP value by default. You can think of the MPLS EXP interaction with IPv6 as identical to how IPv4 works.

#### &#x20;<a href="#caec9bbe-ad19-486c-94e9-aa4b92156a94" id="caec9bbe-ad19-486c-94e9-aa4b92156a94"></a>

### Matching/Marking IPv6 Traffic Class <a href="#caec9bbe-ad19-486c-94e9-aa4b92156a94" id="caec9bbe-ad19-486c-94e9-aa4b92156a94"></a>

The classification and marking commands for IPv6 are the exact same as the commands you use for IPv4.



The classification command for matching IPP or DSCP works for _both_ IPv4 and IPv6 traffic.

```
R1(config)#class-map example
R1(config-cmap)#match ?
  <snip>
  dscp                 Match DSCP in IPv4 and IPv6 packets
  <snip>
  precedence           Match Precedence in IPv4 and IPv6 packets
```



Likewise, marking the IPP or DSCP value of an IPv6 packet uses the same command as for IPv4 packets.

```
R1(config)#policy-map example
R1(config-pmap)#class class-default
R1(config-pmap-c)#set ?
  dscp           Set DSCP in IP(v4) and IPv6 packets
  precedence     Set precedence in IP(v4) and IPv6 packets
```



### IPv6 Flow Label <a href="#b57e0508-cb77-4873-a41b-73bef5b9e2a5" id="b57e0508-cb77-4873-a41b-73bef5b9e2a5"></a>

The only difference between IPv4 and IPv6, in terms of QoS, is that IPv6 has a flow label field. This is 20 bits and is placed directly after the Traffic Class field.

<figure><img src="https://1203572585-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgAMH3CMtmYTBkob03NUj%2Fuploads%2F4xbRvaAkQF4T5qKR0QbM%2FUntitled%202.png?alt=media&#x26;token=453a57b3-5d3a-44c4-a932-b5fa2285c283" alt=""><figcaption></figcaption></figure>



As far as I can tell, this is not intended to be used for QoS these days. Therefore it is a little strange that this field is listed on the SPCOR blueprint in section 1.4.e under _Describe QoS Architecture_.



Originally, this field does appear to have been intended for QoS. RFC2460, publicished in 1998, says this about the Flow label:

```
   The 20-bit Flow Label field in the IPv6 header may be used by a
   source to label sequences of packets for which it requests special
   handling by the IPv6 routers, such as non-default quality of service
   or "real-time" service.  This aspect of IPv6 is, at the time of
   writing, still experimental and subject to change as the requirements
   for flow support in the Internet become clearer.
```



However, the flow label was never really implemented for QoS. We have more than enough DSCP values to use for traffic that requires special QoS treatment.



RFC6437, published in 2011, is specifically about the IPv6 Flow Label. In this RFC, the purpose of the Flow label is defined as the following:

```
   The usage of the Flow Label field enables efficient IPv6 flow
   classification based only on IPv6 main header fields in fixed
   positions.
```



This makes much more sense. A flow label can simply identify a flow, instead of a router needing to match flows based on identical layer 3 and layer 4 information. The router can more efficiently hash flows for ECMP by only reading the flow label. In fact, RFC6437 makes no mention of QoS at all!



Additionally, the flow label cannot be matched or marked using the MQC on IOS. So it is pretty clear that the flow label is _not_ a QoS mechanism, and instead it is used as an ECMP mechanism to ease the burden of flow classification on routers.



### Further Reading <a href="#id-0249e5b2-8b53-4f11-8c9c-7182cb151d72" id="id-0249e5b2-8b53-4f11-8c9c-7182cb151d72"></a>

[https://www.rfc-editor.org/rfc/rfc6437](https://www.rfc-editor.org/rfc/rfc6437)

\
[https://ccie-or-null.net/tag/ipv6-flow-label/](https://ccie-or-null.net/tag/ipv6-flow-label/)

\
[https://www.youtube.com/watch?v=b0CRjOpnT7w\&ab\_channel=NANOG](https://www.youtube.com/watch?v=b0CRjOpnT7w\&ab_channel=NANOG)
