Network Layer – Introduction To IP Protocol (IPv4 version of IP)

In the last post we have seen the ARP (Address Resolution Protocol) in detail. Now we should proceed further to understand the other important protocols of this layer. So in this post, we mainly concentrate on the IP protocol of the Network layer.

This is the host to host a delivery protocol that belongs to the network layer and is designed for the Internet. The Internet has chosen the datagram approach to switch in the network layer.

It uses the universal addresses defined in the network layer to route packets from the source to the destination

IP is a connectionless datagram protocol with no guarantee of reliability. It is an unreliable protocol because it does not provide any error control or flow control. 

IP can only detect the error and discards the packet if it is corrupted. IPv4 assumes the unreliability of the underlying layers and does its best to get a transmission through to its destination, but with no guarantees.

If IP is to be made more reliable, then it must be paired with a reliable protocol such as TCP at the transport layer. Each IP datagram is handled independently and each one can follow a different route to the destination. So there is a possibility of receiving out of order packets at the destination.

Some packets may even be lost or corrupted. IP relies on a higher level protocol to take care of all these problems.Let us take one example first.

An example (consider IP in place of the post office) of a more commonly understood best-effort delivery service (i.e the service used by the IP) is the post office.

The post office does its best to deliver the mail but does not always succeed. If an unregistered letter is lost, it is up to the sender or would-be recipient to discover the loss and rectify the problem. The post office itself does not keep track of every letter and cannot notify a sender of loss or damage.

What is a Datagram in IPv4 ?

Packets (of data) in IP layer are called datagrams. A datagram has two parts namely the header and data as shown. The length of datagram is not fixed. It varies from 20 bytes to 65536 bytes. 

The length of the header is 20 to 60 bytes. The information necessary for the routing and delivery of the datagram has been stored in the header. The other part of the datagram is the data field which is of variable length.

 

Network Layer - Introduction To IP Protocol (IPv4 version of IP)

Structure of IP Frame Header in IPv4 

The IP frame header contains routing information and control information associated with datagram delivery. The IP header structure is as shown below :

Network Layer - Introduction To IP Protocol (IPv4 version of IP)

Let us now see each of these fields in a brief manner :

VER (Version) : This 4 bit long field defines the version of IP. Current version of IP is IPv4 and the latest. The version of IP is IPv6.

HLEN (Header Length) : This field is 4 bit long and defines the length of the datagram header in 4-byte word. The value of this field multiplied by 4 to give the length in bytes.

Differential services (DS) : This is an 8 bit field. Its job is to define the class of the datagram for quality of service (QoS) purpose.

 Total length : This 16 bit field is used to define the total length of the IP datagram. The total length includes the length of the header as well as the data field. 

The field length of this fields is 16 bits so the total length of the IP datagram is restricted to 65535 bytes out of which 20 to 60 bytes constitute the header and the remaining bytes are reserved to carry data from upper layers.

              Length of data = Total length – Header length

Identification – This field is used to identify the datagram originating from the source host. When a datagram is fragmented. the contents of the identification field get copied into all fragments. This identification number is used by the destination to reassemble the fragments of the datagram.

Flags –  This is a three bit field. The 3 bits are: First bit is reserved, and it should be 0 , The second bit is known as the “Do Not Fragment” bit. If this bit is “1” then the machine understands that the datagram is not to be fragmented. The third bit is known as “More Fragment Bit (M). M = 1 indicates that the datagram is not the host fragment and M = 0 indicates that this is the last.

                Network Layer - Introduction To IP Protocol (IPv4 version of IP)

Fragmentation offset : This is a 13 bit field which is used to indicate the relative position of this fragment with respect to the  complete datagram . It is the offset of the data in the original datagram measured in units of 8 bytes. The original IP packet (datagram) contains 4000 bytes numbered from 0 to 3999. It is fragmented into three fragments.

Time to live : A datagram has a limited lifetime in its travel through the internet. This is an 8 bit length field which controls the maximum number of routers visited by the data.

Protocol :  This 8-bit field defines the higher-level protocol that uses the services of the IPv4 layer. This field defines the higher-level protocol which uses the services of the IP layer.

An IP datagram can encapsulate data from various higher-level protocols such as TCP, UDP, ICMP and IGMP. The protocol field specifies the final destination protocol to which the IP datagram should be delivered .

                                              

Value  Protocol
1 ICMP
2 IGMP
6 TCP
17 UDP
89 OSPF

Header checksum : A checksum in IP packet covers on the header only. Since some header fields change, this field is recomputed and verified at each point that the Internet header is processed .

Source address : This field is used for defining the IP address of the source. This field must remain unchanged during the time the IPv4 datagram travels .

Destination address :  This field is used for defining the IP address of the destination. This field must remain unchanged during the time the IPv4 datagram travels from the source host to the destination host.

Options : IP provides several optional features, allowing a packet’s sender to set requirements on the path it takes through the network (source routing), trace the route a packet takes (record route), and label packets with security features.

List of Services provided by the IP in the Network Layer

IP provides following services :

Addressing: IP headers contain 32-bit addresses which identify the sending and receiving hosts. These addresses are used by intermediate routers to select a path through the network for the packet.

Fragmentation : IP packets may be split, or fragmented, into smaller packets. This permits a large packet to travel across a network which can only handle smaller packets.

Packet timeout: Each IP packet contains a Time To Live (TTL) field, which is decremented every time a router handles the packet. If TTL reaches zero, the packet is discarded, preventing packets from running in circles forever and flooding a network.

Type of Service: IP supports traffic prioritization by allowing packets to be labeled with an abstract type of service.

Addressing in IPv4 

All the IP addresses are 32 bit long and they are used in the source address and destination address fields of the IP header. The IP address format consists of two fields called Network ID and Host ID . 

An IP address consists of two parts. The first part of the address, called the network number, identifies a network on the internet, the remainder called the host ID, identifies an individual host on that network.

Address Space in IPv4

The IPv4 protocol has an address space. It is defined as the total number of addresses used by the protocol. The 32 bit IPv4 address is grouped into groups of eight bits, separated by dots.

Each 8 bit group is then converted into its equivalent binary number . We will more on addressing formats used in IPv4 in the next post . So stay tuned..

Spread the Wisdom !!

Techie Aric

Aric is a tech enthusiast , who love to write about the tech related products and 'How To' blogs . IT Engineer by profession , right now working in the Automation field in a Software product company . The other hobbies includes singing , trekking and writing blogs .

Leave a Reply

Your email address will not be published. Required fields are marked *