correctly set the ack delay in an ACK of packet number 0

This commit is contained in:
Marten Seemann 2019-01-05 13:04:51 +07:00
parent 8ac77be934
commit 5e3c96024a
2 changed files with 5 additions and 5 deletions

View file

@ -74,7 +74,7 @@ func (h *receivedPacketHandler) ReceivedPacket(packetNumber protocol.PacketNumbe
} }
isMissing := h.isMissing(packetNumber) isMissing := h.isMissing(packetNumber)
if packetNumber > h.largestObserved { if packetNumber >= h.largestObserved {
h.largestObserved = packetNumber h.largestObserved = packetNumber
h.largestObservedReceivedTime = rcvTime h.largestObservedReceivedTime = rcvTime
} }

View file

@ -95,17 +95,17 @@ var _ = Describe("receivedPacketHandler", func() {
} }
It("always queues an ACK for the first packet", func() { It("always queues an ACK for the first packet", func() {
err := handler.ReceivedPacket(1, time.Time{}, false) Expect(handler.ReceivedPacket(1, time.Now(), false)).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(handler.ackQueued).To(BeTrue()) Expect(handler.ackQueued).To(BeTrue())
Expect(handler.GetAlarmTimeout()).To(BeZero()) Expect(handler.GetAlarmTimeout()).To(BeZero())
Expect(handler.GetAckFrame().DelayTime).To(BeNumerically("~", 0, time.Second))
}) })
It("works with packet number 0", func() { It("works with packet number 0", func() {
err := handler.ReceivedPacket(0, time.Time{}, false) Expect(handler.ReceivedPacket(0, time.Now(), false)).To(Succeed())
Expect(err).ToNot(HaveOccurred())
Expect(handler.ackQueued).To(BeTrue()) Expect(handler.ackQueued).To(BeTrue())
Expect(handler.GetAlarmTimeout()).To(BeZero()) Expect(handler.GetAlarmTimeout()).To(BeZero())
Expect(handler.GetAckFrame().DelayTime).To(BeNumerically("~", 0, time.Second))
}) })
It("queues an ACK for every second retransmittable packet at the beginning", func() { It("queues an ACK for every second retransmittable packet at the beginning", func() {