IPv4 Datagram Header

When data moves through the Internet, it does not travel as a simple block. It is wrapped inside a structure called a datagram. This datagram contains two main parts. One is the header, which carries control information. The other is the actual data being sent. If you want to understand how routing and delivery really work, you need to understand what’s inside this header.

Each field in the IPv4 header has a specific purpose. Together, they help routers process, forward, and manage packets correctly across networks.

ipv4-datagram-header-1

A. Version and Header Length

The first field is the version field, which is 4 bits long. This simply tells the system which version of IP is being used. For IPv4, the value is always 4. This helps devices know how to interpret the rest of the packet.

Right after that comes the header length field, also 4 bits. This tells how long the header is. Normally, the IPv4 header is 20 bytes, but it can be longer if options are included. This field is important because it marks where the actual data begins. Without it, the receiver would not know where the header ends and the payload starts.

B. Type of Service, DSCP, and ECN

The next part is the Type of Service field, which is 8 bits. This field was designed to allow different types of traffic to be handled differently. Over time, it evolved into two parts.

The first part is DSCP, which stands for Differentiated Services Code Point. It is used to classify traffic. For example, real time applications like video or voice need low delay, while file transfers care more about reliability. DSCP helps routers prioritize packets based on these needs.

The second part is ECN, which stands for Explicit Congestion Notification. This helps in managing congestion in the network. Instead of dropping packets when the network is busy, routers can signal congestion early so that the sender can slow down transmission.

Originally, this field also included precedence bits and flags for delay, throughput, and reliability. Precedence used 3 bits to define priority levels. Additional bits indicated whether a packet required low delay, high throughput, or high reliability. Although modern networks use updated methods, the idea remains the same. Different data types have different requirements.

C. Total Length of Datagram

The datagram length field is 16 bits long. It tells the total size of the packet, including both header and data. This allows the receiver to know how much data to expect. The maximum size of an IPv4 packet is 65,535 bytes.

D. Identification, Flags, and Fragmentation Offset

Sometimes, a packet is too large to pass through a network with a smaller maximum size. In that case, it is broken into smaller pieces. This process is called fragmentation.

The identification field, which is 16 bits, helps group fragments together. All fragments of the same original packet carry the same identification number.

The flags field controls fragmentation behavior. One important flag is DF, which means Don’t Fragment. If this is set, the packet must not be broken into smaller pieces. Another flag is MF, which means More Fragments. This tells the receiver that more fragments are coming.

The fragmentation offset field, which is 13 bits, indicates the position of a fragment within the original packet. This helps the destination reassemble the fragments in the correct order.

E. Time to Live

The Time to Live field is 8 bits. Its purpose is simple but critical. It prevents packets from circulating endlessly in the network.

Each time a packet passes through a router, the TTL value is reduced by one. When it reaches zero, the packet is discarded. This avoids infinite loops and helps keep the network stable. In practice, TTL acts as a hop counter.

F. Protocol Field

The protocol field is also 8 bits. It tells the IP layer which protocol should handle the data next.

For example, if the value corresponds to TCP, the packet is passed to the TCP layer. If it corresponds to UDP, it goes to UDP. This field ensures that the data reaches the correct process at the transport layer.

G. Header Checksum

The header checksum is 16 bits and is used for error detection. It checks whether the header has been corrupted during transmission.

Each router recalculates this checksum as the packet moves through the network. If an error is detected, the packet is discarded. This ensures that corrupted control information does not cause incorrect routing.

H. Source and Destination Addresses

These fields carry the 32 bit IP addresses of the sender and receiver. They are essential for routing.

Routers use the destination address to decide where to forward the packet. The source address allows the destination to send a response back.

I. Options and Data

The options field is optional and not used in every packet. It can include additional features like security settings or routing instructions. Because it increases header size and processing time, it is rarely used in normal communication.

Finally, the data field contains the actual information being sent. This is the payload generated by the application layer, such as a file, message, or request.

Bringing It Together

When you look at the IPv4 header as a whole, it acts like a control guide for the packet. It tells the network what the packet is, where it came from, where it is going, how it should be handled, and when it should be discarded.

Each field may seem small on its own, but together they make reliable communication across the Internet possible. Without this structure, routers would not know how to forward packets, and devices would not be able to communicate effectively.

Share: Facebook LinkedIn X

More Study Materials

Useful Resources