From 6180aa78409627325cbba1a2e751260410cac54f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Fri, 1 Apr 2022 21:07:16 +0200 Subject: lib: Add support for Linux RTT estimator This adds the option to use the Round-Trip-Time (RTT) estimation algorithm as it is implemented in the TCP implementation in Linux. It looks like it outperforms the TCP default algorithm, so I enabled this one by default. Also adds the option to change the RTO timeout calculation to include more (or less) than 4 times the mdev (specified as a power of 2. Left the default value to 2 (so, 4 mdevs), but 3 (8 mdevs) gives better results in my tests. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/CMakeLists.txt | 4 ++++ src/lib/config.h.in | 2 ++ src/lib/frct.c | 9 +++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src/lib') diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 0c327320..4f7d5d18 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -196,6 +196,10 @@ set(FRCT_REORDER_QUEUE_SIZE 256 CACHE STRING "Size of the reordering queue, must be a power of 2") set(FRCT_START_WINDOW 64 CACHE STRING "Start window, must be a power of 2") +set(FRCT_LINUX_RTT_ESTIMATOR TRUE CACHE BOOL + "Use Linux RTT estimator formula instead of the TCP RFC formula") +set(FRCT_RTO_MDEV_MULTIPLIER 2 CACHE STRING + "Multiplier for deviation term in the RTO: RTO = sRTT + (mdev << X)") set(FRCT_RTO_MIN 250 CACHE STRING "Minimum Retransmission Timeout (RTO) for FRCT (us)") set(FRCT_TICK_TIME 5000 CACHE STRING diff --git a/src/lib/config.h.in b/src/lib/config.h.in index a51c2791..3bf6274a 100644 --- a/src/lib/config.h.in +++ b/src/lib/config.h.in @@ -69,12 +69,14 @@ #define DU_BUFF_TAILSPACE @DU_BUFF_TAILSPACE@ /* Default Delta-t parameters */ +#cmakedefine FRCT_LINUX_RTT_ESTIMATOR #define DELT_A (@DELTA_T_ACK@) /* ns */ #define DELT_R (@DELTA_T_RTX@) /* ns */ #define RQ_SIZE (@FRCT_REORDER_QUEUE_SIZE@) #define START_WINDOW (@FRCT_START_WINDOW@) #define RTO_MIN (@FRCT_RTO_MIN@ * 1000) +#define MDEV_MUL (@FRCT_RTO_MDEV_MULTIPLIER@) #define TICTIME (@FRCT_TICK_TIME@ * 1000) /* ns */ diff --git a/src/lib/frct.c b/src/lib/frct.c index b823b3fa..4effad3b 100644 --- a/src/lib/frct.c +++ b/src/lib/frct.c @@ -773,14 +773,19 @@ static void rtt_estimator(struct frcti * frcti, } else { time_t delta = mrtt - srtt; srtt += (delta >> 3); - rttvar += (ABS(delta) - rttvar) >> 2; + delta = (ABS(delta) - rttvar) >> 2; +#ifdef FRCT_LINUX_RTT_ESTIMATOR + if (delta < 0) + delta >>= 3; +#endif + rttvar += delta; } #ifdef PROC_FLOW_STATS frcti->n_rtt++; #endif frcti->srtt = MAX(1000U, srtt); frcti->mdev = MAX(100U, rttvar); - frcti->rto = MAX(RTO_MIN, frcti->srtt + (frcti->mdev << 3)); + frcti->rto = MAX(RTO_MIN, frcti->srtt + (frcti->mdev << MDEV_MUL)); } /* Always queues the next application packet on the RQ. */ -- cgit v1.2.3