Christmas Offer - Every Learner Must Check Out - Flat 88% OFF on All Access Pass
00
days
:
00
hours
:
00
minutes
:
00
seconds
PyNet Labs- Network Automation Specialists

IPv4 Header Format, Diagram, and its Significance

Author : PyNet Labs
Last Modified: July 4, 2024 
Date: December 29, 2023
Blog Featured Image of IPv4 Header format blog with image of a boy working on a laptop and a girl working on a server

Introduction

Internet Protocol version 4, or IPv4, is one of the most widely used protocols for sending or receiving data over different kinds of networks. It is a connectionless protocol and does not guarantee the delivery of data, order, or integrity of the packets. Furthermore, it is used to provide a logical connection between the network devices simply by assigning a unique identification number (IP address) to each device available on the network. In this blog, we will explain the IPv4 header format, which is the information that is used to add data before it is transmitted over the network.

Apart from that, we will be discussing different components of the IPv4 header format that are essential for the routing and delivery of packets. IPv4 and IPv6 are integral part of every network engineers life. The basics of IP Addressing is covered in CCNA Course. If you want to learn more about IPv4 header, you can opt for ENCOR 350-401 Training.

Before getting into more details, let’s first understand the IPv4.

What is IPv4?

IPv4 stands for Internet Protocol version 4 is the addressing system which assigns unique labels to devices on the internet. You can think of IPv4 as the address label on a package you are sending in the mail. Just like the label includes information about the sender, receiver, and nature of the contents, the IPv4 Header also contains information regarding the data that is being sent over the internet.

What is the IPv4 Packet Header?

As we all know, that IPv4 packet is also known as a datagram. It mainly consists of two parts, i.e., a header and a payload. When we talk about the header, it is the meta information that is added to the data by the sender and removed by the receiver. It is a 20-byte structure and has a fixed format that is defined by the IETF in RFC 791. Furthermore, it is divided into four sections, i.e., version, IHL (Internet Header Length), TOS (type of services), and total length; and total length; identification, flags, and fragment offset; time to live (TTL), protocol, and header checksum; source address and destination address.

After the header comes the optional part that can be up to 40 bytes long. Options are additional information that can be used for various purposes, such as security, routing, or timestamping. On the other hand, the payload is the actual data that is being transmitted to the receiver.

Below, we have provided an IPv4 header diagram for better understanding.

IPv4 Header Diagram

IPv4 header diagram showing its 12 components with their bytes

IPv4 Header Format Components

In this section, we will explain each component of the IPv4 header format and will also discuss how each component is used. Let’s begin!

Version

The version field is 4-bit, which indicates the version of the Internet protocol that is used in the packet. In this case, it is version 4, i.e., IPv4.

IP VersionDescription
0Reserved
1-3Unassigned
4IP Version 4
5Stream IP Datagram Mode (experimental protocol)
6IP Version 6
7TP/IX
8The “P” internet protocol
9TUBA
10-14Unassigned
15Reserved

IHL

IHL or Internet Header Length is also a 4-bit length that specifies the header’s length in 32-bit words. The minimum header length is 20 bytes, i.e., 5 words, and the maximum header length is 60 bytes, i.e., 15 words. Hence, this field can only have values between 5 and 15.

TOS

TOS or type of service is 8-bit long, which indicates the QoS (Quality of service) that is requested for the packet. Further, it can be used to specify parameters such as priority, delay, throughput, reliability, or cost. TOS has been redefined several times; moreover, different standards use different interpretations of its bits.

Let’s understand what these parameters are –

  • Priority: The precedence subfield specifies the packet’s priority among other packets, along with different QoS requirements.
  • Delay: The delay subfield is to specify whether low delay is preferred or not.
  • Throughput: Same as delay, in the throughput subfield, it specifies whether high throughput is preferred or not.
  • Reliability: It specifies whether high reliability is preferred or not.
