当前位置:网站首页>What would happen if disconnecting during the process of TCP connection?
What would happen if disconnecting during the process of TCP connection?
2022-08-10 22:31:00 【TABE_】
What happens if the network cable is unplugged during a TCP connection?
In response to this issue, it is necessary to discuss in different scenarios:
- After unplugging the network cable, there is data transmission;
- After unplugging the network cable, there is no data transmission;
Data transmission after unplugging the network cable
After the client unplugs the network cable, the data packet sent by the server to the client will not receive any response. After waiting for a certain period of time, The server will trigger a timeout retransmission mechanism, retransmit data packets that do not receive a response.
If the client just plugs the network cable back in while the server is retransmitting the message.Since unplugging the network cable does not change the TCP connection status of the client, and it is still in the ESTABLISHED state, the client can normally receive the data packet sent by the server, and then the client will return an ACK response packet.At this point, the TCP connection between the client and the server still exists, and it feels like nothing happened.
But if the client has not plugged the network cable back in the process of retransmitting the message from the server.When the number of times the server retransmits the message over time reaches a certain threshold, the kernel will determine that there is a problem with the TCP, and then tell the application that there is a problem with the TCP connection through the Socket interface, so the TCP connection on the server will be disconnected.After the client is plugged back into the network cable, if the client sends data to the server, since the server has no TCP connection with the same quadruple ancestor as the client, the server kernel willReply to the RST message, and the client will release the TCP connection after receiving it.At this point, both the client and server TCP connections have been disconnected.
No data transfer after unplugging the network cable
- If the TCP keepalive mechanism is not enabled by both parties, after the client unplugs the network cable, if the client does not plug in the network cable, the TCP connection state between the client and the server will always exist.
- If both parties have enabled the TCP keepalive mechanism, then after the client unplugs the network cable, if the client does not plug back the network cable, the TCP keepalive mechanism will detect that the other party's TCP connection is not alive, so it will disconnect the TCP connection.However, if the client plugs back the network cable during the TCP detection period, the original TCP connection between the two parties can still exist normally.
KeepAlive mechanism: When there is no data transmission in the connection for a period of time, TCP automatically sends a message with empty data to the other party. If the other party responds to this message, it means that the other party is still online and connected.It can continue to be maintained. If the other party does not return a message and retries many times, the connection is considered lost, and there is no need to maintain the connection.
边栏推荐
- 高通平台开发系列讲解(应用篇)QCMAP应用框架介绍
- 虚拟地址空间
- Using SylixOS virtual serial port, serial port free implementation system
- 关于 DataFrame: 处理时间
- Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems
- JVM classic fifty questions, now the interview is stable
- camera preview process --- from HAL to OEM
- ThreadLocal comprehensive analysis (1)
- Redis Performance Impact - Asynchronous Mechanisms and Response Latency
- 云服务器基于 SSH 协议实现免密登录
猜你喜欢
mmpose关键点(一):评价指标(PCK,OKS,mAP)
A shell script the for loop statements, while statement
win系统下pytorch深度学习环境安装
Using SylixOS virtual serial port, serial port free implementation system
Shell编程规范与变量
《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛
shell (text printing tool awk)
C#【必备技能篇】Hex文件转bin文件的代码实现
为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
How to translate financial annual report, why choose a professional translation company?
随机推荐
Shell 编程--Sed
链表中的节点每k个一组翻转
【640. 求解方程】
Interpretation of the paper (g-U-Nets) "Graph U-Nets"
uni-app微信小程序——下拉多选框
阿里云贾朝辉:云XR平台支持彼真科技呈现国风科幻虚拟演唱会
APP UI自动化测试常见面试题,或许有用呢~
LeetCode每日一题(1573. Number of Ways to Split a String)
2022年8月的10篇论文推荐
shell(文本打印工具awk)
2022.8.9 Mock Competition
边缘与云计算:哪种解决方案更适合您的连接设备?
元宇宙社交应用,靠什么吸引用户「为爱发电」?
Extended Chinese Remainder Theorem
MySQL Advanced Commands
Self-organization is a two-way journey between managers and members
关于 DataFrame: 处理时间
Live Classroom System 09--Tencent Cloud VOD Management Module (1)
LeetCode-36-Binary search tree and doubly linked list
ASCII、Unicode和UTF-8