当前位置:网站首页>图解网络:揭开TCP四次挥手背后的原理,结合男女朋友分手的例子,通俗易懂
图解网络:揭开TCP四次挥手背后的原理,结合男女朋友分手的例子,通俗易懂
2022-07-07 23:59:00 【InfoQ】
TCP三次握手简单回顾
- 首先客户端将发送一个SYN消息(
SYNchroniz
e 的缩写)表示客户端要建立与服务端的连接。
- 服务端收到客户端的SYN报文后,回复SYN-ACK报文,包括一个SYN序列号和一个ACK号。
- 客户端收到服务端的 SYN-ACK 消息后,向服务端发送ACK消息。

TCP四次挥手
生活中的例子

- 第一次:小美对小明说“小明,相处那么长时间了,我觉得我们不合适,分手吧”
- 第二次:小明听完其实没有太吃惊,但是也不能直接答应啊,不然不就成了铁打的渣男了嘛,所以第二次挥手,他礼貌的说了一下“别,我还有话和你说,其实你蛮好的,不仅人长得漂亮,性格也挺好的,也通情达理,学习也蛮刻苦的,非常开心在大学能够遇到你!”
- 第三次:小明哔哩啪啦也讲的差不多了,是时候露出真面目了,随后他就对小美说“既然你想好了,我再纠缠你也没意思,那就和平分手吧~”
- 第四次:小美听完小明一大堆虚伪的话,非常生气,就甩了一句“那就这样了,互删微信吧,再见!”

四次挥手原理分析

- 客户端会发送一个 FIN 消息,FIN是
FINISH
的缩写,FIN 消息的目的是使 TCP 能够优雅地终止已建立的连接,然后客户端进入称为FIN-WAIT 状态的状态,在 FIN-WAIT 状态下,客户端继续接收来自服务端的消息,并继续处理已经在队列中的消息,但客户端不会发送任何额外的数据。
- 服务端向客户端发送ACK消息,确认他已经收到了结束的消息了,这个时候服务端将不再接受来自客户端的数据。
- 服务端可以继续向客户端发送数据(最后交代点事情),如果服务端没有更多数据要发送,它也会通过发送 FIN 消息来终止连接。
- 然后客户端向服务端发送ACK确认收到了服务端主动断开的消息。

- 客户端向服务端发送FIN M给服务端。
- 服务端向客户端发送ACK M+1,客户端收到M+1,就知道服务端收到了自己的Finish消息。
- 服务端向客户端发送FIN N代表是服务端主动向客户端发送结束消息。
- 客户端向服务端回复ACK N+1消息,服务端看到是自己的N,所以就知道客户端也收到了自己的结束消息了。
断开连接的最大生命周期

- 防止使用相同源地址、源端口、目的地址和目的端口的其他 TCP 连接接收到延迟的数据段。
- 保证TCP连接被远程正确关闭,即等待被动关闭连接的一方收到ACK对应的消息。
总结
- TCP三次握手简单回顾
- TCP四次挥手
- 生活中的例子
- 四次挥手原理分析
- 断开连接的最大生命周期
- 总结
边栏推荐
- Solve the error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
- 如何让导电滑环信号更好
- Matlab code on error analysis (MAE, MAPE, RMSE)
- [loss function] entropy / relative entropy / cross entropy
- 2021 tea master (primary) examination materials and tea master (primary) simulation test questions
- 城市土地利用分布数据/城市功能区划分布数据/城市poi感兴趣点/植被类型分布
- 滑环使用如何固定
- Problems of font legend and time scale display of MATLAB drawing coordinate axis
- 2022 safety officer-c certificate examination paper and safety officer-c certificate simulated examination question bank
- The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1
猜你喜欢
Leetcode exercise - Sword finger offer 36 Binary search tree and bidirectional linked list
Talk about smart Park
The persistence mode of redis - RDB and AOF persistence mechanisms
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
2022 examination for safety production management personnel of hazardous chemical production units and new version of examination questions for safety production management personnel of hazardous chem
5、离散控制与连续控制
Write a pure handwritten QT Hello World
2、TD+Learning
ANSI / NEMA- MW- 1000-2020 磁铁线标准。. 最新原版
The Ministry of housing and urban rural development officially issued the technical standard for urban information model (CIM) basic platform, which will be implemented from June 1
随机推荐
Chapter improvement of clock -- multi-purpose signal modulation generation system based on ambient optical signal detection and custom signal rules
Redis cluster
写一个纯手写的qt的hello world
从Starfish OS持续对SFO的通缩消耗,长远看SFO的价值
Redis集群
Write a pure handwritten QT Hello World
NPDP在国内有认可度吗?看一看就明白了!
4. Strategic Learning
Understanding of prior probability, posterior probability and Bayesian formula
ANSI / NEMA- MW- 1000-2020 磁铁线标准。. 最新原版
qt--将程序打包--不要安装qt-可以直接运行
Grey correlation analysis link (portal) matlab
碳刷滑环在发电机中的作用
About snake equation (1)
如果时间是条河
Guojingxin center "APEC investment +": some things about the Internet sector today | observation on stabilizing strategic industrial funds
COMSOL----微阻梁模型的搭建---最终的温度分布和变形情况----几何模型的建立
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
用户之声 | 冬去春来,静待花开 ——浅谈GBase 8a学习感悟
Gnuradio3.9.4 create OOT module instances