IPv4 Packet Header

(Lazaros Agapides) #41

Hello Muhammad

An IPv4 header is designed to have a variable header length. That is, it can have many options that come after the source and destination IP addresses. If you look at the diagram of the IP header in the lesson, you will see an options field. Now that options field is not often used. Actually, it is very rarely used. The header length field is used to indicate if there are any options in the header. Specifically, the value in the header length field is multiplied by 32 to indicate the size of the header in bits. So, a value of 5 indicates 5X32 = 160 bits or 20 bytes. This is the minimum size of the IP header, and is indeed the default size, without options. When no options are used, the header length value is 5.

Having said all that, for the vast majority of applications, the header length is 5 due to the fact that no options are implemented.

Now the total length field is a value that states the total size of the packet including both header and payload. This value is used along with the fragment offset to be able to reassemble fragmented packets.

The IP flags are used when fragmenting IP packets. Fragmentation of an IP packet occurs during encapsulation. When a host is encapsulating data down the OSI stack, when it comes to encapsulating the packet into a frame, there are often restrictions as to how big of a packet can fit in a frame. Such restrictions are due to the Maximum Transmission Unit (MTU) allowed on a particular Ethernet link. If the packet is too large, it will be broken into two and placed into two frames. If the DF bit is set to 1, then fragmentation is not allowed, thus the packet is dropped. If it is set to 0, fragmentation is allowed and the MF bit is set to 1, indicating that the part of the packet in the particular frame has MORE FRAGMENTS coming after it that are carrying part of the same packet. The final frame carrying the final fragment of the same packet will have MF set to 0 indicating that it is the last one. The Fragment Offset is used to keep track of what part of the fragmented packet this frame is part of. The MF along with the Fragment Offset are used to successfully reassemble a fragmented packet when it reaches its destination.

For more information about fragmentation, take a look at this lesson:

I hope this has been helpful!


(Muhammad Rasoul A) #42

Hello Lazaros

Thank you very much you are great Lazaros, very clear explanation.