switch to a byte-based congestion controller

Chrome removed the packet-based congestion controller and switched to
byte-based as well.
This commit is contained in:
Marten Seemann
2018-04-06 14:54:20 +07:00
parent 2127e2f1de
commit 2b97fb41c9
13 changed files with 442 additions and 459 deletions

View File

@@ -5,7 +5,6 @@ import (
. "github.com/onsi/gomega"
"github.com/lucas-clemente/quic-go/internal/protocol"
"github.com/lucas-clemente/quic-go/internal/utils"
)
var _ = Describe("PRR sender", func() {
@@ -27,11 +26,11 @@ var _ = Describe("PRR sender", func() {
// Ack a packet. PRR allows one packet to leave immediately.
prr.OnPacketAcked(protocol.DefaultTCPMSS)
bytesInFlight -= protocol.DefaultTCPMSS
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeZero())
Expect(prr.CanSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeTrue())
// Send retransmission.
prr.OnPacketSent(protocol.DefaultTCPMSS)
// PRR shouldn't allow sending any more packets.
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(Equal(utils.InfDuration))
Expect(prr.CanSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeFalse())
// One packet is lost, and one ack was consumed above. PRR now paces
// transmissions through the remaining 48 acks. PRR will alternatively
@@ -40,11 +39,11 @@ var _ = Describe("PRR sender", func() {
// Ack a packet. PRR shouldn't allow sending a packet in response.
prr.OnPacketAcked(protocol.DefaultTCPMSS)
bytesInFlight -= protocol.DefaultTCPMSS
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(Equal(utils.InfDuration))
Expect(prr.CanSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeFalse())
// Ack another packet. PRR should now allow sending a packet in response.
prr.OnPacketAcked(protocol.DefaultTCPMSS)
bytesInFlight -= protocol.DefaultTCPMSS
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeZero())
Expect(prr.CanSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeTrue())
// Send a packet in response.
prr.OnPacketSent(protocol.DefaultTCPMSS)
bytesInFlight += protocol.DefaultTCPMSS
@@ -57,7 +56,7 @@ var _ = Describe("PRR sender", func() {
// Ack a packet.
prr.OnPacketAcked(protocol.DefaultTCPMSS)
bytesInFlight -= protocol.DefaultTCPMSS
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeZero())
Expect(prr.CanSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeTrue())
// Send a packet in response, since PRR allows it.
prr.OnPacketSent(protocol.DefaultTCPMSS)
bytesInFlight += protocol.DefaultTCPMSS
@@ -65,7 +64,7 @@ var _ = Describe("PRR sender", func() {
// Since bytes_in_flight is equal to the congestion_window,
// PRR disallows sending.
Expect(bytesInFlight).To(Equal(congestionWindow))
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(Equal(utils.InfDuration))
Expect(prr.CanSend(congestionWindow, bytesInFlight, sshthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeFalse())
}
})
@@ -86,20 +85,20 @@ var _ = Describe("PRR sender", func() {
bytesInFlight -= protocol.DefaultTCPMSS
// PRR-SSRB should allow two packets to be sent.
for j := 0; j < 2; j++ {
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, ssthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeZero())
Expect(prr.CanSend(congestionWindow, bytesInFlight, ssthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeTrue())
// Send a packet in response.
prr.OnPacketSent(protocol.DefaultTCPMSS)
bytesInFlight += protocol.DefaultTCPMSS
}
// PRR should allow no more than 2 packets in response to an ack.
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, ssthreshAfterLoss*protocol.DefaultTCPMSS)).To(Equal(utils.InfDuration))
Expect(prr.CanSend(congestionWindow, bytesInFlight, ssthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeFalse())
}
// Out of SSRB mode, PRR allows one send in response to each ack.
for i := 0; i < 10; i++ {
prr.OnPacketAcked(protocol.DefaultTCPMSS)
bytesInFlight -= protocol.DefaultTCPMSS
Expect(prr.TimeUntilSend(congestionWindow, bytesInFlight, ssthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeZero())
Expect(prr.CanSend(congestionWindow, bytesInFlight, ssthreshAfterLoss*protocol.DefaultTCPMSS)).To(BeTrue())
// Send a packet in response.
prr.OnPacketSent(protocol.DefaultTCPMSS)
bytesInFlight += protocol.DefaultTCPMSS