cubic算法优化_TCP拥塞控制算法 — CUBIC的补丁(七) | 学步园
描述
以下是提交者Stephen Hemminger對這個patch的描述:
limit delayed_ack ratio to prevent divide error
TCP Cubic keeps a metirc that estimates the amount of delayed acknowledgements to use
in adjusting the window. If an abnormally large number of packets are acknowledged at once,
then the update could wrap and reach zero. This kind of ACK could only happen when there
was a large window and huge number of ACK's were lost.
This patch limits the value of delayed ack ratio. The choice of 32 is just a conservative value
since normally it should be range of 1 to 4 packets.
代碼
--- a/net/ipv4/tcp_cubic.c
+++ b/net/ipv4/tcp_cubic.c
@@ -93,6 +93,7 @@ struct bictcp {
u32ack_cnt;/* number of acks */
u32tcp_cwnd;/* estimated tcp cwnd */
#define ACK_RATIO_SHIFT4
+#define ACK_RATIO_LIMIT (32u << ACK_RATIO_SHIFT)
u16delayed_ack;/* estimate the ratio of Packets/ACKs << 4 */
u8sample_cnt;/* number of samples to decide curr_rtt */
u8found;/* the exit point is found? */
@@ -398,8 +399,12 @@ static void bictcp_acked(struct sock *sk, u32 cnt, s32 rtt_us)
u32 delay;
if (icsk->icsk_ca_state == TCP_CA_Open) {
-cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT;
-ca->delayed_ack += cnt;
+u32 ratio = ca->delayed_ack;
+
+ratio -= ca->delayed_ack >> ACK_RATIO_SHIFT;
+ratio += cnt;
+
+ca->delayed_ack = min(ratio, ACK_RATIO_LIMIT);
}
/* Some calls are for duplicates without timetamps */
評價
這個補丁限制了delayed_ack的最大值為(32 << 4)。也就是說Packets/ACKs的最大估計值限制為32。
為什么要增加這個限制呢?這是因為如果發送窗口很大,并且這個窗口的數據包的ACK大量丟失,那
么發送端就會得到一個累積確認了非常多數據包的ACK,這會造成delayed_ack值劇烈的增大。如果
一個ACK累積確認的數據包超過4096個,那么16位的delayed_ack就會溢出,最后的值可能為0。我
們知道delayed_ack在bictcp_update中是作為除數的,這時會產生除數為0的錯誤。
Author
zhangskd @ csdn blog
《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的cubic算法优化_TCP拥塞控制算法 — CUBIC的补丁(七) | 学步园的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 58同城申请赔付步骤
- 下一篇: 华夏鼎茂债券c安全吗