mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
actually store LargestObserved in OutgoingPacketAckHandler
This commit is contained in:
parent
47d7f98383
commit
4be2ef710c
2 changed files with 32 additions and 5 deletions
|
@ -9,10 +9,11 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
errAckForUnsentPacket = errors.New("OutgoingPacketAckHandler: Received ACK for an unsent package")
|
||||
errEntropy = errors.New("OutgoingPacketAckHandler: Wrong entropy")
|
||||
errMapAccess = errors.New("OutgoingPacketAckHandler: Packet does not exist in PacketHistory")
|
||||
retransmissionThreshold = uint8(3)
|
||||
errAckForUnsentPacket = errors.New("OutgoingPacketAckHandler: Received ACK for an unsent package")
|
||||
errDuplicateOrOutOfOrderAck = errors.New("OutgoingPacketAckHandler: Duplicate or out-of-order ACK")
|
||||
errEntropy = errors.New("OutgoingPacketAckHandler: Wrong entropy")
|
||||
errMapAccess = errors.New("OutgoingPacketAckHandler: Packet does not exist in PacketHistory")
|
||||
retransmissionThreshold = uint8(3)
|
||||
)
|
||||
|
||||
type outgoingPacketAckHandler struct {
|
||||
|
@ -114,7 +115,7 @@ func (h *outgoingPacketAckHandler) ReceivedAck(ackFrame *frames.AckFrame) error
|
|||
}
|
||||
|
||||
if ackFrame.LargestObserved <= h.LargestObserved { // duplicate or out-of-order AckFrame
|
||||
return nil
|
||||
return errDuplicateOrOutOfOrderAck
|
||||
}
|
||||
|
||||
expectedEntropy, err := h.calculateExpectedEntropy(ackFrame)
|
||||
|
@ -132,6 +133,7 @@ func (h *outgoingPacketAckHandler) ReceivedAck(ackFrame *frames.AckFrame) error
|
|||
|
||||
highestInOrderAckedPacketNumber := ackFrame.GetHighestInOrderPacketNumber()
|
||||
highestInOrderAckedEntropy := h.highestInOrderAckedEntropy
|
||||
h.LargestObserved = ackFrame.LargestObserved
|
||||
|
||||
// if this ACK increases the highestInOrderAckedPacketNumber, the packet will be deleted from the packetHistory map, thus we need to save it's Entropy before doing so
|
||||
if highestInOrderAckedPacketNumber > h.highestInOrderAckedPacketNumber {
|
||||
|
|
|
@ -253,6 +253,31 @@ var _ = Describe("AckHandler", func() {
|
|||
Expect(handler.packetHistory).To(HaveKey(protocol.PacketNumber(6)))
|
||||
})
|
||||
|
||||
It("rejects duplicate ACKs", func() {
|
||||
largestObserved := 3
|
||||
ack := frames.AckFrame{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
err = handler.ReceivedAck(&ack)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(Equal(errDuplicateOrOutOfOrderAck))
|
||||
})
|
||||
|
||||
It("rejects out of order ACKs", func() {
|
||||
largestObserved := 3
|
||||
ack := frames.AckFrame{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
ack.LargestObserved--
|
||||
err = handler.ReceivedAck(&ack)
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(Equal(errDuplicateOrOutOfOrderAck))
|
||||
})
|
||||
|
||||
It("rejects ACKs with a LargestObserved packet number higher than what was sent out previously", func() {
|
||||
ack := frames.AckFrame{
|
||||
LargestObserved: packets[len(packets)-1].PacketNumber + 1337,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue