diff --git a/ackhandler/received_packet_handler.go b/ackhandler/received_packet_handler.go index ed7fea72..7db808d7 100644 --- a/ackhandler/received_packet_handler.go +++ b/ackhandler/received_packet_handler.go @@ -67,7 +67,7 @@ func (h *receivedPacketHandler) getNackRanges() ([]frames.NackRange, EntropyAccu var ranges []frames.NackRange inRange := false entropy := h.highestInOrderObservedEntropy - for i := h.highestInOrderObserved + 1; i <= h.largestObserved; i++ { + for i := h.largestObserved; i > h.highestInOrderObserved; i-- { entropyBit, ok := h.packetHistory[i] if !ok { if !inRange { @@ -78,7 +78,7 @@ func (h *receivedPacketHandler) getNackRanges() ([]frames.NackRange, EntropyAccu ranges = append(ranges, r) inRange = true } else { - ranges[len(ranges)-1].LastPacketNumber++ + ranges[len(ranges)-1].FirstPacketNumber-- } } else { inRange = false diff --git a/ackhandler/received_packet_handler_test.go b/ackhandler/received_packet_handler_test.go index f218ddad..bff0847c 100644 --- a/ackhandler/received_packet_handler_test.go +++ b/ackhandler/received_packet_handler_test.go @@ -117,8 +117,7 @@ var _ = Describe("receivedPacketHandler", func() { Expect(handler.largestObserved).To(Equal(protocol.PacketNumber(9))) nackRanges, entropy := handler.getNackRanges() Expect(len(nackRanges)).To(Equal(1)) - Expect(nackRanges[0].FirstPacketNumber).To(Equal(protocol.PacketNumber(5))) - Expect(nackRanges[0].LastPacketNumber).To(Equal(protocol.PacketNumber(5))) + Expect(nackRanges[0]).To(Equal(frames.NackRange{FirstPacketNumber: 5, LastPacketNumber: 5})) Expect(handler.highestInOrderObserved).To(Equal(protocol.PacketNumber(4))) Expect(entropy).To(Equal(expectedEntropy)) }) @@ -139,8 +138,7 @@ var _ = Describe("receivedPacketHandler", func() { Expect(handler.largestObserved).To(Equal(protocol.PacketNumber(11))) nackRanges, entropy := handler.getNackRanges() Expect(len(nackRanges)).To(Equal(1)) - Expect(nackRanges[0].FirstPacketNumber).To(Equal(protocol.PacketNumber(5))) - Expect(nackRanges[0].LastPacketNumber).To(Equal(protocol.PacketNumber(6))) + Expect(nackRanges[0]).To(Equal(frames.NackRange{FirstPacketNumber: 5, LastPacketNumber: 6})) Expect(handler.highestInOrderObserved).To(Equal(protocol.PacketNumber(4))) Expect(entropy).To(Equal(expectedEntropy)) }) @@ -161,10 +159,8 @@ var _ = Describe("receivedPacketHandler", func() { Expect(handler.largestObserved).To(Equal(protocol.PacketNumber(9))) nackRanges, entropy := handler.getNackRanges() Expect(len(nackRanges)).To(Equal(2)) - Expect(nackRanges[0].FirstPacketNumber).To(Equal(protocol.PacketNumber(3))) - Expect(nackRanges[0].LastPacketNumber).To(Equal(protocol.PacketNumber(3))) - Expect(nackRanges[1].FirstPacketNumber).To(Equal(protocol.PacketNumber(7))) - Expect(nackRanges[1].LastPacketNumber).To(Equal(protocol.PacketNumber(7))) + Expect(nackRanges[0]).To(Equal(frames.NackRange{FirstPacketNumber: 7, LastPacketNumber: 7})) + Expect(nackRanges[1]).To(Equal(frames.NackRange{FirstPacketNumber: 3, LastPacketNumber: 3})) Expect(handler.highestInOrderObserved).To(Equal(protocol.PacketNumber(2))) Expect(entropy).To(Equal(expectedEntropy)) }) @@ -182,10 +178,8 @@ var _ = Describe("receivedPacketHandler", func() { Expect(handler.largestObserved).To(Equal(protocol.PacketNumber(9))) nackRanges, entropy := handler.getNackRanges() Expect(len(nackRanges)).To(Equal(2)) - Expect(nackRanges[0].FirstPacketNumber).To(Equal(protocol.PacketNumber(2))) - Expect(nackRanges[0].LastPacketNumber).To(Equal(protocol.PacketNumber(4))) - Expect(nackRanges[1].FirstPacketNumber).To(Equal(protocol.PacketNumber(7))) - Expect(nackRanges[1].LastPacketNumber).To(Equal(protocol.PacketNumber(8))) + Expect(nackRanges[0]).To(Equal(frames.NackRange{FirstPacketNumber: 7, LastPacketNumber: 8})) + Expect(nackRanges[1]).To(Equal(frames.NackRange{FirstPacketNumber: 2, LastPacketNumber: 4})) Expect(handler.highestInOrderObserved).To(Equal(protocol.PacketNumber(1))) Expect(entropy).To(Equal(expectedEntropy)) })