From 470ae7b39b6f82648fb915d52f92ed77bed77d8e Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 30 Apr 2023 10:47:09 +0200 Subject: [PATCH] enable packet pacing, for packets sent before handshake completion It's not clear why this was disabled so far. The pacer should have some allowance for bursts, and it is expected that the handshake flights fit into this burst budget and therefore won't be delayed by the pacer. However, when using 0-RTT, it actually makes sense to start pacing right away, to avoid inducing packet loss very early in the connection. --- connection.go | 2 +- connection_test.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/connection.go b/connection.go index c942cf1f0..946d17f25 100644 --- a/connection.go +++ b/connection.go @@ -1739,7 +1739,7 @@ func (s *connection) sendPackets() error { var sentPacket bool // only used in for packets sent in send mode SendAny for { sendMode := s.sentPacketHandler.SendMode() - if sendMode == ackhandler.SendAny && s.handshakeComplete && !s.sentPacketHandler.HasPacingBudget() { + if sendMode == ackhandler.SendAny && !s.sentPacketHandler.HasPacingBudget() { deadline := s.sentPacketHandler.TimeUntilSend() if deadline.IsZero() { deadline = deadlineSendImmediately diff --git a/connection_test.go b/connection_test.go index d66b33e32..0a2ab9297 100644 --- a/connection_test.go +++ b/connection_test.go @@ -1771,6 +1771,7 @@ var _ = Describe("Connection", func() { sph.EXPECT().GetLossDetectionTimeout().AnyTimes() sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes() sph.EXPECT().TimeUntilSend().Return(time.Now()).AnyTimes() + sph.EXPECT().HasPacingBudget().Return(true).AnyTimes() gomock.InOrder( sph.EXPECT().SentPacket(gomock.Any()).Do(func(p *ackhandler.Packet) { Expect(p.EncryptionLevel).To(Equal(protocol.EncryptionInitial))