IP is a datagram protocol for internetworks, but it was introduced for use on the Internet.
The Internet consists of a series of interconnected networks, which internally
may be of switched or broadcast nature, linked by IP routers. IP is intended to
allow communication between any two hosts connected to the Internet, whether
they are on the same or separate networks. An IP datagram will, therefore,
typically cross several networks, encountering gateways called
IP routers.
There is no concept of setup or closedown and no attempt to track sequences of
related packets either on an individual link, or over the path of a message.
The one exception to this is where it is necessary to fragment a single
datagram to allow it to cross a network with a
maximum transmission unit (MTU) (the largest IP packet that will fit into the
network's biggest allowable frame), too small to
accommodate it as a single PDU. In this case, the router where the datagram
enters the network performs the fragmentation, and
the fragments are reassembled later within the IP layer at the destination.
Before proceeding further, let
us see what an IP datagram looks like. The IP protocol used at present is
version 4 (IPv4) and all IPv4 datagrams have the same format, shown in Figure 1. This
consists of a fixed header, five 32-bit words in length, followed by a
variable length options field, which may be omitted, and a variable amount of
data. Datagrams are sent, most significant bits first
(in the diagram these are on the left). The fields in the header are explained
below.
Figure
1 IPv4 datagram
Version is a 4-bit IP version
number (4 for IPv4).
IHL is the 4-bit Internet
header length, quoted as a number of 32-bit words. The minimum value is 5.
Until recently this was known
as Type of service, which theoretically allowed the choice of various levels of
reliability and speed. However the mechanisms for using it were never outlined
and the field was so little used that IETF has redefined it as part of its
standardisation of differentiated services (DiffServ).
The field is now used to carry a 6-bit differentiated services code point (DSCP) which is
interpreted at each router
Total length is the length of
the whole datagram in bytes. The maximum length is 216 but some
networks will set an MTU lower than this.
Identifier is unique for any
outstanding datagram passing between two IP addresses.
The
Flags field comprises 3
bits, one of which is unused. The others are used to control and track datagram
fragmentation in those subnets where it is necessary. The normal approach is to
fragment the datagram, and to use the MF (More Fragments) flag, which is set in
all fragments but the last. All fragments must carry the same Identifier as the
original. The last of the flags,
DF (Don’t
Fragment) prevents fragmentation. However, if a datagram with this flag set
attempts to enter a subnet whose MTU is too small, it will be discarded. Care
must therefore be taken to route such datagrams
around any problem subnets.
Fragment Offset (13 bits)
indicates the position of the current fragment in the original datagram, and is
used for reassembly. It is measured in 64-bit units.
Time-to-live (8-bits) is
decremented at each hop. When it reaches zero, the datagram is discarded and a
warning packet is sent back to the source. This prevents datagrams
from wandering round in the network for indefinite periods, if anything goes
wrong with the routing mechanism.
Protocol indicates which transport protocol (e.g TCP or UDP) will handle the datagram when it arrives. Internet protocols are numbered in RFC 1700 (e.g TCP is number 6, UDP is number 17).
Header checksum is an error
detection field computed on the header only, by taking the one’s complement sum
of all the 16-bit half-words, with the checksum itself omitted. Note that this
checksum must be recomputed at every node, because, of course, the header
changes at every node, since, at the very least, Time to live is always
decremented.
The
Source and Destination
addresses are simply the IP numbers of the originating and receiving hosts.
The Options field encodes a number of optional features that IP may employ.
The IP service has only two primitives, SEND, and DELIVER. SEND includes parameters which map exactly onto the features just discussed, and the service user specifies all information required to generate the IP header.