forked from quic-go/quic-go
calculate MinLength for QUIC 34 ACKs with long ranges of missing packets
ref #182
This commit is contained in:
@@ -267,12 +267,11 @@ func (f *AckFrameNew) MinLength(version protocol.VersionNumber) (protocol.ByteCo
|
||||
var length protocol.ByteCount
|
||||
length = 1 + 2 + 1 + 1 + 4 // 1 TypeByte, 2 ACK delay time, 1 Num Timestamp, 1 Delta Largest Observed, 4 FirstTimestamp
|
||||
length += protocol.ByteCount(protocol.GetPacketNumberLength(f.LargestObserved))
|
||||
// for the first ACK block length
|
||||
|
||||
missingSequenceNumberDeltaLen := protocol.ByteCount(protocol.PacketNumberLen6)
|
||||
|
||||
if f.HasMissingRanges() {
|
||||
length += (1 + missingSequenceNumberDeltaLen) * protocol.ByteCount(len(f.AckRanges))
|
||||
length += (1 + missingSequenceNumberDeltaLen) * protocol.ByteCount(f.numWrittenNackRanges())
|
||||
} else {
|
||||
length += missingSequenceNumberDeltaLen
|
||||
}
|
||||
|
||||
@@ -351,6 +351,20 @@ var _ = Describe("AckFrame", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.MinLength(0)).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
|
||||
It("has the proper min length for an ACK with long gaps of missing packets", func() {
|
||||
f := &AckFrameNew{
|
||||
LargestObserved: 2000,
|
||||
AckRanges: []AckRange{
|
||||
AckRange{FirstPacketNumber: 1500, LastPacketNumber: 2000},
|
||||
AckRange{FirstPacketNumber: 290, LastPacketNumber: 295},
|
||||
AckRange{FirstPacketNumber: 1, LastPacketNumber: 19},
|
||||
},
|
||||
}
|
||||
err := f.Write(b, 0)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(f.MinLength(0)).To(Equal(protocol.ByteCount(b.Len())))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user