当前位置:网站首页>TCP connection and disconnection, detailed explanation of state transition diagram
TCP connection and disconnection, detailed explanation of state transition diagram
2022-06-26 06:14:00 【Ah Jie's small fish pond】
One 、 summary
This paper mainly focuses on TCP The three handshakes and four waves in the state transition diagram are summarized , About the process of handshake and wave, you can see the following :
https://blog.csdn.net/hjlogzw/article/details/122312496
Two 、 Explain the state transition diagram in detail
Let's start with a classic state transition diagram :
CLOSED: The initial state .
LISTEN: That is, the server is listening , You can receive customer connections , It's called listen Function is in this state .
SYN_RCVD: It generally indicates the status of the server , I'll take it SYN The message is sent until the client returns the last of the three handshakes ACK message , After receiving the client ACK Then establish the connection , Enter into ESTABLISHED state .
SYN_SENT: It generally indicates the status of the client , And SYN_RCVD Corresponding , When the client calls connect Function time , It will be sent first SYN message , This is when we enter SYN_SENT state , And wait for the server to ACK message .
ESTABLISHED: This status indicates that the connection has been established .
FIN_WAIT_1: When the connection enters ESTABLISHED Post state , If one end wants to actively close the connection , Send to the opposite end FIN message , Now enter FIN_WAIT_1 state , When the opposite end replies ACK After the message , Then go to FIN_WAIT_2 state .
FIN_WAIT_2: The connection in the changed state is in the semi connected state , It means that one party requests to close the connection , But the other party still has data to send , Close the connection later .
TIME_WAIT: When receiving from the other party FIN message , And sent ACK After the message , becomes TIME_WAIT state , Waiting for the 2MSL Then return to the initial state CLOSED. It is worth noting that , If in FIN_WAIT_1 State, , Receive the other party and bring FIN Logo and ACK When the message is marked , You can go straight to TIME_WAIT state , No need to go through FIN_WAIT_2 state , As shown in the figure below .
CLOSING: This state is rare , In general , Sending FIN After the message , Should first receive the other party's ACK message , Again ( Or received at the same time ) The other person's FIN message . But CLOSING Status indicates sending FIN After the message , Didn't receive the other party's ACK message , But also received the other party's FIN message , This actually shows that both sides should close This connection , As shown in the figure below :
CLOSE_WAIT: I.e. wait for shutdown , When the opposite end calls close Post send FIN The message is sent to the local terminal , In response ACK And then we went to CLOSE_WAIT state , Next, you need to consider whether there is any data not sent to the other party , If not, you can send FIN Message to the other party , This closes the connection .
LAST_ACK: That is, the passive closing party is sending FIN After the message , Waiting for each other's ACK Status of the message , When you receive it, you will enter CLOSED The initial state .
notes :
2MSL Why :
- Give Way 4 This handshake closure process is more reliable ;4 The last handshake ACK It is sent by the active shutdown party , If this ACK The loss of , The passive closing party will send another FIN To come over . If the active shutdown party can maintain a 2MSL Of TIME_WAIT state , There is a greater chance for the lost ACK Sent again .
- Prevent the last response package from affecting the new connection .
Reference resources :
https://blog.csdn.net/qq_32642107/article/details/107289298
https://www.csdn.net/tags/MtTaEg3sMzAxNTI3LWJsb2cO0O0O.html
https://baijiahao.baidu.com/s?id=1707040989071212058&wfr=spider&for=pc
https://wenku.baidu.com/view/d165f05c3b3567ec102d8a2a.html
边栏推荐
- Transformer中的Self-Attention以及Multi-Head Self-Attention(MSA)
- E-commerce seeks growth breakthrough with the help of small program technology
- Day4 branch and loop
- Install pyinstaller
- numpy. tile()
- Summary of JVM interview focus (II) -- garbage collector (GC) and memory allocation strategy
- Getting started with Python
- ES6的搭配环境
- Detailed explanation of serial port communication principle 232, 422, 485
- Basic construction of SSM framework
猜你喜欢

Vs2022 offline installation package download and activation

数据治理工作的几种推进套路

消息队列-全方位对比

消息队列-功能、性能、运维对比

University Information Management System

Prototype mode, Baa Baa

Understanding of nil in go language

Test depends on abstraction and does not depend on concrete

MySQL 索引底层原理

How to design a good technical scheme
随机推荐
tf.nn.top_k()
Playing RTSP streaming video on Web pages (webrtc)
SQL Server 函数
SSH keygen specifies the path
Message queuing - omnidirectional comparison
Implement the runnable interface
Spark source code analysis (I): RDD collection data - partition data allocation
Explore small program audio and video calls and interactive live broadcast from New Oriental live broadcast
Install pyinstaller
numpy. frombuffer()
技术Leader的思考技巧
Factory method pattern, abstract factory pattern
Tencent's 2022 school recruitment of large factories started with salary, and the general contracting of cabbage is close to 40W!
MVC source code sharing
MySQL-06
在web页面播放rtsp流视频(webrtc)
消息队列-功能、性能、运维对比
Redis underlying data structure
Transaction and message semantics
架构设计方法