Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 12: Networks


❑ versionspecifies the IP protocol version used. Currently, this field accepts the value 4 or 6. On
hosts that support both versions, the version used is indicated by the transmission protocol iden-
tifier discussed in the previous chapter; this identifier also holds different values for the two
versions of the protocol.
❑ IHLdefines the header length, which is not always the same owing to the variable number of
options.
❑ CodepointorType of Serviceis required for more complex protocol options that need not con-
cern us here.
❑ Lengthspecifies thetotal lengthof the packet, in other words, the length of the header plus data.
❑ Thefragment IDidentifies the individual parts of a fragmented IP packet. The fragmenting sys-
tem assigns thesamefragment ID to all parts of an original packet so that they can be identified
as members of the same group. The relative arrangement of the parts is defined in thefragment
offsetfield. The offset is specified in units of 64 bits.
❑ Three status bits (flags) enable and disable specific characteristics; only two of them are used.

❑ DFstands fordon’t fragmentand specifies that the packet must not be split into smaller units.
❑ MFindicates that the present packet is a fragment of a larger packet and is followed by other
fragments (the bit is set for all fragments but the last).

The third field is ‘‘reserved for future use,’’ which is very unlikely in view of the presence of
IPv6.
❑ TTLstands forTime to Liveand specifies the number of intermediate stations (or hops) along the
route to the receiver.^15
❑ Protocolidentifies the higher-layer protocol (transport layer) carried in the IP datagram. For
example, there are unique values for TCP and UDP.
❑ Checksumcontains a checksum calculated on the basis of the contents of the header and the data.
If the specified checksum does not match the figure calculated upon receipt, the packet is dis-
carded because a transmission error has occurred.
❑ srcanddestspecify the 32-bit IP address of the source and destination.
❑ optionsis used for extended IP options, not discussed here.
❑ dataholds the packet data (payload).

All numeric values in the IP header must be in network byte order (big endian).

In the kernel sources the header is implemented in theiphdrdata structure:

<ip.h>
struct iphdr {
#if defined(__LITTLE_ENDIAN_BITFIELD)
__u8 ihl:4,
version:4;
#elif defined (__BIG_ENDIAN_BITFIELD)
__u8 version:4,

(^15) In the past, this value was interpreted as the maximum lifetime in seconds.

Free download pdf