The Linux Programming Interface

(nextflipdebug5) #1

1186 Chapter 58


(Each IP fragment is itself an IP datagram that contains an offset field giving the
location of that fragment within the original datagram.)
IP fragmentation occurs transparently to higher protocol layers, but nevertheless
is generally considered undesirable ([Kent & Mogul, 1987]). The problem is that,
because IP doesn’t perform retransmission, and a datagram can be reassembled at
the destination only if all fragments arrive, the entire datagram is unusable if any
fragment is lost or contains transmission errors. In some cases, this can lead to signif-
icant rates of data loss (for higher protocol layers that don’t perform retransmission,
such as UDP) or degraded transfer rates (for higher protocol layers that do perform
retransmission, such as TCP). Modern TCP implementations employ algorithms
(path MTU discovery) to determine the MTU of a path between hosts, and accord-
ingly break up the data they pass to IP, so that IP is not asked to transmit datagrams
that exceed this size. UDP provides no such mechanism, and we consider how UDP-
based applications can deal with the possibility of IP fragmentation in Section 58.6.2.

58.5 IP Addresses


An IP address consists of two parts: a network ID, which specifies the network on
which a host resides, and a host ID, which identifies the host within that network.

IPv4 addresses
An IPv4 address consists of 32 bits (Figure 58-5). When expressed in human-readable
form, these addresses are normally written in dotted-decimal notation, with the 4 bytes of
the address being written as decimal numbers separated by dots, as in 204.152.189.116.

Figure 58-5: An IPv4 network address and corresponding network mask

When an organization applies for a range of IPv4 addresses for its hosts, it receives
a 32-bit network address and a corresponding 32-bit network mask. In binary form,
this mask consists of a sequence of 1s in the leftmost bits, followed by a sequence of
0s to fill out the remainder of the mask. The 1s indicate which part of the address
contains the assigned network ID, while the 0s indicate which part of the address is
available to the organization to assign as unique host IDs on its network. The size
of the network ID part of the mask is determined when the address is assigned.
Since the network ID component always occupies the leftmost part of the mask, the
following notation is sufficient to specify the range of assigned addresses:

204.152.189.0/24

The /24 indicates that the network ID part of the assigned address consists of the
leftmost 24 bits, with the remaining 8 bits specifying the host ID. Alternatively, we
could say that the network mask in this case is 255.255.255.0 in dotted-decimal notation.

Network ID

all 1s

Host ID

all 0s

32 bits
Network address

Network mask
Free download pdf