File: hybrid_slow_start_test.go

package info (click to toggle)
golang-github-lucas-clemente-quic-go 0.50.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,496 kB
  • sloc: sh: 54; makefile: 7
file content (73 lines) | stat: -rw-r--r-- 2,251 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package congestion

import (
	"time"

	"github.com/quic-go/quic-go/internal/protocol"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

var _ = Describe("Hybrid slow start", func() {
	var slowStart HybridSlowStart

	BeforeEach(func() {
		slowStart = HybridSlowStart{}
	})

	It("works in a simple case", func() {
		packetNumber := protocol.PacketNumber(1)
		endPacketNumber := protocol.PacketNumber(3)
		slowStart.StartReceiveRound(endPacketNumber)

		packetNumber++
		Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse())

		// Test duplicates.
		Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse())

		packetNumber++
		Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse())
		packetNumber++
		Expect(slowStart.IsEndOfRound(packetNumber)).To(BeTrue())

		// Test without a new registered end_packet_number;
		packetNumber++
		Expect(slowStart.IsEndOfRound(packetNumber)).To(BeTrue())

		endPacketNumber = 20
		slowStart.StartReceiveRound(endPacketNumber)
		for packetNumber < endPacketNumber {
			packetNumber++
			Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse())
		}
		packetNumber++
		Expect(slowStart.IsEndOfRound(packetNumber)).To(BeTrue())
	})

	It("works with delay", func() {
		rtt := 60 * time.Millisecond
		// We expect to detect the increase at +1/8 of the RTT; hence at a typical
		// RTT of 60ms the detection will happen at 67.5 ms.
		const hybridStartMinSamples = 8 // Number of acks required to trigger.

		endPacketNumber := protocol.PacketNumber(1)
		endPacketNumber++
		slowStart.StartReceiveRound(endPacketNumber)

		// Will not trigger since our lowest RTT in our burst is the same as the long
		// term RTT provided.
		for n := 0; n < hybridStartMinSamples; n++ {
			Expect(slowStart.ShouldExitSlowStart(rtt+time.Duration(n)*time.Millisecond, rtt, 100)).To(BeFalse())
		}
		endPacketNumber++
		slowStart.StartReceiveRound(endPacketNumber)
		for n := 1; n < hybridStartMinSamples; n++ {
			Expect(slowStart.ShouldExitSlowStart(rtt+(time.Duration(n)+10)*time.Millisecond, rtt, 100)).To(BeFalse())
		}
		// Expect to trigger since all packets in this burst was above the long term
		// RTT provided.
		Expect(slowStart.ShouldExitSlowStart(rtt+10*time.Millisecond, rtt, 100)).To(BeTrue())
	})
})