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
- For addressing, IP uses the logical network address.
- For switching purposes, it uses the packet switching method.
- For route selection, it uses the dynamic routing method.
- 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.
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., 22.214.171.124. the available IP addresses for this class have already been exhausted and are not available for further distribution.
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, 126.96.36.199. 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, 188.8.131.52.
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:
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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Flags – The bits in the flags field deal with fragmentation.
- Fragmentation offset – the fragmentation offset is a pointer that shows the offset of the data in the original datagram.
- 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.
- Protocol – The protocol field defines which upper-layer protocols namely, TCP, UDP, ICMP, etc. are encapsulated in the datagram.
- Header checksum – This is a 16-bit field used to check the integrity of the header, not the rest of the packet.
- Source address – The source address field is a four-byte (32-bit) internet address. it identifies the original source of the datagram.
- Destination Address – The destination address field is a four-byte (32-bit) internet address. it identifies the final destination of the datagram.
- Options – The options field gives more functionality to the IP datagram. it can carry fields that control routing, timing, management, and alignment.
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:
- class type
These parts are of varying lengths, depending on the class of the address.
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.
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.