Welcome to the fifth article in the IPv6 series. In past articles, we have looked at IPv6 address types, the IPv6 scoped address architecture and, most recently, interface identifiers for unicast addresses. In this article, we will consider the structure of an IPv6 packet and also look at the IPv6 header and how it compares to the IPv4 header.
IPv4 and IPv6 Packet Structures
From our IPv4 knowledge, we are familiar with the concept of encapsulation, in which each lower-level OSI layer takes the data passed down from higher layers of the OSI model and encapsulates it in its own format, including a header (and sometimes a footer). At the IP (network) layer, we call this message an IP packet or IP datagram. The general format of an IPv4 packet is as shown below:
Image may be NSFW.
Clik here to view.
The IP header is added at the IP layer and contains information such as the source and destination IP address, while the payload contains the upper-layer protocol data unit (i.e., the upper-layer header + upper-layer payload). Stemming from this format, the IPv6 packet is also similar except that the Payload portion is made up of upper-layer protocol data and IPv6 extension headers if available.
Image may be NSFW.
Clik here to view.
We will talk about IPv6 extension headers in a later section of this article, but keep in mind that an IPv6 packet may not contain an IPv6 extension header, effectively making the structure of that IPv6 packet similar to that of an IPv4 packet.
IPv4 and IPv6 Headers
As usual, let us begin with what we are familiar with. According to the RFC on IPv4, the IPv4 header is shown below:
Image may be NSFW.
Clik here to view.
Let’s briefly highlight what each field is about, because it will help in our understanding of the IPv6 header:
-
Version—Identifies the format of the header. For IPv4, this value will be 4. As we will see, the value will be 6 for IPv6.
-
IHL—This stands for Internet header length. Remember that, because of IP options, the IPv4 header does not have a fixed length. The minimum length is 20 bytes and the maximum length is 60 bytes.
-
Type of Service—This has been renamed the differentiated services field and it finds its use in quality of service (QoS).
-
Total Length—Entire length of the IPv4 packet, i.e., the header plus payload.
-
Identification—Helps in reassembly of fragmented packets.
-
Flags—Conveys information about fragmentation.
-
Fragment Offset—Indicates the position of a fragment in the payload.
-
Time to Live (TTL)—Specifies the maximum lifetime of a packet as it traverses links.
-
Protocol—Indicates the upper-layer protocol, e.g., TCP (6), ICMP (1).
-
Header Checksum—Ensures integrity of the IPv4 header. The payload is not included in the checksum calculation.
-
Source Address—Address of sending host.
-
Destination Address—Address of recipient.
-
Options—Variable length field that carries IPv4 options information, such as loose source routing.
-
Padding—Used to ensure that the header is a multiple of 32 bits.
Let’s look at an example packet (telnet session) captured through Wireshark.
Image may be NSFW.
Clik here to view.
The first thing you will notice is the concept of encapsulation that I mentioned above, i.e., the TCP segment is encapsulated in the IP packet, which is encapsulated in an Ethernet frame, and so on. Then, if we look at the IPv4 portion, we will see all the fields we discussed above, although there are no options (or padding) specified in this packet.
We can now move on to the IPv6 header. As I mentioned in the introductory article, the IPv6 header is much simpler than the IPv4 header even though it is twice the (minimum) size of an IPv4 header. According to RFC 2460, the main IPv6 header format is as shown below:
Image may be NSFW.
Clik here to view.
Let’s also highlight the fields in the IPv6 header as we did for IPv4:
-
Version—The same as in IPv4 except that it has a value of 6.
-
Traffic Class—Similar functionality as the differentiated services (ToS) field.
-
Flow Label—New to IPv6, this allows the source to identify that a packet belongs to a sequence of packets (i.e., flow) that require special handling by the router
-
Payload Length—This is similar to the Total Length field in the IPv4 header except that it specifies only the length of the payload, i.e., the IPv6 extension headers (if any) + upper-layer PDU.
-
Next Header—Uses the same values as the Protocol field in the IPv4 header. It identifies the type of header after the IPv6 header, i.e., an IPv6 extension header or an upper-layer protocol (e.g., TCP, UDP).
-
Hop Limit—Similar to the TTL field in the IPv4 header. The TTL field initially related to time in theory but, as we know, practical implementations used TTL as hop counts. This is why the field was renamed in IPv6.
-
Source Address—128-bit IPv6 address of the sender.
-
Destination Address—128-bit IPv6 address (unicast, anycast, or multicast) of the destination.
Let’s now try to compare the IPv4 and IPv6 headers.
-
Looking at the IPv6 header, the first thing you notice is that there are only 8 fields compared to the 14 fields in the IPv4 header; thus it is simpler.
-
There is no header length field in the IPv6 header because it has a fixed value of 40 bytes.
-
All fragmentation fields in the IPv4 header have been removed completely from the IPv6 header. They have been moved to an IPv6 extension header.
-
The header checksum field has also been removed from the IPv6 header.
-
As highlighted above, there is a new field in IPv6: Flow Label.
-
Finally, all options have been moved away from the main IPv6 header to IPv6 extension headers.
IPv6 Extension Headers
All through this article, I have mentioned the IPv6 Extension headers, so let’s talk about them now. In IPv4, if options are present in the IP header, all intermediate routers must also process them, thereby slowing down packet forwarding. In IPv6, all options have been moved to the IPv6 extension headers and intermediate routers do not need to process these headers (with the exception of the hop-by-hop options header). This speeds up the IPv6 header processing and also the packet forwarding.
There are six IPv6 extension headers that must be supported by all implementations as defined by RFC 2460:
-
Hop-by-hop options header
-
Routing (Type 0) header
-
Fragment header
-
Destination options header
-
Authentication header
-
Encapsulating security payload header
Hint: We are already familiar with the authentication header (AH) and encapsulating security payload Header (ESP) from IPsec.
An IPv6 packet may or may not include any of these IPv6 Extension headers the same way an IPv4 packet may or may not have options specified in the IPv4 header.
Image may be NSFW.
Clik here to view.
We can also look at a Wireshark capture of a ping (ICMPv6) between two IPv6 hosts and see the fields in the IPv6 header.
Image may be NSFW.
Clik here to view.
Notice that the Next Header field in the IPv6 packet shown above contains the value “58,” which is the protocol number of ICMPv6. The table below shows common values (in decimal) that can be found in the Next Header field of an IPv6 header.
Image may be NSFW.
Clik here to view.
You can find a list of all the protocol numbers here. Also, you can find a list of the values for the IPv6 extension header types here.
Let us end this article with an example of the Next Header field values.
Image may be NSFW.
Clik here to view.
Using the Next header value table above, we can fill in the values for what the next header field will be in this diagram:
Image may be NSFW.
Clik here to view.
Below is a real capture of a fragmented ping between two hosts. Notice the IPv6 Fragment Headerand also Next Header values as discussed above.
Image may be NSFW.
Clik here to view.
Summary
In this article, we have looked at the packet and header structures for IPv6. We saw that IPv6 headers have a fixed length of 40 bytes and options from IPv4 have been moved to extension headers in IPv6.
In the next article, we will discuss ICMPv6, which plays a very important role in IPv6. I hope you have found this article insightful.
References and Further Reading
-
RFC 2460: Internet Protocol, Version 6 (IPv6) Specification: http://www.ietf.org/rfc/rfc2460.txt
-
RFC 791: Internet Protocol: http://www.ietf.org/rfc/rfc791.txt
-
Introduction to IPv6: http://technet.microsoft.com/library/bb726944.aspx
-
IPv6 for IPv4 Experts: https://sites.google.com/site/yartikhiy/home/ipv6book
-
Protocol Numbers: http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
-
Internet Protocol Version 6 (IPv6) Parameters: http://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml
Source: http://resources.intenseschool.com/ipv6-packet-header-and-structure/
Filed under: IPv6 Image may be NSFW.
Clik here to view.
Clik here to view.
