当前位置:网站首页>You need to know the TCP wave four times
You need to know the TCP wave four times
2022-08-01 01:08:00 【Front-end watermelon brother】
Hello everyone, I'm the front-end watermelon brother.Today I will tell you about the four waves of TCP.
After establishing a TCP connection for a period of time, if you want to disconnect the TCP connection, the process of waving TCP four times will be performed to complete the disconnection operation.
The process of TCP four times is a bit like the three-way handshake that TCP establishes a connection.About the three-way handshake, you can read my article: "TCP three-way handshake you need to know"
The following figure shows the structure of the TCP header. Our TCP four-way wave mainly uses the yellow part.

The initiator of the three-way handshake must be different from the client, and the initiator of the disconnection of the TCP connection can be any party.For the convenience of explanation, below we describe the client as the initiator.
TCP four wave process
Let's look at the schematic first.

The first wave, the client sends a TCP request to the server, and the
in the TCP headerFIN set to 1
seq is set to a random number x
FIN is a flag bit that means finish, 1 is equivalent to true.
seq is a serial number, a place for data, we set it as a random number here to confirm to the server, so as to correspond to this TCP request.
The second wave, the server sends the TCP, and adds the
in the TCP headerACK is set to 1 (acknowledge, meaning "received")
The ack confirmation number is set to x+1 (x is from the first wave)
When the client receives this TCP request, it means that the channel from the client to the server has been closed, and you can no longer send normal data requests to the server.
At this time, the server can still send data to the client.If the server has some previous TCP requests that have not had time to respond, it can still return during the second wave and the third wave.
The third wave, the server sends a TCP request to the client:
FIN set to 1
seq is set to a random number y
Similar to the first wave, only this time the sender is the server.
The fourth wave, the client sends a TCP request to the server:
ACK set to 1
ack confirmation number set to y+1
After the server receives this request, the server can successfully change to the CLOSE state.The client will wait for a period of time before entering the closed state, because the fourth wave may not be successfully sent to the server, so wait and see if the server will resend the first wave because it did not receive the fourth wave.Three waves.
End
Different from the TCP three-way handshake.There are four full waves of TCP to close the connection.This is because between the second wave and the third wave, there may be some slow-processing data that the server needs to send to return, so the two waves are not combined.
I am the front-end watermelon brother, welcome to follow me and master more front-end knowledge.
边栏推荐
- Rasa 3.x 学习系列- Rasa - Issues 4918 学习笔记
- 两院院士直言:不要迷信院士
- Cmake introductory study notes
- Recommendation system: Summary of common evaluation indicators [accuracy rate, precision rate, recall rate, hit rate, (normalized depreciation cumulative gain) NDCG, mean reciprocal ranking (MRR), ROC
- Academicians of the two academies speak bluntly: Don't be superstitious about academicians
- 继承和友元,静态成员的关系
- What is the meaning of JS timestamp?Know SQL will consider to add a timestamp, JS timestamp for the scene?
- leetcode: 1648. Color ball with decreasing sales value [Boundary find by two points]
- NIO programming
- 网关gateway跨域
猜你喜欢
随机推荐
值传递还是引用传递(By Value or By Reference)
【Cryptography/Cryptanalysis】Cryptanalysis method based on TMTO
RTL8762DK Lighting/LED (3)
TCP协议详解
Academicians of the two academies speak bluntly: Don't be superstitious about academicians
Web API 介绍和类型
设计消息队列存储消息数据的MySQL表格
OSF understands the agile development model in one minute
现代企业架构框架1
Nmap Operation Manual - Full Version
Blueprint: Yang Hui's Triangular Arrangement
mySql data view
Classes and Objects: Medium
Nmap 操作手册 - 完整版
OSD read SAP CRM One Order application log way of optimization
Notes on how to use zeno
vector的基本实现
Binary tree traversal non-recursive program -- using stack to simulate system stack
What is the meaning of JS timestamp?Know SQL will consider to add a timestamp, JS timestamp for the scene?
Rainbow share | how to use moving targets defense technology to guard against the unknown







![leetcode: 1562. Find latest grouping of size M [simulation + endpoint record + range merge]](/img/72/f52b5d3dcdb271f096c3e5108f0042.png)

