IP Datagram Format: A Comprehensive Breakdown

IP Datagram Format

IP Datagram Format 2.5 dl (i): The IP datagram is the data base for data transfer, containing origin and destination information. It travels through the data field, which changes physically as it traverses networks. Each datagram can traverse multiple routers. The physical plot of the network it leaves will adapt to the data field of the next network. This mechanism allows the same IP datagram to traverse distinct networks, such as point-to-point links, ATM networks, Ethernet networks, and Token Ring networks.

The IP datagram also has a data field where the packets of superior layers travel.

Datagram Fields

  • Version (4 bits): Indicates the protocol version used to create the IP datagram. The current version is 4 (IPv4), and version 6 (IPv6) is being developed.
  • Length (4 bits): The header length, expressed in multiples of 32 bits. The minimum is 5, resulting in 160 bits = 20 bytes.
  • Type of Service (8 bits): This field is divided into:
    • Priority (3 bits): A value of 0 indicates low priority, and a value of 7 indicates top priority.
    • The next 3 bits indicate how to prioritize the message. These are suggestions for routers to consider when finding a path.
      • Bit D (Delay): Requests a short (fast) route.
      • Bit T (Throughput): Requests high throughput (send much data in the shortest time possible).
      • Bit R (Reliability): Requests minimizing the probability of the datagram being lost or damaged.
    • The following 2 bits are not in use.
  • Total Length (16 bits): Indicates the total length of the datagram in bytes. With 16 bits, the maximum possible datagram length is 65,535 bytes.
  • Identification (16 bits): A sequence number that, along with the origin and destination addresses, uniquely identifies a datagram across the network. If a datagram is fragmented, all fragments will have the same identification.
  • Flags (3 bits): Only 2 of the 3 available bits are currently used:
    • MF (More Fragments): Indicates that it is not the last datagram fragment.
    • DF (Don’t Fragment): Prohibits fragmentation of the datagram. If this bit is enabled and a network requires fragmentation, the datagram will be discarded.
  • Fragmentation Offset (13 bits): Indicates the position where the current fragment should be inserted within the complete datagram, measured in units of 64 bits. Therefore, the data fields of all fragments except the last one must be a multiple of 64-bit length. If the packet is not fragmented, this field has a value of zero.
  • Time to Live (TTL) (8 bits): The maximum number of routers that the datagram can traverse in the network (30 by default). Each time a datagram traverses a router, this number is decremented by 1. When it reaches zero, the datagram is discarded, and an ICMP time exceeded message is sent to the origin to inform of the incident.
  • Protocol (8 bits): Indicates the protocol used in the data field: 1 for ICMP, 2 for IGMP, 6 for TCP, and 17 for UDP.
  • Header Checksum (16 bits): Contains a checksum for error testing of the datagram header only. Error verification of the data corresponds to superior layers.
  • Source Address (32 bits): Contains the IP address of the origin.
  • Destination Address (32 bits): Contains the IP address of the destination.
  • IP Options: This field is not mandatory and specifies options requested by the user sending the data (generally for tests and network debugging).
  • Padding: If the IP options (if they exist) do not occupy a multiple of 32 bits, this field is completed with additional bits to reach a multiple of 32 bits (the header length must be a multiple of 32 bits).