IP packets are encapsulated in datalink frames, and, therefore, the link MTU affects larger IP packets and forces them to be split into pieces equal to or smaller than the MTU size.
This can be accomplished by several approaches:
Three fields in the IP header are used to implement fragmentation and reassembly. The "Identification", "Flags" and "Fragment Offset" fields.
Flags:
Fragment Offset specifies the fragment's position within the original packet, measured in 8-byte units.
Accordingly, every fragment except the last must contain a multiple of 8 bytes of data. It is obvious that Fragment Offset can hold 8192 (2^13) units but the packet can't have 8192 * 8 = 65,536 bytes of data because "Total Length" field of IP header records the total size including the header and data. An IP header is at least 20 bytes long, so the maximum value for "Fragment Offset" is restricted to 8189, which leaves room for 3 bytes in the last fragment.
Because an IP internet can be connectionless, fragments from one packet may be interleaved with those from another at the destination. The "Identification field" uniquely identifies the fragments of a particular packet.
The source system sets "Identification" field in each packet to a unique value for all packets which use the same source IP address, destination IP address, and "Protocol" values, for the lifetime of the packet on the internet. This way the destination can distinguish which incoming fragments belong to a unique packet and buffer all of them until the last fragment is received. The last fragment sets the "More Fragment" bit to 0 and this tells the receiving station to start reassembling the data if all fragments have been received.
The following is a real-life fragmentation example:
The following was obtained using the Ethereal protocol analyzer to capture ICMP echo request packets. To simulate this open up a terminal and type ping ip_dest -n 1 -l 65000.
The results are as follows:
Note that only the first fragment contains the ICMP header and all remaining fragments are generated without the ICMP header.
Two important points here:
Network infrastructure equipment such as routers, load-balancers, firewalls and IDS have inconsistent visibility into fragmented packets. For example, a device may subject the initial fragment to rigorous inspection and auditing, but might allow all additional fragments to pass unchecked. Some attacks may use this fact to evade detection by placing incriminating payload data in fragments. Devices operating in "full" proxy mode are generally not susceptible to this subterfuge.
Kurose, James F. (2013). Computer Networking: A Top-down Approach. Ross, Keith W., 1956- (6th ed.). Boston: Pearson. p. 338. ISBN 9780132856201. OCLC 769141382. 9780132856201 ↩
Hollis, Ken. "The Rose Fragmentation Attack Explained". Archived from the original on 2012-02-24. Retrieved 2013-11-25. https://web.archive.org/web/20120224113108/http://www.digital.net/~gandalf/Rose_Frag_Attack_Explained.htm ↩