IP Datagram General Format
IP Datagram General Format
(Page 1 of 3)
3/8
Flags
(3 bits)
Fragment Offset: When fragmentation of a message occurs,
this field specifies the offset, or position, in the overall
Fragment 1 5/8 message where the data in this fragment goes. It is specified
Offset (13 bits) in units of 8 bytes (64 bits). The first fragment has an offset of
0. Again, see the discussion of fragmentation for a description
of how the field is used.
TTL 1 Time To Live (TTL): Short version: Specifies how long the
datagram is allowed to “live” on the network, in terms of router
hops. Each router decrements the value of the TTL field
(reduces it by one) prior to transmitting it. If the TTL field drops
to zero, the datagram is assumed to have taken too long a
route and is discarded.
Protocol 1
Header Checksum: A checksum computed over the header to
provide basic protection against corruption in transmission.
This is not the more complex CRC code typically used by data
link layer technologies such as Ethernet; it's just a 16-bit
Header checksum. It is calculated by dividing the header bytes into
2
Checksum words (a word is two bytes) and then adding them together.
The data is not checksummed, only the header. At each hop
the device receiving the datagram does the same checksum
calculation and on a mismatch, discards the datagram as
damaged.
Source 4 Source Address: The 32-bit IP address of the originator of the
Address datagram. Note that even though intermediate devices such as
routers may handle the datagram, they do not normally put
their address into this field—it is always the device that
originally sent the datagram.
Destination Address: The 32-bit IP address of the intended
Destination recipient of the datagram. Again, even though devices such as
4
Address routers may be the intermediate targets of the datagram, this
field is always for the ultimate destination.
Options: One or more of several types of options may be
Options Variable included after the standard headers in certain IP datagrams. I
discuss them in the topic that follows this one.
Padding: If one or more options are included, and the number
of bits used for them is not a multiple of 32, enough zero bits
Padding Variable
are added to “pad out” the header to a multiple of 32 bits (4
bytes).
Data: The data to be transmitted in the datagram, either an
Data Variable
entire higher-layer message or a fragment of one.
Figure 86: Internet Protocol Version 4 (IPv4) Datagram Format
This diagram shows graphically the all-important IPv4 datagram format. The first 20
bytes are the fixed IP header, followed by an optional Options section, and a variable-
length Data area. Note that the Type Of Service field is shown as originally defined in
the IPv4 standard.
That’s a pretty big table, because the IP datagram format is pretty important
and has a lot of fields that need explaining. To keep it from being even longer,
I decided to move a couple of the more complex descriptions out of the table.
IP Datagram General Format
(Page 2 of 3)
Since IP datagrams are sent from router to router as they travel across an
internetwork, it is possible that a situation could result where a datagram gets
passed from router A to router B to router C and then back to router A. Router
loops are not supposed to happen, and rarely do, but are possible.
In practice, this field is not used in exactly this manner. Routers today are fast
and usually take far less than a second to forward a datagram; measuring the
time that a datagram “lives” would be impractical. Instead, this field is used as
a “maximum hop count” for the datagram. Each time a router processes a
datagram, it reduces the value of the TTL field by one. If doing this results in
the field being zero, the datagram is said to have expired. It is dropped, and
usually an ICMP Time Exceeded message is sent to inform the originator of
the message that this happened.
3/8
Precedence
(3 bits)
1/8 Delay: Set to 0 to request “normal” delay in delivery; set to 1 if
D
(1 bit) low delay delivery is requested.
1/8 Throughput: Set to 0 to request “normal” delivery throughput;
T
(1 bit) set to 1 if higher throughput delivery is requested.
1/8 Reliability: Set to 0 to request “normal” reliability in delivery; set
R
(1 bit) to 1 if higher reliability delivery is requested.
2/8
Reserved Reserved: Not used.
(2 bits)
The IETF, seeing the field unused, attempted to revive its use. In 1998, RFC
2474 redefines the first six bits of the TOS field to support a technique
called Differentiated Services (DS). Under DS, the values in the TOS field are
called codepoints and are associated with different service levels. This starts
to get rather complicated, so refer to RFC 2474 if you want all the details.