Subject: [quicwg/base-drafts] Refactor DetectLostPackets (#2066)

From: Martin Thomson <[email-masked]>
Date: Wed, 28 Nov 2018 16:43:34 -0800

This had a couple of problems that I think this addresses, and some that
it doesn't.

The first is that it isn't clear what is being iterated over and in what
order.  I think that the point here is to iterate over sent_packets,
starting with the oldest.  Correct me if that is wrong.  In any case,
this change doesn't assume an iteration order.  The only reason the
iteration order is important is in setting loss_time, which needs to be
the earliest time (assuming that I'm right).

This simplifies the function, by setting thresholds at the top and doing
a simple comparison.

I've added a note about loss_time potentially being in the past.

The problem that remains is that this appeared to iterate only over
packets that have a packet number less than the largest acknowledged.
I've added that condition to the loop, but I don't think that it's
right.  I think that it's just redundant - and while an implementation
might stop its iteration at the largest acknowledged to save cycles,
this function will operate the same without the extra check.

It's also not clear whether the greater than comparisons here were
correct.  If you assume that firing of the timer cannot take zero time,
this is never an issue, but with discrete intervals on time values,
that's not always going to happen.  As setup, this code could be called
at exactly loss_time for a packet, in which case that packet will not be
declared lost.  I think that this wants >= in the time comparison for
that reason.

Finally, should the early retransmit timer be configurable?  Should it
be set based on kTimeReorderingThreshold?
You can view, comment on, or merge this pull request online at:

  https://github.com/quicwg/base-drafts/pull/2066

-- Commit Summary --

  * Refactor DetectLostPackets

-- File Changes --

    M draft-ietf-quic-recovery.md (35)

-- Patch Links --

https://github.com/quicwg/base-drafts/pull/2066.patch
https://github.com/quicwg/base-drafts/pull/2066.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/2066

---

From: janaiyengar <[email-masked]>
Date: Wed, 28 Nov 2018 19:32:18 -0800

janaiyengar commented on this pull request.

Some comments, but I think this refactor is basically correct (mod the corrections I've noted), and is definitely helpful! @ianswett should take a look as well.

>    else if (largest_acked.packet_number == largest_sent_packet):
     // Early retransmit timer.
-    delay_until_lost = 9/8 * max(latest_rtt, smoothed_rtt)
-  foreach (unacked < largest_acked.packet_number):
-    time_since_sent = now() - unacked.time_sent
-    delta = largest_acked.packet_number - unacked.packet_number
-    if (time_since_sent > delay_until_lost ||
-        delta > reordering_threshold):
+    loss_delay = 9/8 * max(latest_rtt, smoothed_rtt)

This can be (1 + time_reordering_fraction)

> -  foreach (unacked < largest_acked.packet_number):
-    time_since_sent = now() - unacked.time_sent
-    delta = largest_acked.packet_number - unacked.packet_number
-    if (time_since_sent > delay_until_lost ||
-        delta > reordering_threshold):
+    loss_delay = 9/8 * max(latest_rtt, smoothed_rtt)
+  // Packets sent before this time are deemed lost.
+  lost_send_time -= loss_delay
+  lost_pn = largest_acked.packet_number - reordering_threshold
+
+  foreach unacked:
+    if unacked.packet_number > largest_acked.packet_number:
+      continue
+
+    if (unacked.time_sent > lost_send_time ||
+        unacked.packet_number > lost_pn):

This should be
```
    if (lost_send_time > unacked.time_sent || lost_pn > unacked.packet_number)
```

   // Inform the congestion controller of lost packets and
   // lets it decide whether to retransmit immediately.
   if (!lost_packets.empty()):
     OnPacketsLost(lost_packets)
 ~~~
 
+This algorithm results in loss_time being set to the earliest time that the
+earliest packet was sent.  As a result loss_time could be in the past.  Timers

This algorithm results in loss_time being set based on the earliest packet that is still in flight. As a result ...

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/2066#pullrequestreview-179615473

---

From: Martin Thomson <[email-masked]>
Date: Wed, 28 Nov 2018 19:39:21 -0800

@martinthomson pushed 1 commit.

9d6bd27  Review changes

-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/quicwg/base-drafts/pull/2066/files/1102009604f82c55fc2d279a6696393a03a7a11e..9d6bd274b4fe1b7a71a1a17f3ac643c01a11d583

---

From: janaiyengar <[email-masked]>
Date: Wed, 28 Nov 2018 19:40:38 -0800

> +  lost_packet_send_time = now()
+  lost_pn = largest_acked.packet_number - reordering_threshold
+
+  // Time-based recovery, or early retransmit.
+  if (kUsingTimeLossDetection ||
+      largest_acked.packet_number == largest_sent_packet):
+    loss_delay = (1 + time_reordering_fraction) *
+                     max(latest_rtt, smoothed_rtt)
+    lost_send_time -= loss_delay
+
+  foreach unacked in sent_packets:
+    if unacked.packet_number > largest_acked.packet_number:
+      continue
+
+    if (unacked.time_sent < lost_send_time ||
+        unacked.packet_number < lost_pn):

```suggestion
        unacked.packet_number <= lost_pn):
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/quicwg/base-drafts/pull/2066#pullrequestreview-179618270

---

From: Martin Thomson <[email-masked]>
Date: Wed, 28 Nov 2018 19:45:12 -0800

d183b1e  Use <= for cutoffs

-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/quicwg/base-drafts/pull/2066/files/9d6bd274b4fe1b7a71a1a17f3ac643c01a11d583..d183b1e14b704b56d6b62bcbcba38a98b7816f8e