linux - 应用层TCP的确认机制
巴扎黑
巴扎黑 2017-04-17 15:53:26
0
5
470
巴扎黑
巴扎黑

reply all(5)
Peter_Zhu

You mean TCP protocol?
The TCP protocol itself includes mechanisms for confirmation of delivery and automatic retransmission. As long as you use TCP connections, you don’t need to consider this issue.

左手右手慢动作

TCP is a protocol that is generally implemented by your machine equipment. You do not need to pay attention to TCP retransmissions. Generally, your application layer, such as HTTP, and the network layer are TCP. When calling the HTTP protocol, you do not need to pay attention to the implementation of the lower layer protocol. The lower layer network protocol is transparent to the upper layer protocol

刘奇

Let’s discuss it with you using the Modbus protocol mechanism. The communication between the master station and the slave station belongs to the request-response mechanism. When the master station sends a request to the slave station, if the slave station does not reply in time, after the delay time expires, the master station will send the request to the slave station 5 times in a row. The timeout and the number of retransmissions are used to ensure that each request is successful as much as possible. If the retransmission fails 5 times, it is judged that the transmission failed. At this time, the physical link may be abnormal, and subsequent unfinished data will not be sent. Send again.

PHPzhong

TCP is a reliable transmission protocol. For every packet you send, the peer needs ACK confirmation.
For example, if you send 5 packets to the peer, and packet No. 3 is lost,
Then when the peer receives No. 4 When receiving the packet, the peer will send you ACK 3, and at the same time, the peer will save packet No. 4. When the peer receives packet No. 5, the peer will still send you ACK 3, and at the same time, the peer will save packet No. 5. Packet No. 3 is saved.
In the TCP protocol, when you receive 3 consecutive "ACK 3"s, you will know that packet No. 3 is lost and needs to be resent. This is called the fast retransmission mechanism.

When you resend packet No. 3 to the peer, the peer will respond with ACK 6 after receiving it successfully, because the peer has successfully received packet No. 4 and No. 5 before.

This is guaranteed by TCP for you.

If packet No. 3 still fails after being retransmitted multiple times at the TCP layer, then the entire transmission has failed.
You need to check the network connection and resend it at the application layer.

小葫芦

No need, what you mentioned is implemented by the TCP protocol layer, you just use it.
If you want to know the details, you can refer to this article

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!