当前位置:网站首页>Three handshakes and four waves
Three handshakes and four waves
2022-07-31 05:31:00 【The flowers are blooming in the south of the city^】
Three handshake
1. The first handshake: The client sends a data packet with the bit code SYN = 1 (the SYN flag bit is set) and randomly generates the initial sequence number Seq = J to the server.The server is informed by SYN = 1 (set) that the client has requested to establish a connection.
2. The second handshake: After the server receives the request, it needs to confirm the connection information, and sends the confirmation number to the client Ack = (client's Seq +1, J+1), SYN = 1, ACK = 1 (SYN,ACK flag bit is set), randomly generated sequence number Seq = K data packet.
3. The third handshake: After the client receives it, check whether the Ack is correct, that is, the Seq +1 (J+1) sent for the first time, and whether the bit code ACK is 1.If it is correct, the client will send Ack = (Seq+1 on the server side, K+1), ACK = 1, and an acknowledgment packet whose sequence number Seq is the server acknowledgment number J.After the server receives it and confirms the previously sent Seq(K+1) value and ACK= 1 (ACK is set), the connection is established successfully.After these three steps, the client and the server successfully establish a TCP connection.These three steps are collectively referred to as the three-way handshake.
The above Seq represents the sequence number, Ack represents the confirmation number, SYN and ACK and FIN are all flag bits.ACK is set to 1 to indicate that the acknowledgment number field is valid, if ACK is 0, the segment does not contain acknowledgment information.SYN is used in the connection establishment process. In the connection request, SYN = 1 and ACK = 0 indicate that the segment does not have a piggybacked acknowledgment field.The connection reply will piggyback an acknowledgment, so the reply will have SYN= 1 and ACK= 1.Also there is no cost to send an ACK, so we will see that once a connection is established, the ACK flag is always set to 1
Four waves
1. The client sends a FIN Seq = M (FIN set, serial number is M) packet to close the data transfer from the client to the server.
2. When the server receives this FIN, it sends back an ACK, confirming that the sequence number Ack is the received sequence number M+1.
3. The server closes the connection with the client and sends a FIN Seq = N to the client.
4. The client sends back an ACK message for confirmation, and the confirmation sequence number Ack is the received sequence number N+1.
For the four times of wave, in fact, if you look carefully, it is twice, because TCP is full-duplex, and both sides must be closed.At the time of termination, one side is passive, so it seems to be four waves.
边栏推荐
猜你喜欢

Apache DButils使用注意事项--with modifiers “public“

为什么要用Flink,怎么入门使用Flink?

centos7安装mysql5.7

Anaconda配置环境指令

基于web3.0使用钱包Metamask的三方登陆
【一起学Rust】Rust的Hello Rust详细解析

DVWA之SQL注入

Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?

Centos7 install mysql5.7

Mysql——字符串函数
随机推荐
Flask 的初识
数据集划分以及交叉验证法
Anaconda配置环境指令
Minesweeper game (written in c language)
Distributed transaction processing solution big PK!
账号或密码多次输入错误,进行账号封禁
Redis的初识
MySQL8.0.26安装配置教程(windows 64位)
Why use Flink and how to get started with Flink?
Three oj questions on leetcode
ABC D - Distinct Trio (Number of k-tuples
MySQL事务隔离级别详解
centos7安装mysql5.7
Input length must be multiple of 8 when decrypting with padded cipher
Lock wait timeout exceeded解决方案
Tapdata 与 Apache Doris 完成兼容性互认证,共建新一代数据架构
MySQL-如何分库分表?一看就懂
Interviewer: If the order is not paid within 30 minutes, it will be automatically canceled. How to do this?
1. 获取数据-requests.get()
MySQL forgot password