当前位置:网站首页>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.
边栏推荐
- An article to teach you a quick start and basic explanation of Pytest, be sure to read
- shell (text printing tool awk)
- 爬虫request.get()出现错误
- 【PCBA方案】电子握力测试仪方案she‘ji
- 电力系统潮流计算(牛顿-拉夫逊法、高斯-赛德尔法、快速解耦法)(Matlab代码实现)
- 3D model reconstruction of UAV images based on motion structure restoration method based on Pix4Dmapper
- Live Classroom System 08 Supplement - Tencent Cloud Object Storage and Course Classification Management
- 测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
- 华为HCIE云计算之Fusion Access桌面云
- LeetCode-36-Binary search tree and doubly linked list
猜你喜欢
xshell (sed 命令)
【Maui正式版】创建可跨平台的Maui程序,以及有关依赖注入、MVVM双向绑定的实现和演示
shell编程之免交互
如何成为一名正义黑客?你应该学习什么?
Use Cloudreve to build a private cloud disk
这些不可不知的JVM知识,我都用思维导图整理好了
RK3399平台开发系列讲解(内核驱动外设篇)6.35、IAM20680陀螺仪介绍
JVM classic fifty questions, now the interview is stable
What is Jmeter? What are the principle steps used by Jmeter?
LeetCode-36-Binary search tree and doubly linked list
随机推荐
《DevOps围炉夜话》- Pilot - CNCF开源DevOps项目DevStream简介 - feat. PMC成员胡涛
Shell 编程--Sed
使用 Cloudreve 搭建私有云盘
2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
Shell编程规范与变量
交换机和生成树知识点
[SQL brush questions] Day3----Special exercises for common functions that SQL must know
华为HCIE云计算之Fusion Access桌面云
APP UI自动化测试常见面试题,或许有用呢~
Black cats take you learn Makefile article 13: a Makefile collection compile problem
QT笔记——vs + qt 创建一个带界面的 dll 和 调用带界面的dll
12 Recurrent Neural Network RNN2 of Deep Learning
SDP
LeetCode-402 - Remove K digits
什么是Jmeter?Jmeter使用的原理步骤是什么?
艺术与科技的狂欢,阿那亚2022砂之盒沉浸艺术季
Live Classroom System 09--Tencent Cloud VOD Management Module (1)
STL-deque
为什么一般公司面试结束后会说「回去等消息」,而不是直接告诉面试者结果?
c语言之 练习题1 大贤者福尔:魔法数,神奇的等式