The Structure of the IPv6 Packet and its Extension Headers.
The IPv6 Packet is made of three part :
. A fixed mandatory header
. Optional extensions headers
. A payload ( TCP, UDP, ICMP, ... )
The extension headers are optional. They should only appear once, except for the Destination Options header, which may appear twice.
The fixed and extensions headers each hold a Next Header field, that identifies the next header by its IP protocol number ( ICMP=1, ICMPv6=58, TCP=6, UDP=17, GRE=47 ... ). Thus they are linked together, from the fixed header to the optional headers to the payload. Here are the IPv6 Extension Headers, in the recommended order :
Here are some examples of Extension Headers chaining :
Please note that the Hop-by-Hop Extension header MUST be placed first. This is because Intermediate nodes don't have to examine headers, except Hop-by-Hop Extension header. So the Routers just have to check the first Extension header. This is to improve Routers performance.
Here are some Fixed and Extension Headers with details :
Do note that the Fixed header's Payload length field = Extension headers length + upper layer length
One thing to note :
. Header Ext Length is the Extension Length minus 8 octets
The IPv6 Packet metrics
The Fixed header is 40 octets in size, and each Extension header is a multiple of 8 octets.
Thus, the IPv6 packet size is ( in octets ) : 40 + n1*8 + n2*8 + .... + p
Routers can't perform fragmentation over IPv6 packets they forward, they return a ICMPv6 packet too big error message. Hosts are supposed to discover the network path MTU through the use of Path MTU Discovery. All links on the network are supposed to be capable to forward IPv6 packets of at least 1280 octets without fragmentation.
If the Host's software upper-layer-protocol doesn't perform Path MTU Discovery, the IP layer can use the IPv6 Fragment Extension header and perform fragmentation by itself.
Finally, let's re-check the Fixed header payload length :
The Mobile IPv6 Header
The Mobile IPv6 header is like an IPv6 Extensions headers, placed after an IPv6 Fixed header. There are a few differences :
Payload Protocol is the same as the Next Header field.
Header Length is the same as Ext Header Length ( ie length minus 8 octets )
The Mobile IPv6 header is still a multiple of 8 octets in size.