github.com/tumi8/quic-go@v0.37.4-tum/noninternal/congestion/hybrid_slow_start_test.go (about) 1 package congestion 2 3 import ( 4 "time" 5 6 "github.com/tumi8/quic-go/noninternal/protocol" 7 . "github.com/onsi/ginkgo/v2" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("Hybrid slow start", func() { 12 var slowStart HybridSlowStart 13 14 BeforeEach(func() { 15 slowStart = HybridSlowStart{} 16 }) 17 18 It("works in a simple case", func() { 19 packetNumber := protocol.PacketNumber(1) 20 endPacketNumber := protocol.PacketNumber(3) 21 slowStart.StartReceiveRound(endPacketNumber) 22 23 packetNumber++ 24 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse()) 25 26 // Test duplicates. 27 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse()) 28 29 packetNumber++ 30 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse()) 31 packetNumber++ 32 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeTrue()) 33 34 // Test without a new registered end_packet_number; 35 packetNumber++ 36 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeTrue()) 37 38 endPacketNumber = 20 39 slowStart.StartReceiveRound(endPacketNumber) 40 for packetNumber < endPacketNumber { 41 packetNumber++ 42 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeFalse()) 43 } 44 packetNumber++ 45 Expect(slowStart.IsEndOfRound(packetNumber)).To(BeTrue()) 46 }) 47 48 It("works with delay", func() { 49 rtt := 60 * time.Millisecond 50 // We expect to detect the increase at +1/8 of the RTT; hence at a typical 51 // RTT of 60ms the detection will happen at 67.5 ms. 52 const hybridStartMinSamples = 8 // Number of acks required to trigger. 53 54 endPacketNumber := protocol.PacketNumber(1) 55 endPacketNumber++ 56 slowStart.StartReceiveRound(endPacketNumber) 57 58 // Will not trigger since our lowest RTT in our burst is the same as the long 59 // term RTT provided. 60 for n := 0; n < hybridStartMinSamples; n++ { 61 Expect(slowStart.ShouldExitSlowStart(rtt+time.Duration(n)*time.Millisecond, rtt, 100)).To(BeFalse()) 62 } 63 endPacketNumber++ 64 slowStart.StartReceiveRound(endPacketNumber) 65 for n := 1; n < hybridStartMinSamples; n++ { 66 Expect(slowStart.ShouldExitSlowStart(rtt+(time.Duration(n)+10)*time.Millisecond, rtt, 100)).To(BeFalse()) 67 } 68 // Expect to trigger since all packets in this burst was above the long term 69 // RTT provided. 70 Expect(slowStart.ShouldExitSlowStart(rtt+10*time.Millisecond, rtt, 100)).To(BeTrue()) 71 }) 72 })