当前位置:网站首页>图解网络:揭开TCP四次挥手背后的原理,结合男女朋友分手的例子,通俗易懂
图解网络:揭开TCP四次挥手背后的原理,结合男女朋友分手的例子,通俗易懂
2022-07-07 23:59:00 【InfoQ】
TCP三次握手简单回顾
- 首先客户端将发送一个SYN消息(
SYNchronize 的缩写)表示客户端要建立与服务端的连接。
- 服务端收到客户端的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四次挥手
- 生活中的例子
- 四次挥手原理分析
- 断开连接的最大生命周期
- 总结
边栏推荐
- 2、TD+Learning
- 第七章 行为级建模
- Leetcode notes No.7
- Guojingxin center "APEC education +" Shanghai Jiaotong University Japan Cooperation Center x Fudan philosophy class "Zhe Yi" 2022 New Year greetings
- 2022 high voltage electrician examination skills and high voltage electrician reexamination examination
- How does Matplotlib generate multiple pictures in turn & only save these pictures without displaying them in the compiler
- Mat file usage
- Problems of font legend and time scale display of MATLAB drawing coordinate axis
- NPM internal split module
- 5. Contrôle discret et contrôle continu
猜你喜欢

Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布

Redis cluster

LeetCode 练习——剑指 Offer 36. 二叉搜索树与双向链表

2021-03-06 - play with the application of reflection in the framework

如何让导电滑环信号更好

2021-04-12 - new features lambda expression and function functional interface programming

ANSI / NEMA- MW- 1000-2020 磁铁线标准。. 最新原版
Common fault analysis and Countermeasures of using MySQL in go language

Understanding of maximum likelihood estimation

Gnuradio3.9.4 create OOT module instances
随机推荐
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
2022 tea master (intermediate) examination questions and tea master (intermediate) examination skills
Guojingxin center "friendship and righteousness" - the meta universe based on friendship and friendship, and the parallel of "honguniverse"
Macro definition and multiple parameters
Scalar / vector / matrix derivation method
2022 safety officer-b certificate examination question bank and safety officer-b certificate simulation test questions
How to get the first and last days of a given month
regular expression
Deep learning website
滑环使用如何固定
break net
Gnuradio transmits video and displays it in real time using VLC
4. Strategic Learning
Getting started STM32 -- how to learn stm32
Leetcode notes No.21
5. Discrete control and continuous control
common commands
Qml 字体使用pixelSize来自适应界面
Understanding of sidelobe cancellation
COMSOL - Construction of micro resistance beam model - final temperature distribution and deformation - establishment of geometric model