IPv4 Header
The IPv4 header is a critical component of the Internet Protocol version 4 (IPv4), which is the fourth version of the Internet Protocol and a foundational technology for packet-switched networks such as the Internet. The header contains the information necessary for the routing and delivery of the packet from the source to the destination.
Structure of the IPv4 Header
The IPv4 packet header consists of several fields, each with a specific purpose:
- Version: A 4-bit field that specifies the version of the IP protocol; for IPv4, this is always set to 4.
- Internet Header Length (IHL): A 4-bit field that indicates the size of the IPv4 header in 32-bit words. The minimum value is 5, which corresponds to a length of 20 bytes.
- Differentiated Services Code Point (DSCP): Used for specifying the type of service for QoS purposes.
- Explicit Congestion Notification (ECN): Carries information about congestion seen in the route.
- Total Length: A 16-bit field that specifies the entire packet size, including header and data, in bytes.
- Identification: Used for reassembling fragmented packets; all fragments of a packet share this value.
- Flags: A 3-bit field used for managing packet fragmentation.
- Fragment Offset: Indicates where in the original packet a fragment belongs.
- Time to Live (TTL): Decremented by each router that forwards the packet; when it reaches zero, the packet is discarded.
- Protocol: An 8-bit field that indicates the next level protocol used in the data portion of the IP packet.
- Header Checksum: Used for error-checking of the header.
- Source Address: A 32-bit field that contains the IP address of the sender.
- Destination Address: A 32-bit field that contains the IP address of the receiver.
- Options: An optional field used for various purposes such as security, record route, and timestamp, among others.
Functionality
IPv4 is a connectionless protocol, meaning it does not establish a dedicated end-to-end connection before sending packets. It operates on a best-effort delivery model, which means it does not guarantee delivery, proper sequencing, or avoidance of duplicate delivery. These aspects are handled by higher layer protocols like TCP.
IPv4 uses 32-bit addresses, which limits the address space to approximately 4.3 billion unique addresses. Special address blocks are reserved for private networks and multicast addresses.
Header Fields and Error Handling
The IPv4 header does not include a data checksum; error checking is typically handled by the link layer or transport layer protocols. The header checksum field is used to detect errors in the header only.
Addressing
IPv4 addresses are most commonly written in dot-decimal notation, which consists of four octets of the address expressed individually in decimal and separated by periods (e.g., 192.168.1.5).
Conclusion
The IPv4 header is essential for the proper routing and delivery of data over IP networks. Its fields provide the necessary information to guide packets to their destination while allowing for fragmentation and reassembly, error checking, and other network functions. Despite the introduction of IPv6, IPv4 remains widely used due to its long-standing deployment and extensive infrastructure support.