Network Layer takes data Segments from Transport Layer and converts the segments into packets. IP packet encapsulates data unit received from the above layer and add to its own IPv4 Packet header information as shown in the figure below. The IPv4 packet header has different fields containing important information about the packet. These fields contain binary numbers which examined by the network layer processes. The binary values of each field identify various settings of the IPv4 packet. Protocol header diagrams, like the one shown in the figure below:
Important fields in the IPv4 packet header include
- Version – IPv4 packet header contains a 4-bit binary value set to 0100 that identifies this as an IP version 4 packet.
- Internet Header Length (IHL)- This is a 4-bit field which tells us the length of the IP header in 32-bit increments. The minimum length of an IP header is 20 bytes. The maximum value we can create with 4 bits is 15 so with 32-bit increments; that would be a header length of 60 bytes.
- Differentiated Services (DS) – Previously called the Type of Service (ToS) field, the DS field is an 8-bit field used to decide the priority of each packet.
- Differentiated Services Code Point (DSCP)– Usually set to 0, but may indicate particular Quality of Service needs from the network; the DSCP defines the way routers should queue packets while they are waiting to be forwarded.
- ECN: Explicit Congestion Notification, It carries information about the congestion seen in the route.
- Total Length: Length of entire IP Packet (including IP header and IP Payload).
- Identification: If IP packet fragmented during the transmission, all the fragments contain the same identification number. to find original IP packet they belong to.
- Flags: As required by the network resources, if IPv4 Packet is too large to handle, these ‘flags’ tell if they fragmented or not. In this 3-bit flag, the MSB is always set to ‘0’.
- Fragment Offset: this 13-bit field specifies the place of the fragment in the original fragmented IP packet.
- Time-to-Live (TTL) – This field has an 8-bit binary value used to limit the lifetime of a packet. The packet sender sets the initial TTL value, and it decreased by one each time the packet processed by a router. 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.
- 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).
- Header Checksum: this 16-bit field used to store a checksum of the header. The receiver can use the checksum to check if there are any errors in the header.
- 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 IPv4 address of the packet.
- Options: This is an optional field of IPv4 packet header, which is used if the value of IHL is greater than 5. These options may contain values for options such as Security, Record-Route, Time Stamp, etc.
The two most common fields of the IPv4 packet header are the source and destination IP addresses. These fields find the source and destination of the packet. Typically these addresses do not change while travelling from the source to the destination.