Packet Fragmenting

IP packets are fragmented into smaller units by ip_fragment, as shown in Figure 12-20.

IP

TCP

i Payload

;

! i i

IP

TCP

®

IP

©

IP

©

IP

0

Figure 12-20: Fragmenting of an IP packet.

Figure 12-20: Fragmenting of an IP packet.

IP fragmenting is very straightforward if we ignore the subtleties documented in RFC 791. A data fragment, whose size is compatible with the corresponding MTU, is extracted from the packet in each cycle of a loop. A new socket buffer, whose old IP header can be reused with a few modifications, is created to hold the extracted data fragment. A common fragment ID is assigned to all fragments to support reassembly in the destination system. The sequence of the fragments is established on the basis of the fragment offset, which is also set appropriately. The more fragments bit must also be set. Only in the last packet of the series must this bit be set to 0. Each fragment is sent using ip_output after ip_send_check has generated a checksum.22

21 The kernel also uses a hard header cache. This holds frequently needed hardware headers that are copied to the start of a packet. If the cache contains a required entry, it is output using a cache function that is slightly faster than dst->neighbour->output.

22ip_output is invoked via a function pointer passed to ip_fragment as a parameter. This means, of course, that other send functions can be selected. The bridging subsystem is the only user of this possibility, and is not discussed in more detail.

Continue reading here: Routing

Was this article helpful?

0 0