6.4.1 如何测量带宽 bw_est和 bbr 算法不同,tcpw 带宽计算相当粗糙 。tcpw 每经过一个 RTT 测量一次带宽 。假设经过时间为 delta,该时间内发送完成的数据量为 bk,则采样值为 bk / delta 。然后和 rtt 一样,带宽采样值会经过一个平滑处理算出最终的带宽值 。

文章插图
6.4.2 如何确认单位时间的发送量 bk
tcpw 采用一种粗糙的估算方式 。在收到回包后,会根据当前的 snd_una 和之前的 snd_una 之间的差值来估算被 ACK 的字节数,即关于 SACK 的信息会被丢失 。具体逻辑见westwood_acked_count函数 。
static inline u32 westwood_acked_count(struct sock *sk){const struct tcp_sock *tp = tcp_sk(sk);struct westwood *w = inet_csk_ca(sk);w->cumul_ack = tp->snd_una - w->snd_una;/* If cumul_ack is 0 this is a dupack since it's not moving* tp->snd_una.*/if (!w->cumul_ack) {w->accounted += tp->mss_cache;w->cumul_ack = tp->mss_cache;}if (w->cumul_ack > tp->mss_cache) {/* Partial or delayed ack */if (w->accounted >= w->cumul_ack) {w->accounted -= w->cumul_ack;w->cumul_ack = tp->mss_cache;} else {w->cumul_ack -= w->accounted;w->accounted = 0;}}w->snd_una = tp->snd_una;return w->cumul_ack;}6.4.3 计算 ssthresh计算 ssthresh 公式很简单:
文章插图
源码如下:
/* * TCP Westwood * Here limit is evaluated as Bw estimation*RTTmin (for obtaining it * in packets we use mss_cache). Rttmin is guaranteed to be >= 2 * so avoids ever returning 0. */static u32 tcp_westwood_bw_rttmin(const struct sock *sk){const struct tcp_sock *tp = tcp_sk(sk);const struct westwood *w = inet_csk_ca(sk);return max_t(u32, (w->bw_est * w->rtt_min) / tp->mss_cache, 2);}七、参考文档- TCP 的那些事儿(上) TCP 的那些事儿(下)
- TCP 系列 08—连接管理—7、TCP 常见选项(option)
- TCP timestamp
- Early Retransmit forTCP
- TCP Tail Loss Probe(TLP)
- TCP 重点系列之拥塞状态机
- Congestion Control in Linux TCP
- TCP 拥塞控制图解
- TCP 进入快速恢复时的窗口下降算法
- tcp 中 RACK 算法
- TCP 系列 23—重传—13、RACK 重传
- TCP 系列 18—重传—8、FACK 及 SACK reneging 下的重传
【万字详文:TCP 拥塞控制详解】
推荐阅读
- 如何基于TCP/IP协议进行MFC Socket网络通讯编程
- Treck TCP/IP协议库多个漏洞安全风险通告
- tcp,icmp,http 基于wireshark报文分析快速过滤报文时延
- 服务器海量TCP连接如何高效保活?
- 两万字深度介绍分布式,一文入魂
- TCP 半连接队列和全连接队列满了,怎么破?
- 说起来 TCP 的连接与释放真是个浪漫的故事呢!
- 网络安全常见协议解析:TCP、UDP、HTTP、FTP、SMTP等之间的区别
- 全网最强TCP/IP拥塞控制总结
- 轻松学习http知识让枯燥的内容变得生动有趣:TCP/IP四层模型
