Fragmentation and reassembly Main article: IP fragmentation
The Internet Protocol enables networks to communicate with one
another. The design accommodates networks of diverse physical nature;
it is independent of the underlying transmission technology used in
the Link Layer. Networks with different hardware usually vary not only
in transmission speed, but also in the maximum transmission unit
(MTU). When one network wants to transmit datagrams to a network with
a smaller MTU, it may fragment its datagrams. In IPv4, this function
was placed at the Internet Layer, and is performed in IPv4 routers,
which thus only require this layer as the highest one implemented in
their design.
In contrast, IPv6, the next generation of the Internet Protocol, does
not allow routers to perform fragmentation; hosts must determine the
path MTU before sending datagrams.
Fragmentation
When a router receives a packet, it examines the destination address
and determines the outgoing interface to use and that interface's MTU.
If the packet size is bigger than the MTU, and the Do not Fragment
(DF) bit in the packet's header is set to 0, then the router may
fragment the packet.
The router divides the packet into fragments. The max size of each
fragment is the MTU minus the IP header size (20 bytes minimum; 60
bytes maximum). The router puts each fragment into its own packet,
each fragment packet having following changes:
- The total length field is the fragment size.
- The more fragments (MF) flag is set for all fragments except the last one, which is set to 0.
- The fragment offset field is set, based on the offset of the fragment in the original data payload. This is measured in units of
eight-byte blocks.
- The header checksum field is recomputed.
For example, for an MTU of 1,500 bytes and a header size of 20 bytes,
the fragment offsets would be multiples of (1500–20)/8 = 185. These
multiples are 0, 185, 370, 555, 740, ...
It is possible for a packet to be fragmented at one router, and for
the fragments to be fragmented at another router. For example,
consider a Transport layer segment with size of 4,500 bytes, no
options, and IP header size of 20 bytes. So the IP packet size is
4,520 bytes. Assume that the packet travels over a link with an MTU of
2,500 bytes. Then it will become two fragments:

Note that the fragments preserve the data size: 2480 + 2020 = 4500.
Note how we get the offsets from the data sizes:
0.
0 + 2480/8 = 310.
Assume that these fragments reach a link with an MTU of 1,500 bytes.
Each fragment will become two fragments:

Note that the fragments preserve the data size: 1480 + 1000 = 2480,
and 1480 + 540 = 2020.
Also in this case, the More Fragments bit remains 1 for ALL the
fragments that came with 1 in them and for the last fragment that
arrives, it works as usual, that is the MF bit is set to 0 only in the
last one. And of course, the Identification field continues to have
the same value in all re-fragmented fragments. This way, even if
fragments are re-fragmented, the receiver knows they have initially
all started from the same packet.
Note how we get the offsets from the data sizes:
0.
0 + 1480/8 = 185
185 + 1000/8 = 310
310 + 1480/8 = 495
We can use the last offset and last data size to calculate the total
data size: 495*8 + 540 = 3960 + 540 = 4500.
Reassembly
A receiver knows that a packet is a fragment if at least one of the
following conditions is true:
- The "more fragments" flag is set. (This is true for all fragments except the last.)
- The "fragment offset" field is nonzero. (This is true for all fragments except the first.)
The receiver identifies matching fragments using the foreign and local
internet address, the protocol ID, and the identification field. The
receiver will reassemble the data from fragments with the same ID
using both the fragment offset and the more fragments flag. When the
receiver receives the last fragment (which has the "more fragments"
flag set to 0), it can calculate the length of the original data
payload, by multiplying the last fragment's offset by eight, and
adding the last fragment's data size. In the example above, this
calculation was 495*8 + 540 = 4500 bytes.
When the receiver has all the fragments, it can put them in the
correct order, by using their offsets. It can then pass their data up
the stack for further processing.
As for the reserved bit, it is reserved and must be zero and has no special significance.