IP Datagram: an Analysis

An IP datagram's format is most generally broken down into two parts: the Header and the Data. Below is a simplistic view of an IP datagram:

Datagram Header Datagram Data Area


Of course, things never tend to be as simplistic as we'd like them to be. An actual datagram (while still divided into two main parts) can be further broken down into the following parts:

0 4 8 12 16 19 24 31
Version Header Length Service Type Total Length
Identification Flags Fragment Offset
Time to Live Protocol Header Checksum
Source IP Address
Destination IP Address
IP Options (if any) Padding
Data
...


The numbers above the IP datagram represent bit ranges (offsets). The first bit range covers the first to the fourth bit, and so on until you end at 31. Of course, this is a rather simplistic view as well, but it should suffice for now.

As seen from an ethernet's point of view:

IP: ----- IP Header -----
IP:
IP: Version=4
IP: Header length=20 bytes
IP: Type of service=0x00
IP: xxx. ....=0 (precedence)
IP: ...0 ....=normal delay
IP: .... 0...=normal throughput
IP: .... .0..=normal reliability
IP: Total length=84 bytes
IP: Identification=21003
IP: Flags=0x0
IP: .0.. ....=may fragment
IP: ..0. ....=last fragment
IP: Fragment offset=0 bytes
IP: Time to live=253 seconds/hops
IP: Protocol=1 (ICMP)
IP: Header checksum=4647
IP: Source address=192.69.70.2, mars
IP: Destination address=252.202.70.35, venis
IP: No options
IP:

The following chart explains what each part of the IP datagram plays:

Version (4-bits) The Version of the IP Protocol being used
Header Length (4-bits) Length of IP header
Service Type (8-bit) Specifies how the datagram should be handled
Total Length (16-bit) Total length of datagram
Identification (16-bit) Fragmentation control. Allows destination to know which fragments belong to which datagrams.
Flags (3-bit) More frag control. Marks where, in the datagram, a fragment belongs.
Fragment Offset (13-bit) Specifies the offset of the fragmented data in the original datagram.
Time to Live (8-bit) How long, in seconds, a datagram can remain in an internet (AKA: TTL).
Protocol (8-bit) Specifies which high-level protocol created the message. e.g., FTP.
Header Checksum (16-bit) Computational field to ensure header value integrity.
Source of IP Address (32-bit) Datagram's sender's IP Address
Destination of IP Address (32-bit) Datagram's intended recipient's IP Address
IP Options (x-bit) An unrequired field. Mostly used for testing.
Padding (32 - x-bit) As the size indicates, it fills whatever of the 32-bits is not used by the IP Options field.
Data (32-bit) This is where the Header ends and the actual Data is stored.
... Loose ends...
*** Currently, the maximum size of an IP datagram is 65,535 octets.