TOS Byte showing its 8 bytes where 3 bytes are of precedence and rest 5 are of type of service
Bit 3:0 = normal delay1 = low delay
Bit 4:0 = normal throughput1 = high throughput
Bit 5:0 = normal reliability1 = high reliability
Bit 6-7:Reserved for future use

Below we have shown these parameters along with their possible values in the form of the table.

PrecedenceDelayThroughputReliability
Routine (000)Normal (0)Normal (0)Normal (0)
Priority (001)Low (1)Normal (0)Normal (0)
Immediate (010)Normal (0)High (1)Normal (0)
Flash (011)Low (1)High (1)Normal (0)
Flash Override (100)Normal (0)Normal (0)High (1)
Critical/ECP (101)Low (1)Normal (0)High (1)
Internetwork Control (110)Normal (0)High (1)High (1)
Network Control (111)Low (1)High (1)High (1)

Total Length

The total length field is 16 bits long and specifies the length of the entire packet in bytes. This includes both the header and the payload. The minimum value can vary from 20 bytes, i.e., the minimum header length, to a maximum value of 65535 bytes, i.e., the maximum size of the packet. If the packet is larger than the provided maximum size, the packet will then be fragmented into smaller pieces by the routers or hosts.

Identification

The identification field is 16 bits long and is mainly used to identify packets that belong to a fragment group. When we talk about fragment groups, it consists of all the packets that are fragmented from the original packet. The main work of the identification field is to assist in reassembling the fragments at the destination.

Flags

The flag field is 3 bits long and controls as well as identifies fragments. It has three possible values. These are:

  • Bit 0: Reserved and must be zero.
  • Bit 1: DF or don’t fragment. If set to one, it usually indicates that the packet should not be fragmented by any device. If a device cannot forward the packet without fragmenting it, it should drop it and send an ICMP message to the sender.
  • Bit 2: MF or more fragments. If set to one, it indicates that there are more fragments. On the other hand, if it is set to zero, it signifies that this is the last or only fragment in the group.

Fragment Offset

The position of the packet in the original datagram is indicated by fragment offset. It is measured in units of 8 bytes. Fragment offset of zero belongs to the first packet of a datagram. The following other packets have a fragment offset that is equal to the sum of the lengths of the previous packets divided by 8. The fragment offset field further assists in reassembling the fragments at the destination.

TTL

TTL, or time-to-live field, is 8 bits long, and with the help of TTL, one can easily know the maximum time that a packet can live in the network. It is measured in seconds, and it keeps on being decremented by one by every device that processes the packet. When the value reaches zero, the packet is discarded, and an ICMP message is sent back to the sender. With the help of TTL, it is now possible to prevent packets from looping endlessly in the network and consuming resources.

Protocol

The protocol field indicates the type of protocol that is used in the payload. Furthermore, it identifies the next-level protocol that processes the data after the IP layer.

Below, we have shown some common values for this field for better understanding.

ProtocolFieldDescription
ICMP1Internet Control Message Protocol
TCP6Transmission Control Protocol
UDP17User Datagram Protocol

Header Checksum

In order to verify the integrity of the header, header checksum field is utilized. It is calculated by adding all the 16-bit words in the header and taking one’s complement of the result. If there are any errors in the header, such as bit flips or corrupted fields, the checksum will not match, and the packet will be discarded.

Source Address

This field signifies the IP address of the sender of the packet. The source address field is a 32-bit number used to identify a host or a network interface on the internet.

Destination Address

Similar to the source address field, the destination address field indicates the IP address of the receiver of the packet. It is also a 32-bit number that uniquely identifies a host or a network interface on the internet.

Options

The option field is variable in length and contains optional information that can be further used for different purposes. Some of these are security, routing, or timestamping. Each option has a format of:

  • Option Type: It is of 8 bits and usually indicates what kind of option it is and whether it should be copied to all the fragments or not.
  • Option Length: It is also 8 bits, and it simply signifies the length of the option in bytes. This includes option type and option length fields.
  • Option Data: Variable – Contains the data for the option.
