Packet Fragment (Frag) Object
A-14
A.4 Packet Fragment (Frag) Object
A.4.1 Synopsis
A Fragment object is a container for packet data. The concept behind the frag
is that a packet data buffer can be represented by the following properties:
-
A pool from which the packet buffer was allocated
-
A pointer to the packet data buffer
-
The size (total byte capacity) of the buffer
-
The size (in bytes) of the data which is currently valid in the buffer
-
The offset from the start of the buffer to the current valid data
-
An “invisible” amount of padding at the end of the buffer (only used when
buffer is allocated)
When a packet buffer is properly created, sufficient room is left at the head of
the buffer to insert network protocol headers. In most cases, only the minimum
header size will be allocated. Applications building packets that will use things
like IP options, must specify the size of the options in advance. When the buffer
is allocated, the offset parameter contains the cumulative size of all the re-
served space. The data payload is copied to this offset.
As network layers are added on the packet, the offset is decreased according
to the size requirements of the packet. A protocol can check to see if its header
has already been incorporated into the packet by checking the packet status
flags (as discussed in the previous section). IP is intended to deviate from strict
layering restrictions such that any code can build any portion of the packet
header it wishes.
The figure below illustrates this concept. The five parameters illustrated (buffer
pointer, buffer size, offset, valid size, and pad) along with the buffer pool indica-
tor make up a FRAG object.