]> git.meshlink.io Git - utcp/commitdiff
Reset the retransmission timer when receiving duplicate ACKs.
authorGuus Sliepen <guus@sliepen.org>
Wed, 18 Mar 2020 21:24:52 +0000 (22:24 +0100)
committerGuus Sliepen <guus@sliepen.org>
Wed, 18 Mar 2020 21:24:52 +0000 (22:24 +0100)
While we are getting duplicate ACKs, and are likely in fast recovery,
keep resetting the retransmission timer, so that if fast recovery takes
longer than the RTO, we don't trigger a slow start.

When we do get a real timeout during fast recovery, reset the duplicate
ACK counter to signal we are no longer in fast recovery.

We also should not do anything when receiving duplicate ACKs when all
data has already been ACKed.

utcp.c

diff --git a/utcp.c b/utcp.c
index 67d4be3a7a632d4cdafd004b217ad01976092caa..ac598ddae28667fd9a40c28ace29255b7dd22f66 100644 (file)
--- a/utcp.c
+++ b/utcp.c
@@ -848,6 +848,7 @@ static void retransmit(struct utcp_connection *c) {
        }
 
        c->rtt_start.tv_sec = 0; // invalidate RTT timer
+       c->dupack = 0; // cancel any ongoing fast recovery
 
 cleanup:
        free(pkt);
@@ -1457,7 +1458,7 @@ synack:
                        break;
                }
        } else {
-               if(!len && is_reliable(c)) {
+               if(!len && is_reliable(c) && c->snd.una != c->snd.last) {
                        c->dupack++;
                        debug(c, "duplicate ACK %d\n", c->dupack);
 
@@ -1484,6 +1485,11 @@ synack:
 
                                debug_cwnd(c);
                        }
+
+                       // We got an ACK which indicates the other side did get one of our packets.
+                       // Reset the retransmission timer to avoid going to slow start,
+                       // but don't touch the connection timeout.
+                       start_retransmit_timer(c);
                }
        }