IP Datagram

A IP datagram is a unit of data transmitted using the IP protocol, following a specific format which describes various aspects of the datagram, its source and its destination.

The IPv4 datagram consists of the following headers and fields:

Bits Name Description
4 VERS  IP version number 0100 (4) or 0110 (6).
4 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.
8 Type of Service The TOS field.
16 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.
16 Identification  The Identification is a unique number assigned to a datagram fragment to help in the reassembly of fragmented datagrams.
3 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).
13 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.
8 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.
8 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.
16 Header Checksum  Header checksum error control.
?? IP Options  Optional field for testing, debugging and security.
?? Data  Packet contents, actual data.
?? Padding  Optionally, padding is added to make the datagram into multiples of 32 bits.