Skip to content

Commit

Permalink
don't send path MTU probe packets on a timer
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 22, 2022
1 parent fa0dba9 commit fdc5227
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 39 deletions.
5 changes: 0 additions & 5 deletions connection.go
Expand Up @@ -751,11 +751,6 @@ func (s *connection) maybeResetTimer() {
deadline = s.idleTimeoutStartTime().Add(s.idleTimeout)
}
}
if s.handshakeConfirmed && !s.config.DisablePathMTUDiscovery {
if probeTime := s.mtuDiscoverer.NextProbeTime(); !probeTime.IsZero() {
deadline = utils.MinTime(deadline, probeTime)
}
}

if ackAlarm := s.receivedPacketHandler.GetAlarmTimeout(); !ackAlarm.IsZero() {
deadline = utils.MinTime(deadline, ackAlarm)
Expand Down
6 changes: 1 addition & 5 deletions connection_test.go
Expand Up @@ -1692,11 +1692,7 @@ var _ = Describe("Connection", func() {
written := make(chan struct{}, 1)
sender.EXPECT().WouldBlock().AnyTimes()
sender.EXPECT().Send(gomock.Any()).DoAndReturn(func(p *packetBuffer) { written <- struct{}{} })
gomock.InOrder(
mtuDiscoverer.EXPECT().NextProbeTime(),
mtuDiscoverer.EXPECT().ShouldSendProbe(gomock.Any()).Return(true),
mtuDiscoverer.EXPECT().NextProbeTime(),
)
mtuDiscoverer.EXPECT().ShouldSendProbe(gomock.Any()).Return(true)
ping := ackhandler.Frame{Frame: &wire.PingFrame{}}
mtuDiscoverer.EXPECT().GetPing().Return(ping, protocol.ByteCount(1234))
packer.EXPECT().PackMTUProbePacket(ping, protocol.ByteCount(1234)).Return(getPacket(1), nil)
Expand Down
14 changes: 0 additions & 14 deletions mock_mtu_discoverer_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions mtu_discoverer.go
Expand Up @@ -11,7 +11,6 @@ import (

type mtuDiscoverer interface {
ShouldSendProbe(now time.Time) bool
NextProbeTime() time.Time
GetPing() (ping ackhandler.Frame, datagramSize protocol.ByteCount)
}

Expand Down Expand Up @@ -53,16 +52,7 @@ func (f *mtuFinder) ShouldSendProbe(now time.Time) bool {
if f.probeInFlight || f.done() {
return false
}
return !now.Before(f.NextProbeTime())
}

// NextProbeTime returns the time when the next probe packet should be sent.
// It returns the zero value if no probe packet should be sent.
func (f *mtuFinder) NextProbeTime() time.Time {
if f.probeInFlight || f.done() {
return time.Time{}
}
return f.lastProbeTime.Add(mtuProbeDelay * f.rttStats.SmoothedRTT())
return !now.Before(f.lastProbeTime.Add(mtuProbeDelay * f.rttStats.SmoothedRTT()))
}

func (f *mtuFinder) GetPing() (ackhandler.Frame, protocol.ByteCount) {
Expand Down
4 changes: 0 additions & 4 deletions mtu_discoverer_test.go
Expand Up @@ -38,17 +38,14 @@ var _ = Describe("MTU Discoverer", func() {
It("only allows a probe 5 RTTs after the handshake completes", func() {
Expect(d.ShouldSendProbe(now)).To(BeFalse())
Expect(d.ShouldSendProbe(now.Add(rtt * 9 / 2))).To(BeFalse())
Expect(d.NextProbeTime()).To(BeTemporally("~", now.Add(5*rtt), scaleDuration(20*time.Millisecond)))
Expect(d.ShouldSendProbe(now.Add(rtt * 5))).To(BeTrue())
})

It("doesn't allow a probe if another probe is still in flight", func() {
ping, _ := d.GetPing()
Expect(d.ShouldSendProbe(now.Add(10 * rtt))).To(BeFalse())
Expect(d.NextProbeTime()).To(BeZero())
ping.OnLost(ping.Frame)
Expect(d.ShouldSendProbe(now.Add(10 * rtt))).To(BeTrue())
Expect(d.NextProbeTime()).ToNot(BeZero())
})

It("tries a lower size when a probe is lost", func() {
Expand Down Expand Up @@ -79,7 +76,6 @@ var _ = Describe("MTU Discoverer", func() {
}
Expect(sizes).To(Equal([]protocol.ByteCount{1500, 1750, 1875, 1937, 1968, 1984}))
Expect(d.ShouldSendProbe(t.Add(10 * rtt))).To(BeFalse())
Expect(d.NextProbeTime()).To(BeZero())
})

It("finds the MTU", func() {
Expand Down

0 comments on commit fdc5227

Please sign in to comment.