mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
rename defaultTCPMSS to maxDatagramSize
This commit is contained in:
parent
31e4691ffd
commit
d4de582fad
6 changed files with 131 additions and 131 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
const initialCongestionWindowPackets = 10
|
||||
const defaultWindowTCP = protocol.ByteCount(initialCongestionWindowPackets) * defaultTCPMSS
|
||||
const defaultWindowTCP = protocol.ByteCount(initialCongestionWindowPackets) * maxDatagramSize
|
||||
|
||||
type mockClock time.Time
|
||||
|
||||
|
@ -22,7 +22,7 @@ func (c *mockClock) Advance(d time.Duration) {
|
|||
*c = mockClock(time.Time(*c).Add(d))
|
||||
}
|
||||
|
||||
const MaxCongestionWindow protocol.ByteCount = 200 * defaultTCPMSS
|
||||
const MaxCongestionWindow protocol.ByteCount = 200 * maxDatagramSize
|
||||
|
||||
var _ = Describe("Cubic Sender", func() {
|
||||
var (
|
||||
|
@ -40,7 +40,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
ackedPacketNumber = 0
|
||||
clock = mockClock{}
|
||||
rttStats = NewRTTStats()
|
||||
sender = newCubicSender(&clock, rttStats, true /*reno*/, initialCongestionWindowPackets*defaultTCPMSS, MaxCongestionWindow)
|
||||
sender = newCubicSender(&clock, rttStats, true /*reno*/, initialCongestionWindowPackets*maxDatagramSize, MaxCongestionWindow)
|
||||
})
|
||||
|
||||
SendAvailableSendWindowLen := func(packetLength protocol.ByteCount) int {
|
||||
|
@ -60,9 +60,9 @@ var _ = Describe("Cubic Sender", func() {
|
|||
sender.MaybeExitSlowStart()
|
||||
for i := 0; i < n; i++ {
|
||||
ackedPacketNumber++
|
||||
sender.OnPacketAcked(ackedPacketNumber, defaultTCPMSS, bytesInFlight, clock.Now())
|
||||
sender.OnPacketAcked(ackedPacketNumber, maxDatagramSize, bytesInFlight, clock.Now())
|
||||
}
|
||||
bytesInFlight -= protocol.ByteCount(n) * defaultTCPMSS
|
||||
bytesInFlight -= protocol.ByteCount(n) * maxDatagramSize
|
||||
clock.Advance(time.Millisecond)
|
||||
}
|
||||
|
||||
|
@ -76,12 +76,12 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
// Does not increment acked_packet_number_.
|
||||
LosePacket := func(number protocol.PacketNumber) {
|
||||
sender.OnPacketLost(number, defaultTCPMSS, bytesInFlight)
|
||||
bytesInFlight -= defaultTCPMSS
|
||||
sender.OnPacketLost(number, maxDatagramSize, bytesInFlight)
|
||||
bytesInFlight -= maxDatagramSize
|
||||
}
|
||||
|
||||
SendAvailableSendWindow := func() int { return SendAvailableSendWindowLen(defaultTCPMSS) }
|
||||
LoseNPackets := func(n int) { LoseNPacketsLen(n, defaultTCPMSS) }
|
||||
SendAvailableSendWindow := func() int { return SendAvailableSendWindowLen(maxDatagramSize) }
|
||||
LoseNPackets := func(n int) { LoseNPacketsLen(n, maxDatagramSize) }
|
||||
|
||||
It("has the right values at startup", func() {
|
||||
// At startup make sure we are at the default.
|
||||
|
@ -121,7 +121,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
bytesToSend := sender.GetCongestionWindow()
|
||||
// It's expected 2 acks will arrive when the bytes_in_flight are greater than
|
||||
// half the CWND.
|
||||
Expect(bytesToSend).To(Equal(defaultWindowTCP + defaultTCPMSS*2*2))
|
||||
Expect(bytesToSend).To(Equal(defaultWindowTCP + maxDatagramSize*2*2))
|
||||
})
|
||||
|
||||
It("exponential slow start", func() {
|
||||
|
@ -139,7 +139,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
cwnd := sender.GetCongestionWindow()
|
||||
Expect(cwnd).To(Equal(defaultWindowTCP + defaultTCPMSS*2*numberOfAcks))
|
||||
Expect(cwnd).To(Equal(defaultWindowTCP + maxDatagramSize*2*numberOfAcks))
|
||||
Expect(sender.BandwidthEstimate()).To(Equal(BandwidthFromDelta(cwnd, rttStats.SmoothedRTT())))
|
||||
})
|
||||
|
||||
|
@ -152,12 +152,12 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Lose a packet to exit slow start.
|
||||
LoseNPackets(1)
|
||||
packetsInRecoveryWindow := expectedSendWindow / defaultTCPMSS
|
||||
packetsInRecoveryWindow := expectedSendWindow / maxDatagramSize
|
||||
|
||||
// We should now have fallen out of slow start with a reduced window.
|
||||
expectedSendWindow = protocol.ByteCount(float32(expectedSendWindow) * renoBeta)
|
||||
|
@ -165,7 +165,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
// Recovery phase. We need to ack every packet in the recovery window before
|
||||
// we exit recovery.
|
||||
numberOfPacketsInWindow := expectedSendWindow / defaultTCPMSS
|
||||
numberOfPacketsInWindow := expectedSendWindow / maxDatagramSize
|
||||
AckNPackets(int(packetsInRecoveryWindow))
|
||||
SendAvailableSendWindow()
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
@ -177,7 +177,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
// Next ack should increase cwnd by 1.
|
||||
AckNPackets(1)
|
||||
expectedSendWindow += defaultTCPMSS
|
||||
expectedSendWindow += maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Now RTO and ensure slow start gets reset.
|
||||
|
@ -197,26 +197,26 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Lose a packet to exit slow start. We should now have fallen out of
|
||||
// slow start with a window reduced by 1.
|
||||
LoseNPackets(1)
|
||||
expectedSendWindow -= defaultTCPMSS
|
||||
expectedSendWindow -= maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Lose 5 packets in recovery and verify that congestion window is reduced
|
||||
// further.
|
||||
LoseNPackets(5)
|
||||
expectedSendWindow -= 5 * defaultTCPMSS
|
||||
expectedSendWindow -= 5 * maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
packetsInRecoveryWindow := expectedSendWindow / defaultTCPMSS
|
||||
packetsInRecoveryWindow := expectedSendWindow / maxDatagramSize
|
||||
|
||||
// Recovery phase. We need to ack every packet in the recovery window before
|
||||
// we exit recovery.
|
||||
numberOfPacketsInWindow := expectedSendWindow / defaultTCPMSS
|
||||
numberOfPacketsInWindow := expectedSendWindow / maxDatagramSize
|
||||
AckNPackets(int(packetsInRecoveryWindow))
|
||||
SendAvailableSendWindow()
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
@ -228,7 +228,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
// Next ack should increase cwnd by 1.
|
||||
AckNPackets(1)
|
||||
expectedSendWindow += defaultTCPMSS
|
||||
expectedSendWindow += maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Now RTO and ensure slow start gets reset.
|
||||
|
@ -244,23 +244,23 @@ var _ = Describe("Cubic Sender", func() {
|
|||
const numberOfAcks = 10
|
||||
for i := 0; i < numberOfAcks; i++ {
|
||||
// Send our full send window in half sized packets.
|
||||
SendAvailableSendWindowLen(defaultTCPMSS / 2)
|
||||
SendAvailableSendWindowLen(maxDatagramSize / 2)
|
||||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindowLen(defaultTCPMSS / 2)
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
SendAvailableSendWindowLen(maxDatagramSize / 2)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Lose a packet to exit slow start. We should now have fallen out of
|
||||
// slow start with a window reduced by 1.
|
||||
LoseNPackets(1)
|
||||
expectedSendWindow -= defaultTCPMSS
|
||||
expectedSendWindow -= maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Lose 10 packets in recovery and verify that congestion window is reduced
|
||||
// by 5 packets.
|
||||
LoseNPacketsLen(10, defaultTCPMSS/2)
|
||||
expectedSendWindow -= 5 * defaultTCPMSS
|
||||
LoseNPacketsLen(10, maxDatagramSize/2)
|
||||
expectedSendWindow -= 5 * maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
})
|
||||
|
||||
|
@ -287,7 +287,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
LoseNPackets(1)
|
||||
|
@ -302,7 +302,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
// outstanding packets. The number of packets before we exit recovery is the
|
||||
// original CWND minus the packet that has been lost and the one which
|
||||
// triggered the loss.
|
||||
remainingPacketsInRecovery := sendWindowBeforeLoss/defaultTCPMSS - 2
|
||||
remainingPacketsInRecovery := sendWindowBeforeLoss/maxDatagramSize - 2
|
||||
|
||||
for i := protocol.ByteCount(0); i < remainingPacketsInRecovery; i++ {
|
||||
AckNPackets(1)
|
||||
|
@ -311,7 +311,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
}
|
||||
|
||||
// We need to ack another window before we increase CWND by 1.
|
||||
numberOfPacketsInWindow := expectedSendWindow / defaultTCPMSS
|
||||
numberOfPacketsInWindow := expectedSendWindow / maxDatagramSize
|
||||
for i := protocol.ByteCount(0); i < numberOfPacketsInWindow; i++ {
|
||||
AckNPackets(1)
|
||||
Expect(SendAvailableSendWindow()).To(Equal(1))
|
||||
|
@ -319,7 +319,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
}
|
||||
|
||||
AckNPackets(1)
|
||||
expectedSendWindow += defaultTCPMSS
|
||||
expectedSendWindow += maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
})
|
||||
|
||||
|
@ -336,13 +336,13 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Lose one more than the congestion window reduction, so that after loss,
|
||||
// bytes_in_flight is lesser than the congestion window.
|
||||
sendWindowAfterLoss := protocol.ByteCount(renoBeta * float32(expectedSendWindow))
|
||||
numPacketsToLose := (expectedSendWindow-sendWindowAfterLoss)/defaultTCPMSS + 1
|
||||
numPacketsToLose := (expectedSendWindow-sendWindowAfterLoss)/maxDatagramSize + 1
|
||||
LoseNPackets(int(numPacketsToLose))
|
||||
// Immediately after the loss, ensure at least one packet can be sent.
|
||||
// Losses without subsequent acks can occur with timer based loss detection.
|
||||
|
@ -384,8 +384,8 @@ 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(2 * defaultTCPMSS))
|
||||
Expect(sender.SlowstartThreshold()).To(Equal(5 * defaultTCPMSS))
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(2 * maxDatagramSize))
|
||||
Expect(sender.SlowstartThreshold()).To(Equal(5 * maxDatagramSize))
|
||||
})
|
||||
|
||||
It("RTO congestion window no retransmission", func() {
|
||||
|
@ -399,8 +399,8 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
It("tcp cubic reset epoch on quiescence", func() {
|
||||
const maxCongestionWindow = 50
|
||||
const maxCongestionWindowBytes = maxCongestionWindow * defaultTCPMSS
|
||||
sender = newCubicSender(&clock, rttStats, false, initialCongestionWindowPackets*defaultTCPMSS, maxCongestionWindowBytes)
|
||||
const maxCongestionWindowBytes = maxCongestionWindow * maxDatagramSize
|
||||
sender = newCubicSender(&clock, rttStats, false, initialCongestionWindowPackets*maxDatagramSize, maxCongestionWindowBytes)
|
||||
|
||||
numSent := SendAvailableSendWindow()
|
||||
|
||||
|
@ -433,7 +433,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
savedCwnd = sender.GetCongestionWindow()
|
||||
SendAvailableSendWindow()
|
||||
AckNPackets(1)
|
||||
Expect(savedCwnd).To(BeNumerically("~", sender.GetCongestionWindow(), defaultTCPMSS))
|
||||
Expect(savedCwnd).To(BeNumerically("~", sender.GetCongestionWindow(), maxDatagramSize))
|
||||
Expect(maxCongestionWindowBytes).To(BeNumerically(">", sender.GetCongestionWindow()))
|
||||
})
|
||||
|
||||
|
@ -463,7 +463,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
LoseNPackets(1)
|
||||
|
@ -484,7 +484,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
Expect(sender.InRecovery()).To(BeFalse())
|
||||
|
||||
// Out of recovery now. Congestion window should not grow for half an RTT.
|
||||
packetsInSendWindow := expectedSendWindow / defaultTCPMSS
|
||||
packetsInSendWindow := expectedSendWindow / maxDatagramSize
|
||||
SendAvailableSendWindow()
|
||||
AckNPackets(int(packetsInSendWindow/2 - 2))
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
@ -492,7 +492,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
// Next ack should increase congestion window by 1MSS.
|
||||
SendAvailableSendWindow()
|
||||
AckNPackets(2)
|
||||
expectedSendWindow += defaultTCPMSS
|
||||
expectedSendWindow += maxDatagramSize
|
||||
packetsInSendWindow++
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
|
@ -504,7 +504,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
// Next ack should cause congestion window to grow by 1MSS.
|
||||
SendAvailableSendWindow()
|
||||
AckNPackets(2)
|
||||
expectedSendWindow += defaultTCPMSS
|
||||
expectedSendWindow += maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
})
|
||||
|
||||
|
@ -518,7 +518,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
LoseNPackets(1)
|
||||
|
@ -539,7 +539,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
Expect(sender.InRecovery()).To(BeFalse())
|
||||
|
||||
// Out of recovery now. Congestion window should not grow during RTT.
|
||||
for i := protocol.ByteCount(0); i < expectedSendWindow/defaultTCPMSS-2; i += 2 {
|
||||
for i := protocol.ByteCount(0); i < expectedSendWindow/maxDatagramSize-2; i += 2 {
|
||||
// Send our full send window.
|
||||
SendAvailableSendWindow()
|
||||
AckNPackets(2)
|
||||
|
@ -549,7 +549,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
// Next ack should cause congestion window to grow by 1MSS.
|
||||
SendAvailableSendWindow()
|
||||
AckNPackets(2)
|
||||
expectedSendWindow += defaultTCPMSS
|
||||
expectedSendWindow += maxDatagramSize
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
})
|
||||
|
||||
|
@ -562,7 +562,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(1)
|
||||
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(protocol.ByteCount(renoBeta * float32(defaultWindowTCP))))
|
||||
windowInPackets := renoBeta * float32(defaultWindowTCP) / float32(defaultTCPMSS)
|
||||
windowInPackets := renoBeta * float32(defaultWindowTCP) / float32(maxDatagramSize)
|
||||
numSent := SendAvailableSendWindow()
|
||||
Expect(numSent).To(BeEquivalentTo(windowInPackets))
|
||||
})
|
||||
|
@ -580,7 +580,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
AckNPackets(2)
|
||||
}
|
||||
SendAvailableSendWindow()
|
||||
expectedSendWindow := defaultWindowTCP + (defaultTCPMSS * 2 * numberOfAcks)
|
||||
expectedSendWindow := defaultWindowTCP + (maxDatagramSize * 2 * numberOfAcks)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(expectedSendWindow))
|
||||
|
||||
// Loses a packet to exit slow start.
|
||||
|
@ -600,9 +600,9 @@ var _ = Describe("Cubic Sender", func() {
|
|||
})
|
||||
|
||||
It("default max cwnd", func() {
|
||||
sender = newCubicSender(&clock, rttStats, true /*reno*/, initialCongestionWindowPackets*defaultTCPMSS, maxCongestionWindow)
|
||||
sender = newCubicSender(&clock, rttStats, true /*reno*/, initialCongestionWindowPackets*maxDatagramSize, maxCongestionWindow)
|
||||
|
||||
defaultMaxCongestionWindowPackets := maxCongestionWindow / defaultTCPMSS
|
||||
defaultMaxCongestionWindowPackets := maxCongestionWindow / maxDatagramSize
|
||||
for i := 1; i < int(defaultMaxCongestionWindowPackets); i++ {
|
||||
sender.MaybeExitSlowStart()
|
||||
sender.OnPacketAcked(protocol.PacketNumber(i), 1350, sender.GetCongestionWindow(), clock.Now())
|
||||
|
@ -612,7 +612,7 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
It("limit cwnd increase in congestion avoidance", func() {
|
||||
// Enable Cubic.
|
||||
sender = newCubicSender(&clock, rttStats, false, initialCongestionWindowPackets*defaultTCPMSS, MaxCongestionWindow)
|
||||
sender = newCubicSender(&clock, rttStats, false, initialCongestionWindowPackets*maxDatagramSize, MaxCongestionWindow)
|
||||
numSent := SendAvailableSendWindow()
|
||||
|
||||
// Make sure we fall out of slow start.
|
||||
|
@ -644,6 +644,6 @@ var _ = Describe("Cubic Sender", func() {
|
|||
|
||||
// Ack two packets. The CWND should increase by only one packet.
|
||||
AckNPackets(2)
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(savedCwnd + defaultTCPMSS))
|
||||
Expect(sender.GetCongestionWindow()).To(Equal(savedCwnd + maxDatagramSize))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue