forked from quic-go/quic-go
don't send more packets when there are too many unacked
fixes #249, fixes #322
This commit is contained in:
@@ -20,7 +20,7 @@ type SentPacketHandler interface {
|
||||
BytesInFlight() protocol.ByteCount
|
||||
GetLeastUnacked() protocol.PacketNumber
|
||||
|
||||
CongestionAllowsSending() bool
|
||||
SendingAllowed() bool
|
||||
CheckForError() error
|
||||
|
||||
TimeOfFirstRTO() time.Time
|
||||
|
||||
@@ -269,8 +269,10 @@ func (h *sentPacketHandler) GetStopWaitingFrame(force bool) *frames.StopWaitingF
|
||||
return h.stopWaitingManager.GetStopWaitingFrame(force)
|
||||
}
|
||||
|
||||
func (h *sentPacketHandler) CongestionAllowsSending() bool {
|
||||
return h.BytesInFlight() <= h.congestion.GetCongestionWindow()
|
||||
func (h *sentPacketHandler) SendingAllowed() bool {
|
||||
congestionLimited := h.BytesInFlight() > h.congestion.GetCongestionWindow()
|
||||
maxTrackedLimited := protocol.PacketNumber(len(h.retransmissionQueue)+h.packetHistory.Len()) >= protocol.MaxTrackedSentPackets
|
||||
return !(congestionLimited || maxTrackedLimited)
|
||||
}
|
||||
|
||||
func (h *sentPacketHandler) CheckForError() error {
|
||||
|
||||
@@ -741,11 +741,17 @@ var _ = Describe("SentPacketHandler", func() {
|
||||
Expect(cong.argsOnCongestionEvent[3]).To(Equal(congestion.PacketVector{{Number: 2, Length: 2}}))
|
||||
})
|
||||
|
||||
It("allows or denies sending", func() {
|
||||
Expect(handler.CongestionAllowsSending()).To(BeTrue())
|
||||
It("allows or denies sending based on congestion", func() {
|
||||
Expect(handler.SendingAllowed()).To(BeTrue())
|
||||
err := handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: protocol.DefaultTCPMSS + 1})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.CongestionAllowsSending()).To(BeFalse())
|
||||
Expect(handler.SendingAllowed()).To(BeFalse())
|
||||
})
|
||||
|
||||
It("allows or denies sending based on the number of tracked packets", func() {
|
||||
Expect(handler.SendingAllowed()).To(BeTrue())
|
||||
handler.retransmissionQueue = make([]*Packet, protocol.MaxTrackedSentPackets)
|
||||
Expect(handler.SendingAllowed()).To(BeFalse())
|
||||
})
|
||||
|
||||
It("should call OnRetransmissionTimeout", func() {
|
||||
|
||||
@@ -444,7 +444,7 @@ func (s *Session) sendPacket() error {
|
||||
// Do this before checking the congestion, since we might de-congestionize here :)
|
||||
s.sentPacketHandler.MaybeQueueRTOs()
|
||||
|
||||
if !s.sentPacketHandler.CongestionAllowsSending() {
|
||||
if !s.sentPacketHandler.SendingAllowed() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -67,9 +67,9 @@ func (h *mockSentPacketHandler) GetStopWaitingFrame(force bool) *frames.StopWait
|
||||
h.requestedStopWaiting = true
|
||||
return &frames.StopWaitingFrame{LeastUnacked: 0x1337}
|
||||
}
|
||||
func (h *mockSentPacketHandler) CongestionAllowsSending() bool { return !h.congestionLimited }
|
||||
func (h *mockSentPacketHandler) CheckForError() error { return nil }
|
||||
func (h *mockSentPacketHandler) TimeOfFirstRTO() time.Time { panic("not implemented") }
|
||||
func (h *mockSentPacketHandler) SendingAllowed() bool { return !h.congestionLimited }
|
||||
func (h *mockSentPacketHandler) CheckForError() error { return nil }
|
||||
func (h *mockSentPacketHandler) TimeOfFirstRTO() time.Time { panic("not implemented") }
|
||||
|
||||
func (h *mockSentPacketHandler) MaybeQueueRTOs() {
|
||||
h.maybeQueueRTOsCalled = true
|
||||
|
||||
Reference in New Issue
Block a user