The transport and network layers are the two most important parts of the OSI model.
In this tutorial, we’ll explore the fundamentals and the services offered by these two layers.
Finally, we’ll highlight the core differences between them.
2. Introduction to Transport Layer
Transport Layer is the fourth layer of the OSI Model:
It’s an end-to-end or process-to-process communication layer that is responsible for delivering the entire message.
A process is an application running on the host system. There might be more than one process running on the host. The transport layer ensures the communication between the process of a host to the process of another host.
For the process to process communication, the transport layer uses a port number assigned to each process uniquely.
Let’s take a real-life example of a postcard delivery. There are two houses, Home-A, and Home-B. Jack belongs to Home-A, and Jones belongs to Home-B. Jack wants to send a postcard to Jones. So, in order to deliver the postcard to the correct address, he needs to write the details on the postcard, such as the address, name of the receiver, and type of postcard.
In this example, Home-A and Home-B are two different networks. Jack and Jones are the IP addresses of the two hosts. The type of postcard represents different types of processes:
It’s important to note that the use of ports is crucial in the transport layer. Certainly, there can be multiple types of processes that may run on a single host at a particular time. In general, a single IP address is assigned to a host. A sender host sends the data to the receiver host with a port number. Furthermore, the receiver host can identify the port and will route the data to a specific process.
3. Services of Transport Layer
The transportation layer provides a lot of services:
This layer is responsible for delivering the messages, not only from a host to another host but also from a specific process of a host to a specific process of another host.
Also, it provides reliability by offering services like in-order delivery of packets to process, no loss of data, and control of data duplication.
In addition, the transport layer is responsible for flow control of data transmission. Here, the receiver host controls the amount of data that is to be sent from the sender host. This is used to prevent the overhead of data on the receiver host because there’ll be a possibility that the receiver host is not capable of processing the data at the same rate. The transport layer provides the mechanism of flow control using Selective Repeat:
This layer provides the error control using checksum bits. The sender host generates a checksum using some algorithm. Furthermore, the receiver host decodes that checksum so that it can detect the corrupted packets. At the time of transmission, if there are any noises, it can alter the data. Hence, the transport layer uses the automatic repeat request method to re-transmit the missing or error packets:
It also facilitates the efficient use of the network by using multiplexing. There might be a case that multiple processes from the sender host need to send packets, but there is only one transport layer at a time. In this layer, a protocol accepts data from the different processes, differentiated by their assigned port, and adds them in the header.
On the receiver’s host, to process the incoming data, we need to perform demultiplexing. Here, the transport layer differentiates all the data and sends them to their respective processes according to their port addresses:
4. Introduction to Network Layer
Network Layer is the third layer of the OSI Model. It’s responsible for source-to-destination or host-to-host delivery of packets across multiple networks.
This layer takes the data from the transport layer, adds its header, and forwards it to the data link layer. This layer ensures that each packet reaches from its point of origin to its final destination. Switches and routers are used in this layer. The network layer is implemented on networking devices.
It uses the destination host and the source host’s logical address (IP address) to send the data. An IP address is a combination of the network address and host machine address.
5. Services of Network Layer
Like the transport layer, the network layer also provides some important services:
The network layer uses logical addresses to communicate from host to host in different networks. Furthermore, it adds the IP address of the sender and the receiver in each packet so that each sent packet can reach its designated destination.
Network Layer also provides the services for routing and switching. When there are more than one independent networks which are connected to create a larger network, the connecting devices (routers and switches) route and switch the packets from source to destination.
There can be more than one route to send packets from source to destination. Hence, the network layer is responsible for choosing the best route or path to send packets using routing protocols.
The network layer created a routing table to maintain the details of the shortest possible path from host to destination. We also use this table in the switching process. Switching is a process that uses the routing table and guides the packets to different networking devices:
In this example, we want to send a packet from Host-A to Host-B. There are two paths: P1 and P2. The network layer will choose the optimal path P1.
Another important service provided by the network layer is fragmentation. It breaks the packets into fragments to decrease the overload on the routes. There is a possibility that the size of data is larger than the capacity of the router to handle.
This layer divides the data into small fragments and sends them further. Moreover, it is also responsible for accumulating the fragmented data on the receiver host. The accumulation process of fragmented data, however, takes place on the destination node only:
6. Flow of Transport and Network Layer
Now let’s explore how the transport and network layer works through a practical example:
In the diagram, there are two host devices Host-A, Host-B, running in Network-A and Network-B. Moreover, three processes are running on each end device. Each process of Host-A wants to send the data to some processes of Host-B.
Sending data from one process to another process is accomplished by the transport layer. In order to send data from one process to another, first we need to send the data to the destination host. In order to achieve this, we use the network layer as both of the processes are in different networks.
Now, the transport layer adds its header, assigns each process a unique port number, and passes it to the network layer. Furthermore, the network layer uses the logical addresses of the source host and destination host. It routes the data to its destination host. This is the reason the network layer is known as the source-to-destination delivery layer. It’ll make a routing table for the shortest possible path from source to destination. Also, it switches the packets from different networking devices.
As in this example, there are two paths going out from Network-A. The network layer will decide which path to choose for sending packets.
When the packets reach their destination host, the transport layer will route the packets to their respective processes using their port number.
Communication between a process to process is known as end-to-end delivery. However, communication from a host to a host is known as source-to-destination delivery. Furthermore, communication between two networking devices is known as hop-to-hop delivery.
7. Difference Between Transport and Network Layer
Let’s look at the fundamental differences of the transport and network layer:
In this tutorial, we’ve discussed two important layers in the OSI model: the transport and network layer. We also explained the services offered by the two layers and the core differences between them.