We know that the communication modes between client A and server B can be divided into: full-duplex, half-duplex, and simplex:
TCP is full-duplex.
How TCP works Next, I will show you how TCP works. From the previous knowledge, we learned that TCP has three handshakes (previous reference: HTTP also has long and short connections? HTTP long connection vs short connection). Schematic diagram of TCP's three-way handshake: The specific meaning can be understood as follows: 1. A handshake The client wants to send a packet to the server with the SYN flag set to 1 and the initial sequence number X, which is encapsulated in the sequence number field in the packet header. The client enters the SYN_SEND state and waits for confirmation from the server. 2. Second handshake The server sends back an ACK (acknowledgement packet), setting both the SYN and ACK flags to 1, and modifying the sequence number to X+1. At the same time, it also sends a packet, a SYN packet, with a sequence number (seq = Y), that is, a SYN + ACK packet. At this point the server enters the SYN_RECV state. 3. The third handshake The client receives the (ACK+SYN) packet sent by the server, and the SYN flag is 0. The ACK flag is 1. At the same time, add 1 to the sequence number field of the ACK packet sent by the server and put it in the packet, and send it to the server, that is, ACK=Y+1. Popular explanation: Do you still find it difficult to understand? Let me give you an example. First, we assume that A and B are the two parties communicating this time. Sending a message represents a handshake.
Then we started a pleasant chat. Is a two-way handshake possible? So let's explore whether two handshakes are possible.
But what about client A? There is no guarantee that it will receive the information sent by server B. What if client A does not receive the information sent by the server? The client will think that the communication between us has not been established. Such a communication process is obviously unsuccessful. If there are a large number of such cases, Server B will crash. It seems that only two handshakes are not enough to complete the working principle of TCP communication. If two times is not enough, what about four times? Is a four-way handshake OK? According to the TCP communication principle above, we know that after the three-way handshake, client A and server B can both confirm the messages they sent before, and each can receive and send the messages to the other party successfully. According to the above conclusion, whether you shake hands four times or five times, it is futile, because after the "three handshakes", everything that needs to be done has been done. in conclusion TCP's three-way handshake is a classic, and the communication protocols on computers are also based on TCP's three-way handshake and four-way handshake. Because the direct communication between computer applications is based on the HTTP protocol, and HTTP is actually implemented by the TCP protocol, which has been mentioned before.
We can see that after three handshakes, we can draw the following conclusions:
|
>>: What should you do if you forget the wireless router backend login address?
I have shared iWebFusion many times in my blog. I...
[[357457]] This article is reprinted from the WeC...
The emergence of electricity has completely chang...
As streaming, remote work, and online education t...
On the morning of December 8, at the 2016 GNTC Gl...
If you don't talk about AI after dinner, you ...
It's a new year, so let's summarize some ...
While drawing parallels between 5G and national s...
Mr. Dongguo and the wolf, Lu Dongbin and the dog,...
A strange theory about wireless routers has appea...
1. Overview of DHCP Working Principle Before lear...
[[184286]] The software development cycle require...
Amazon may not be as well-known as Google, Apple,...
1. Introduction In the previous thread series art...
The last time the tribe shared information about ...