Basics of networking
11. Network layer tasks and protocols
11.1. IPv4 protocol
The IPv4 protocol is designed in such a way that there is no need to add much control data during the encapsulation process. It provides only the basic functionality required to transmit packets from source to destination. It is connectionless, meaning that it does not establish a connection before sending data and operates on a 'best effort' basis, meaning that it does not use flow control or any acknowledgements of data delivery as the TCP protocol does, but does everything it can to make the communication efficient. It is also a medium-independent protocol, meaning that data can be transferred between hosts regardless of the medium used.
After all, in one network we may be using twisted pair, in another fibre, and in a third radio waves. The IP protocol works exactly the same in every network. The problem that can arise when sending data over different media is the maximum packet size, which is the MTU (Maximum Transmission Unit) value, if the packet is too large, the routers connected to the network will split it into smaller pieces. This process is called fragmentation.
To help understand how IPv4 works and how packets are transmitted over the Internet, let us use the example of a package sent from the United States to explain how it works. The package consists of 3 cardboard boxes joined together. The sender wrote an address for it and sent it to the courier company. When they send the package, they give up additional options such as confirmation of receipt or tracking. An employee of the company marks the carton with the destination and return address before releasing the parcel. It was transported by car to the port along with dozens of other parcels, where it was packed into a container and then crossed the ocean.
At the port of destination, the containers are unpacked, the parcels sorted and then transported by car to the various cities and local pick-up points. From the pick-up point by car, the parcel is supposed to be delivered to the specified address, but it turns out that the three combined cartons are too big to be transported on a trolley, so the courier separates them into individual cartons and delivers them to the recipient as such. As the sender has not chosen the additional options, the courier company has not provided them with a receipt.
Converting this to IP communication would look like this:
· The parcel is sent without prior notification to the recipient - we have a connectionless mode;
· During the encapsulation process, a source and a destination address are assigned;
· The consignment did not contain much control data, which could slow down communication - for which the sender gave up an extra option, confirmation and tracking;
· Parcels arrive at their destination via fibre optics, twisted pairs and radio waves - as parcels are delivered by various means of transport: boats, large cars, small cars;
· The parcel is too large to be sent in its entirety through one of the networks, making it fragmented - i.e. the parcel is split at some point so that it can be transported in a small car;
· The IP did not send an acknowledgement of receipt of the package - just as the company did not assure the sender that the package had arrived.
Like any communication protocol, IPv4 also has standardised headers to add control information. An example of a typical IPv4 header is shown below.
Version |
IHL |
Type of service |
Package length |
|
Identification |
Flag |
Moving a fragment |
||
TTL |
Protocol |
Header checksum |
||
Source address |
||||
Destination address |
||||
Options |
Filling |
· destination IP address - the IP address of the device to which the data is directed;
· source IP address - the IP address of the device that is sending the data;
· Time to Live (TTL) - An 8-bit field indicating the remaining lifetime of the packet. The TTL value decreases by at least 1 each time the packet passes through the router (that is, after each hop). When the value reaches 0, the router discards the packet and removes it from the network data flow. This mechanism prevents the infinite transmission of packets that cannot reach their destination between so-called routers. routing loops. If routing loops are allowed, the network will be overloaded with packets that never reach their destination. Decreasing the TTL value at each hop ensures that it will eventually reach 0, and packets with a TTL field of 0 will be discarded.
· Protocol - this 8-bit value specifies the higher (transport) layer protocol used, such as UDP or TCP.
· Type of Service (ToS) - contains an 8-bit value that determines the priority of each packet.
· Fragment Offset - A field used when reconstructing packets split by routers. Indicates the order in which each packet should be arranged during reconstruction.
· More Fragments (MF) flag - A single bit used with the Fragment Offset field for packet partitioning and reconstruction. Setting the MF flag indicates that the fragment is not the last fragment in the packet. When the receiving host notices an incoming packet with MF = 1 set, it checks the Fragment Offset field to place the fragment during packet reconstruction. When the receiving host notices that an incoming packet has MF = 0 set and has a non-zero value in the fragment offset field, it will use the fragment as the last block of the reconstructed packet.
·
DF (Don't Fragment) flag - A single bit which, if set,
indicates,
that packet fragmentation is not allowed. Packet fragmentation is not allowed
if the DF flag is set.
· Version - contains the version number of the IP protocol (in this case IPv4).
· Header length (IHL) - determines the size of the packet header.
·
Packet length - this field gives the total size of the
packet in bytes, including the
including header and data.
· Identification - this field is used to uniquely identify the fragment of a split IP packet.
· Header checksum - this field is used to check for packet header errors.
· Options - this is the space in the IPv4 header for additional fields to support other services. However, it is rarely used.