initial hybrid slow start implementation

This commit is contained in:
Lucas Clemente
2016-04-24 12:24:13 +02:00
parent c72c9336b0
commit 4806807caa
3 changed files with 73 additions and 1 deletions

View File

@@ -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)

View 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
}

View 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())
})
})