Please tell me how TCP guarantees reliability

TCP guarantees reliability

1. Serial number, confirmation response, timeout retransmission When
data arrives at the receiver, the receiver will send a retransmission. Indicates that the data segment has been received. And the confirmation sequence number will indicate the data sequence number it expects to receive next time. If the sender does not receive the response for a long time, it may be that the sent data is lost or the response is lost. At this time, the sender will retransmit the data after waiting for a period of time. This time is generally the round-trip time of a piece of message.

2. Window control and high-speed retransmission
TCP will use window control to increase the transmission speed, which means that within the size of a serial port, it does not need to wait for the response from the other party to continue sending data. The serial port is the maximum value that can continue to send data without waiting. If there is no window control, then every data that does not receive a confirmation response must be resent.

If there is a data segment of 1001-2000 lost, then every time after receiving data, the confirmation response will send a response with a sequence number of 1001. If the sender receives this response three times, it will immediately resend it.

3. Congestion control
If the window is set too large, the sender may send a large amount of data, causing network congestion. Cause network paralysis.

Slow start, congestion avoidance: Define the congestion window, which is 1 at the beginning, and set the window value*2 every time you receive a confirmation response. Set the slow start threshold. If the size of the congestion window reaches this threshold, the congestion window does not increase exponentially , But increase by addition.
When congestion occurs every time, we first set the threshold to the current value of normal, and then set the window value to 1

Fast retransmission and fast recovery: When three repeated confirmation responses are received, it means that three segments have been received, but the previous segment is lost, so retransmission will be performed. Then set the threshold to half of the current window. The window size increases linearly from the threshold.

How does UDP ensure reliability:

The transport layer cannot guarantee reliable transmission, so the confirmation mechanism, retransmission mechanism, and serial port can only be implemented at the application layer.

Guess you like

Origin blog.csdn.net/aaaqqq1234/article/details/108294476