当前位置:网站首页>TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
2022-07-03 02:47:00 【十九(一拖再拖)】
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
文章目录
1:TCP三次握手机制
- 客户端向服务端发送
SYN
包:
标志位:SYN
序号:Seq=x(随机值) - 服务端向客户端发送
SYN
ACK
报文:
标志位:SYN ACK
序号:Seq=y
确认号:Ack=x+1 - 客户端向服务端发送
ACK
报文
标志位:ACK
序号:Seq=x+1
确认号:Ack=y+1
2:TCP四次挥手机制
- 客户端向服务端发送断开报文:
标志位:FIN
序号:Seq=u(随机值) - 服务端向客户端发送报文:
标志位:ACK
序号:Seq=v
确认号:Ack=u+1 - 服务端将待传数据返回给客户端,待传数据发送完毕后再次向客户端发送TCP报文:
标志位:FIN ACK
序号:Seq=w
确认号:Ack=u+1 - 客户端向服务端发送报文:
标志位:ACK
序号:Seq=u+1
确认号:Ack=w+1
3:TCP握手超时处理机制
3.1:第一次握手失败
客户端向服务端发送 SYN
消息以建立连接。如果在一段时间内没有收到服务端的确认消息,它会等待一段时间继续发送 SYN
消息。如果它仍然没有收到服务器确认消息,会继续重复上述动作,直到发送次数超过最大重传次数。
3.2:第二次握手失败
服务端向客户端发送 SYN ACK
报文,服务端此时将阻塞等待客户端连接,等待客户端传来的 ACK
报文。如果客户端未收到该确认报文,则客户端会重新向服务端发送 SYN
报文,执行类似于 第一次握手失败
的处理动作。
3.3:第三次握手失败
客户端收到 SYN ACK
确认消息后,向服务端发送 ACK
报文。如果服务端长时间没有收到客户端的 ACK
消息,它会继续向客户端发送 SYN ACK
消息,重复上述动作,直到超过最大重传次数。
4:TCP为什么要三次握手
TCP的两次握手只能让客户端知道自己发送的数据可以被服务器接收,但是服务端无法判断客户端是否可以接收到自己的数据。
从上图中可以得知,仅仅一个客户端就会导致服务端开启多个端口,造成服务端开销的浪费。
5:TCP为什么要四次挥手
TCP 四次挥手保证了服务端在已经传输完所有数据的情况下断开连接。
边栏推荐
- 为什么会选择框架?选择什么样的框架
- Gbase 8C trigger (II)
- Tensorflow to pytorch notes; tf. gather_ Nd (x, y) to pytorch
- random shuffle注意
- sql server数据库添加 mdf数据库文件,遇到的报错
- [fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
- Process the dataset and use labelencoder to convert all IDs to start from 0
- Gbase 8C system table PG_ am
- Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes
- js根据树结构查找某个节点的下面的所有父节点或者子节点
猜你喜欢
Three. JS local environment setup
The process of connecting MySQL with docker
MATLAB小技巧(24)RBF,GRNN,PNN-神经网络
面试项目技术栈总结
Basic operation of binary tree (C language version)
Principle and application of database
Kubernetes cluster log and efk architecture log scheme
Kubernetes family container housekeeper pod online Q & A?
基于can总线的A2L文件解析(2)
Choose it when you decide
随机推荐
Why choose a frame? What frame to choose
Packing and unpacking of JS
SqlServer行转列PIVOT
【翻译】具有集中控制平面的现代应用负载平衡
Check log4j problems using stain analysis
Three.js本地环境搭建
Can netstat still play like this?
[C语言]给账号密码进行MD5加密
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
HTB-Devel
As a leader, how to control the code version and demand development when the epidemic comes| Community essay solicitation
Getting started | jetpack hilt dependency injection framework
where 1=1 是什么意思
Interview stereotyped version
Two dimensional format array format index subscript continuity problem leads to return JSON format problem
Source code analysis | layout file loading process
What does "where 1=1" mean
2022-2028 global splicing display industry research and trend analysis report
Wechat - developed by wechat official account Net core access
Gbase 8C system table PG_ constraint