Shows an IP Packet in Wireshark

These are the components of IP4 header format.

Purpose of IPv4 Header Fields

Let’s see the purpose of various fields of IPv4 header.

  • Version: This tells the computer which Internet Protocol version being used, which in this case is IPv4.
  • Internet Header Length (IHL): It tells the length of the IP header of the internet packet. It is necessary for the receiving device in order to determine the start of the data portion of the packet.
  • Type of Service: It tells the computer about the desired quality of service. It is needed in prioritizing certain types of traffic or allocating network resources.
  • Total Length: It tells the computer about the total length of the internet packet including the header and the data.
  • Identification: It assists in identifying the original packet if it gets broken into smaller pieces.
  • Flags: It provides information regarding the fragmentation status of the packet. For example, whether the packet can be fragmented or has been fragmented.
  • Fragments Offset: With its help, a packet can be back together if it gets broken into smaller pieces, i.e., reassembly of packet at the receiving end.
  • Time to Live (TTL): It provides information on how long the packet can stay in the network before it is discarded.
  • Protocol: It identifies the type of transport layer protocol, such as TCP or UDP, used within the IP packet.
  • Header Checksum: It is mainly used to check whether the header part of the packet is correct, i.e., to detect errors in the IP header.
  • Source/Destination IP addresses: It gives information on where the packet is coming from (Source) and where the packet is going (Destination).

Significance of IPv4 Header

IPv4 is a critical component of the Internet infrastructure that plays a vital role in routing Internet traffic all over the globe. The significance of the IPv4 header in routing is beyond its technical functions. The header has an impact on the development of the internet. The widespread adoption of IPv4 in the early 1980s and 1990s led to rapid internet growth. Apart from all this, the Header’s design has also influenced the development of subsequent internet protocols, i.e., IPv6.

  • One of the primary functions of the IPv4 header is Routing. The header contains the destination IP address, with which the router can easily forward packets to their next hop, which leads to the final destination.
  • The IPv4 header also contains the TTL field. With TTL, the maximum number of hops a packet can take before being discarded can be specified. This prevents the packet from circulating indefinitely in the network.
  • Another significant aspect of the IPv4 header is its role in packet fragmentation and reassembly. When a packet is transmitted over a network with a smaller MTU than the original packet size, the packet must be fragmented into smaller parts. The IPv4 header allows routers to reassemble these fragments into the original packet at the destination.
  • The IPv4 header is also crucial in packet error detection and correction. The header checksum field is mainly used to detect errors during the transmission process. If any error is detected, the packet can be discarded, and a request for re-transmission can be sent to the source.

Frequently Asked Questions

Q1. What is IPv4 header format?

The IPv4 header format is a 20-byte structure that contains information such as source and destination addresses, protocol, and checksum.

Q2. What is IPv4 format?

IPv4 format is a 32-bit number divided into four octets. A dot separates each octet and has a value from 0 to 255.

Q3. What is IPv6 header format?

IPv6 header format consists of 8 fields: version, traffic class, flow label, payload length, next header, hop limit, source address, and destination address. Each field has a fixed size and position in the header.

Q4. What are the 12 basic header fields IPv4?

Twelve basic header fields of IPv4 are Version, IHL, DSCP, ECN, Total Length, Identification, Flags, Fragment Offset, TTL, Protocol, Header Checksum, Source Address and Destination Address. Their main purpose is to provide information regarding packets and their routing.

Conclusion

In this blog post, we learned about the IPv4 header format, which is the additional information attached to the data before it is transmitted over the network. We have explained different fields of the IPv4 header in detail and also explained their purpose.

If you have any questions or feedback, please feel free to leave a comment below.

Recent Blog Post

Leave a Reply

Your email address will not be published. Required fields are marked *

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram