The IPv4 (Internet Protocol) Header
The IPv4 (Internet Protocol) Header
Version field
• The Version field keeps track of which version of the protocol the
datagram belongs to.
• By including the version at the start of each datagram, it becomes
possible to have a transition between versions over a long period of
time.
IHL
• Since the header length is not constant, a field in the header, IHL, is
provided to tell how long the header is, in 32-bit words.
• The minimum value is 5, which applies when no options are present.
The maximum value of this 4-bit field is 15, which limits the header to
60 bytes, and thus the Options field to 40 bytes.
Differentiated services
• Originally, it was called the Type of service field. It was and still is
intended to distinguish between different classes of service. Various
combinations of reliability and speed are possible. For digitized voice,
fast delivery beats accurate delivery. For file transfer, error-free
transmission is more important than fast transmission. The Type of
service field provided 3 bits to signal priority and 3 bits to signal
whether a host cared more about delay, throughput, or reliability.
However, no one really knew what to do with these bits at routers, so
they were left unused for many years. When differentiated services
were designed, IETF threw in the towel and reused this field. Now, the
top 6 bits are used to mark the packet with its service class. The
bottom 2 bits are used to carry explicit congestion notification
information, such as whether the packet has experienced congestion.
Total length
• The Total length includes everything in the datagram—both header
and data.
• The maximum length is 65,535 bytes. At present, this upper limit is
tolerable, but with future networks, larger datagrams may be needed.
Identification
• The Identification field is needed to allow the destination host to
determine which packet a newly arrived fragment belongs to. All the
fragments of a packet contain the same Identification value.
DF
• DF stands for Don’t Fragment.
• It is an order to the routers not to fragment the packet.
• Originally, it was intended to support hosts incapable of putting the
pieces back together again. Now it is used as part of the process to
discover the path MTU, which is the largest packet that can travel
along a path without being fragmented.
MF
• MF stands for More Fragments.
• All fragments except the last one have this bit set. It is needed to
know when all fragments of a datagram have arrived.
Fragment offset
• The Fragment offset tells where in the current packet this fragment
belongs.
• All fragments except the last one in a datagram must be a multiple of
8 bytes, the elementary fragment unit. Since 13 bits are provided,
there is a maximum of 8192 fragments per datagram, supporting a
maximum packet length up to the limit of the Total length field.
Working together, the Identification, MF, and Fragment offset fields
are used to implement fragmentation.
Time to live
• The TtL (Time to live) field is a counter used to limit packet lifetimes.
• It was originally supposed to count time in seconds, allowing a
maximum lifetime of 255 sec. It must be decremented on each hop
and is supposed to be decremented multiple times when a packet is
queued for a long time in a router. In practice, it just counts hops.
• When it hits zero, the packet is discarded and a warning packet is sent
back to the source host. This feature prevents packets from
wandering around forever, something that otherwise might happen if
the routing tables ever become corrupted.
Protocol
• The Protocol field tells it which transport process to give the packet
to.
• TCP is one possibility, but so are UDP and some others. The
numbering of protocols is global across the entire Internet.
Header checksum
• Since the header carries vital information such as addresses, it rates
its own checksum for protection, the Header checksum. The
algorithm is to add up all the 16-bit halfwords of the header as they
arrive, using one’s complement arithmetic, and then take the one’s
complement of the result. For purposes of this algorithm, the Header
checksum is assumed to be zero upon arrival. Such a checksum is
useful for detecting errors while the packet travels through the
network. Note that it must be recomputed at each hop because at
least one field always changes (the Time to live field), but tricks can
be used to speed up the computation.
Source address and Destination address
• The Source address and Destination address indicate the IP address of
the source and destination network interfaces.
Options
• The Options field was designed to provide an escape to allow
subsequent versions of the protocol to include information not
present in the original design, to permit experimenters to try out new
ideas, and to avoid allocating header bits to information that is rarely
needed. The options are of variable length. Each begins with a 1-byte
code identifying the option. Some options are followed by a 1-byte
option length field, and then one or more data bytes. The Options
field is padded out to a multiple of 4 bytes. Originally, the five options
listed in Fig. 5-47 were defined.
Some of the IP options