21.5 IP DATAGRAM FORMAT

 < Day Day Up > 



21.5 IP DATAGRAM FORMAT

The IP that runs on most of the hosts and routers on the Internet is IP Version 4 (IPv4). Gradually, the IP software will be upgraded to IP Version 6 (IPv6). We will first study the IPv4 and then study IPv6.

The basic unit of data transfer is called datagram in IP Version 4 and a packet in IP Version 6. We will use the words datagram and packet interchangeably in the following discussion. The datagram of IPv4 has a header and the data fields. The detailed format of the datagram is shown in Figure 21.2. Each of the fields is explained.

click to expand
Figure 21.2: IPv4 datagram format.

Version number (4 bits): Version number of the IP. The version presently running in most of the systems is Version 4. Version 6 is now slowly being deployed. This field ensures that the correct version of the software is used to process the datagram.

Header length (4 bits): Length of the IP header in 32-bit words. Note that some fields in the header are variable, and so the IP datagram header length may vary. The minimum length of the header is 20 bytes, and so the minimum value of this field is 5.

Service type (8 bits): These bits specify how the datagram has to be handled by systems. The first three bits specify the precedence—0 indicating normal precedence and 7 network control. Most routers ignore these bits, but if all the routers implement it, these bits can be used for providing precedence to send control information such as congestion control. The 4th, 5th, and 6th bits are called D, T, and R bits. Setting D bit is to request low delay, setting T bit is to request high throughput, and setting R bit is to request high reliability. However, it is only a request; there is no guarantee that the request will be honored. Note that these bits are to set the quality of service (QoS) parameters. there is no guarantee that the required QoS will be provided. That is the reason we keep hearing that sentence "IP does not guarantee a desired QoS".

Length (16 bits): Total length of the datagram in bytes including header and data. The length of the data field is calculated by subtracting the header length from the value of this field. Since 16 bits is allotted to this field, the maximum size of an IP datagram is limited to 65,535 bytes.

Note that the IP datagram size is much larger than can be accommodated by a LAN that can handle only 1526 bytes in one frame for instance. In such a case, the datagram has to be fragmented and sent over the network. The minimum datagram size that every host and router must handle is 576 bytes. Each fragment contains most of the original datagram header. The fragmentation is done at routers, but the reassembly is done at the destination.

Note 

The minimum datagram size every host and router must handle is 576 bytes. If larger datagrams are received, they may need to be fragmented and reassembled.

Identification (16 bits): Unique ID to identify the datagram. This field lets the destination know which fragment belongs to which datagaram. The source address, destination address, and identification together uniquely identify the datagram on the Internet.

Flags (3 bits): If the first bit, called the do-not-fragment bit, is set to 1, this is to indicate that the datagram should not be fragmented. If a router cannot handle the datagram without fragmenting it, the datagram is discarded, and an error message is sent to the source. The second bit is called the more-fragments bit and is set to 0 to indicate that this is the last fragment. The third bit remains unused.

start example

The time-to-live field is used to ensure that a datagram does not go round and round in the network without reaching its destination. Every router decrements this field by 1, and if a router receives a datagram with this field value of 0, the datagram is discarded.

end example

Fragment offset (3 bits): Specifies the offset of the fragment in the datagram, measured in 8 octets (one octet is 8 bits), starting at offset 0. The destination receives all the fragments and reassembles the fragments using the offset value, starting with 0 to the highest value.

Time-to-live (12 bits): It may happen that a packet on the Internet may go round and round without reaching the destination, particularly when using the dynamic routing algorithms. To avoid such unnecessary traffic, this field is very useful. This field contains the number of hops a packet can travel. At every router, this field is decremented by 1, and either the packet reaches the destination before the field becomes 0 or, if it reaches 0 earlier, it is discarded. The default hop count is 64—the packet can traverse at most through 64 routers.

Note 

It is possible for some packets to be discarded by a router and IP is said to provide an unreliable service. The TCP has to take care of the lost datagrams by asking for retransmission.

Protocol (8 bits): The protocol field specifies which higher layer protocol is encapsulated in the data area of the IP packet. The higher layer protocol can be TCP or UDP.

Header checksum (16 bits): The bit pattern is considered as a 16-bit integer, and these bit patterns are added using one's complement arithmetic. The one's complement of the result is taken as the header checksum. Note that checksum is calculated only for the header, and this value has to be calculated at each router because some of the fields in the header change at each router. For calculation of the checksum, this field is considered to be having all zeros.

Source IP address (32 bits): This field contains the IP address of the source that is sending the datagram.

Destination IP address (32 bits): This field contains the IP address of the final destination.

Options: This is a variable-length field. This field contains data for network testing and debugging. The format for the option field is option code of one octet followed by data for the option. These options are for operations such as recording the route of a datagram, timestamping a datagram along the route, and source routing that specifies the route to be taken by the datagram.

When the record route option is set, each router adds its IP address in the options field and then forwards it. When the source route option is set and the IP addresses of all the hops are mentioned in the options field, the datagram takes only that route. This is not of any significance from an end user point of view but network administrators use it for finding the throughput of the specific paths. However, one needs to know the topology of the network to specify the source routing.

When the timestamp option is set, each router inserts its IP address (32 bits, which again is optional) and timestamp (32 bits) in the options field, which can be analyzed at the destination.

Padding (8 bits): To make the IP header an exact multiple of 32 bits, the padding bits are added if required.

Data (variable): This is a variable field whose length is specified in the datagram header. It should be an integer multiple of 8 bits.



 < Day Day Up > 



Principles of Digital Communication Systems and Computer Networks
Principles Digital Communication System & Computer Networks (Charles River Media Computer Engineering)
ISBN: 1584503297
EAN: 2147483647
Year: 2003
Pages: 313
Authors: K V Prasad

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net