当前位置:网站首页>TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
2022-07-03 02:47:00 【十九(一拖再拖)】
TCP 三次握手和四次挥手机制,TCP为什么要三次握手和四次挥手,TCP 连接建立失败处理机制
文章目录
1:TCP三次握手机制

- 客户端向服务端发送
SYN包:
标志位:SYN
序号:Seq=x(随机值) - 服务端向客户端发送
SYNACK报文:
标志位: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 四次挥手保证了服务端在已经传输完所有数据的情况下断开连接。
边栏推荐
- Source code analysis | resource loading resources
- How to return ordered keys after counter counts the quantity
- Gbase 8C trigger (I)
- HTB-Devel
- Error invalid bound statement (not found): com ruoyi. stock. mapper. StockDetailMapper. XXXX solution
- Matlab tips (24) RBF, GRNN, PNN neural network
- [fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
- Check log4j problems using stain analysis
- [principles of multithreading and high concurrency: 1_cpu multi-level cache model]
- Add some hard dishes to the interview: how to improve throughput and timeliness in delayed task scenarios!
猜你喜欢

Add automatic model generation function to hade
![[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)](/img/6a/ae44ddb090ce6373f04a550a15f973.jpg)
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)

Sqlserver row to column pivot

Super easy to use logzero

Random Shuffle attention
![[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)](/img/65/c1fe95f8c391394f7ff1b75c7d75b6.jpg)
[shutter] setup of shutter development environment (supplement the latest information | the latest installation tutorial on August 25, 2021)

Deep learning: multi-layer perceptron and XOR problem (pytoch Implementation)

基于can总线的A2L文件解析(2)

Today, it's time to copy the bottom!

Build a private cloud disk cloudrev
随机推荐
Cron表达式介绍
[advanced ROS] Lesson 6 recording and playback in ROS (rosbag)
定了,就选它
Use optimization | points that can be optimized in recyclerview
"Analysis of 43 cases of MATLAB neural network": Chapter 43 efficient programming skills of neural network -- Discussion Based on the characteristics of the new version of MATLAB r2012b
Simple understanding of SVG
javeScript 0.1 + 0.2 == 0.3的问题
Super easy to use logzero
Random shuffle note
where 1=1 是什么意思
Build a private cloud disk cloudrev
[fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
random shuffle注意
Compréhension simple de SVG
Three.js本地环境搭建
Source code analysis | layout file loading process
How to return ordered keys after counter counts the quantity
一文带你了解 ZigBee
【翻译】Flux安全。通过模糊处理获得更多信心
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记