Facebook Pixel

Introduction to IPv4

Internet Protocol Version 4 is the primary protocol responsible for addressing and delivering data across global networks. It operates on a connectionless, best effort basis. This means it does not establish a dedicated connection before sending data, and it does not guarantee successful delivery or correct ordering. Those reliability tasks are delegated to the Transport Layer.

Key Characteristics of IPv4

  • 32 Bit Address Space: Addresses are mathematically limited to approximately 4.29 billion unique values.
  • Dotted Decimal Notation: Addresses are formatted into four readable decimal octets separated by dots. For example, 192.168.1.5.
  • Communication Types: Supports Unicast (one to one), Broadcast (one to all), and Multicast (one to many) transmissions.
  • Fragmentation Support: Allows oversized packets to be broken down into smaller fragments to pass through restrictive network links.

The IPv4 Datagram

When the Network Layer receives data from the Transport Layer, it encapsulates it into a structured unit called a datagram. A datagram consists of a Header containing critical routing controls, and a Payload containing the actual data.

Datagram Header Fields

The standard IPv4 header has a minimum size of 20 bytes and can expand up to 60 bytes if optional fields are included. It consists of multiple specific fields.

  • Version (4 bits): Strictly contains the binary value 0100 to indicate IPv4.
  • Header Length / HLEN (4 bits): Measures the header size in 4 byte blocks. A minimum value of 5 means the header is 20 bytes long. A maximum value of 15 means it is 60 bytes long.
  • Type of Service (8 bits): Indicates the Quality of Service or priority level requested for the packet.
  • Total Length (16 bits): Specifies the complete byte size of the datagram including both header and payload. For example, a 20 byte header carrying 1000 bytes of data will have a Total Length of 1020.
  • Identification (16 bits): A unique number assigned to all fragments belonging to the same original packet. For example, if a datagram is fragmented into three pieces, all three fragments carry the exact same ID, such as 12345.
  • Flags (3 bits): Controls fragmentation. The Do Not Fragment (DF) bit forces routers to drop oversized packets instead of breaking them. The More Fragments (MF) bit is set to 1 for all fragments except the final one.
  • Fragment Offset (13 bits): Indicates exactly where a specific fragment belongs in relation to the original payload, measured in 8 byte units. For example, if a fragment begins at byte 1600, its offset value is simply 1600 divided by 8, which equals 200.
  • Time to Live / TTL (8 bits): Prevents infinite routing loops. The sender sets a value (like 64). Every router decrements this value by 1. If TTL hits 0, the packet is forcefully discarded.
  • Protocol (8 bits): Identifies the specific Transport Layer protocol inside the payload. For example, a value of 6 dictates that the payload must be passed to the Transmission Control Protocol (TCP).
  • Header Checksum (16 bits): Detects corruption strictly within the header. Because the TTL value changes at every single router hop, this checksum must be mathematically recalculated at every hop.
  • Source and Destination IP (32 bits each): The exact logical IP addresses of the sending and receiving devices.

Detailed Fragmentation Example

Suppose an original datagram is exactly 4000 bytes (20 bytes of header and 3980 bytes of data). It hits a network link with a Maximum Transmission Unit (MTU) of 1500 bytes.

The router must break this into smaller pieces. Each piece gets its own 20 byte header, leaving exactly 1480 bytes for data payload per fragment.

FragmentData PayloadOffset ValueMore Fragments (MF) Bit
Fragment 11480 bytes01
Fragment 21480 bytes185 (1480 divided by 8)1
Fragment 31020 bytes370 (2960 divided by 8)0

Advantages and Disadvantages

  • Advantages: Universally supported across all modern hardware. Highly flexible due to subnetting support, and easily handles varying network MTU sizes via dynamic fragmentation.
  • Disadvantages: The 32 bit address space is completely exhausted globally. It lacks native security encryption and incurs heavy processing overhead due to constant Header Checksum recalculations at every router hop.

Sort the Concepts

Test your knowledge! Sort these definitions into their correct header fields.

Time to Live
Fragment Offset
Protocol Field
Unsorted Items:
Decremented by 1 at every single router hop.
Measured in strict 8 byte units.
A value of 6 indicates the payload belongs to TCP.
Prevents infinite routing loops.
A value of 1 indicates the payload belongs to ICMP.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.