当前位置:网站首页>Three handshake and four wave in tcp
Three handshake and four wave in tcp
2022-08-05 00:59:00 【hgswnsa】
Three handshake
The three-way handshake is the process of establishing a connection
Image
Before a connection is established: The server is in the LISTEN state and the client is in the CLOSED state.
First handshake: The client sends a synchronization segment SYN to the server, and specifies the client's initial serial number ISN. At this time, the client is in SYN_SENT status.
The synchronization bit in the header SYN=1 (SYN is just a flag bit, 0 means not SYN, 1 means SYN), initial serial number seq=x .A segment with SYN=1 cannot carry any data, but a sequence number must be specified.
Second handshake: After the server receives the synchronization segment SYN from the client, it will respond with its own SYN message, and also specify its own initial sequence number ISN, and at the same timeThe client's seq+1 will be used as the value of the confirmation sequence number ack, indicating that it has received the client's synchronization segment SYN, and the server is in the state of SYN_RCVD .
In the confirmation segment SYN=1, ACK=1 (ACK is also just a flag, 0 means notACK, 1 means ACK), initial serial number seq=y , confirmation serial number ack=x+1 , p>
Third handshake: After the client receives the synchronization segment SYN from the server, it will send an acknowledgement segment ACK, using the server's seq+1 as the value of ack, indicating thatI have received the synchronization segment SYN from the server.The client enters the ESTABLISHED state, and the server also enters the ESTABLISHED state after confirming the ACK of the segment.
Confirm the message segment ACK=1, the serial number seq=x+1, confirm the serial number ack=y+1,
At this point, both parties have established a connection and can send data normally.
Why is the three-way handshake three times?

Three handshakes to confirm that both parties are ready
The first handshake: the client can't confirm anything, the server confirms: the other party sends normally, and it receives normally
Second handshake: the client confirms: its own sending and receiving are normal, and the other party's sending and receiving are normal; the server confirms: the other party's sending is normal, and its own receiving is normal
The third handshake: The client confirms: its own sending and receiving are normal, and the other party's sending and receiving are normal; the server confirms: the other party's sending and receiving are normal, and its own sending and receiving are normal.
Four waves
Four waving is the disconnection process
Image
Both the client and the server can actively close the connection, only the first party to request to close will enter the TIME_WAIT state
Before disconnecting: Both client and server are in ESTABLISHED state, both parties can actively disconnect, and the client can actively disconnectIt is better to open the connection.
The first wave: The client intends to disconnect and sends a FIN message to the server. The FIN message will specify a serial number, and then the client enters FIN_WAIT_1 status.
That is, the client sends a connection release segment FIN=1, specifies the serial number seq=u, and actively closesTCP connection, waiting for confirmation from the server.
The second wave: After the server receives the FIN message, it sends an ACK response message to the client, using the client's FIN message sequence number seq+1 as the ACK response messageThe confirmation sequence number ack=u+1 of the segment, and the specified sequence number seq=v.
Then the server enters the CLOSE_WAIT state. At this time, the TCP is in a half-closed state, and the connection between the client and the server is released.After the client receives the ACK response segment from the server, it enters the FIN_WAIT_2 state.
The third wave: The server also intends to disconnect and send a FIN message to the client, after which the server enters the LASK_ACK state, waiting for the clientend confirmation.
In the connection release segment of the server FIN=1, ACK=1, serial number seq=w, confirm the serial number ack=u+1.
Fourth wave: After the client receives the FIN segment from the server, it will send an ACK response segment to the server, and the ACK sequence number ack of the FIN segment is used as the ACKThe sequence number seq of the response segment, and the sequence number seq+1 of the FIN segment is used as the acknowledgment sequence number ack.
After that, the client enters the state of TIME_WAIT. After the server receives the ACK response segment, the server enters the state of CLOSED.At this point, the connection to the server has been closed.
When the client is in the TIME_WAIT state, the TCP has not been released at this time, and it needs to wait for 2MSL before the client enters the CLOSED state.
边栏推荐
- 硬实力和软实力,哪个对测试人来说更重要?
- 张驰咨询:揭晓六西格玛管理(6 Sigma)长盛不衰的秘密
- Software testing interview questions: the difference and connection between black box testing, white box testing, and unit testing, integration testing, system testing, and acceptance testing?
- JVM类加载简介
- 2021年11月网络规划设计师上午题知识点(下)
- MongoDB搭建及基础操作
- GCC:屏蔽动态库之间的依赖
- 深度学习:使用nanodet训练自己制作的数据集并测试模型,通俗易懂,适合小白
- node uses redis
- gorm joint table query - actual combat
猜你喜欢

Bit rate vs. resolution, which one is more important?

5. PCIe official example

JWT简单介绍

LiveVideoStackCon 2022 上海站明日开幕!

Day Fourteen & Postman
](/img/4d/2d81dc75433c23c5ba6b31453396f0.png)
二叉树[全解](C语言)

CNI (Container Network Plugin)

MongoDB construction and basic operations

LiveVideoStackCon 2022 Shanghai Station opens tomorrow!

Gartner Hype Cycle:超融合技术将在2年内到达“生产力成熟期”
随机推荐
方法重写与Object类
JUC thread pool (1): FutureTask use
LiveVideoStackCon 2022 上海站明日开幕!
Gartner Hype Cycle:超融合技术将在2年内到达“生产力成熟期”
The method of freely controlling concurrency in the sync package in GO
如何用 Solidity 创建一个“Hello World”智能合约
Software testing interview questions: What are the three modules of LoadRunner?
sqlite--nested exception is org.apache.ibatis.exceptions.PersistenceException:
2021年11月网络规划设计师上午题知识点(上)
2022 Hangzhou Electric Power Multi-School Session 3 Question B Boss Rush
Software testing interview questions: How many types of software are there?
Software Testing Interview Questions: What is Software Testing?The purpose and principle of software testing?
接口自动化测试框架postman tests常用方法
【七夕如何根据情侣倾听的音乐进行薅羊毛】背景音乐是否会影响情侣对酒的选择
linux(centOs7)部署mysql(8.0.20)数据库
D - I Hate Non-integer Number (count of selected number dp
2022 Nioke Multi-School Training Session 2 J Question Link with Arithmetic Progression
B站7月榜单丨飞瓜数据B站UP主排行榜发布!
Interview summary: Why do interviewers in large factories always ask about the underlying principles of Framework?
面试汇总:为何大厂面试官总问 Framework 的底层原理?