forked from quic-go/quic-go
set max tracked packets to max cwnd * 2
This commit is contained in:
@@ -75,7 +75,7 @@ func (h *receivedPacketHandler) ReceivedPacket(packetNumber protocol.PacketNumbe
|
||||
|
||||
h.receivedTimes[packetNumber] = time.Now()
|
||||
|
||||
if uint32(len(h.receivedTimes)) > protocol.MaxTrackedReceivedPackets {
|
||||
if protocol.PacketNumber(len(h.receivedTimes)) > protocol.MaxTrackedReceivedPackets {
|
||||
return errTooManyOutstandingReceivedPackets
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ var _ = Describe("receivedPacketHandler", func() {
|
||||
})
|
||||
|
||||
It("doesn't store more than MaxTrackedReceivedPackets packets", func() {
|
||||
for i := uint32(0); i < protocol.MaxTrackedReceivedPackets; i++ {
|
||||
for i := protocol.PacketNumber(0); i < protocol.MaxTrackedReceivedPackets; i++ {
|
||||
packetNumber := protocol.PacketNumber(1 + 2*i)
|
||||
err := handler.ReceivedPacket(packetNumber)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
@@ -274,7 +274,7 @@ func (h *sentPacketHandler) CongestionAllowsSending() bool {
|
||||
|
||||
func (h *sentPacketHandler) CheckForError() error {
|
||||
length := len(h.retransmissionQueue) + h.packetHistory.Len()
|
||||
if uint32(length) > protocol.MaxTrackedSentPackets {
|
||||
if protocol.PacketNumber(length) > protocol.MaxTrackedSentPackets {
|
||||
return ErrTooManyTrackedSentPackets
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -213,7 +213,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||
|
||||
Context("DOS mitigation", func() {
|
||||
It("checks the size of the packet history, for unacked packets", func() {
|
||||
for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ {
|
||||
for i := protocol.PacketNumber(1); i < protocol.MaxTrackedSentPackets+10; i++ {
|
||||
packet := Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1}
|
||||
err := handler.SentPacket(&packet)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
@@ -44,7 +44,7 @@ const MaxNewStreamIDDelta = 4 * MaxStreamsPerConnection
|
||||
const MaxIdleConnectionStateLifetime = 60 * time.Second
|
||||
|
||||
// MaxSessionUnprocessedPackets is the max number of packets stored in each session that are not yet processed.
|
||||
const MaxSessionUnprocessedPackets = 2000
|
||||
const MaxSessionUnprocessedPackets = DefaultMaxCongestionWindow
|
||||
|
||||
// RetransmissionThreshold + 1 is the number of times a packet has to be NACKed so that it gets retransmitted
|
||||
const RetransmissionThreshold = 3
|
||||
@@ -59,13 +59,10 @@ const MaxTrackedSkippedPackets = 10
|
||||
const STKExpiryTimeSec = 24 * 60 * 60
|
||||
|
||||
// MaxTrackedSentPackets is maximum number of sent packets saved for either later retransmission or entropy calculation
|
||||
// TODO: find a reasonable value here
|
||||
// TODO: decrease this value after dropping support for QUIC 33 and earlier
|
||||
const MaxTrackedSentPackets = 2000
|
||||
const MaxTrackedSentPackets = 2 * DefaultMaxCongestionWindow
|
||||
|
||||
// MaxTrackedReceivedPackets is the maximum number of received packets saved for doing the entropy calculations
|
||||
// TODO: think about what to do with this when adding support for QUIC 34
|
||||
const MaxTrackedReceivedPackets = 2000
|
||||
const MaxTrackedReceivedPackets = 2 * DefaultMaxCongestionWindow
|
||||
|
||||
// MaxStreamFrameSorterGaps is the maximum number of gaps between received StreamFrames
|
||||
// prevents DOS attacks against the streamFrameSorter
|
||||
|
||||
@@ -762,7 +762,7 @@ var _ = Describe("Session", func() {
|
||||
|
||||
It("errors when the SentPacketHandler has too many packets tracked", func() {
|
||||
streamFrame := frames.StreamFrame{StreamID: 5, Data: []byte("foobar")}
|
||||
for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ {
|
||||
for i := protocol.PacketNumber(1); i < protocol.MaxTrackedSentPackets+10; i++ {
|
||||
packet := ackhandler.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1}
|
||||
err := session.sentPacketHandler.SentPacket(&packet)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
@@ -774,7 +774,7 @@ var _ = Describe("Session", func() {
|
||||
|
||||
It("stores up to MaxSessionUnprocessedPackets packets", func(done Done) {
|
||||
// Nothing here should block
|
||||
for i := 0; i < protocol.MaxSessionUnprocessedPackets+10; i++ {
|
||||
for i := protocol.PacketNumber(0); i < protocol.MaxSessionUnprocessedPackets+10; i++ {
|
||||
session.handlePacket(nil, nil, nil)
|
||||
}
|
||||
close(done)
|
||||
|
||||
Reference in New Issue
Block a user