tcp: make newreno byte instead of acks dependent 39/11939/5
authorFlorin Coras <fcoras@cisco.com>
Wed, 18 Apr 2018 23:40:55 +0000 (16:40 -0700)
committerFlorin Coras <fcoras@cisco.com>
Fri, 20 Apr 2018 12:33:43 +0000 (05:33 -0700)
Should be more resilient to ack losses

Change-Id: Icec3b93c1d290dec437fcc4e6fe5171906c9ba8a
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_debug.h
src/vnet/tcp/tcp_input.c
src/vnet/tcp/tcp_newreno.c

index 9606a0e..8a6f74a 100644 (file)
@@ -283,6 +283,7 @@ typedef struct _tcp_connection
 
   /* Congestion control */
   u32 cwnd;            /**< Congestion window */
+  u32 cwnd_acc_bytes;  /**< Bytes accumulated for cwnd increment */
   u32 ssthresh;                /**< Slow-start threshold */
   u32 prev_ssthresh;   /**< ssthresh before congestion */
   u32 prev_cwnd;       /**< ssthresh before congestion */
index e37b3cd..d356911 100755 (executable)
@@ -721,7 +721,7 @@ if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now())                \
 {                                                                      \
   ELOG_TYPE_DECLARE (_e) =                                             \
   {                                                                    \
-    .format = "rto_stat: rto %u srtt %u rttvar %u ",                   \
+    .format = "rcv_stat: rto %u srtt %u rttvar %u ",                   \
     .format_args = "i4i4i4",                                           \
   };                                                                   \
   DECLARE_ETD(_tc, _e, 3);                                             \
@@ -730,6 +730,23 @@ if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now())               \
   ed->data[2] = _tc->rttvar;                                           \
 }                                                                      \
 }
+#define TCP_EVT_CC_SND_STAT_HANDLER(_tc, ...)                          \
+{                                                                      \
+if (_tc->c_cc_stat_tstamp + STATS_INTERVAL < tcp_time_now())           \
+{                                                                      \
+  ELOG_TYPE_DECLARE (_e) =                                             \
+  {                                                                    \
+    .format = "snd_stat: dack %u sacked %u lost %u out %u rxt %u",     \
+    .format_args = "i4i4i4i4i4",                                       \
+  };                                                                   \
+  DECLARE_ETD(_tc, _e, 5);                                             \
+  ed->data[0] = _tc->rcv_dupacks;                                      \
+  ed->data[1] = _tc->sack_sb.sacked_bytes;                             \
+  ed->data[2] = _tc->sack_sb.lost_bytes;                               \
+  ed->data[3] = tcp_bytes_out (_tc);                                   \
+  ed->data[3] = _tc->snd_rxt_bytes;                                    \
+}                                                                      \
+}
 
 #define TCP_EVT_CC_STAT_HANDLER(_tc, ...)                              \
 {                                                                      \
index 5a1e84f..a1cdc76 100644 (file)
@@ -941,6 +941,7 @@ tcp_cc_init_congestion (tcp_connection_t * tc)
 {
   tcp_fastrecovery_on (tc);
   tc->snd_congestion = tc->snd_una_max;
+  tc->cwnd_acc_bytes = 0;
   tc->cc_algo->congestion (tc);
   TCP_EVT_DBG (TCP_EVT_CC_EVT, tc, 4);
 }
index 103fea4..7ae7f48 100644 (file)
@@ -36,8 +36,14 @@ newreno_rcv_ack (tcp_connection_t * tc)
     }
   else
     {
-      /* Round up to 1 if needed */
-      tc->cwnd += clib_max ((tc->snd_mss * tc->snd_mss) / tc->cwnd, 1);
+      /* tc->cwnd += clib_max ((tc->snd_mss * tc->snd_mss) / tc->cwnd, 1); */
+      tc->cwnd_acc_bytes += tc->bytes_acked;
+      if (tc->cwnd_acc_bytes >= tc->cwnd)
+       {
+         u32 inc = tc->cwnd_acc_bytes / tc->cwnd;
+         tc->cwnd += inc * tc->snd_mss;
+         tc->cwnd_acc_bytes -= inc * tc->cwnd;
+       }
     }
 }