askvity

What are IP Flags?

Published in Network Protocols 3 mins read

IP Flags are a 3-bit field within an IP (Internet Protocol) header that control how packets are fragmented, or broken down, when they exceed the maximum size allowed by a network. These flags are crucial for managing how data is transmitted across networks with different maximum transfer units (MTUs).

Understanding the IP Flags Field

The IP Flags field, as mentioned in the reference, consists of 3 bits. However, bit 0 is reserved and always set to 0, limiting the practical flags to two bits. The remaining bits are used to signal whether or not a packet can be fragmented.

Here's a breakdown of each relevant bit:

Bit Flag Name Value Description
0 Reserved 0 Always set to zero, as specified in the reference.
1 Don't Fragment (DF) 0 or 1 If set to 1, it means the packet should not be fragmented. If a router receives such a packet and can't forward it because it's too large, it drops it and may send back an ICMP message to the source. If set to 0, the packet can be fragmented if needed.
2 More Fragments (MF) 0 or 1 If set to 1, it indicates that this packet is a fragment of a larger message, and there are more fragments to follow. When set to 0, it means this is either the final fragment or that the packet was never fragmented.

Practical Application and Examples

  • Fragmentation Scenario: When a large packet needs to travel through a network with a smaller MTU, a router will fragment the packet based on the flags set.

    • If DF=0 (Don't Fragment is not set), and fragmentation is required, the router will divide the IP packet into smaller ones.
    • All except the last fragment will have the MF=1 (More Fragments) flag set. The final fragment will have MF=0.
  • Avoiding Fragmentation: The DF=1 (Don't Fragment set) flag is used when the sender is certain that the network path can handle the packet's size, or the sender does not wish to fragment the packet and wants to know if fragmentation is needed (through receiving an ICMP message).

  • Setting DF = 1 is often used in path MTU discovery processes.

  • Reassembly: The receiver uses the fragmentation flags, the identification field, and offset to reconstruct the original IP packet.

Summary

In short, IP flags control how fragmentation is handled for IP packets. The "Don't Fragment" and "More Fragments" bits are essential for ensuring reliable data transmission when networks have different MTU sizes.

Related Articles