retransmit two outstanding packets on RTO

fixes #324
This commit is contained in:
Lucas Clemente
2016-09-20 11:08:42 +02:00
parent 9e5bba7937
commit 8f7a96dfaf
2 changed files with 37 additions and 14 deletions

View File

@@ -295,21 +295,29 @@ func (h *sentPacketHandler) MaybeQueueRTOs() {
return
}
for el := h.packetHistory.Front(); el != nil; el = el.Next() {
packet := &el.Value
packetsLost := congestion.PacketVector{congestion.PacketInfo{
Number: packet.PacketNumber,
Length: packet.Length,
}}
h.congestion.OnCongestionEvent(false, h.BytesInFlight(), nil, packetsLost)
h.congestion.OnRetransmissionTimeout(true)
utils.Debugf("\tQueueing packet 0x%x for retransmission (RTO)", packet.PacketNumber)
h.queuePacketForRetransmission(el)
// Reset the RTO timer here, since it's not clear that this packet contained any retransmittable frames
h.lastSentPacketTime = time.Now()
h.consecutiveRTOCount++
return
// Always queue the two oldest packets
if h.packetHistory.Front() != nil {
h.queueRTO(h.packetHistory.Front())
}
if h.packetHistory.Front() != nil {
h.queueRTO(h.packetHistory.Front())
}
// Reset the RTO timer here, since it's not clear that this packet contained any retransmittable frames
h.lastSentPacketTime = time.Now()
h.consecutiveRTOCount++
}
func (h *sentPacketHandler) queueRTO(el *PacketElement) {
packet := &el.Value
packetsLost := congestion.PacketVector{congestion.PacketInfo{
Number: packet.PacketNumber,
Length: packet.Length,
}}
h.congestion.OnCongestionEvent(false, h.BytesInFlight(), nil, packetsLost)
h.congestion.OnRetransmissionTimeout(true)
utils.Debugf("\tQueueing packet 0x%x for retransmission (RTO)", packet.PacketNumber)
h.queuePacketForRetransmission(el)
}
func (h *sentPacketHandler) getRTO() time.Duration {

View File

@@ -834,6 +834,21 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.retransmissionQueue[0].PacketNumber).To(Equal(p.PacketNumber))
Expect(time.Now().Sub(handler.lastSentPacketTime)).To(BeNumerically("<", time.Second/2))
})
It("queues two packets if RTO expired", func() {
for i := 1; i < 4; i++ {
p := &Packet{PacketNumber: protocol.PacketNumber(i), Length: 1}
err := handler.SentPacket(p)
Expect(err).NotTo(HaveOccurred())
}
handler.lastSentPacketTime = time.Now().Add(-time.Second)
handler.MaybeQueueRTOs()
Expect(handler.retransmissionQueue).To(HaveLen(2))
Expect(handler.retransmissionQueue[0].PacketNumber).To(Equal(protocol.PacketNumber(1)))
Expect(handler.retransmissionQueue[1].PacketNumber).To(Equal(protocol.PacketNumber(2)))
Expect(time.Now().Sub(handler.lastSentPacketTime)).To(BeNumerically("<", time.Second/2))
Expect(handler.consecutiveRTOCount).To(Equal(uint32(1)))
})
})
It("works with DequeuePacketForRetransmission", func() {