A small trick and a small patch for TCP BBR stall control

Arrived in Shenzhen in the early hours of last night, and I have limited time this morning, so I will make a long story short, but there will be some output anyway, this time about BBR. I once said that I don’t need too much sleep. If I go to bed at 3 am and get up at 6 am, I should be able to boil Huawei’s people to cusi… I don’t know.

  On the train at night, it was difficult to charge my mobile phone, so I gestured with some traditional things with a pen and paper, and finally rubbed a charging pile... After 100% full, I read several technical articles, one of which was violent. Regarding the optimization of BBR, of course, this is not written by me. Although I refer to what I wrote, it is not written by me. Although I know how to write it, I have never written it. Instead, I deliberately misled it and wrote it back.

  I see humanity! I saw the nature of selfishness. ...well, I admit, Google's BBR 2.0 has gradually satisfied the nature of people's greed, which is OK, very OK, but very easy to be maliciously exploited. Therefore, I strongly oppose open source code in this cybernetic category, and strongly oppose it.

  No one knows how to measure fairness, and yes, no one knows, and people don't care. What people care about is that they are proud of being radical and ashamed of retreating.

  Clouds are green and it is about to rain, the water is light and smoky, but the beautiful scenery of West Lake in Hangzhou is crowded with people who took pictures and sent them to Moments, throwing tons of garbage, TCP... not to mention...

  Leaning against the south window to express pride, to examine Yi An of the knee. Small bridges and flowing water, you can chat with Hongru, in the misty rain in the south of the Yangtze River, a cup of tea and a cup of tea can share your thoughts, walking on the muddy dirt road, looking up, thinking of 5 years ago...


BBR Stall Control

Many people really don't understand these details, which can be learned from how many chats. The previous article said the principle of TCP stall:
starting from the TCP ACK stall of CUBIC/BBR : https://blog.csdn.net/dog250/article/details/80140194
Here is the principle of TCP BBR stall control:

write picture description here

It can be seen that the reason why no real stall occurs is because cwnd is compensated in some way , ie by extra!

  In summary, the key to stall control is that you keep a window large enough that you still have enough send windows in the event of a stall due to ACK loss, aggregation ( rather than original data loss ) .

  Please note that this is an active compensation , not a blind compensation , compared to those who fly in the sky to increase the window n times, and the head-beating practice of increasing the parameters is obviously advisable. Also worth noting is how to calculate the current extra ? I use a common solution here, and of course there is another solution that BBR recommends ( however I don't like it ):

  • My plan: use moving exponential average to take extra;
  • BBR solution: use Window max to take extra.

Which is better? Decide for yourself, anyway, the idea is here, and the changes are inseparable. It's pretty boring too.


One of my BBR stall control patches

It's the same sentence, see through, don't tell, don't spread negative energy. Through the above diagram, it is easy to see the solution of this scenario, then the following is a patch of how to do it :

--- tcp_bbr.c   2018-05-02 10:43:40.167859439 -0400
+++ tcp_bbr_new.c       2018-05-02 12:13:49.380154588 -0400
@@ -58,6 +58,7 @@
  */
 #include <linux/module.h>
 #include <net/tcp.h>
+#include <linux/skbuff.h>
 #include <linux/inet_diag.h>
 #include <linux/inet.h>
 #include <linux/random.h>
@@ -116,6 +117,9 @@
                unused_b:5;
        u32     prior_cwnd;     /* prior cwnd upon entering loss recovery */
        u32     full_bw;        /* recent bw, to estimate if pipe is full */
+       u32     sextral;
+       u64     ack_interval;
+
 };

 #define CYCLE_LEN      8       /* number of phases in a pacing gain cycle */
@@ -429,6 +433,9 @@
                cwnd = cwnd + acked;
        cwnd = max(cwnd, bbr_cwnd_min_target);

+       if (!rs->losses) 
+               cwnd += bbr->sextral;
+
 done:
        tp->snd_cwnd = min(cwnd, tp->snd_cwnd_clamp);   /* apply global cap */
        if (bbr->mode == BBR_PROBE_RTT)  /* drain queue, refresh min_rtt */
@@ -653,7 +660,11 @@
 {
        struct tcp_sock *tp = tcp_sk(sk);
        struct bbr *bbr = inet_csk_ca(sk);
+       u32 extral;
        u64 bw;
+       u64 temp;
+
+       bbr->ack_interval = tcp_stamp_us_delta(tcp_clock_us(), bbr->ack_interval);

        bbr->round_start = 0;
        if (rs->delivered < 0 || rs->interval_us <= 0)
@@ -676,6 +687,10 @@
        bw = (u64)rs->delivered * BW_UNIT;
        do_div(bw, rs->interval_us);

+       temp = (u64)rs->delivered*bbr->ack_interval;
+       extral = (u64)rs->delivered - do_div(temp, rs->interval_us);
+       bbr->sextral = bbr->sextral - (bbr->sextral >> 3) + (extral >> 3);
+
        /* If this sample is application-limited, it is likely to have a very
         * low delivered count that represents application behavior rather than
         * the available network rate. Such a sample could drag down estimated
@@ -856,6 +871,8 @@
        bbr->cycle_idx = 0;
        bbr_reset_lt_bw_sampling(sk);
        bbr_reset_startup_mode(sk);
+       bbr->ack_interval = 0;
+       bbr->sextral = 0;

        cmpxchg(&sk->sk_pacing_status, SK_PACING_NONE, SK_PACING_NEEDED);
 }
@@ -952,3 +969,4 @@
 MODULE_AUTHOR("Soheil Hassas Yeganeh <[email protected]>");
 MODULE_LICENSE("Dual BSD/GPL");
 MODULE_DESCRIPTION("TCP BBR (Bottleneck Bandwidth and RTT)");
+// for Linux 4.14 by zhaoya the shabi!

Some people are going to ask, is it really possible to do this? Oh, I don't understand what the so-called can refer to can do...

  The answer is, you can't do this, you can't do anything like this, it's just an idea, it's not a deliverable! Plus, there's a good chance you'll pay a price for doing so...

  There are too many similar artifacts now, and I am not afraid to offend anyone, so I will tell the truth. At the beginning, 12,306 people lined up in the hospital to grab tickets. Later, the license plate was taken in Shanghai, and then various school districts were crowded and seized... In short, we are already in a reality where resources must be grabbed, and if we can’t grab them, we will be destroyed . Everyone’s psychology tends to hurt others. Unfavorable to oneself , please pay attention to this unfavorable word, very important! It doesn't matter if you succeed or not, as long as others fail.

  This is the classic result-oriented evil! If I can't pass, then everyone should not pass, it's that simple. Extending to the technology, that is TCP acceleration! BBR is a very good algorithm, but it is wrong in open source. As a result, a large number of people with various purposes have changed the parameters to enlarge the trick . As a result, the Internet transmission path is becoming more and more messed up. BBR has given people a weapon for crime. , a knife without a blade, but by no means a gun without bullets.


I believe that no one wants to spread the negative energy of technology and use technology to control resources for their own possession. If they have the ability, they will not let those tool boys who don’t know how to pretend to understand continue to do evil.

postscript

By the way, I bought a book at the high-speed rail station yesterday. It's good to read it when I'm very tired. This book is "Half-hour Comic World History" written by the pseudonym Erlianzi. I wanted to write a collection like this myself, but in the end I didn’t have enough action... Originally, I wanted to ask the author about the details after reading this book, but I didn’t find a place to argue, so I thought Ask offline for advice, and someone familiar with it can help me introduce it. I think the author and I can become friends...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325552780&siteId=291194637