
The TCP/IP Guide - Version 3.0 (Contents) ` 501 _ © 2001-2005 Charles M. Kozierok. All Rights Reserved.
IPv6 Datagram Extension Headers
After the mandatory “main” header in an IPv6 datagram, one or more extension headers
may appear before the encapsulated payload. These headers were created in an attempt to
provide both flexibility and efficiency in the creation of IPv6 datagrams. All fields that are
needed only for special purposes are put into extension headers and placed in the
datagram when needed. This allows the size of the main datagram header to be made
small and streamlined, containing only those fields that really must be present all the time.
There is often confusion regarding the role of extension headers, especially compared to
datagram options. The IPv4 datagram had only one header, but it included a provision for
options, and IPv6 also has options, so why bother with extension headers? Good question.
It would have been possible to do everything using options. However, it was deemed a
better design to employ extension headers for certain sets of information that are needed
for common functions such as fragmenting. Options are indeed still supported in IPv6; they
are used to provide even more flexibility by providing variable-length fields that can be used
for any purpose. They are themselves defined using extension headers as we will see
below (and in their own topic, which follows.)
When extension headers are included in an IPv6 datagram, they appear one after the other
following the main header. Each extension header type has its own internal structure of
fields.
IPv6 Header Chaining Using the Next Header Field
The only field common to all extension header types is the Next Header field (which actually
appears at the end of one header type, the ESP header). The 8-bit Next Header field is
used to logically link all the headers in an IPv6 datagram as follows:
☯ The Next Header field in the main header contains a reference number for the first
extension header type.
☯ The Next Header field in the first extension header contains the number of the second
extension header type, if there is a second one. If there's a third, the second header's
Next Header points to it, and so on.
☯ The Next Header field of the last extension header contains the protocol number of the
encapsulated higher-layer protocol. In essence, this field points to the “next header”
within the payload itself.
For example, suppose a datagram that encapsulates TCP has a Hop-By-Hop Options
extension header and a Fragment extension header. Then, the Next Header fields of these
headers would contain the following values:
☯ The main header would have a Next Header value of 0, indicating the Hop-By-Hop
Options header.
☯ The Hop-By-Hop Options header would have a Next Header value of 44 (decimal), the
value for the Fragment extension header.
☯ The Fragment header would have a Next Header value of 6.