diff --git a/client.go b/client.go index 9ede391f..21a14ab7 100644 --- a/client.go +++ b/client.go @@ -352,6 +352,7 @@ func (c *client) createNewTLSSession(version protocol.VersionNumber) error { IdleTimeout: c.config.IdleTimeout, MaxBidiStreams: uint64(c.config.MaxIncomingStreams), MaxUniStreams: uint64(c.config.MaxIncomingUniStreams), + MaxAckDelay: protocol.MaxAckDelay, AckDelayExponent: protocol.AckDelayExponent, DisableMigration: true, } diff --git a/internal/ackhandler/received_packet_handler.go b/internal/ackhandler/received_packet_handler.go index 282115ed..6ee66039 100644 --- a/internal/ackhandler/received_packet_handler.go +++ b/internal/ackhandler/received_packet_handler.go @@ -11,8 +11,6 @@ import ( ) const ( - // maximum delay that can be applied to an ACK for an ack-eliciting packet - ackSendDelay = 25 * time.Millisecond // initial maximum number of ack-eliciting packets received before sending an ack. initialAckElicitingPacketsBeforeAck = 2 // number of ack-eliciting that an ACK is sent for diff --git a/internal/ackhandler/received_packet_tracker.go b/internal/ackhandler/received_packet_tracker.go index 6b73e08d..42f7de59 100644 --- a/internal/ackhandler/received_packet_tracker.go +++ b/internal/ackhandler/received_packet_tracker.go @@ -16,8 +16,8 @@ type receivedPacketTracker struct { packetHistory *receivedPacketHistory - ackSendDelay time.Duration - rttStats *congestion.RTTStats + maxAckDelay time.Duration + rttStats *congestion.RTTStats packetsReceivedSinceLastAck int ackElicitingPacketsReceivedSinceLastAck int @@ -37,7 +37,7 @@ func newReceivedPacketTracker( ) *receivedPacketTracker { return &receivedPacketTracker{ packetHistory: newReceivedPacketHistory(), - ackSendDelay: ackSendDelay, + maxAckDelay: protocol.MaxAckDelay, rttStats: rttStats, logger: logger, version: version, @@ -126,7 +126,7 @@ func (h *receivedPacketTracker) maybeQueueAck(packetNumber protocol.PacketNumber } } else if h.ackAlarm.IsZero() { // wait for the minimum of the ack decimation delay or the delayed ack time before sending an ack - ackDelay := utils.MinDuration(ackSendDelay, time.Duration(float64(h.rttStats.MinRTT())*float64(ackDecimationDelay))) + ackDelay := utils.MinDuration(h.maxAckDelay, time.Duration(float64(h.rttStats.MinRTT())*float64(ackDecimationDelay))) h.ackAlarm = rcvTime.Add(ackDelay) if h.logger.Debug() { h.logger.Debugf("\tSetting ACK timer to min(1/4 min-RTT, max ack delay): %s (%s from now)", ackDelay, time.Until(h.ackAlarm)) @@ -141,9 +141,9 @@ func (h *receivedPacketTracker) maybeQueueAck(packetNumber protocol.PacketNumber h.ackQueued = true } else if h.ackAlarm.IsZero() { if h.logger.Debug() { - h.logger.Debugf("\tSetting ACK timer to max ack delay: %s", ackSendDelay) + h.logger.Debugf("\tSetting ACK timer to max ack delay: %s", h.maxAckDelay) } - h.ackAlarm = rcvTime.Add(ackSendDelay) + h.ackAlarm = rcvTime.Add(h.maxAckDelay) } } // If there are new missing packets to report, set a short timer to send an ACK. diff --git a/internal/ackhandler/received_packet_tracker_test.go b/internal/ackhandler/received_packet_tracker_test.go index eb1d3587..a06a2e2a 100644 --- a/internal/ackhandler/received_packet_tracker_test.go +++ b/internal/ackhandler/received_packet_tracker_test.go @@ -151,7 +151,7 @@ var _ = Describe("Received Packet Tracker", func() { err = tracker.ReceivedPacket(12, rcvTime, true) Expect(err).ToNot(HaveOccurred()) Expect(tracker.ackQueued).To(BeFalse()) - Expect(tracker.GetAlarmTimeout()).To(Equal(rcvTime.Add(ackSendDelay))) + Expect(tracker.GetAlarmTimeout()).To(Equal(rcvTime.Add(protocol.MaxAckDelay))) }) It("queues an ACK if it was reported missing before", func() { diff --git a/internal/protocol/params.go b/internal/protocol/params.go index 4dc217f7..6488a36c 100644 --- a/internal/protocol/params.go +++ b/internal/protocol/params.go @@ -125,3 +125,6 @@ const DefaultConnectionIDLength = 4 // AckDelayExponent is the ack delay exponent used when sending ACKs. const AckDelayExponent = 3 + +// MaxAckDelay is the maximum time by which we delay sending ACKs. +const MaxAckDelay = 25 * time.Millisecond diff --git a/server.go b/server.go index fe2f9388..be386468 100644 --- a/server.go +++ b/server.go @@ -445,6 +445,7 @@ func (s *server) createNewSession( IdleTimeout: s.config.IdleTimeout, MaxBidiStreams: uint64(s.config.MaxIncomingStreams), MaxUniStreams: uint64(s.config.MaxIncomingUniStreams), + MaxAckDelay: protocol.MaxAckDelay, AckDelayExponent: protocol.AckDelayExponent, DisableMigration: true, StatelessResetToken: &token,