当前位置:网站首页>After a/b machine is connected normally, B machine suddenly restarts. Ask a what is the TCP status at this time? How to eliminate this state in the server program?
After a/b machine is connected normally, B machine suddenly restarts. Ask a what is the TCP status at this time? How to eliminate this state in the server program?
2022-06-11 01:21:00 【zhen12321】
This is a very interesting problem . ha-ha .
First , be based on tcp Come here , In the course of such a communication , It probably takes a few steps , for example tcp Three and four waves of .
that , The difference between three times and four times is that there is no need to transmit data , Don't have to etc. 1 Round trip time , Save bandwidth .
that ,SYN Mainly used for connection confirmation ,FIN It is mainly used for initialization confirmation when one party abandons the connection ,RET What is the ?
This is the key to the problem .
linux Generally speaking, the kernel will have a lot of time to cover up , To ensure a maximum lifetime of a connection .
stay ubuntu18.04 On , once tcp The maximum lifetime of a connection is several days , Each time a connection is initiated by both parties, a ACK The confirmation of . This confirmation message is critical , It was this link before the confirmation was received , Not disconnected . that ubuntu18.04 Well , The confirmation time is 5 minute .
that , When a party suddenly hangs up , The other party cannot know that the other party hangs up , Because they didn't give it to themselves FIN To break off , If you don't take the initiative to contact each other , Then the connection will be maintained , Until the time of the operating system comes .
Say it again , In fact, it's easy to say how long the operating system has been running , Because that time every time there is a new TCP When the activity comes, it will refresh . While the latter ACK Mainly in the ACK It will refresh itself when it comes . because TCP Links are expensive , So I put forward keep-alive This field is used to reuse as many requests as possible in one connection , It can't be used as a magic medicine to reuse it all the time .
keep-alive You can set the timeout time , This is the timeout of the application layer , Is the time controlled by the application layer , The priority weight is greater than the lower level .
So in B Within one end of the time of hang up and restart ,A Also a bit this connection remains , So it will always exist , know B Restart and naturally enter listen state , This is the time ,B I don't know myself and A There were connections before .
At this point, the only thing that can change the status quo is A,A Take the initiative to send any message to B,B It was detected that the communication was abnormal , Will ask to reset the connection , So send RST to A,A After receiving it, you will reset yourself tcp Various times of connection . then A It is in the critical state of sending messages to the kernel , It will naturally enter SYN_SEND state .
边栏推荐
- Beijing Pinggu District high tech enterprise cultivation support standard, with a subsidy of 100000 yuan
- 深圳市南山区专精特新企业申报流程,补贴10-50万
- 北京中国专利奖申报流程介绍,补贴100万
- IRS应用发布之十五:应用安全自测指南
- 快递鸟系统对接
- How much is the bonus of China Patent Award, with a subsidy of 1million yuan
- Time dependent - format, operation, comparison, conversion
- 2022北京怀柔区新技术新产品(服务)认定要求
- ion_dma_buf_begin_cpu_access
- 深圳中国专利奖申报流程介绍,补贴100万
猜你喜欢

Docking of express bird system

ZABBIX offline installation

NVIDIA Jetson's PWM Fan custom control

ViewPager和底部无线循环的小圆点

Network foundation (1) -- understanding the network

Direct insert sort and shell sort

Summary of pytorch classification problems

Team management | how to improve the thinking skills of technical leaders?

Recruitment | Nanjing | triostudio Sanli Agency - Interior Designer / construction drawing deepening Designer / device / Product Designer / Intern, etc
![[introduction to ROS] - 03 basic concepts and instructions of ROS](/img/d4/a9b49dddbe0be8b53acf71219d0959.png)
[introduction to ROS] - 03 basic concepts and instructions of ROS
随机推荐
Understanding of multithreading
Some tips for programmers to deal with stress
What is the C-end and what is the b-end? Let me tell you
WPF - timeline class
[introduction to ROS] - 03 single chip microcomputer, PC host and ROS communication mechanism
Hash table (hash table \u hashtable)_ Array + linked list_ Code for employee management
中国专利奖申报流程介绍,补贴100万
什么是C端 什么是B端 这里告诉你
Array simulation [queue] and [ring queue]_ code implementation
IRS application release 15: application security self test guide
Clean up the broken artifacts data (.lastUpdated files) and reload the project. Problem resolution
Introduction to the application process of Shenzhen China Patent Award, with a subsidy of 1million yuan
Centos7 actual deployment mysql8 (binary mode)
限流与下载接口请求数控制
How much is the bonus of China Patent Award, with a subsidy of 1million yuan
北京东城区高新技术企业培育支持标准,补贴10万
Project_ Visual analysis of epidemic data based on Web Crawler
Store binary tree in sequence [store tree in array]
北京中国专利奖申报流程介绍,补贴100万
OTA升级