don't reduce the bytes in flight for RTO probe packets

This commit is contained in:
Marten Seemann
2018-03-20 14:08:03 +00:00
parent a5688f954f
commit 8772acab0a
3 changed files with 16 additions and 8 deletions

View File

@@ -20,6 +20,7 @@ type Packet struct {
sendTime time.Time
queuedForRetransmission bool
includedInBytesInFlight bool
retransmittedAs []protocol.PacketNumber
isRetransmission bool // we need a separate bool here because 0 is a valid packet number
retransmissionOf protocol.PacketNumber

View File

@@ -157,6 +157,7 @@ func (h *sentPacketHandler) sentPacketImpl(packet *Packet) bool /* isRetransmitt
if isRetransmittable {
packet.largestAcked = largestAcked
h.lastSentRetransmittablePacketTime = packet.sendTime
packet.includedInBytesInFlight = true
h.bytesInFlight += packet.Length
}
h.congestion.OnPacketSent(packet.sendTime, h.bytesInFlight, packet.PacketNumber, packet.Length, isRetransmittable)
@@ -315,6 +316,8 @@ func (h *sentPacketHandler) detectLostPackets(now time.Time) error {
if err := h.queuePacketForRetransmission(p); err != nil {
return err
}
h.bytesInFlight -= p.Length
p.includedInBytesInFlight = false
h.congestion.OnPacketLost(p.PacketNumber, p.Length, h.bytesInFlight)
}
return nil
@@ -389,11 +392,11 @@ func (h *sentPacketHandler) onPacketAcked(p *Packet) error {
}
func (h *sentPacketHandler) removeAllRetransmissions(p *Packet) error {
if !p.queuedForRetransmission {
// The bytes in flight are reduced when a packet is queued for retransmission.
// When a packet is acked, we only need to reduce it for packets that were not retransmitted.
if p.includedInBytesInFlight {
h.bytesInFlight -= p.Length
} else {
p.includedInBytesInFlight = false
}
if p.queuedForRetransmission {
for _, r := range p.retransmittedAs {
packet := h.packetHistory.GetPacket(r)
if packet == nil {
@@ -501,7 +504,6 @@ func (h *sentPacketHandler) queuePacketForRetransmission(p *Packet) error {
if _, err := h.packetHistory.QueuePacketForRetransmission(p.PacketNumber); err != nil {
return err
}
h.bytesInFlight -= p.Length
h.retransmissionQueue = append(h.retransmissionQueue, p)
h.stopWaitingManager.QueuedRetransmissionForPacketNumber(p.PacketNumber)
return nil

View File

@@ -424,11 +424,15 @@ var _ = Describe("SentPacketHandler", func() {
})
})
Context("Ack processing, for retransmitted packets", func() {
Context("ACK processing, for retransmitted packets", func() {
losePacket := func(pn protocol.PacketNumber) {
p := getPacket(pn)
ExpectWithOffset(1, p).ToNot(BeNil())
handler.queuePacketForRetransmission(p)
if p.includedInBytesInFlight {
p.includedInBytesInFlight = false
handler.bytesInFlight -= p.Length
}
r := handler.DequeuePacketForRetransmission()
ExpectWithOffset(1, r).ToNot(BeNil())
ExpectWithOffset(1, r.PacketNumber).To(Equal(pn))
@@ -587,12 +591,12 @@ var _ = Describe("SentPacketHandler", func() {
cong.EXPECT().OnPacketLost(
protocol.PacketNumber(1),
protocol.ByteCount(1),
protocol.ByteCount(2),
protocol.ByteCount(3),
)
cong.EXPECT().OnPacketLost(
protocol.PacketNumber(2),
protocol.ByteCount(1),
protocol.ByteCount(1),
protocol.ByteCount(3),
)
handler.SentPacket(retransmittablePacket(1))
handler.SentPacket(retransmittablePacket(2))
@@ -709,6 +713,7 @@ var _ = Describe("SentPacketHandler", func() {
p = handler.DequeuePacketForRetransmission()
Expect(p).ToNot(BeNil())
Expect(p.PacketNumber).To(Equal(protocol.PacketNumber(2)))
Expect(handler.bytesInFlight).To(Equal(protocol.ByteCount(2)))
Expect(handler.rtoCount).To(BeEquivalentTo(1))
})