Skip to main content

Transport Layer

The Transport Layer is the fourth layer in the OSI model, and it plays a crucial role in ensuring reliable communication between devices across a network. It is responsible for end-to-end delivery, segmentation, flow control, error control, congestion control, and more. Let’s explore these functions in detail.

End-to-End Delivery​

End to End Delivery

End to End Delivery

Imagine you and your friend are having a chat on WhatsApp. Both of you also have other apps like Facebook and Instagram installed on your devices. When you send the message "How are you?" on WhatsApp, it’s crucial that this message reaches your friend on WhatsApp and not on any other app like Instagram or Facebook. This precise delivery is managed by the Transport Layer using a system called ports.

What is a Port?​

Think of a port as a room number in a large apartment building. If you want to meet and talk with a specific person, you need to know their room number. Similarly, if an application wants to communicate with another application on the same or a different device, it must know the specific port number. For example, WhatsApp on your device might be using port 37328, while your friend's WhatsApp is using port 36277. This ensures that your message reaches the correct application.

Note

End-to-End Delivery can also be called App-to-App Delivery.

Segmentation​

The data from higher layers in the OSI Model reaches the Transport Layer. The Transport Layer divides this data into smaller chunks, called segments. Each segment has a header that includes important information, such as the destination port number and sequence number, ensuring data is transmitted in the correct order.

Example:​

Suppose you want to download a large game from the internet. This large file cannot be sent in a single block. The Transport Layer divides it into smaller segments, each with its own header information. These segments are sent over the network, and upon reaching the destination, the Transport Layer reassembles them into the original game file.

Note

TCP and UDP are the protocols used at the Transport Layer.

Flow Control​

TCP Flow Control

Flow Control in TCP

Flow control in the Transport Layer prevents the sender from overwhelming the receiver with too much data too quickly. Without flow control, the receiver’s buffer might overflow, leading to data loss and inefficient communication.

Example:​

  • Computer A: A powerful machine capable of sending data at a high rate.

  • Computer B: A less powerful machine with a smaller buffer size, capable of handling only 10 segments at a time.

If Computer A sends 50 segments at once, Computer B will process only the first 10 segments, and the rest will be dropped. Computer A would then have to retransmit the dropped segments, wasting resources.

Sliding Window Solution​

  1. Computer B advertises an initial window size of 5 segments, meaning Computer A can send up to 5 segments before needing an acknowledgment.

  2. Computer A sends 5 segments (1 to 5) to Computer B.

  3. Computer B processes the segments and sends an acknowledgment (ACK) back to Computer A.

  4. If Computer B's buffer is full, it advertises a window size of 0, signaling Computer A to pause sending. Computer A will periodically send a probe asking for the current window size.

  5. As Computer B processes segments and sends ACKs, Computer A’s window slides forward, allowing it to send additional segments.

Error Control​

TCP Error Control

TCP Error Control

The Transport Layer ensures data integrity by managing error control. Data is sent in segments, and the receiver acknowledges each one. If the sender does not receive an acknowledgment within a designated timeframe, it assumes the segment is lost and retransmits it.

Congestion Control​

Imagine a busy highway where cars travel to their destinations. When the number of cars is within the highway’s capacity, traffic flows smoothly. However, during rush hour, the highway becomes congested, leading to traffic jams.

Similarly, in a network, data segments travel to their destination. The network has a maximum capacity (bandwidth). If too many segments are sent beyond this limit, congestion occurs, similar to a traffic jam.

Problems with Congestion​

  • Segment loss due to network congestion leads to retransmission, which uses up bandwidth inefficiently.

  • Excessive retransmission reduces network performance and affects the overall user experience.

Solutions​

  1. Slow Start: Gradually increase the transmission rate to explore the network capacity without causing immediate congestion.

  2. Congestion Avoidance: Incrementally increase the transmission rate to avoid congestion.

  3. Fast Retransmit and Fast Recovery: Quickly detect packet loss and reduce the transmission rate to minimize congestion while maintaining network throughput.

Full Duplex Communication​

Full duplex communication allows simultaneous two-way data transmission, meaning data can be sent and received at the same time.

Achieving Full Duplex​

  • Separate Channels: Establish separate channels for sending and receiving data simultaneously.

  • Buffering: Use buffers to manage incoming and outgoing data streams independently.

Example:​

In a video call, both parties can speak and listen simultaneously. The Transport Layer supports full duplex communication, allowing voice and video data to be sent and received concurrently. This is achieved through separate channels for each direction of data flow and buffering mechanisms to handle the data streams effectively.