Home » Computer Network » How does the transport layer ensure that the complete message arrives at the destination and in the proper order?

How does the transport layer ensure that the complete message arrives at the destination and in the proper order?

Last updated:

Support this post with a reaction:

4,498 views

The transport layer is the fourth layer of the OSI (Open Systems Interconnection) model. It is responsible for providing end-to-end communication between applications running on different devices.

The transport layer ensures that data is delivered completely, accurately, and in the correct order from the sender to the receiver. It uses different mechanisms such as segmentation, sequence numbers, acknowledgements, error detection, retransmission, and flow control to achieve reliable data transmission.

TCP (Transmission Control Protocol) is the main transport layer protocol that provides reliable and ordered data delivery.

How Does the Transport Layer Ensure Complete and Ordered Message Delivery?

Figure : TCP Transport Layer Protocol

The transport layer uses the following mechanisms to ensure that the complete message reaches the destination in the proper order.

1. Segmentation

The transport layer divides large messages received from the application layer into smaller units called segments.

Each segment is transmitted separately over the network. This makes data transmission easier and more efficient.

At the receiver side, the transport layer collects these segments and prepares them for reassembly.

Example: If a message contains 5000 bytes of data, the transport layer may divide it into smaller segments before transmission.

2. Sequence Numbers

TCP assigns a sequence number to each byte of data transmitted.

These sequence numbers help the receiver identify the correct order of incoming data and detect missing or out-of-order segments.

If segments arrive in the wrong order, TCP uses their sequence numbers to rearrange the data correctly.

Example: Suppose the sender transmits three segments in the following order:

  • Segment 1
  • Segment 2
  • Segment 3

If they arrive at the receiver in the order 1, 3, 2, TCP uses sequence numbers to arrange the data in the original order.

3. Acknowledgement (ACK)

TCP uses acknowledgements to confirm that data has been received successfully.

After receiving data, the receiver sends an acknowledgement (ACK) to the sender.

The acknowledgement number indicates the next byte expected by the receiver.

If the sender does not receive the expected acknowledgement within a specified time, it may retransmit the missing data.

Example: If the receiver successfully receives the first 1000 bytes, it may send an acknowledgement number of 1001, indicating that byte 1001 is expected next.

4. Error Detection

TCP uses a checksum mechanism to detect errors in transmitted segments.

The sender calculates a checksum and includes it in the TCP header. The receiver recalculates the checksum after receiving the segment and compares the result.

If an error is detected, the segment is treated as corrupted and is not accepted as valid data.

This helps maintain the accuracy of transmitted information.

5. Retransmission

Sometimes, data segments may be lost or damaged during transmission.

TCP uses retransmission to recover lost data. If an acknowledgement is not received within the retransmission timeout, the sender retransmits the unacknowledged data.

TCP can also use duplicate acknowledgements as an indication of possible segment loss and trigger fast retransmission.

This ensures that missing data can be delivered again.

6. Reassembly

At the receiver side, the transport layer collects the received segments and arranges them according to their sequence numbers.

It then reassembles the data into the original message and delivers it to the appropriate application.

This ensures that the receiving application gets the complete data in the correct order.

7. Flow Control

TCP uses a sliding window mechanism to control the amount of data transmitted by the sender.

It prevents the sender from sending more data than the receiver can handle.

The receiver advertises its available buffer space through the receive window field in the TCP header.

This helps prevent data loss due to receiver buffer overflow.

Figure : TCP Transport Layer Protocol