implement cubic "exponential slow start" test

This commit is contained in:
Lucas Clemente
2016-04-28 10:34:27 +02:00
parent 2da6f1860e
commit f869be1eb1
3 changed files with 30 additions and 0 deletions

View File

@@ -199,3 +199,13 @@ func (c *cubicSender) isCwndLimited(bytesInFlight uint64) bool {
slowStartLimited := c.InSlowStart() && bytesInFlight > congestionWindow/2
return slowStartLimited || availableBytes <= maxBurstBytes
}
// BandwidthEstimate returns the current bandwidth estimate
func (c *cubicSender) BandwidthEstimate() Bandwidth {
srtt := c.rttStats.SmoothedRTT()
if srtt == 0 {
// If we haven't measured an rtt, the bandwidth estimate is unknown.
return 0
}
return BandwidthFromDelta(c.GetCongestionWindow(), srtt)
}

View File

@@ -100,4 +100,23 @@ var _ = Describe("Cubic Sender", func() {
// half the CWND.
Expect(bytesToSend).To(Equal(defaultWindowTCP + protocol.DefaultTCPMSS*2*2))
})
It("exponential slow start", func() {
const kNumberOfAcks = 20
// At startup make sure we can send.
Expect(sender.TimeUntilSend(clock.Now(), 0)).To(BeZero())
Expect(sender.BandwidthEstimate()).To(BeZero())
// Make sure we can send.
Expect(sender.TimeUntilSend(clock.Now(), 0)).To(BeZero())
for i := 0; i < kNumberOfAcks; i++ {
// Send our full send window.
SendAvailableSendWindow(protocol.DefaultTCPMSS)
AckNPackets(2)
}
cwnd := sender.GetCongestionWindow()
Expect(cwnd).To(Equal(defaultWindowTCP + protocol.DefaultTCPMSS*2*kNumberOfAcks))
Expect(sender.BandwidthEstimate()).To(Equal(congestion.BandwidthFromDelta(cwnd, rttStats.SmoothedRTT())))
})
})

View File

@@ -11,4 +11,5 @@ type SendAlgorithm interface {
OnPacketSent(sentTime time.Time, bytesInFlight uint64, packetNumber protocol.PacketNumber, bytes uint64, isRetransmittable bool) bool
GetCongestionWindow() uint64
OnCongestionEvent(rttUpdated bool, bytesInFlight uint64, ackedPackets PacketVector, lostPackets PacketVector)
BandwidthEstimate() Bandwidth
}