use the receipt of a Retry packet to get a first RTT estimate

This commit is contained in:
Marten Seemann 2019-11-03 13:37:04 +07:00
parent 05514ab375
commit 6299ef3ab1
2 changed files with 48 additions and 0 deletions

View file

@ -1149,5 +1149,37 @@ var _ = Describe("SentPacketHandler", func() {
// make sure we keep increasing the packet number for 0-RTT packets
Expect(handler.PopPacketNumber(protocol.Encryption0RTT)).To(BeNumerically(">", pn))
})
It("uses a Retry for an RTT estimate, if it was not retransmitted", func() {
handler.SentPacket(ackElicitingPacket(&Packet{
PacketNumber: 42,
EncryptionLevel: protocol.EncryptionInitial,
SendTime: time.Now().Add(-500 * time.Millisecond),
}))
handler.SentPacket(ackElicitingPacket(&Packet{
PacketNumber: 43,
EncryptionLevel: protocol.EncryptionInitial,
SendTime: time.Now().Add(-10 * time.Millisecond),
}))
Expect(handler.ResetForRetry()).To(Succeed())
Expect(handler.rttStats.SmoothedRTT()).To(BeNumerically("~", 500*time.Millisecond, 100*time.Millisecond))
})
It("doesn't use a Retry for an RTT estimate, if it was not retransmitted", func() {
handler.SentPacket(ackElicitingPacket(&Packet{
PacketNumber: 42,
EncryptionLevel: protocol.EncryptionInitial,
SendTime: time.Now().Add(-800 * time.Millisecond),
}))
Expect(handler.OnLossDetectionTimeout()).To(Succeed())
Expect(handler.SendMode()).To(Equal(SendPTOInitial))
handler.SentPacket(ackElicitingPacket(&Packet{
PacketNumber: 43,
EncryptionLevel: protocol.EncryptionInitial,
SendTime: time.Now().Add(-100 * time.Millisecond),
}))
Expect(handler.ResetForRetry()).To(Succeed())
Expect(handler.rttStats.SmoothedRTT()).To(BeZero())
})
})
})