[multicat-devel] [Git][videolan/multicat][master] add refractory period in reordertp

Massiot gitlab at videolan.org
Sat Jul 22 13:23:51 CEST 2017


Massiot pushed to branch master at videolan / multicat


Commits:
b846ff1a by Christophe Massiot at 2017-07-16T19:15:53+02:00
add refractory period in reordertp

- - - - -


2 changed files:

- NEWS
- reordertp.c


Changes:

=====================================
NEWS
=====================================
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Changes between 2.2 and 2.3:
   * Fix potential segfault in aggregartp
   * Do not do retx in reordertp with multicast inputs
   * Add support for null weights in aggregartp and reordertp
+  * Add refractory period in case of too many errors in reordertp
 
 Changes between 2.1 and 2.2:
 ----------------------------


=====================================
reordertp.c
=====================================
--- a/reordertp.c
+++ b/reordertp.c
@@ -54,6 +54,9 @@
 #define DEFAULT_RETX_DELAY 200 /* ms */
 #define MIN_RETX_DELAY 10 /* ms */
 #define DEFAULT_MAX_RETX_BURST 15 /* packets */
+#define RETX_REFRACTORY_TRIGGER 100 /* uncorrected errors */
+#define RETX_REFRACTORY_PERIOD 15000 /* ms */
+#define RETX_REFRACTORY_RESET 3000 /* ms */
 
 /*****************************************************************************
  * Local declarations
@@ -112,6 +115,10 @@ static uint64_t i_retx_delay = DEFAULT_RETX_DELAY * 27000;
 static int i_retx_fd = -1;
 static unsigned int i_max_retx_burst = DEFAULT_MAX_RETX_BURST;
 static int i_last_retx_input = 0;
+static unsigned int i_retx_uncorrected_errors = 0;
+static uint64_t i_retx_uncorrected_errors_expiration = UINT64_MAX;
+static uint16_t i_last_output_seqnum = 0;
+static uint64_t i_retx_refractory_end = 0;
 
 static void usage(void)
 {
@@ -213,6 +220,40 @@ static void RetxPacketSent( block_t *p_block )
     for ( i = 0; i < i_nb_retx; i++ )
         if ( pp_retx[i] == p_block )
             pp_retx[i] = NULL;
+
+    uint16_t i_seqnum = p_block->i_seqnum;
+
+    if ( i_retx_refractory_end )
+    {
+        if ( p_block->i_date > i_retx_refractory_end )
+        {
+            msg_Warn( NULL, "now reenabling retx" );
+            i_retx_refractory_end = 0;
+        }
+    }
+    else if ( i_seqnum != i_last_output_seqnum + 1 )
+    {
+        if ( ++i_retx_uncorrected_errors >= RETX_REFRACTORY_TRIGGER )
+        {
+            msg_Warn( NULL, "too many errors, disabling retx for a while" );
+            i_retx_uncorrected_errors = 0;
+            i_retx_refractory_end =
+                p_block->i_date + RETX_REFRACTORY_PERIOD * 27000;
+        }
+        else
+        {
+            i_retx_uncorrected_errors_expiration =
+                p_block->i_date + RETX_REFRACTORY_RESET * 27000;
+        }
+    }
+    else if ( p_block->i_date > i_retx_uncorrected_errors_expiration )
+    {
+        i_retx_uncorrected_errors_expiration = UINT64_MAX;
+        i_retx_uncorrected_errors = 0;
+    }
+
+
+    i_last_output_seqnum = i_seqnum;
 }
 
 static void RetxDereference( block_t *p_block )
@@ -298,7 +339,8 @@ static void RetxCheck( uint64_t i_current_date )
                                             (i_prev_seqnum + 1)) % POW2_16;
                 sockaddr_t *p_sockaddr;
                 int i_fd;
-                if ( i_nb_packets <= i_max_retx_burst &&
+                if ( !i_retx_refractory_end &&
+                     i_nb_packets <= i_max_retx_burst &&
                      (i_fd = RetxGetFd(&p_sockaddr)) != -1 )
                 {
                     uint8_t p_buffer[RETX_HEADER_SIZE];



View it on GitLab: https://code.videolan.org/videolan/multicat/commit/b846ff1ad9a9834473b8831502e2717c8561f3a9

---
View it on GitLab: https://code.videolan.org/videolan/multicat/commit/b846ff1ad9a9834473b8831502e2717c8561f3a9
You're receiving this email because of your account on code.videolan.org.


More information about the multicat-devel mailing list