Data Network Resource
       Earn on the Web

The IP Datagram

Structure of the IP Datagram

The IP datagram looks like this:

IP Datagram

The datagram fields are clarified below:
  • VERS - is the IP version number (currently binary 0100 (4), but can now also be version 6). All nodes must use the same version.
  • HLEN - header length in 32-bit words, so if the number is 6, then 6 x 32 bit words are in the header i.e. 24 bytes. The maximum size is 15 x 32-bit words which is 60 bytes. The minimum size is 20 bytes or 5 x 32-bit words.
  • Type of Service - is how the datagram should be used, e.g. delay, precedence, reliability, minimum cost, throughput etc. This TOS field is now used by Differentiated Services and is called the Diff Serv Code Point (DSCP).
  • Total Length - is the number of octets that the IP datagram takes up including the header. The maximum size that an IP datagram can be is 65,535 octets.
  • Identification - The Identification is a unique number assigned to a datagram fragment to help in the reassembly of fragmented datagrams.
  • Flags - Bit 0 is always 0 and is reserved. Bit 1 indicates whether a datagram can be fragmented (0) or not (1). Bit 2 indicates to the receiving unit whether the fragment is the last one in the datagram (1) or if there are still more fragments to come (0).
  • Frag Offset - in units of 8 octets (64 bits) this specifies a value for each data fragment in the reassembly process. Different sized Maximum Transmission Units (MTUs) can be used throughout the Internet.
  • TTL - the time that the datagram is allowed to exist on the network. A router that processes the packet decrements this by one. Once the value reaches 0, the packet is discarded.
  • Protocol - Layer 4 protocol sending the datagram, UDP uses the number 17, TCP uses 6, ICMP uses 1, IGRP uses 88 and OSPF uses 89.
  • Header Checksum - error control for the header only.
  • IP Options - this field is for testing, debugging and security.
  • Padding - there is padding added sometimes just to make sure that the datagram is confined within a 32 bit boundary in multiples of 32 bits.
RFC 791 describes IP in detail.

IP Options

There may, or may not be an option field. If there is one, it can vary in length.

The option field contains an Option-Type octet, an Option-Length octet and a variable number of Option-data octets.

IP Options

  • Option-Type
    • Copied Flag - 0 indicates that the option is NOT to be copied to each fragment if the datagram is fragmented. A 1 indicates that the option IS to be copied.
    • Option Class - 0 is used for Control (used normally) and 2 is used for debugging and measurement used for the Internet Timestamp option.
    • Option Number
      • 0 - Special case indicating the end of the option list, in this case the option field is just one octet as no length or data fields are present.
      • 1 - No Operation, again the option field is just one octet with no length or data fields.
      • 2 - Security the length is 11 octets and the various security codes can be found in RFC 791.
      • 3 - Loose Source Routing which is IP routing based on information supplied by the source station where the routers can forward the datagram to any number of intermediate routers in order to get to the destination.
      • 4 - Internet Timestamp
      • 7 - Record Route records the route that a datagram takes.
      • 8 - Stream ID has a length of 4 octets.
      • 9 - Strict Source Routing which is IP routing based on information supplied by the source station where the routers can only forward the datagram to a directly connected router in order to get to the next hop indicated in the source route path.
  • Option-Length - variable and not present for the NOP and the end of Option List
  • Option-Data - variable and not present for the NOP and the end of Option List. See RFC 791 for the detail on the data content for each of the Options.
IP Options are not often used today, you may come across IP source-routing (loose or strict) on Unix machines and the like, perhaps for load balancing traffic where modern routing protocols are not being used.

Type of Service (TOS) Field

The following diagram illustrates the TOS field in detail:

TOS Field
Precedence - The following table details the precedence bits and their possible values:
  • 000 (0) - Routine
  • 001 (1) - Priority
  • 010 (2) - Immediate
  • 011 (3) - Flash
  • 100 (4) - Flash Override
  • 101 (5) - Critical
  • 110 (6) - Internetwork Control
  • 111 (7) - Network Control
Now the TOS bits themselves:
  • Delay - when set to '1' the packet requests low delay.
  • Throughout - when set to '1' the packet requests high throughput.
  • Reliability - when set to '1' the packet requests high reliability.
  • Cost - when set to '1' the packet has a low cost.
  • MBZ - checking bit.
The thing to remember with the TOS bits is that bits set to 1 basically help speed up the packet flow.

Type of Service (TOS) has never really been used despite being part of TCP/IP for a long time. It has three parameters, Delay, Throughput and Reliability. TOS Application Routing is supported by OSPF and IS-IS but no application really supports it

RFC 791 describes TOS with the IP Precedence values and RFC 1583 describes TOS Application Routing.

The TOS field has been redefined as the Differentiated Services Code Point (DSCP) which consists of the first 6 bits and 2 unallocated. For more detail on IP Precedence and DSCP see Quality of Service.

For a comprehensive list of IANA assignments for ports, protocols etc. go to

Valid HTML 4.01 Transitional

Earn on the Web    

All rights reserved. All trademarks, logos, and copyrights are property of their respective owners.