[PATCH v2] ipcpd: Fix slow start in multi-bit (F)ECN policy

  • From: Dimitri Staessens <dimitri@ouroboros.rocks>
  • To: ouroboros@xxxxxxxxxxxxx
  • Date: Sun, 6 Dec 2020 14:24:51 +0100

There is a check not to rapidly double the window to astronomical
sizes when there is no congestion experienced for long periods of
time, but the if-else logic was botched and it still grew to
astronomical sizes (albeit linear instead of exponential).
I also lowered the ECN threshold a bit.

Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks>
---
 src/ipcpd/unicast/pol/ca-mb-ecn.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/ipcpd/unicast/pol/ca-mb-ecn.c 
b/src/ipcpd/unicast/pol/ca-mb-ecn.c
index 31a646b..1baaca7 100644
--- a/src/ipcpd/unicast/pol/ca-mb-ecn.c
+++ b/src/ipcpd/unicast/pol/ca-mb-ecn.c
@@ -46,7 +46,7 @@
 #define CA_IWL       1 << 16              /* Initial limit ~4MiB/s  */
 #define CA_MINPS     8                    /* Mimimum pkts / slot    */
 #define CA_MAXPS     64                   /* Maximum pkts / slot    */
-#define ECN_Q_SHFT   5
+#define ECN_Q_SHFT   4
 #define ts_to_ns(ts) (ts.tv_sec * BILLION + ts.tv_nsec)
 
 struct mb_ecn_ctx {
@@ -127,13 +127,16 @@ ca_wnd_t mb_ecn_ctx_update_snd(void * _ctx,
         if (slot > ctx->tx_slot) {
                 ctx->tx_slot = slot;
 
-                if (!ctx->tx_cav && ctx->tx_wbc > ctx->tx_wbl) /* Slow start */
-                        ctx->tx_wbl <<= 1;
-                else if (ctx->tx_ece) /* Multiplicative Decrease */
-                        ctx->tx_wbl -= (ctx->tx_wbl * ctx->tx_ece)
-                                >> (CA_SHFT + 8);
-                else /* Additive Increase */
-                        ctx->tx_wbl = ctx->tx_wbl + ctx->tx_inc;
+                if (!ctx->tx_cav) { /* Slow start */
+                        if (ctx->tx_wbc > ctx->tx_wbl)
+                                ctx->tx_wbl <<= 1;
+                } else {
+                        if (ctx->tx_ece) /* Mult. Decrease */
+                                ctx->tx_wbl -= (ctx->tx_wbl * ctx->tx_ece)
+                                        >> (CA_SHFT + 8);
+                        else if (ctx->tx_wbc > ctx->tx_wbl) /* Add. Increase */
+                                ctx->tx_wbl = ctx->tx_wbl + ctx->tx_inc;
+                }
 
                 /* Window scaling */
                 if (ctx->tx_wpc < CA_MINPS) {
-- 
2.29.2


Other related posts: