This knowledge base posted by MiniTool corporation explains the meaning and definition of the IP header for you. It tells you the functions and structure of an IP header. What’s more, this article also lists some common parts of the IPv4 header and IPv6 header.
IP Header Explained
What Is IP Header?
An IP header is header information at the beginning of an Internet Protocol (IP) packet, which is the smallest message entity exchanged via the IP across an IP network. An IP packet structure includes a header for addressing and routing and a payload for user data.
An IP packet has no data checksum or any other footer after the data section. And, IP header consists of info about IP version, source IP address, destination IP address, time-to-live (TTL), and so on.
Typically, the payload of the IP packet is a datagram or segment of the higher-level transport layer protocol. It may also be data for an Internet layer (like ICMP or ICMPv6) or link layer (such as OSPF) instead. Usually, the link-layer encapsulates IP packets n frames with a CRC footer that detects most errors.
Today, there are 2 different versions of IP, IPv4 and IPv6. The IPv6 header makes use of IPv6 addresses so as to provide a much bigger address space. Yet, it is not backward compatible with IPv4.
Internet Protocol Version 4 (IPv4) Header
The IPv4 packet header contains 14 fields with 13 of which are necessary. The 14th field is optional and aptly named: options. The fields in the header are packed with the most significant byte first (big-endian).
For the diagram and discussion, the most significant bits are considered to come first (MSB 0 bit numbering). For example, the most significant bit is numbered 0, so the version field is actually found in the 4 most significant bits of the first byte.
The following are the 14 fields in the IPv4 header:
- Version: The first header field in an IP packet is the 4-bit version field. For IPv4, this is always equal to 4.
- Internet Header Length (IHL): The IPv4 header is variable in size due to the optional 14th The maximum IP header size is 480 bits (60 bytes) while the minimum length is 160 bits (20 bytes).
- Differentiated Services Code Point (DSCP): Originally defined as the type of service (ToS), this field specifies differentiated services (DiffServ) per RFC 2474.
- Explicit Congestion Notification (ECN): It is defined in RFC 3168 and enables end-to-end notification of network congestion without dropping packets.
- Total IP Header Length: The 16-bit field defines the whole packet size in bytes including both header and data section with a maximum size of 65,535 bytes and a minimum size of 20 bytes (header without data).
- Identification: This field identifies the group of a single IP datagram.
- Flags: This is a 3-bit field. It is used to control or identify fragments.
- Fragment Offset: It specifies the offset of a particular fragment relative to the beginning of the original unfragmented IP datagram in units of 8-byte blocks.
- Time To Live (TTL): An eight-bit time to live field prevents datagrams from persisting on the Internet.
- Protocol: This field defines the protocol used in the data portion of the IP datagram.
- IP Header Checksum: This 16-bit header checksum field is applied to error-checking of the IPv4 header.
- Source Address: This field is the IPv4 address of the sender of the packet.
- Destination Address: It is the IPv4 address of the receiver of the packet.
- Options: This field isn’t usually used, but note that the IHL field must include enough extra 32-bit words to hold all the options.
Internet Protocol Version 6 (IPv6) Header
There are two types of headers for IPv6.
Fixed Header
The fixed header starts an IPv6 packet and has a size of 40 octets (320 bits).
- Version (4 bits): The constant 6 (bit sequence 0110).
- Traffic class (6+2 bits): The 6 most significant bits hold the differentiated services (DS) field used to classify packets; The other 2 bits are used for ECN.
- Flow Label (20 bits): It is a high-entropy identifier of a flow of packets between a source and destination.
- Payload Length (16 bits): It defines the size of the payload in octets including any extension headers.
- Next Header (8 bits): This specifies the type of the next header.
- Hop Limit (8 bits): It replaces the TTL field in IPv4.
- Source Address (128 bits): This is the unicast IPv6 address of the sending node.
- Destination Address (128 bits): It is the IPv6 unicast or multicast address of the destination node(s).
Extension Headers
Extension headers carry optional Internet layer info and are placed between the fixed header and the upper-layer protocol header.
Extension headers form a chain relying on the next header fields in the fixed header. The next header indicates the type of the first extension header; the next header field of the last extension header indicates the type of the upper-layer protocol header in the payload of the packet.
All extension headers are a multiple of 8 octets while some require internal padding to meet this requirement. All extension headers are optional and should only appear at most once, except for the destination options header extension that may appear twice.
Below are some extension headers:
- Hop-by-Hop Options: Options that need to be examined by all devices on the path.
- Routing: Methods to specify the route of a datagram (used with Mobile IPv6).
- Fragment: Contains parameters for fragmentation of datagrams.
- Authentication Header (AH): Contains info used to verify the authenticity of most parts of the packet.
- Encapsulating Security Payload (ESP): Carries encrypted data for secure communication.
- Destination Options (before the upper-layer header): Options that need to be examined only by the destination of the packet.
- Mobility (currently without upper-layer header): Parameters used with Mobile IPv6.
- Host Identity Protocol: Used for Host Identity Protocol Version 2 (HIPv2).
- Shim6 Protocol: Used for Shim6.
- Reserved: Used for experimentation and testing.