当前位置:网站首页>面试突击:为什么 TCP 需要 3 次握手?
面试突击:为什么 TCP 需要 3 次握手?
2022-07-25 15:41:00 【51CTO】
TCP 三次握手是一道经典的面试题,它是指 TCP 在传递数据之前,需要进行 3 次交互才能正式建立起连接,并进行数据传递。TCP 之所以需要 3 次握手是因为 TCP 双方都是全双工的。所谓全双工指的是,TCP 任何一端既是发送数据方,又是接收数据方,因此这就要求 TCP 通讯双方既要保证自己的发送能力,又要保证自己的接收能力才行。这就好像打电话时,通讯双方都要保证自己能话筒(传递声音)和耳机(接收声音)都是正常的才行,这样才能进行有效的交流,通常打电话时,都是这样开头的:
- 我:喂,能听到我说话吗?
- 对方:能听到你说话,你能听到我说话吗?
- 我:能听到你说话,那我们就来聊正事吧。
TCP 三次握手也是相同的道理,3 次握手证明的能力详情如下:

TCP 三次握手流程
TCP 三次握手流程如下:
- 客户端发送 SYN 给服务器端,表示希望建立连接;
- 服务器端接收到消息之后,回应一个 SYN 和 ACK(确认应答)给客户端;
- 客户端收到服务器端的 SYN 报文之后,回应一个 ACK 报文。
具体执行流程如下图所示:

总结
TCP 之所以需要 3 次握手,是因为 TCP 通讯双方都是全双工的,所以要经过 3 次交互才能确认双方的发送能力和接收能力,并且 TCP 握手必须是 3 次,如果是 2 次握手,不能证明服务器端的发送能力和客户端的接收能力;也不能是 4 次握手,因为 3 次已经能证明的事情,再交互握手 1 次完全没有必要。
边栏推荐
- Okaleido上线聚变Mining模式,OKA通证当下产出的唯一方式
- CVPR 2022 | in depth study of batch normalized estimation offset in network
- MySQL - Summary of common SQL statements
- Endnote add Chinese gbt7714 style how to quote documents in word
- HDD杭州站·HarmonyOS技术专家分享HUAWEI DevEco Studio特色功能
- Use cpolar to build a business website (how to buy a domain name)
- Pytoch framework exercise (based on kaggle Titanic competition)
- 2021 Jiangsu race a Array line segment tree, maintain value range, Euler power reduction
- ML - Speech - traditional speech model
- Leetcode - 677 key value mapping (Design)*
猜你喜欢

No tracked branch configured for branch xxx or the branch doesn‘t exist. To make your branch trac

Leetcode - 380 o (1) time to insert, delete and get random elements (design hash table + array)

Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel

Google Blog: training general agents with multi game decision transformer

「数字安全」警惕 NFT的七大骗局

Why is preparestatement better and safer?

MySQL—常用SQL语句整理总结

Idea - click the file code to automatically synchronize with the directory

MySQL - user and permission control

CircleIndicator组件,使指示器风格更加多样化
随机推荐
SQL cultivation manual from scratch - practical part
LeetCode - 641 设计循环双端队列(设计)*
Leetcode - 359 log rate limiter (Design)
MySQL - user and permission control
Wechat applet
CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
Why is preparestatement better and safer?
2019 Shaanxi provincial competition j-bit operation + greed
HDD Hangzhou station · harmonyos technical experts share the features of Huawei deveco studio
LeetCode - 359 日志速率限制器 (设计)
How to disable hosting when Flink SQL in flink-1.13.6 runs in yarn session mode
The difference between mouseover and mouseenter
C # fine sorting knowledge points 12 exception handling (recommended Collection)
Data system partition design - partition and secondary index
Pytoch learning notes - Teacher Liu Er RNN advanced chapter - code comments and results
Where is there a demo to set up the flex CDC to draw the number of MySQL?
Activity review | July 6 Anyuan AI X machine heart series lecture No. 2 | MIT professor Max tegmark shares "symbiotic evolution of human and AI"
I want to ask whether the variable configuration function can only be used in SQL mode
华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场
十字链表的存储结构