IPv4 Packet Structure

IPv4 has been in use since 1983 when it was deployed on the Advanced Research Projects Agency Network (ARPANET), which was the precursor to the Internet. The Internet is largely based on IPv4, which is still the most widely-used network layer protocol.

TCP/IP Version 4 Packet Structure

An IPv4 packet has two parts:

  • IP Header – Identifies the packet characteristics
  • Payload – Contains the Layer 4 segment information and the actual data.

IPV4-packet

IPV4 packet

As shown in the figure, an IPv4 packet header consists of fields containing important information about the packet. These fields contain binary numbers which are examined by the Layer 3 process. The binary values of each field identify various settings of the IP packet.

Significant fields in the IPv4 header include:

  • Version – Contains a 4-bit binary value identifying the IP packet version. For IPv4 packets, this field is always set to 0100.
  • Differentiated Services (DS) – Formerly called the Type of Service (ToS) field, the DS field is an 8-bit field used to determine the priority of each packet. The first 6 bits identify the Differentiated Services Code Point (DSCP) value that is used by a quality of service (QoS) mechanism. The last 2 bits identify the explicit congestion notification (ECN) value that can be used to prevent dropped packets during times of network congestion.
  • Time-to-Live (TTL) – Contains an 8-bit binary value that is used to limit the lifetime of a packet. It is specified in seconds but is commonly referred to as hop count. The packet sender sets the initial time-to-live (TTL) value and is decreased by one each time the packet is processed by a router, or hop. If the TTL field decrements to zero, the router discards the packet and sends an Internet Control Message Protocol (ICMP) Time Exceeded message to the source IP address. The traceroute command uses this field to identify the routers used between the source and destination.
  • Protocol – This 8-bit binary value indicates the data payload type that the packet is carrying, which enables the network layer to pass the data to the appropriate upper-layer protocol. Common values include ICMP (1), TCP (6), and UDP (17).
  • Source IP Address – Contains a 32-bit binary value that represents the source IP address of the packet.
  • Destination IP Address – Contains a 32-bit binary value that represents the destination IP address of the packet.

The two most commonly referenced fields are the source and destination IP addresses. These fields identify where the packet is from and where it is going. Typically these addresses do not change while travelling from the source to the destination.

IPv4 Header Field

The remaining fields are used to identify and validate the packet, or to reorder a fragmented packet.

IPv4 packet hedar

As shown in the figure, The fields used to identify and validate the packet include:

  • Internet Header Length (IHL) – Contains a 4-bit binary value identifying the number of 32-bit words in the header. The IHL value varies due to the Options and Padding fields. The minimum value for this field is 5 (i.e., 5×32 = 160 bits = 20 bytes) and the maximum value is 15 (i.e., 15×32 = 480 bits = 60 bytes).
  • Total Length – Sometimes referred to as the Packet Length, this 16-bit field defines the entire packet (fragment) size, including header and data, in bytes. The minimum length packet is 20 bytes (20-byte header + 0 bytes data) and the maximum is 65,535 bytes.
  • Header Checksum – The 16-bit field is used for error checking of the IP header. The checksum of the header is recalculated and compared to the value in the checksum field. If the values do not match, the packet is discarded.

A router may have to fragment a packet when forwarding it from one medium to another medium that has a smaller MTU. When this happens, fragmentation occurs and the IPv4 packet uses the following fields to keep track of the fragments:

  • Identification – This 16-bit field uniquely identifies the fragment of an original IP packet.
  • Flags – This 3-bit field identifies how the packet is fragmented. It is used with the Fragment Offset and Identification fields to help reconstruct the fragment into the original packet.
  • Fragment Offset – This 13-bit field identifies the order in which to place the packet fragment in the reconstruction of the original unfragmented packet.

Thanks, If you like this tutorial please share this article to your friends in FBTwitter,

Add a Comment

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