Introduction
An IPv4 datagram is the structured packet used by the Network Layer to move data across multiple interconnected networks. Routers do not forward raw application data directly. Instead, the Network Layer places that data inside an IPv4 datagram so it can be addressed, routed, fragmented if required, and delivered to the correct destination.
This is why the IPv4 datagram is so important. It carries both the real data and the control information needed for packet forwarding. Without that structure, routers would not know where the packet came from, where it should go next, or how to handle limits such as MTU and routing loops.
What an IPv4 Datagram Contains
An IPv4 datagram has two major parts:
Header: Contains control information used for routing, forwarding, fragmentation, and delivery.
Payload: Contains the actual upper-layer data being carried.
The payload may contain a TCP segment, a UDP datagram, ICMP data, or some other higher-layer content. The header exists to make sure that payload can travel correctly across networks.
Main IPv4 Header Fields
The IPv4 header contains several fields, and each one serves a specific purpose during transmission.
Field | Purpose |
|---|---|
Version | Identifies the IP version being used |
IHL | Tells the receiver how large the IPv4 header is |
DSCP and ECN | Influence packet treatment and congestion behavior |
Total Length | Specifies the full size of the datagram |
Identification | Groups fragments that belong to the same original datagram |
Flags | Controls fragmentation behavior |
Fragment Offset | Shows where a fragment belongs in the original datagram |
TTL | Prevents packets from circulating forever |
Protocol | Identifies the upper-layer protocol in the payload |
Header Checksum | Detects errors in the IPv4 header |
Source IP Address | Identifies the sender |
Destination IP Address | Identifies the intended receiver |
Data or Payload | Carries the actual upper-layer information |
IPv4 Datagram
Version and IHL
The Version field tells the receiver which version of the Internet Protocol is being used. For IPv4, that value is 4. This matters because the device must know how to interpret the rest of the packet.
The Internet Header Length, or IHL, tells how large the IPv4 header is. The value is measured in 4-byte words, not in bytes directly.
For example:
IHL = 5: Header length is 5 words
1 word = 4 bytes: Total header length becomes 20 bytes
This 20-byte size is the minimum IPv4 header length. The header can grow larger if optional fields are present.
Why IPv4 Header Length Can Vary
Unlike some simpler packet formats, the IPv4 header is not always fixed in size. Its length changes because the header may include options.
That is why:
Minimum header size: 20 bytes
Maximum header size: 60 bytes
Routers and receiving devices use the IHL field to understand where the header ends and where the payload begins.
DSCP and ECN
The Differentiated Services Field is used to influence how the packet is treated in the network. This field is 8 bits long and is divided into two parts:
DSCP: 6 bits used for traffic classification and priority
ECN: 2 bits used for congestion signaling
DSCP helps the network give different treatment to different kinds of traffic. For example, voice, video, or network control traffic may receive higher priority than ordinary background traffic.
ECN helps indicate congestion without immediately dropping packets. That allows endpoints to react earlier and adjust transmission behavior.
Total Length
The Total Length field specifies the complete size of the IPv4 datagram, including both header and payload.
This field is 16 bits long, so the theoretical maximum IPv4 datagram size is 65,535 bytes
In practice, packets are usually much smaller because they must fit within the MTU, or Maximum Transmission Unit, of the underlying network.
Why Fragmentation Is Needed
Different links support different maximum packet sizes. If a router receives a datagram that is too large for the next outgoing link, it may need to split that datagram into smaller parts. This process is called fragmentation.
Example:
Datagram size: 5000 bytes
Next-hop MTU: 1500 bytes
Since the datagram cannot fit in one piece, it must be broken into fragments.
IPv4 uses three important fields to support fragmentation and reassembly.
Field | Purpose |
|---|---|
Identification | Gives the original datagram a value shared by all its fragments |
Flags | Controls whether fragmentation is allowed and whether more fragments follow |
Fragment Offset | Indicates where the current fragment belongs in the original datagram |
These fields work together so the receiving device can rebuild the original packet correctly.
Identification, Flags, and Fragment Offset
The Identification field is assigned when the original datagram is created. If fragmentation happens, every fragment carries the same identification value so the destination knows they all belong to the same packet.
The Flags field controls fragmentation behavior. Two important flags are:
DF, Don't Fragment: If set, the router must not fragment the packet
MF, More Fragments: If set, more fragments follow after the current one
The Fragment Offset field tells where a fragment belongs within the original datagram. This value is measured in units of 8-byte blocks, not individual bytes.
That means:
Offset 0: Fragment starts at byte 0
Offset 185: Fragment starts after 1480 bytes
Offset 370: Fragment starts after 2960 bytes
TTL
The Time To Live, or TTL, field prevents a packet from circulating forever in the network. Every time a router forwards the packet, it reduces the TTL by one.
Example:
Initial TTL: 64
Routers crossed: 5
Remaining TTL: 59
If TTL reaches zero, the router discards the packet. This protects the network from endless routing loops.
Protocol and Header Checksum
The Protocol field tells the receiving device what kind of upper-layer data is inside the payload.
Common values include:
1: ICMP
6: TCP
17: UDP
This field helps the operating system deliver the payload to the correct upper-layer protocol.
The Header Checksum field provides error detection for the IPv4 header. It protects the header only, not the payload. Since routers may change values such as TTL at every hop, they must recalculate the header checksum each time they forward the packet.
Source IP, Destination IP, and Payload
The Source IP Address identifies where the packet came from. The Destination IP Address identifies where the packet is supposed to go. Routers mainly examine the destination IP address while making forwarding decisions.
The Payload field contains the actual upper-layer content. In most cases, that payload is a TCP segment or UDP datagram carrying application data.
The IPv4 datagram is the layer that gives the transport data a routable structure for movement across networks.
Summary
An IPv4 datagram is the Layer 3 packet format that carries both user data and the control information needed for routing, forwarding, fragmentation, and delivery. It consists of a header and a payload, and the header contains fields such as version, IHL, DSCP, ECN, total length, identification, flags, fragment offset, TTL, protocol, checksum, source IP, and destination IP.
These fields allow IPv4 packets to travel across networks, fit within MTU limits, survive router-to-router forwarding, and eventually reach the intended destination. Understanding the IPv4 datagram is essential because it connects addressing, packet structure, fragmentation, and delivery into one complete Network Layer concept.
Be the first to add a comment.