当前位置:网站首页>TCP three handshakes and four swings
TCP three handshakes and four swings
2022-07-20 10:00:00 【worn. xiao】
TCP(Transmission Control Protocol, Transmission control protocol ) It's a connection oriented protocol , in other words , Before sending and receiving data , Must establish a reliable connection with the other party . One TCP The connection has to go through three times “ dialogue ” To build it up , The process is very complicated , Just briefly describe the simple process of these three conversations .
Briefly describe the process of three handshakes :
Before we start to explain , First, let's talk about the full names of several important fields , Convenient memory :
seq:(sequence number) Serial number
ack:(acknowledgement number) Confirmation no.
Sign a :
SYN :(SYNchronization) Sync
ACK :(ACKnowlegment) confirm
FIN :(FINish) End
Let's take a look at the general picture first :
The first handshake :Client The flag bit will be synchronized SYN Set as 1(SYN by 1 It means to establish a connection , After the connection is successful, the location will be set to 0), Request number seq=x( In all byte arrangements , Which byte does the request start from , This serial number generally indicates which serial number has been sent to , After the server agrees, it will send from the next serial number , The first handshake only has the request serial number but no confirmation number ), And send the packet to Server,Client Get into SYN_SENT state , wait for Server confirm .
The second handshake :Server After receiving the data packet, the synchronization flag bit SYN=1 know Client Request to establish a connection , Confirm flag bit ACK Set as 1( Only then will there be a confirmation flag , The first handshake did not confirm the flag bit . When the confirmation flag is 0 when , Confirmation number does not work ),ack=x+1( Confirm that the sequence number is equal to the request sequence number +1, Express x+1 Previous Server received , from Server The request sent has been received ).TCP It's full duplex protocol , therefore Server May also give Client send data , therefore Server Also will Client Establishing a connection ,Server The flag bit will be synchronized SYN Set as 1(Server We should also ask for help Client Send a request , therefore SYN It should also be set to 1),seq=y It means Server to Client Start sequence number of sent data . And send the packet to Client To confirm the connection request ,Server Get into SYN_RCVD state .
The third handshake : Because the connection should be bidirectional ,Server After confirmation, only Client To Server Connected , therefore Client Also make sure , To make Server towards Client The connection of is also connected .Client and Server Get into ESTABLISHED state , Complete three handshakes , And then Client And Server You can start transferring data between .
Design such a similar scenario :
1、 Client host C say :“ Can I send you data ?”
2、 The server S say :“ Tolerable , But I may also send you data .”
3、C:“ good , Let me start sending data to each other .”
Four waves
Four waves (Four-Way Wavehand) Termination TCP Connect , To disconnect one TCP When the connection , The client and server need to send a total of 4 Packages to confirm disconnection . stay socket Programming , This process is performed by either the client or the server close To trigger .
because TCP Connection is full duplex , therefore , Each direction must be closed separately . The principle is that when one party completes the data transmission task , Send a FIN To terminate the connection in this direction , Receive a FIN It just means there's no data flow in this direction , No more data . But here TCP Data can still be sent on the connection , Until the other direction also sent FIN. Active shutdown will be performed by the first party to close , The other party performs a passive shutdown , This is what is described above .
First wave :Client Send a FIN, And the selection number seq=u( Express :u All previous data has been sent , And the data is sent to u It can be cut off , There will be no more data ), Used to close Client To Server Data transfer of .Client Get into FIN_WAIT_1 state .
Second wave :Server received FIN after , Send a request number seq=v And confirm the serial number ack=u+1 to Client.Server Get into CLOSE_WAIT state .
Third wave :Server Send a FIN, The request number is the latest seq=w And confirm the serial number ack=u+1, Used to close Server To Client Data transfer of .Server Get into LAST_ACK state .
Fourth wave :Client received FIN after ,Client Get into TIME_WAIT state , And then send a ACK to Server, Confirm serial number is w+1.Server Get into CLOSED state , Finish four waves .
The scene of four waves is roughly like this :
1、 Client host C say :“ I have no data , Disconnect . ”
2、 The server S say :“ good , But I still have data ( Continue to C send data , here C Can't give S Sent data , But if you have to, just accept S Data sent ).”
3、( When S to C After sending data )S say :“ I'm done , Disconnect .”
4、C say :“ good , Disconnect .”
边栏推荐
- 内网渗透隧道技术的相关知识
- FPGA -- detailed explanation of the principle of displaying images with VGA timing (2)
- Infrared decoding program based on timer capture function (NEC protocol)
- Carte centrale de la série g2l - Introduction au processeur rz / g2l | schéma de cadre | consommation d'énergie | schéma et Guide de conception matérielle
- Add directory navigation to personal blog website articles
- Openstack uses dashboard to perform image operations, manage instances, and other operations
- 雷达基础知识
- ARM中断优先级之理解
- RDO deployment openstack single node
- 二分查找 mid值溢出问题
猜你喜欢
Output PWM square wave with ls1028a development board
详细讲解JS中的加法(+)运算,基本数据类型相加,引用数据类型相加底层的运算规则,[]+{},{}+[]
FPGA majority voter (including code)
[vscade configuration markdown environment] user friendly~
Intelligent gateway based on Ruixin micro 3568 core board
川菜菜谱(一)
When the vivado project version is upgraded, the relevant IP version IP status displays using cached IP results
Precautions for the selection and conversion of single power supply operational amplifier and dual power supply operational amplifier and their power supply mode
【Vscode配置Markdown环境】亲测好用~
First hand evaluation of Reza g2l core board and development board
随机推荐
2022-7-11 第八小组 顾宇佳 学习笔记(Js)
Vulnhub target earth
[DOM] first knowledge of DOM
Differences between types any, void, unknown, and never in typescript
Depth evaluation of Ruixin micro rk3568 development board
Qt给控件添加鼠标事件
Quanzhi t507 realizes the whole process of SPI to can
Cible vulnhub jangow: 1.0.1
解决问题phpstudy导入数据库失败
First hand evaluation of Reza g2l core board and development board
三极管串联线性稳压电路原理详解及Multisim仿真
FPGA majority voter (including code)
代码审计之企业级进销存管理系统
软件工程期末复习思维导图
皮尔逊相关系数及代码实现(C语言+MATLAB)
i. Mx8mp development board porting USBWiFi rtl8192eu driver
ESM测向误差对定位误差的影响分析
Ktor 2.0? Half fragrant embarrassment
Summary of errors reported during compilation of vivado2020
(data and electricity) summary of various triggers - FPGA octet (1)