forked from quic-go/quic-go
initial hybrid slow start implementation
This commit is contained in:
@@ -70,7 +70,7 @@ var _ = Describe("Cubic", func() {
|
||||
Expect(current_cwnd).To(Equal(expected_cwnd))
|
||||
})
|
||||
|
||||
// TODO: Test copied form Chromium has no assertions
|
||||
// TODO: Test copied from Chromium has no assertions
|
||||
It("has increasing cwnd stats during convex region", func() {
|
||||
rtt_min := 100 * time.Millisecond
|
||||
current_cwnd := uint64(10)
|
||||
|
||||
25
congestion/hybrid_slow_start.go
Normal file
25
congestion/hybrid_slow_start.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package congestion
|
||||
|
||||
import "time"
|
||||
|
||||
// HybridSlowStart implements the TCP hybrid slow start algorithm
|
||||
type HybridSlowStart struct {
|
||||
endPacketNumber uint64
|
||||
lastSentPacketNumber uint64
|
||||
started bool
|
||||
currentMinRTT time.Duration
|
||||
rttSampleCount uint32
|
||||
}
|
||||
|
||||
// StartReceiveRound is called for the start of each receive round (burst) in the slow start phase.
|
||||
func (s *HybridSlowStart) StartReceiveRound(last_sent uint64) {
|
||||
s.endPacketNumber = last_sent
|
||||
s.currentMinRTT = 0
|
||||
s.rttSampleCount = 0
|
||||
s.started = true
|
||||
}
|
||||
|
||||
// IsEndOfRound returns true if this ack is the last packet number of our current slow start round.
|
||||
func (s *HybridSlowStart) IsEndOfRound(ack uint64) bool {
|
||||
return s.endPacketNumber < ack
|
||||
}
|
||||
47
congestion/hybrid_slow_start_test.go
Normal file
47
congestion/hybrid_slow_start_test.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package congestion_test
|
||||
|
||||
import (
|
||||
"github.com/lucas-clemente/quic-go/congestion"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
var _ = Describe("Hybrid slow start", func() {
|
||||
var (
|
||||
slowStart congestion.HybridSlowStart
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
slowStart = congestion.HybridSlowStart{}
|
||||
})
|
||||
|
||||
It("works in a simple case", func() {
|
||||
packet_number := uint64(1)
|
||||
end_packet_number := uint64(3)
|
||||
slowStart.StartReceiveRound(end_packet_number)
|
||||
|
||||
packet_number++
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeFalse())
|
||||
|
||||
// Test duplicates.
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeFalse())
|
||||
|
||||
packet_number++
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeFalse())
|
||||
packet_number++
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeTrue())
|
||||
|
||||
// Test without a new registered end_packet_number;
|
||||
packet_number++
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeTrue())
|
||||
|
||||
end_packet_number = 20
|
||||
slowStart.StartReceiveRound(end_packet_number)
|
||||
for packet_number < end_packet_number {
|
||||
packet_number++
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeFalse())
|
||||
}
|
||||
packet_number++
|
||||
Expect(slowStart.IsEndOfRound(packet_number)).To(BeTrue())
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user