advertize the max_ack_delay in the transport parameters

This commit is contained in:
Marten Seemann 2019-05-08 13:22:37 +09:00
parent 4042a8258c
commit af8c03ebaf
6 changed files with 12 additions and 9 deletions

View file

@ -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,
}

View file

@ -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

View file

@ -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.

View file

@ -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() {

View file

@ -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

View file

@ -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,