Original | As usual, why does TCP have a three-way handshake?

Preface

Fei Chao and everyone talked about a common question today, why does TCP shake hands three times. Why do you suddenly think of this topic?

According to Fei Chao's past style, a lot of articles were searched on the Internet, and Fei Chao was generally reluctant to mention it. In fact, every technical person has more or less the idea of ​​blogging, but later found that the content he wanted to write seemed to be available online, and finally broke the idea.

image

Therefore, Fei Chao has two positions, one is a systematic source code analysis article (similar to the Dubbosource code analysis in 17 years and the graphic source code in 19 years SpringBoot), and the other is the actual source code of the real scene. Since it is a real scene, the probability of the same It is almost negligible.

In that case, why mention TCP's three-way handshake? Let alone these online, there are a lot of university textbooks, and they are authoritative.

Some thoughts on learning

In 计算机原理, 网络, 编译原理, 数据结构与算法and so on standard computer knowledge, we often encounter the problem is, learn to forget the interview finished, the next interview, again, the "back" title, which would lead to cost too much time. Therefore, Fei Chao is also thinking about 如何学习this issue during this period . Because these standard knowledge points are often obscure and require a certain amount of skill and working years to do it 理解性记忆. I am thinking, can the process of learning knowledge be like the evolution of architecture, from 0 to 1, from 1 to 10, from 10 to 100? What does it mean specifically?

Just like the evolution of the architecture, we first use the simplest single-machine application to quickly build the business to seize the market, rather than directly distributed, highly available, and containerized.

In the same way, we understand a point of knowledge, is it not necessary to be so authoritative at the beginning, but to get a rough understanding of his basic ideas, and when the work experience and knowledge system are gradually enriched and perfected, we will go back and learn further. Will the effect be better?

Back to topic

To say why TCP is a three-way handshake, in fact, from another perspective, it is necessary to prove that 2 times are too few and 4 times are unnecessary.

What is the nature of the so-called three-way handshake? TCP is a reliable transmission protocol. Its essence is to determine the client and server, 发送and 接收there is no problem with their ability to and. That is, the client service side to examine 发送and 接收capacity, the server must examine the client 发送and 接收ability.

First handshake

Fei Chao whispered: The server received the data packet for the first handshake, and it was confirmed that the client's sending ability was no problem (pictured)

Second handshake

Fei Chao whispered: The client received the data packet in the second handshake. At this time, it can be proved that the sending ability of the server is correct. But is there any problem with the receiving capability of the server? When we shook hands for the first time, the question we asked was "How do I find the official account of Fei Chao?", and the answer we received was "You can search for the name of Fei Chao on the official account. You can tell me if you try it." The answer is exactly what we just asked, which means that there is no problem with the receiving capability of the server (as shown in the figure)

So, back to the question at the beginning, why the two handshake fails , because at this time, the client has determined that there is no problem with the server's capabilities 发送and 接收capabilities, but the server has not determined whether 接收there is any problem with the client's capabilities.

Third handshake

image

Fei Chao whispered and forced: In the third handshake, the server received the data packet and found that it was indeed the answer to the question just now. Then, it was determined that the client's 接收capabilities were not problematic.

Going back to the question just now, 3 times is the minimum number of times to complete the inspection 发送and 接收ability of both parties . This is why it is not 2 times, not 4 times.

Write at the end

Of course, if you want to see more professional TCP related knowledge, university and postgraduate teaching materials are also good choices. Leave a message and tell Fei Chao about your Chinese New Year study.



image


Guess you like

Origin blog.51cto.com/15082403/2591232