当前位置:网站首页>TCP重传机制有哪些?
TCP重传机制有哪些?
2022-07-29 01:58:00 【Meme_xp】
TCP 实现可靠传输的⽅式之⼀,是通过序列号与确认应答。
在 TCP 中,当发送端的数据到达接收主机时,接收端主机会返回⼀个确认应答消息,表示已收到消息。
1、超时重传
重传机制的其中⼀个⽅式,就是在发送数据时,设定⼀个定时器,当超过指定的时间后,没有收到对⽅的 ACK确认应答报⽂,就会重传该数据,也就是我们常说的超时重传。
TCP 会在以下两种情况发⽣超时重传:
1.数据包丢失
2.确认应答丢失
超时时间应该设置为多少呢?
1.当超时时间较⼤时,重发就慢,丢了⽼半天才重传,没有效率,性能差;
2.当超时时间 较⼩时,会导致可能并没有丢就重发,于是重传的就快,会增加⽹络拥塞,导致更多的超时,更多的超时导致更多的重传。
根据上述的两种情况,我们可以得知,超时重传时间 RTO 的值应该略⼤于报⽂往返 RTT 的值。
2、快速重传
快速重传(Fast Retransmit)机制,它不以时间为驱动,⽽是以数据驱动重传。
快速重传的⼯作⽅式是当收到三个相同的 ACK 报⽂时,会在定时器过期之前,重传丢失的报⽂段。
快速重传机制只解决了⼀个问题,就是超时时间的问题,但是它依然⾯临着另外⼀个问题。就是重传的时候,是重传之前的⼀个,还是重传所有的问题。
为了解决不知道该重传哪些 TCP 报⽂,于是就有 SACK ⽅法。
3、SACK 方法
SACK ( Selective Acknowledgment 选择性确认):这种⽅式需要在 TCP 头部「选项」字段⾥加⼀个 SACK 的东⻄,它可以将缓存的地图发送给发送⽅,这样发送⽅就可以知道哪些数据收到了,哪些数据没收到,知道了这些信息,就可以只重传丢失的数据。
4、Duplicate SACK
其主要使⽤了 SACK 来告诉「发送方」有哪些数据被重复接收了。
(1)情形1:ACK 丢包
1.「接收⽅」发给「发送⽅」的两个 ACK 确认应答都丢失了,所以发送⽅超时后,重传第⼀个数据包(3000 ~3499)
2.于是「接收⽅」发现数据是重复收到的,于是回了⼀个 SACK = 3000~3500,告诉「发送⽅」 3000~3500的数据早已被接收了,因为 ACK 都到了 4000 了,已经意味着 4000 之前的所有数据都已收到,所以这个SACK 就代表着 D-SACK 。
3.这样「发送⽅」就知道了,数据没有丢,是「接收⽅」的 ACK 确认报⽂丢了。
(2)情形2:网络延时
1.数据包被⽹络延迟了,导致「发送⽅」没有收到 Ack 的确认报⽂然后后⾯报⽂到达的三个相同的 ACK 确认报⽂,就触发了快速重传机制,但是在重传后,被延迟的数据包⼜到了「接收⽅」;
2.所以「接收⽅」回了⼀个 SACK,因为 ACK 已经到了 ,所以这个 SACK 是 D-SACK,表示收到了重复的包。
3.这样发送⽅就知道快速重传触发的原因不是发出去的包丢了,也不是因为回应的 ACK 包丢了,⽽是因为⽹络延迟了。
边栏推荐
- 关于高并发,我想聊一聊。
- Time pit in MySQL driver
- When synchronized encounters this thing, there is a big hole, so be careful
- Experiment 2: Arduino's tricolor lamp experiment
- Derivation of Euler angle differential equation
- Object based real-time spatial audio rendering - Dev for dev column
- 工程经济学知识点总结
- [RT learning note 1] RT thread peripheral routine - control LED light flashing
- Prometheus + AlertManager 消息预警
- Explain asynchronous tasks in detail: task status and lifecycle management
猜你喜欢

MySQL驱动中关于时间的坑

Explain the four asynchronous solutions of JS in detail: callback function, promise, generator, async/await

How to quickly design a set of cross end components that support rendering rich text content

外包公司“混”了2年,我只认真做了5件事,如今顺利拿到字节 Offer。

一文理解分布式开发中的服务治理

数据安全与隐私计算峰会-安全求交集在隐私计算中的发展和应用:学习

如果时间不够,无法进行充分的测试怎么办?

How awesome is the architecture of "12306"?

无线振弦采集系统工作流程

3d智能工厂工艺流转可视化交互展示应用优点
随机推荐
Excel 用countif 统计
Day 15 (VLAN related knowledge)
防止勒索软件攻击数据的十种方法
ES6 event binding (v-on usage)
Read the recent trends of okaleido tiger and tap the value and potential behind it
NPM install reports an error: eperm: operation not permitted, rename
结合Retrofit 改造OKHttp 缓存
Meeting notice of meeting OA
Esbuild Bundler HMR
【golang学习笔记2.2】 Map、结构体和接口
Virsh console connection failure
Prometheus + AlertManager 消息预警
外包公司“混”了2年,我只认真做了5件事,如今顺利拿到字节 Offer。
When I look at the source code, what am I thinking?
I was stunned by this question that I browsed 746000 times
2022/07/28 学习笔记 (day18) 常用API
Resnet50 + k-fold cross validation + data enhancement + drawing (accuracy, recall, F value)
[mqtt from introduction to improvement series | 09] Wireshark packet capturing and analyzing mqtt messages
0728~面试题梳理
How to use RPA to achieve automatic customer acquisition?