IPv4 Packet Header: Format and Structure
When you think about it, the IPv4 packet format is truly fascinating. Learn about the elements at play with this comprehensive guide.
At any given moment, computing devices within a worldwide network called the internet send countless messages to one another. Those messages are split into multiple Internet Protocol (IP) packets – the smallest units of data. The Internet Protocol version 4 packet header – simply put, the IPv4 packet header – is fundamentally important in the delivery process as it contains the source address and destination address. Without the latter, the digital message would stay immobile.
Let’s gain a deeper understanding of the topic, starting from the very basis – the IP address.
IPv4 address – a unique identifier that connects the world
Every device connected to the internet needs an identifier – a locally or globally unique address – to communicate with one another. The Internet Protocol is responsible for identifying devices connected to the web. The main functions of the IP are routing and addressing as it forwards packets from and to computing devices on the network.
Even though the first version of the IP was created around the 1970s, the Internet Protocol version 4 (IPv4), introduced in 1981, was the one that became publicly used.
IPv4 is a 32-bit long address expressed individually in decimal and separated by dots in four octets. It is the most commonly used IP version in the world, with a fully developed and optimized infrastructure. In total, there are 4.29 billion available combinations of IPv4, and this number was officially depleted in 2011, which led to the IPv4 address pool exhaustion.
Due to the shortage of IPv4 resources, Internet Protocol version 6 (IPv6) was introduced as a replacement. IPv6 uses 128 bits for the IP address and offers nearly infinite alphanumeric combinations to identify them. However, ever since its introduction, IPv6 adoption has been slow. Therefore, these two IP versions coexist, and IPv4 remains the dominant one for identifying devices.
The role of the IPv4 packet header
When computers transmit information from one device to another, they split the messages into basic communication units, called packets or datagrams. Then, routers forward these packets along the IP network until they reach the destination where they are reassembled again.
Every IPv4 packet has the maximum value of 65,535 bytes and consists of a header and data. The IP header length can vary: From the minimum length of 20 to a total length of 60 bytes. It includes the source address and destination address, as well as other fields that help route the packet. The data is the actual message (information) of variable length.
In other words, the IPv4 header is like a written form of an address on an envelope, whereas the essential data is the letter, placed inside. Let us look at what should be written on this letter so that it would efficiently reach the recipient.
IPv4 packet header format
An IP packet envelopes the data unit received from the network layer and adds it to its header. All the information the header contains helps the datagram to reach its destination.
The IPv4 packet header contains a fixed mandatory part, which is made of 13 fields. Let’s take a closer look at the IPv4 header format, the header fields and the roles each of them has.
- Version: The first 4-bit header field informs about the current IP version in use, which, in this case, is IPv4
- Internet Header Length (IHL): The IHL has four bits that specify the number of 32-bit words in the header – the minimum header length is 20 data bytes and the minimum value of this field is five
- Service Type: This field provides the queuing of the IP packets in their transmission
- Total Length: This is the total size of the header and data in bytes, where the minimum size of the Total Lenght field is 20 bytes and the maximum size is 65,535 bytes
- Identification: If the IP datagram is fragmented (broken into smaller pieces), the ID field helps identify fragments and determine to which IP packet they belong to
- IP Flags: This is a 3-bit field that uses a few possible configuration combinations of control flags for fragmentation:
- Bit 0 is reserved and always set to 0
- Bit 1 represents the Don’t Fragment (DF) flag, which indicates that this packet should not be fragmented
- Bit 2 represents the More Fragments (MF) flag, which is set on all fragmented packets except the last one
- Fragmentation Offset (Fragment Offset): The Fragment Offset field takes up 13 bits, and it performs packet tracing by representing the data bytes ahead; i.e., it determines where in the original packet the particular fragment belongs
- Time to Live (TTL): TTL limits the datagram’s lifetime to prevent packets from an endless loop in the internet system by causing undeliverable datagrams to be discarded automatically
- Protocol: This 8-bit field defines which protocol is used in the data portion of the packet
- Header Checksum: If there are any communication errors in the header, the Header Checksum field detects them
- Source IP Address: The 32-bit IPv4 address of the sender of the packet
- Destination IP Address: The 32-bit IPv4 address of the receiver of the packet
- Options: This optional feature is used when the value in the Internet Header Length is greater than five, hence the header length field increases (it may contain Time Stamp, Record Route or another optional field)
There’s a limit to how large a message can be, as well as the amount of data transmitted at once. Until the first IP packet is received, computers cannot send another message. The Explicit Congestion Notification (ECN) IP extension informs if there’s congestion seen in the route.
If a packet exceeds the size of 1,500 bytes, it is divided. IP fragmentation is the process of taking a single IP datagram and splitting it up into several smaller pieces (fragments). The fragmented packet of up to 567 bytes is reassembled by the receiving host, whereas the larger ones are silently discarded. The division is made by the TCP/IP network.
Data transmission in the computing network is a crucial element that enables the exchange of information. IPv4 is the most widely used version of the Internet Protocol on the internet, and it is responsible for the rules of data transmission between the computing machines.
Each IPv4 address includes an IPv4 header, which has a central role in IP addressing. A detailed description of the IP header fields above reveals how the header is constructed and what lies underneath every tiny bit (and byte) so that digital messages can reach the destination host quickly and efficiently.
About the author