pass the maximum packet size from MTU discoverer to packet packer

This commit is contained in:
Marten Seemann
2023-04-18 08:48:12 +02:00
parent ecaef04695
commit bef0f3d31a
6 changed files with 225 additions and 353 deletions

View File

@@ -1,6 +1,7 @@
package quic
import (
"net"
"time"
"github.com/quic-go/quic-go/internal/ackhandler"
@@ -26,6 +27,20 @@ const (
mtuProbeDelay = 5
)
func getMaxPacketSize(addr net.Addr) protocol.ByteCount {
maxSize := protocol.ByteCount(protocol.MinInitialPacketSize)
// If this is not a UDP address, we don't know anything about the MTU.
// Use the minimum size of an Initial packet as the max packet size.
if udpAddr, ok := addr.(*net.UDPAddr); ok {
if utils.IsIPv4(udpAddr.IP) {
maxSize = protocol.InitialPacketSizeIPv4
} else {
maxSize = protocol.InitialPacketSizeIPv6
}
}
return maxSize
}
type mtuFinder struct {
lastProbeTime time.Time
probeInFlight bool