From 9dc29effdfc9083256920980f5306cb45906b793 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 16 Apr 2019 11:25:58 +0900 Subject: [PATCH 1/3] rename loss delay variable in sent packet handler That's how it's called in the WG draft pseudo code. --- internal/ackhandler/sent_packet_handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index a0c244cd6..841087c80 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -340,7 +340,7 @@ func (h *sentPacketHandler) detectLostPackets( pnSpace := h.getPacketNumberSpace(encLevel) maxRTT := float64(utils.MaxDuration(h.rttStats.LatestRTT(), h.rttStats.SmoothedRTT())) - delayUntilLost := time.Duration((1.0 + timeReorderingFraction) * maxRTT) + lossDelay := time.Duration((1.0 + timeReorderingFraction) * maxRTT) var lostPackets []*Packet pnSpace.history.Iterate(func(packet *Packet) (bool, error) { @@ -349,14 +349,14 @@ func (h *sentPacketHandler) detectLostPackets( } timeSinceSent := now.Sub(packet.SendTime) - if timeSinceSent > delayUntilLost { + if timeSinceSent > lossDelay { lostPackets = append(lostPackets, packet) } else if h.lossTime.IsZero() && encLevel == protocol.Encryption1RTT { if h.logger.Debug() { - h.logger.Debugf("\tsetting loss timer for packet %#x to %s (in %s)", packet.PacketNumber, delayUntilLost, delayUntilLost-timeSinceSent) + h.logger.Debugf("\tsetting loss timer for packet %#x to %s (in %s)", packet.PacketNumber, lossDelay, lossDelay-timeSinceSent) } // Note: This conditional is only entered once per call - h.lossTime = now.Add(delayUntilLost - timeSinceSent) + h.lossTime = now.Add(lossDelay - timeSinceSent) } return true, nil }) From 2c27cc009056d22e3072e8ebf518092b471d3877 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 16 Apr 2019 11:32:01 +0900 Subject: [PATCH 2/3] rename the reordering threshold constant in the sent packet handler --- internal/ackhandler/sent_packet_handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index 841087c80..8b04a4dc2 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -15,8 +15,8 @@ import ( const ( // Maximum reordering in time space before time based loss detection considers a packet lost. - // In fraction of an RTT. - timeReorderingFraction = 1.0 / 8 + // Specified as an RTT multiplier. + timeThreshold = 9.0 / 8 // Timer granularity. The timer will not be set to a value smaller than granularity. granularity = time.Millisecond ) @@ -340,7 +340,7 @@ func (h *sentPacketHandler) detectLostPackets( pnSpace := h.getPacketNumberSpace(encLevel) maxRTT := float64(utils.MaxDuration(h.rttStats.LatestRTT(), h.rttStats.SmoothedRTT())) - lossDelay := time.Duration((1.0 + timeReorderingFraction) * maxRTT) + lossDelay := time.Duration(timeThreshold * maxRTT) var lostPackets []*Packet pnSpace.history.Iterate(func(packet *Packet) (bool, error) { From 450d777a5124f2a3b2920c75c042e86476dcc636 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Tue, 16 Apr 2019 11:34:07 +0900 Subject: [PATCH 3/3] use the timer granularity as a minimum for the loss detection timer --- internal/ackhandler/sent_packet_handler.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index 8b04a4dc2..9ca04c72e 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -342,6 +342,9 @@ func (h *sentPacketHandler) detectLostPackets( maxRTT := float64(utils.MaxDuration(h.rttStats.LatestRTT(), h.rttStats.SmoothedRTT())) lossDelay := time.Duration(timeThreshold * maxRTT) + // Minimum time of granularity before packets are deemed lost. + lossDelay = utils.MaxDuration(lossDelay, granularity) + var lostPackets []*Packet pnSpace.history.Iterate(func(packet *Packet) (bool, error) { if packet.PacketNumber > pnSpace.largestAcked {