IPv4 Header Format Diagram

IP packets contain a header part and a data part. The header has a fixed length component of 20 bytes and a variable-length component of 40 bytes consisting of option and padding.

IPv4 Header Format Diagram

IPv4 Header Format:

Version:

This field indicates the version number of the IP packet so that the revised version can be distinguished from the previous version. The current IP version is 4.

Internet Header Length (IIHL):

It specifies the length of the IP header in unit 32 bits. In case of no option is present in the IP header, IHL will have a value of 5. So, if the value of IHL is more than 5 then the length of the option field can be easily calculated.

Type of Service:

This field specifies the priority of the packets based on delay, throughput, reliability and cost requirements. Three bits are assigned for priority level and four bits for specific requirements (delay, throughput, reliability and cost).

Total Length:

This field specifies the number of bytes of the IP packet including header and data. As 16 bits are assigned to this field, the maximum length of the packet is 65635 bytes.

Identification:

The identification field is used to identify which packet a particular fragment belongs to so that fragments for different packets don’t get mixed up.

Flags:

The flag field has three bits:
1. Unused bit
2. Don’t fragment (DF) bit
3. More fragment (MF) bit

Fragment Offset:

The fragment offset field identifies the location of the fragment in a packet. The value measures the offset in a unit of 8 bytes, between the beginning of the packet to be fragmented and the beginning of the fragment.

Time to live (TTL):

This field is used to indicate the amount of time in seconds a packet is allowed to remain in the network.

Protocol:

This field specifies the protocol that is to receive the IP data at the destination host.

Header Checksum:

This field verifies the integrity of the header of the IP packet. The integrity of the data part is left to the upper layer protocols. The checksum is generated by the source and it is sent along with the frame header to the next router.

Source IP address & Destination IP address:

These two fields contain the IP addresses of the source and destination hosts respectively.

Options:

Options fields are rarely used to include special features such as security level, the route to be taken and the time stamp at each router. It is used in RSVP.

Padding:

This field is used to make the header a multiple of 32-bit words.