当前位置:网站首页>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.
边栏推荐
- 类和对象:上
- Item 36: Specify std::launch::async if asynchronicity is essential.
- Kyoto University: Masaki Waga | Dynamic Masking for Reinforcement Learning in Black Box Environments
- RTL8762DK Lighting/LED (3)
- RTL8762DK UART (two)
- 考研备考方案
- WAASAP WebClient UI页面标签的决定逻辑介绍
- Carefully organize 16 MySQL usage specifications to reduce problems by 80% and recommend sharing with the team
- Automated machine learning pycaret: PyCaret Basic Auto Classification LightGBM
- 谷歌『云开发者速查表』;清华3D人体数据集;商汤『通用视觉框架』公开课;Web3极简入门指南;高效深度学习免费书;前沿论文 | ShowMeAI资讯日报
猜你喜欢
随机推荐
TFC CTF 2022 WEB Diamand WriteUp
[微服务]分布式事务解决方案-Seata
ECCV2022 Workshop | 复杂环境中的多目标跟踪和分割
Classes and Objects: Medium
sqlserver cannot connect remotely
RTL8762DK 使用DebugAnalyzer(四)
Rasa 3.x 学习系列- Rasa - Issues 4918 学习笔记
RTL8762DK UART (two)
[Microservice] Distributed Transaction Solution - Seata
leetcode: 1648. Color ball with decreasing sales value [Boundary find by two points]
Classes and Objects: Above
An open source and easy-to-use flowchart drawing tool drawio
RTL8762DK PWM(七)
精心总结十三条建议,帮你创建更合适的MySQL索引
虹科分享|如何用移动目标防御技术防范未知因素
力扣2326、197
pycaret源码分析:下载数据集\Lib\site-packages\pycaret\datasets.py
Binary tree traversal non-recursive program -- using stack to simulate system stack
Modern Enterprise Architecture Framework 1
【Cryptography/Cryptanalysis】Cryptanalysis method based on TMTO