In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what the reliable transmission principle of TCP is. I hope you will gain a lot after reading this article. Let's discuss it together.
The IP layer under TCP is delivered with best efforts and is unreliable, so TCP needs to do reliable transmission on its own. Next, let's start with a simple stop-wait protocol to explain how reliable transmission is implemented. It is necessary to pay attention to several characteristics of reliable transmission: no loss, no repetition, and orderly arrival.
Note that TCP does not use the stop wait protocol for reliable transmission.
Stop waiting for the agreement
The data transmission unit of the transport layer is called a segment. The following, for convenience, are called grouping.
The principle of the stop waiting protocol is very simple: after sending a packet, stop sending, wait for the confirmation of the previous packet, and then continue to send the following packet.
The following is analyzed through several different situations:
Error-free situation
The error-free situation is very simple, as shown in the following figure. After each packet is sent, it stops sending, waits for the confirmation of the packet, and then continues to send the subsequent packet.
Make a mistake
There are two kinds of errors, the first is that the sent packet is not successfully delivered to the destination address, and the other is that there is an error in the transmitted packet. Through the illustration, let's analyze two situations.
First, let's take a look at the operation of B: a sends an M1 packet. If the packet is wrong, B will discard the packet when it is received, and then do nothing (A will not be notified that the wrong packet has been received). If B doesn't receive the M1 packet, it doesn't know anything and won't do anything.
Next, let's see how A does it: after A sends the packet, it is too late to receive the confirmation of the M1 packet from B. when the waiting time expires, then the M1 packet needs to be re-sent. To achieve timeout retransmission, you need to set a timeout timer, and when a packet sent is acknowledged before the timeout, the timeout timer is reset, otherwise the packet needs to be retransmitted.
There are a few points to pay attention to:
An after sending a packet, you must also save a copy of the packet for timeout retransmission. When the confirmation of the packet is received, the copy of the packet can be discarded.
Each packet needs to be numbered so that it is the arrival of each packet.
The timeout should be set slightly longer than the average transmission time to avoid unnecessary retransmissions.
Confirm loss and late confirmation
In addition to packet errors during transmission, there will also be errors when returning acknowledgements-lost acknowledgments and late acknowledgements.
First of all, let's look at the loss of confirmation. Packet B of A received and sent an acknowledgement to A, but the acknowledgement was lost and A did not receive it. Because A does not receive an acknowledgement of M1, M1 will be retransmitted to B after waiting for the timeout. At this time, B receives the duplicate packet M1 and needs to do two actions:
Discard duplicate packet M1
Send M1 confirmation to A. Because since A retransmits M1, it means that A has not received the packet of M1. So B needs to continue to send acknowledgements to M1.
In another case, the grouping confirmation for M1 is late (received after the timeout). An after receiving a duplicate confirmation, it will be discarded and do nothing else.
Through the above timeout retransmission mechanism, reliable transmission can be achieved on unreliable network transmission.
Channel utilization
The above stop and wait protocol is simple, but it has a very big disadvantage-the utilization of the channel is too low. During the period of waiting for confirmation, the channel is completely idle and wasteful.
In order to improve the channel utilization, the pipeline transmission can be used, and the pipeline transmission can send multiple packets continuously, which can greatly improve the channel utilization.
The protocols that use pipelined transmission include continuous ARQ protocol and window sliding protocol. TCP uses sliding window protocol to achieve reliable transmission.
After reading this article, I believe you have a certain understanding of the reliable transmission principle of TCP, want to know more about it, welcome to follow the industry information channel, thank you for your reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.