当前位置:网站首页>面试突击:为什么 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 次完全没有必要。
边栏推荐
- < stack simulation recursion >
- 【服务器数据恢复】HP EVA服务器存储意外断电导致RAID信息丢失的数据恢复案例
- Pytoch learning notes -- seresnet50 construction
- Gary marcus: learning a language is more difficult than you think
- Matlab -- CVX optimization kit installation
- 一文入门Redis
- Data system partition design - Request Routing
- "Digital security" alert NFT's seven Scams
- CVPR 2022 | 网络中批处理归一化估计偏移的深入研究
- Dpdk packet receiving and sending problem case: non packet receiving problem location triggered by mismatched packet sending and receiving function
猜你喜欢

通用测试用例写作规范

Solve the vender-base.66c6fc1c0b393478adf7.js:6 typeerror: cannot read property 'validate' of undefined problem

Leetcode - 677 key value mapping (Design)*

Cf888g clever dictionary tree + violent divide and conquer (XOR minimum spanning tree)

MySQL - Summary of common SQL statements

Use cpolar to build a business website (how to buy a domain name)

一文入门Redis

不愧是阿里内部“千亿级并发系统架构设计笔记”面面俱到,太全了

# JWT 图解

【IJCAI 2022】参数高效的大模型稀疏训练方法,大幅减少稀疏训练所需资源
随机推荐
对this对象的理解
30 lines write the concurrency tool class yourself (semaphore, cyclicbarrier, countdownlatch)
Componentization and modularization
Beyond compare 4 realizes class file comparison [latest]
LeetCode - 362 敲击计数器(设计)
Geogle Colab笔记1--运行Geogle云端硬盘上的.py文件
Circulaindicator component, which makes the indicator style more diversified
Qtime definition (manual waste utilization is simple and beautiful)
华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场
Icpc2021 Kunming m-violence + chairman tree
Beyond Compare 4 实现class文件对比【最新】
Cf750f1 thinking DP
Games101 review: linear algebra
2019 Zhejiang race c-wrong arrangement, greedy
用GaussDB(for Redis)存画像,推荐业务轻松降本60%
Leetcode - 225 implements stack with queue
MySQL教程67-使用DISTINCT过滤重复数据
如何实现页面包含
推荐收藏,这或许是最全的类别型特征的编码方法总结
行云管家V6.5.1/2/3系列版本发布:数据库OpenAPI能力持续强化