当前位置:网站首页>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.
边栏推荐
- [MQ I can speak for an hour]
- MySQL optimization slow log query
- sql语句之多表查询
- 【一起学Rust】Rust学习前准备——注释和格式化输出
- Centos7 install mysql5.7
- 信息系统项目管理师核心考点(五十五)配置管理员(CMO)的工作
- Simple read operation of EasyExcel
- 账号或密码多次输入错误,进行账号封禁
- Unity resources management series: Unity framework how to resource management
- Shell重油常压塔模拟仿真与控制
猜你喜欢
随机推荐
Refinement of the four major collection frameworks: Summary of List core knowledge
SQL语句中对时间字段进行区间查询
MySQL优化:从十几秒优化到三百毫秒
快速掌握并发编程 --- 基础篇
[Detailed explanation of ORACLE Explain]
剑指offer基础版 ----第31天
工作流编排引擎-Temporal
Minesweeper game (written in c language)
1. 获取数据-requests.get()
剑指offer专项突击版 --- 第 4 天
【LeetCode-SQL每日一练】——2. 第二高的薪水
pycharm专业版使用
About the problems encountered by Xiaobai installing nodejs (npm WARN config global `--global`, `--local` are deprecated. Use `--location=glob)
如何将项目部署到服务器上(全套教程)
分布式事务处理方案大 PK!
The interviewer asked me TCP three handshake and four wave, I really
面试官竟然问我怎么分库分表?幸亏我总结了一套八股文
剑指offer专项突击版 ---- 第 6 天
CentOS7 安装MySQL 图文详细教程
Input length must be multiple of 8 when decrypting with padded cipher