Internet Protocol (IP) is a connectionless, datagram protocol. that works at the network layer. IP packets are also called IP datagrams. IP uses packet switching. it performs route selection by using dynamic routing tables that are referenced at each hop. the packets making up a message could be routed differently through the internetwork depending on the state of the network at each hop. For example, if a link were to go down or become congested, packets are to be sent through a different route.

Appended to each packet is an IP header. the header includes source and destination information. IP uses sequence numbering if it is necessary to fragment a packet into smaller parts and reassemble it at its destination or at an Intermediate point. IP performs error checking on the header information by way of a checksum.


What is Checksum?


A checksum is an error-checking method in which the data is submitted to an algorithm and the result is appended to the packet. when the packet arrives at its destination, the same calculation is performed on the data to see whether it matches the checksum value.

The functions and methods handle by Internet Protocol

  1. For addressing, IP uses the logical network address.
  2. For switching purposes, it uses the packet switching method.
  3. For route selection, it uses the dynamic routing method.
  4. For connection services, IP provides error control.
IP addresses are unique, 4-byte addresses that must be assigned to every addressable device or node on the internetwork.

What is Internet Protocol (IP) and it's Working Process

In the above figure, you will notice that a big message is divided into smaller packets by the TCP. these are given a header and then enveloped by the IP to be sent to the addresses by various routes using the router. at the receiving end, each envelope is placed in order and the message is reassembled by the TCP and forwarded to the address.

Depending on the class of IP address, a certain number of bytes specifies the network portion and a certain number of bytes specifies the host or node portion. if a connection to the internet is desired, a unique IP network address must be requested from a governing body called the SRI network Information center. this ensures that the new network will have an address different from any other on the Internet. If addresses are assigned according to three classes of networks that are as follows:

Class A addresses

These are used for systems with a small number of networks and a large number of hosts. these addresses use the first byte to specify the network and the last three bytes to specify the host. the first byte of a class A address can be in the range from 0-127 e.g., 88.22.111.5. the available IP addresses for this class have already been exhausted and not available for further distributions.

Class B addresses

Provide for an equal number of networks and hosts by assigning the first two bytes to the network and the last two bytes to the host. the range of values for the first byte of a class B address is 128-191. For example, 111.33.65.23. this class is most often assigned to universities and commercial organizations.

Class C addresses

They use the first three bytes of the address to specify the network and the last byte to specify the host. because there is only one byte available for host addresses, a Class C network will only support a small number of hosts (or nodes). the range of values for the first byte of a Class C address is 192-223. For example, 199.123.45.8.


Datagram


Packets in the IP layer are called datagrams. as you see in the given below image a datagram is a variable-length packet (up to 65,536 bytes) consisting of two parts:
  1. Header
  2. Data
What is Internet Protocol (IP) and it's Working Process

Header

The header can be from 20 to 60 bytes and contains information essential to routing and delivery. it is customary in TCP/IP to show the header in four-byte sections.
  1. Version - the first field defines the version number of IP. the current version is 4 (IPv4), with a binary value of 0100. the newer version 6 (IPv6) is under development.
  2. Header length (HLEN) - The HLEN field defines the length of the header in multiples of four bytes. the four bits can represent a number between - and 15 which, when multiplied by 4, gives a maximum of 60 bytes.
  3. Service type - The service type field defines how the datagram should be handled. it includes bits that define the priority of the datagram. it also contains bits that specify the type of service the sender desires such as the level of throughput reliability, and delay.
  4. Total length - The total length field defines the total length of the IP datagram. it is a two-byte field (16 bits) and can define up to 65,535 bytes.
  5. Identification - The identification field is used in fragmentation. a datagram, when passing through different networks, may be divided into fragments to match the network frame size. when this appears, each fragment is identified with a sequence number in this field.
  6. Flags - The bits in the flags field deal with fragmentation.
  7. Fragmentation offset - the fragmentation offset is a pointer that shows the offset of the data in the original datagram.
  8. Time to live - The time-to-live field defines the number of hops a datagram, can travel before it is discarded. the source host, when it creates the datagram, sets this field to an initial value. then, as the datagram travels through the internet, router by router, each router reduces this value by 1. if this value becomes 0 before the datagram reaches its final destination, the datagram is discarded.
  9. Protocol - The protocol field defines which upper-layer protocol namely, TCP, UDP, ICMP, etc. are encapsulated in the datagram.
  10. Header checksum -  This is a 16-bit field used to check the integrity of the header, not the rest of the packet.
  11. Source address - The source address field is a four-byte (32-bit) internet address. it identifies the original source of the datagram.
  12. Destination Address - The destination address field is a four-byte (32-bit) internet address. it identifies the final destination of the datagram.
  13. Options - The options field gives more functionality to the IP datagram. it can carry fields that control routing, timing, management, and alignment.


Addressing


In addition to the physical addresses contained on network interface cards (NICs) that identify individual devices, the internet requires an additional addressing convention. this address identifies the connection of a host to its network. each internet address consists of four bytes (32 bits), defining three fields:
  1. class type
  2. netid
  3. hostid
What is Internet Protocol (IP) and it's Working Process

These parts are of varying lengths, depending on the class of the address.


Classes


There are five different field-length patterns in use, each defining a class of address. all such classes are designed to cover the needs of different types of organizations. for example, class A addresses are numerically the lowest. they use only one byte to identify the class type and netid and leave three bytes available for hostid numbers.

What is Internet Protocol (IP) and it's Working Process

This division means that class A networks can accommodate far more hosts than can class B or class C networks, which provide two and one-byte hostid fields, respectively. class D is reserved for multicast addresses. Multicasting allows copies of a datagram to be passed to a select group of hosts rather than to an individual host. Multicasting allows the transmission to a selected subset. Class E addresses are reserved for future use.