From d178a02ad86d6e831c8e6cc361554eef9ff7dbf0 Mon Sep 17 00:00:00 2001 From: Lucas Clemente Date: Thu, 5 May 2016 01:41:34 +0200 Subject: [PATCH] change congestion to use protocol.ByteCount fixes #52 --- congestion/bandwidth.go | 8 ++++-- congestion/congestion_vector.go | 2 +- congestion/cubic_sender.go | 26 +++++++++---------- congestion/cubic_sender_test.go | 44 ++++++++++++++++----------------- congestion/hybrid_slow_start.go | 4 +-- congestion/interface.go | 8 +++--- congestion/prr_sender.go | 16 ++++++------ congestion/prr_sender_test.go | 6 ++--- congestion/stats.go | 2 +- protocol/protocol.go | 2 +- 10 files changed, 61 insertions(+), 57 deletions(-) diff --git a/congestion/bandwidth.go b/congestion/bandwidth.go index 6c5c54742..2c7ff2381 100644 --- a/congestion/bandwidth.go +++ b/congestion/bandwidth.go @@ -1,6 +1,10 @@ package congestion -import "time" +import ( + "time" + + "github.com/lucas-clemente/quic-go/protocol" +) // Bandwidth of a connection type Bandwidth uint64 @@ -17,6 +21,6 @@ const ( ) // BandwidthFromDelta calculates the bandwidth from a number of bytes and a time delta -func BandwidthFromDelta(bytes uint64, delta time.Duration) Bandwidth { +func BandwidthFromDelta(bytes protocol.ByteCount, delta time.Duration) Bandwidth { return Bandwidth(bytes) * Bandwidth(time.Second) / Bandwidth(delta) * BytesPerSecond } diff --git a/congestion/congestion_vector.go b/congestion/congestion_vector.go index 7b21c1a4f..fa649b60b 100644 --- a/congestion/congestion_vector.go +++ b/congestion/congestion_vector.go @@ -4,7 +4,7 @@ import "github.com/lucas-clemente/quic-go/protocol" type PacketInfo struct { Number protocol.PacketNumber - Length uint64 + Length protocol.ByteCount } type PacketVector []PacketInfo diff --git a/congestion/cubic_sender.go b/congestion/cubic_sender.go index 79a5686ee..6165ae72b 100644 --- a/congestion/cubic_sender.go +++ b/congestion/cubic_sender.go @@ -55,7 +55,7 @@ type cubicSender struct { numConnections int // ACK counter for the Reno implementation. - congestionWindowCount uint64 + congestionWindowCount protocol.ByteCount initialCongestionWindow protocol.PacketNumber initialMaxCongestionWindow protocol.PacketNumber @@ -77,7 +77,7 @@ func NewCubicSender(clock Clock, rttStats *RTTStats, reno bool, initialCongestio } } -func (c *cubicSender) TimeUntilSend(now time.Time, bytesInFlight uint64) time.Duration { +func (c *cubicSender) TimeUntilSend(now time.Time, bytesInFlight protocol.ByteCount) time.Duration { if c.InRecovery() { // PRR is used when in recovery. return c.prr.TimeUntilSend(c.GetCongestionWindow(), bytesInFlight, c.GetSlowStartThreshold()) @@ -88,7 +88,7 @@ func (c *cubicSender) TimeUntilSend(now time.Time, bytesInFlight uint64) time.Du return math.MaxInt64 } -func (c *cubicSender) OnPacketSent(sentTime time.Time, bytesInFlight uint64, packetNumber protocol.PacketNumber, bytes uint64, isRetransmittable bool) bool { +func (c *cubicSender) OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool) bool { // Only update bytesInFlight for data packets. if !isRetransmittable { return false @@ -110,12 +110,12 @@ func (c *cubicSender) InSlowStart() bool { return c.GetCongestionWindow() < c.GetSlowStartThreshold() } -func (c *cubicSender) GetCongestionWindow() uint64 { - return uint64(c.congestionWindow) * protocol.DefaultTCPMSS +func (c *cubicSender) GetCongestionWindow() protocol.ByteCount { + return protocol.ByteCount(c.congestionWindow) * protocol.DefaultTCPMSS } -func (c *cubicSender) GetSlowStartThreshold() uint64 { - return uint64(c.slowstartThreshold) * protocol.DefaultTCPMSS +func (c *cubicSender) GetSlowStartThreshold() protocol.ByteCount { + return protocol.ByteCount(c.slowstartThreshold) * protocol.DefaultTCPMSS } func (c *cubicSender) ExitSlowstart() { @@ -131,7 +131,7 @@ func (c *cubicSender) SlowstartThreshold() protocol.PacketNumber { // latest_rtt sample has been taken, |byte_in_flight| the bytes in flight // prior to the congestion event. |ackedPackets| and |lostPackets| are // any packets considered acked or lost as a result of the congestion event. -func (c *cubicSender) OnCongestionEvent(rttUpdated bool, bytesInFlight uint64, ackedPackets PacketVector, lostPackets PacketVector) { +func (c *cubicSender) OnCongestionEvent(rttUpdated bool, bytesInFlight protocol.ByteCount, ackedPackets PacketVector, lostPackets PacketVector) { if rttUpdated && c.InSlowStart() && c.hybridSlowStart.ShouldExitSlowStart(c.rttStats.LatestRTT(), c.rttStats.MinRTT(), c.GetCongestionWindow()/protocol.DefaultTCPMSS) { c.ExitSlowstart() } @@ -143,7 +143,7 @@ func (c *cubicSender) OnCongestionEvent(rttUpdated bool, bytesInFlight uint64, a } } -func (c *cubicSender) onPacketAcked(ackedPacketNumber protocol.PacketNumber, ackedBytes uint64, bytesInFlight uint64) { +func (c *cubicSender) onPacketAcked(ackedPacketNumber protocol.PacketNumber, ackedBytes protocol.ByteCount, bytesInFlight protocol.ByteCount) { c.largestAckedPacketNumber = protocol.MaxPacketNumber(ackedPacketNumber, c.largestAckedPacketNumber) if c.InRecovery() { // PRR is used when in recovery. @@ -156,7 +156,7 @@ func (c *cubicSender) onPacketAcked(ackedPacketNumber protocol.PacketNumber, ack } } -func (c *cubicSender) onPacketLost(packetNumber protocol.PacketNumber, lostBytes uint64, bytesInFlight uint64) { +func (c *cubicSender) onPacketLost(packetNumber protocol.PacketNumber, lostBytes protocol.ByteCount, bytesInFlight protocol.ByteCount) { // TCP NewReno (RFC6582) says that once a loss occurs, any losses in packets // already sent should be treated as a single loss event, since it's expected. if packetNumber <= c.largestSentAtLastCutback { @@ -209,7 +209,7 @@ func (c *cubicSender) RenoBeta() float32 { // Called when we receive an ack. Normal TCP tracks how many packets one ack // represents, but quic has a separate ack for each packet. -func (c *cubicSender) maybeIncreaseCwnd(ackedPacketNumber protocol.PacketNumber, ackedBytes uint64, bytesInFlight uint64) { +func (c *cubicSender) maybeIncreaseCwnd(ackedPacketNumber protocol.PacketNumber, ackedBytes protocol.ByteCount, bytesInFlight protocol.ByteCount) { // Do not increase the congestion window unless the sender is close to using // the current window. if !c.isCwndLimited(bytesInFlight) { @@ -229,7 +229,7 @@ func (c *cubicSender) maybeIncreaseCwnd(ackedPacketNumber protocol.PacketNumber, c.congestionWindowCount++ // Divide by num_connections to smoothly increase the CWND at a faster // rate than conventional Reno. - if protocol.PacketNumber(c.congestionWindowCount*uint64(c.numConnections)) >= c.congestionWindow { + if protocol.PacketNumber(c.congestionWindowCount*protocol.ByteCount(c.numConnections)) >= c.congestionWindow { c.congestionWindow++ c.congestionWindowCount = 0 } @@ -238,7 +238,7 @@ func (c *cubicSender) maybeIncreaseCwnd(ackedPacketNumber protocol.PacketNumber, } } -func (c *cubicSender) isCwndLimited(bytesInFlight uint64) bool { +func (c *cubicSender) isCwndLimited(bytesInFlight protocol.ByteCount) bool { congestionWindow := c.GetCongestionWindow() if bytesInFlight >= congestionWindow { return true diff --git a/congestion/cubic_sender_test.go b/congestion/cubic_sender_test.go index e8e9743d5..891c6722a 100644 --- a/congestion/cubic_sender_test.go +++ b/congestion/cubic_sender_test.go @@ -10,7 +10,7 @@ import ( ) const initialCongestionWindowPackets protocol.PacketNumber = 10 -const defaultWindowTCP = uint64(initialCongestionWindowPackets * protocol.DefaultTCPMSS) +const defaultWindowTCP = protocol.ByteCount(initialCongestionWindowPackets) * protocol.DefaultTCPMSS const renoBeta float32 = 0.7 // Reno backoff factor. type mockClock time.Time @@ -27,7 +27,7 @@ var _ = Describe("Cubic Sender", func() { var ( sender congestion.SendAlgorithm clock mockClock - bytesInFlight uint64 + bytesInFlight protocol.ByteCount packetNumber protocol.PacketNumber ackedPacketNumber protocol.PacketNumber rttStats *congestion.RTTStats @@ -42,7 +42,7 @@ var _ = Describe("Cubic Sender", func() { sender = congestion.NewCubicSender(&clock, rttStats, true /*reno*/, initialCongestionWindowPackets, protocol.MaxCongestionWindow) }) - SendAvailableSendWindowLen := func(packetLength uint64) int { + SendAvailableSendWindowLen := func(packetLength protocol.ByteCount) int { // Send as long as TimeUntilSend returns Zero. packets_sent := 0 can_send := sender.TimeUntilSend(clock.Now(), bytesInFlight) == 0 @@ -57,7 +57,7 @@ var _ = Describe("Cubic Sender", func() { } // Normal is that TCP acks every other segment. - AckNPacketsLen := func(n int, packetLength uint64) { + AckNPacketsLen := func(n int, packetLength protocol.ByteCount) { rttStats.UpdateRTT(60*time.Millisecond, 0, clock.Now()) var ackedPackets congestion.PacketVector var lostPackets congestion.PacketVector @@ -66,11 +66,11 @@ var _ = Describe("Cubic Sender", func() { ackedPackets = append(ackedPackets, congestion.PacketInfo{Number: ackedPacketNumber, Length: packetLength}) } sender.OnCongestionEvent(true, bytesInFlight, ackedPackets, lostPackets) - bytesInFlight -= uint64(n) * packetLength + bytesInFlight -= protocol.ByteCount(n) * packetLength clock.Advance(time.Millisecond) } - LoseNPacketsLen := func(n int, packetLength uint64) { + LoseNPacketsLen := func(n int, packetLength protocol.ByteCount) { var ackedPackets congestion.PacketVector var lostPackets congestion.PacketVector for i := 0; i < n; i++ { @@ -78,7 +78,7 @@ var _ = Describe("Cubic Sender", func() { lostPackets = append(lostPackets, congestion.PacketInfo{Number: ackedPacketNumber, Length: packetLength}) } sender.OnCongestionEvent(false, bytesInFlight, ackedPackets, lostPackets) - bytesInFlight -= uint64(n) * packetLength + bytesInFlight -= protocol.ByteCount(n) * packetLength } // Does not increment acked_packet_number_. @@ -163,7 +163,7 @@ var _ = Describe("Cubic Sender", func() { packets_in_recovery_window := expected_send_window / protocol.DefaultTCPMSS // We should now have fallen out of slow start with a reduced window. - expected_send_window = uint64(float32(expected_send_window) * renoBeta) + expected_send_window = protocol.ByteCount(float32(expected_send_window) * renoBeta) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) // Recovery phase. We need to ack every packet in the recovery window before @@ -297,7 +297,7 @@ var _ = Describe("Cubic Sender", func() { // We should now have fallen out of slow start with a reduced window. send_window_before_loss := expected_send_window - expected_send_window = uint64(float32(expected_send_window) * renoBeta) + expected_send_window = protocol.ByteCount(float32(expected_send_window) * renoBeta) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) // Testing TCP proportional rate reduction. @@ -307,7 +307,7 @@ var _ = Describe("Cubic Sender", func() { // triggered the loss. remaining_packets_in_recovery := send_window_before_loss/protocol.DefaultTCPMSS - 2 - for i := uint64(0); i < remaining_packets_in_recovery; i++ { + for i := protocol.ByteCount(0); i < remaining_packets_in_recovery; i++ { AckNPackets(1) SendAvailableSendWindow() Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) @@ -315,7 +315,7 @@ var _ = Describe("Cubic Sender", func() { // We need to ack another window before we increase CWND by 1. number_of_packets_in_window := expected_send_window / protocol.DefaultTCPMSS - for i := uint64(0); i < number_of_packets_in_window; i++ { + for i := protocol.ByteCount(0); i < number_of_packets_in_window; i++ { AckNPackets(1) Expect(SendAvailableSendWindow()).To(Equal(1)) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) @@ -344,7 +344,7 @@ var _ = Describe("Cubic Sender", func() { // Lose one more than the congestion window reduction, so that after loss, // bytes_in_flight is lesser than the congestion window. - send_window_after_loss := uint64(renoBeta * float32(expected_send_window)) + send_window_after_loss := protocol.ByteCount(renoBeta * float32(expected_send_window)) num_packets_to_lose := (expected_send_window-send_window_after_loss)/protocol.DefaultTCPMSS + 1 LoseNPackets(int(num_packets_to_lose)) // Immediately after the loss, ensure at least one packet can be sent. @@ -353,7 +353,7 @@ var _ = Describe("Cubic Sender", func() { AckNPackets(1) // We should now have fallen out of slow start with a reduced window. - expected_send_window = uint64(float32(expected_send_window) * renoBeta) + expected_send_window = protocol.ByteCount(float32(expected_send_window) * renoBeta) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) // Only 2 packets should be allowed to be sent, per PRR-SSRB @@ -387,7 +387,7 @@ var _ = Describe("Cubic Sender", func() { // Expect the window to decrease to the minimum once the RTO fires // and slow start threshold to be set to 1/2 of the CWND. sender.OnRetransmissionTimeout(true) - Expect(sender.GetCongestionWindow()).To(Equal(uint64(2 * protocol.DefaultTCPMSS))) + Expect(sender.GetCongestionWindow()).To(Equal(protocol.ByteCount(2 * protocol.DefaultTCPMSS))) Expect(sender.SlowstartThreshold()).To(Equal(protocol.PacketNumber(5))) }) @@ -423,7 +423,7 @@ var _ = Describe("Cubic Sender", func() { Expect(rttStats.SmoothedRTT()).To(BeNumerically("~", kRttMs, time.Millisecond)) Expect(sender.RetransmissionDelay()).To(BeNumerically("~", expected_delay, time.Millisecond)) Expect(sender.BandwidthEstimate() / congestion.BytesPerSecond).To(Equal(congestion.Bandwidth( - sender.GetCongestionWindow() * uint64(time.Second) / uint64(rttStats.SmoothedRTT()), + sender.GetCongestionWindow() * protocol.ByteCount(time.Second) / protocol.ByteCount(rttStats.SmoothedRTT()), ))) }) @@ -438,7 +438,7 @@ var _ = Describe("Cubic Sender", func() { AckNPackets(2) } expected_send_window := kMaxCongestionWindowTCP * protocol.DefaultTCPMSS - Expect(sender.GetCongestionWindow()).To(Equal(uint64(expected_send_window))) + Expect(sender.GetCongestionWindow()).To(Equal(protocol.ByteCount(expected_send_window))) }) It("tcp reno max congestion window", func() { @@ -458,7 +458,7 @@ var _ = Describe("Cubic Sender", func() { } expected_send_window := kMaxCongestionWindowTCP * protocol.DefaultTCPMSS - Expect(sender.GetCongestionWindow()).To(Equal(uint64(expected_send_window))) + Expect(sender.GetCongestionWindow()).To(Equal(protocol.ByteCount(expected_send_window))) }) It("tcp cubic max congestion window", func() { @@ -480,7 +480,7 @@ var _ = Describe("Cubic Sender", func() { } expected_send_window := kMaxCongestionWindowTCP * protocol.DefaultTCPMSS - Expect(sender.GetCongestionWindow()).To(Equal(uint64(expected_send_window))) + Expect(sender.GetCongestionWindow()).To(Equal(protocol.ByteCount(expected_send_window))) }) It("tcp cubic reset epoch on quiescence", func() { @@ -644,7 +644,7 @@ var _ = Describe("Cubic Sender", func() { LoseNPackets(1) // We should now have fallen out of slow start with a reduced window. - expected_send_window = uint64(float32(expected_send_window) * sender.RenoBeta()) + expected_send_window = protocol.ByteCount(float32(expected_send_window) * sender.RenoBeta()) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) // No congestion window growth should occur in recovery phase, i.e., until the @@ -699,7 +699,7 @@ var _ = Describe("Cubic Sender", func() { LoseNPackets(1) // We should now have fallen out of slow start with a reduced window. - expected_send_window = uint64(float32(expected_send_window) * renoBeta) + expected_send_window = protocol.ByteCount(float32(expected_send_window) * renoBeta) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) // No congestion window growth should occur in recovery phase, i.e., until the @@ -714,7 +714,7 @@ var _ = Describe("Cubic Sender", func() { Expect(sender.InRecovery()).To(BeFalse()) // Out of recovery now. Congestion window should not grow during RTT. - for i := uint64(0); i < expected_send_window/protocol.DefaultTCPMSS-2; i += 2 { + for i := protocol.ByteCount(0); i < expected_send_window/protocol.DefaultTCPMSS-2; i += 2 { // Send our full send window. SendAvailableSendWindow() AckNPackets(2) @@ -810,7 +810,7 @@ var _ = Describe("Cubic Sender", func() { // We should now have fallen out of slow start with a reduced window. Slow // start threshold is also updated. - expected_send_window = uint64(float32(expected_send_window) * renoBeta) + expected_send_window = protocol.ByteCount(float32(expected_send_window) * renoBeta) Expect(sender.GetCongestionWindow()).To(Equal(expected_send_window)) Expect(sender.SlowstartThreshold()).To(Equal(protocol.PacketNumber(expected_send_window / protocol.DefaultTCPMSS))) diff --git a/congestion/hybrid_slow_start.go b/congestion/hybrid_slow_start.go index f1a2b5298..29204ff27 100644 --- a/congestion/hybrid_slow_start.go +++ b/congestion/hybrid_slow_start.go @@ -9,7 +9,7 @@ import ( // Note(pwestin): the magic clamping numbers come from the original code in // tcp_cubic.c. -const hybridStartLowWindow = uint64(16) +const hybridStartLowWindow = protocol.ByteCount(16) // Number of delay samples for detecting the increase of delay. const hybridStartMinSamples = uint32(8) @@ -48,7 +48,7 @@ func (s *HybridSlowStart) IsEndOfRound(ack protocol.PacketNumber) bool { // rtt: the RTT for this ack packet. // minRTT: is the lowest delay (RTT) we have seen during the session. // congestionWindow: the congestion window in packets. -func (s *HybridSlowStart) ShouldExitSlowStart(latestRTT time.Duration, minRTT time.Duration, congestionWindow uint64) bool { +func (s *HybridSlowStart) ShouldExitSlowStart(latestRTT time.Duration, minRTT time.Duration, congestionWindow protocol.ByteCount) bool { if !s.started { // Time to start the hybrid slow start. s.StartReceiveRound(s.lastSentPacketNumber) diff --git a/congestion/interface.go b/congestion/interface.go index 479350d5c..60299a321 100644 --- a/congestion/interface.go +++ b/congestion/interface.go @@ -7,10 +7,10 @@ import ( ) type SendAlgorithm interface { - TimeUntilSend(now time.Time, bytesInFlight uint64) time.Duration - 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) + TimeUntilSend(now time.Time, bytesInFlight protocol.ByteCount) time.Duration + OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool) bool + GetCongestionWindow() protocol.ByteCount + OnCongestionEvent(rttUpdated bool, bytesInFlight protocol.ByteCount, ackedPackets PacketVector, lostPackets PacketVector) BandwidthEstimate() Bandwidth SetNumEmulatedConnections(n int) OnRetransmissionTimeout(packetsRetransmitted bool) diff --git a/congestion/prr_sender.go b/congestion/prr_sender.go index d1122d4c8..f9f6db237 100644 --- a/congestion/prr_sender.go +++ b/congestion/prr_sender.go @@ -9,21 +9,21 @@ import ( // PrrSender implements the Proportional Rate Reduction (PRR) per RFC 6937 type PrrSender struct { - bytesSentSinceLoss uint64 - bytesDeliveredSinceLoss uint64 - ackCountSinceLoss uint64 - bytesInFlightBeforeLoss uint64 + bytesSentSinceLoss protocol.ByteCount + bytesDeliveredSinceLoss protocol.ByteCount + ackCountSinceLoss protocol.ByteCount + bytesInFlightBeforeLoss protocol.ByteCount } // OnPacketSent should be called after a packet was sent -func (p *PrrSender) OnPacketSent(sentBytes uint64) { +func (p *PrrSender) OnPacketSent(sentBytes protocol.ByteCount) { p.bytesSentSinceLoss += sentBytes } // OnPacketLost should be called on the first loss that triggers a recovery // period and all other methods in this class should only be called when in // recovery. -func (p *PrrSender) OnPacketLost(bytesInFlight uint64) { +func (p *PrrSender) OnPacketLost(bytesInFlight protocol.ByteCount) { p.bytesSentSinceLoss = 0 p.bytesInFlightBeforeLoss = bytesInFlight p.bytesDeliveredSinceLoss = 0 @@ -31,13 +31,13 @@ func (p *PrrSender) OnPacketLost(bytesInFlight uint64) { } // OnPacketAcked should be called after a packet was acked -func (p *PrrSender) OnPacketAcked(ackedBytes uint64) { +func (p *PrrSender) OnPacketAcked(ackedBytes protocol.ByteCount) { p.bytesDeliveredSinceLoss += ackedBytes p.ackCountSinceLoss++ } // TimeUntilSend calculates the time until a packet can be sent -func (p *PrrSender) TimeUntilSend(congestionWindow, bytesInFlight, slowstartThreshold uint64) time.Duration { +func (p *PrrSender) TimeUntilSend(congestionWindow, bytesInFlight, slowstartThreshold protocol.ByteCount) time.Duration { // Return QuicTime::Zero In order to ensure limited transmit always works. if p.bytesSentSinceLoss == 0 || bytesInFlight < protocol.DefaultTCPMSS { return 0 diff --git a/congestion/prr_sender_test.go b/congestion/prr_sender_test.go index a2e52b773..66ad58816 100644 --- a/congestion/prr_sender_test.go +++ b/congestion/prr_sender_test.go @@ -21,7 +21,7 @@ var _ = Describe("PRR sender", func() { }) It("single loss results in send on every other ack", func() { - num_packets_in_flight := uint64(50) + num_packets_in_flight := protocol.ByteCount(50) bytes_in_flight := num_packets_in_flight * protocol.DefaultTCPMSS ssthresh_after_loss := num_packets_in_flight / 2 congestion_window := ssthresh_after_loss * protocol.DefaultTCPMSS @@ -39,7 +39,7 @@ var _ = Describe("PRR sender", func() { // One packet is lost, and one ack was consumed above. PRR now paces // transmissions through the remaining 48 acks. PRR will alternatively // disallow and allow a packet to be sent in response to an ack. - for i := uint64(0); i < ssthresh_after_loss-1; i++ { + for i := protocol.ByteCount(0); i < ssthresh_after_loss-1; i++ { // Ack a packet. PRR shouldn't allow sending a packet in response. prr.OnPacketAcked(protocol.DefaultTCPMSS) bytes_in_flight -= protocol.DefaultTCPMSS @@ -74,7 +74,7 @@ var _ = Describe("PRR sender", func() { }) It("burst loss results in slow start", func() { - bytes_in_flight := uint64(20 * protocol.DefaultTCPMSS) + bytes_in_flight := protocol.ByteCount(20 * protocol.DefaultTCPMSS) const num_packets_lost = 13 const ssthresh_after_loss = 10 const congestion_window = ssthresh_after_loss * protocol.DefaultTCPMSS diff --git a/congestion/stats.go b/congestion/stats.go index 3c40180d5..8f272b26d 100644 --- a/congestion/stats.go +++ b/congestion/stats.go @@ -4,5 +4,5 @@ import "github.com/lucas-clemente/quic-go/protocol" type connectionStats struct { slowstartPacketsLost protocol.PacketNumber - slowstartBytesLost uint64 + slowstartBytesLost protocol.ByteCount } diff --git a/protocol/protocol.go b/protocol/protocol.go index 83810de29..32c7b2a3b 100644 --- a/protocol/protocol.go +++ b/protocol/protocol.go @@ -23,7 +23,7 @@ const MaxFrameSize = MaxPacketSize - (1 + 8 + 6) /*public header*/ - 1 /*private // DefaultTCPMSS is the default maximum packet size used in the Linux TCP implementation. // Used in QUIC for congestion window computations in bytes. -const DefaultTCPMSS = 1460 +const DefaultTCPMSS ByteCount = 1460 // InitialCongestionWindow is the initial congestion window in QUIC packets const InitialCongestionWindow PacketNumber = 32