only allow sending of retransmissions if these are RTO probe packets

This commit is contained in:
Marten Seemann
2018-03-16 18:36:37 +00:00
parent bffa2cd621
commit f052861775
6 changed files with 117 additions and 5 deletions

View File

@@ -668,14 +668,21 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.SendMode()).To(Equal(SendAck))
})
It("doesn't allow retransmission if congestion limited", func() {
handler.bytesInFlight = 100
handler.retransmissionQueue = []*Packet{{PacketNumber: 3}}
cong.EXPECT().GetCongestionWindow().Return(protocol.ByteCount(50))
Expect(handler.SendMode()).To(Equal(SendAck))
})
It("allows sending retransmissions", func() {
// note that we don't EXPECT a call to GetCongestionWindow
// that means retransmissions are sent without considering the congestion window
cong.EXPECT().GetCongestionWindow().Return(protocol.MaxByteCount)
handler.retransmissionQueue = []*Packet{{PacketNumber: 3}}
Expect(handler.SendMode()).To(Equal(SendRetransmission))
})
It("allow retransmissions, if we're keeping track of between MaxOutstandingSentPackets and MaxTrackedSentPackets packets", func() {
cong.EXPECT().GetCongestionWindow().Return(protocol.MaxByteCount)
Expect(protocol.MaxOutstandingSentPackets).To(BeNumerically("<", protocol.MaxTrackedSentPackets))
handler.retransmissionQueue = make([]*Packet, protocol.MaxOutstandingSentPackets+10)
Expect(handler.SendMode()).To(Equal(SendRetransmission))
@@ -683,6 +690,14 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.SendMode()).To(Equal(SendNone))
})
It("allows RTOs, even when congestion limited", func() {
// note that we don't EXPECT a call to GetCongestionWindow
// that means retransmissions are sent without considering the congestion window
handler.numRTOs = 1
handler.retransmissionQueue = []*Packet{{PacketNumber: 3}}
Expect(handler.SendMode()).To(Equal(SendRTO))
})
It("gets the pacing delay", func() {
sendTime := time.Now().Add(-time.Minute)
handler.bytesInFlight = 100
@@ -692,6 +707,11 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.TimeUntilSend()).To(Equal(sendTime.Add(time.Hour)))
})
It("allows sending of all RTO probe packets", func() {
handler.numRTOs = 5
Expect(handler.ShouldSendNumPackets()).To(Equal(5))
})
It("allows sending of one packet, if it should be sent immediately", func() {
cong.EXPECT().TimeUntilSend(gomock.Any()).Return(time.Duration(0))
Expect(handler.ShouldSendNumPackets()).To(Equal(1))
@@ -786,6 +806,16 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.retransmissionQueue).To(BeEmpty()) // 1 and 2 were already sent as probe packets
})
It("allows sending of two probe packets", func() {
handler.SentPacket(retransmittablePacket(&Packet{PacketNumber: 1, SendTime: time.Now().Add(-time.Hour)}))
handler.OnAlarm()
Expect(handler.SendMode()).To(Equal(SendRTO))
handler.SentPacket(retransmittablePacket(&Packet{PacketNumber: 2}))
Expect(handler.SendMode()).To(Equal(SendRTO))
handler.SentPacket(retransmittablePacket(&Packet{PacketNumber: 3}))
Expect(handler.SendMode()).ToNot(Equal(SendRTO))
})
It("queues packets sent before the probe packet for retransmission", func() {
handler.SentPacket(retransmittablePacket(&Packet{PacketNumber: 1, SendTime: time.Now().Add(-time.Hour)}))
handler.SentPacket(retransmittablePacket(&Packet{PacketNumber: 2, SendTime: time.Now().Add(-time.Hour)}))