Instead of placing optional fields to the end of datagram header IPv6 designers chose a different approach - extension headers. They are added only if needed, i.e. if it is necessary to fragment the datagram the fragmentation header is put into it.
Extension headers are appended after the basic datagram header. Their number may vary, so some flexible mechanism to identify them is necessary. This mechanism is called header chaining. It is implemented using the Next Header field. The meaning of this field in short is to identify “what follows”.
Actually, the Next Header field has two duties: it determines the following extension header or identifies the upper-layer protocol to which the datagram content should be passed. Because many datagrams are plain - they do not need any extension header at all. In this case the Next Header simulates the Protocol field form IPv4 and contains value identifying the protocol (e.g., TCP or UDP) which ordered the data transport.
If there is an extension header present then the Next Header field determines its type. Every extension header also contains its own Next Header field identifying the following data. Any number of extension headers may be chained in this way - each header simply announces who will be the next header, the last header identifies the upper-layer protocol to which the datagram content belongs.
Table 2-1 Extension Headers

There is one complication hidden in the header chaining mechanism: the processing of complete headers may require a walk through quite a long chain of extension headers which hinders the processing performance. To minimise this, IPv6 specifies a particular order of extension headers. Generally speaking, headers important for all forwarding nodes must be placed first, headers important just for the addressee are located on the end of the chain. The advantage of this sequence is that the processing node may stop header investigation early - as soon as it sees some extension header dedicated to the destination it can be sure that no more important headers follow. This improves the processing performance significantly, because in many cases the investigation of fixed basic header will be sufficient to forward the datagram.
Figure 2-3 illustrates some examples of header chaining. The first datagram is plain IPv6 and TCP, the second one contains a single extension header (Routing) and the chain in third datagram includes two extension headers (Routing and Fragment).
.jpg)
In the rest of this chapter we cover the most important general extension headers - options, routing and fragment. Headers related to particular mechanisms (e.g., mobility header) will be explained in their corresponding chapter.
