Skip to content

Commit

Permalink
check datagram size in PMTUD integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed May 7, 2024
1 parent 05d7135 commit dee0fad
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions integrationtests/self/dplpmtud_test.go
Expand Up @@ -17,10 +17,14 @@ import (

var _ = Describe("DPLPMTUD", func() {
It("discovers the MTU", func() {
const rtt = 100 * time.Millisecond
rtt := scaleDuration(10 * time.Millisecond)
const mtu = 1400

ln, err := quic.ListenAddr("localhost:0", getTLSConfig(), getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true}))
ln, err := quic.ListenAddr(
"localhost:0",
getTLSConfig(),
getQuicConfig(&quic.Config{DisablePathMTUDiscovery: true, EnableDatagrams: true}),
)
Expect(err).ToNot(HaveOccurred())
defer ln.Close()
go func() {
Expand Down Expand Up @@ -73,7 +77,7 @@ var _ = Describe("DPLPMTUD", func() {
context.Background(),
proxy.LocalAddr(),
getTLSClientConfig(),
getQuicConfig(nil),
getQuicConfig(&quic.Config{EnableDatagrams: true}),
)
Expect(err).ToNot(HaveOccurred())
defer conn.CloseWithError(0, "")
Expand All @@ -87,15 +91,27 @@ var _ = Describe("DPLPMTUD", func() {
Expect(err).ToNot(HaveOccurred())
Expect(data).To(Equal(PRDataLong))
}()
err = conn.SendDatagram(make([]byte, 2000))
Expect(err).To(BeAssignableToTypeOf(&quic.DatagramTooLargeError{}))
initialMaxDatagramSize := err.(*quic.DatagramTooLargeError).MaxDatagramPayloadSize
_, err = str.Write(PRDataLong)
Expect(err).ToNot(HaveOccurred())
str.Close()
Eventually(done, 20*time.Second).Should(BeClosed())
err = conn.SendDatagram(make([]byte, 2000))
Expect(err).To(BeAssignableToTypeOf(&quic.DatagramTooLargeError{}))
finalMaxDatagramSize := err.(*quic.DatagramTooLargeError).MaxDatagramPayloadSize

mx.Lock()
defer mx.Unlock()
fmt.Fprintf(GinkgoWriter, "max client packet size: %d, MTU: %d\n", maxPacketSizeClient, mtu)
fmt.Fprintf(GinkgoWriter, "max datagram size: initial: %d, final: %d\n", initialMaxDatagramSize, finalMaxDatagramSize)
fmt.Fprintf(GinkgoWriter, "max server packet size: %d, MTU: %d\n", maxPacketSizeServer, mtu)
Expect(maxPacketSizeClient).To(BeNumerically(">=", mtu-25))
const maxDiff = 40 // this includes the 21 bytes for the short header, 16 bytes for the encryption tag, and framing overhead
Expect(initialMaxDatagramSize).To(BeNumerically(">=", 1252-maxDiff))
Expect(finalMaxDatagramSize).To(BeNumerically(">=", maxPacketSizeClient-maxDiff))
// MTU discovery was disabled on the server side
Expect(maxPacketSizeServer).To(Equal(1252))
})
})

0 comments on commit dee0fad

Please sign in to comment.