Computer Science, asked by iAmSAFWAN, 8 months ago

How does the TCP ensure reliability in data transfer? ​

Answers

Answered by sahatrupti21
2

That is a very good question. The medium over which data is sent, is always unreliable. TCP promises reliability by making sure that data reached its intended destination (over unreliable medium).

It achieves this by Acknowledgments (ACKs). When TCP receives data from upper layer (Application Layer), it chunks the data into segments and appends its own header. This header assigns a unique segment no. to this chunk of data. When this chunk is received by the recipient, it replies to the sender by telling next sequence of data that it is expecting to receive.

There may be no. of reasons why ACK is not received by the sender:

1. Data was lost mid way, and hence destination did not receive it at all.

2. Data was corrupted and destination was not able to make sense out of it.

3. ACK was lost.

4. Destination process closed without intimating the sender, etc., etc.

If this ACK is not received by the sender within a certain interval (called timeout interval), sender resends this data and resets timeout interval. It keeps on trying until it gives up after a certain no. of timeouts. Both sender and destination use a unique random initial sequence no. for this purpose. This sequence no. represents the next byte of data that other side is expecting.

Sender also sends an ACK for each ACK sent by destination, to tell destination that "I know that you received the data". Host (Sender/Client) need not send pack a special packet for ACK, it can piggyback this ACK along with next chunk of segment to be sent.

On the other hand, if ACK is successfully received, the sender is sure that data was received by the destination.

Similar questions