mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 13:17:36 +03:00
ignore the delay field for ACKs sent in Initial and Handshake packets
This commit is contained in:
parent
6c27967c8a
commit
f981339bc0
2 changed files with 21 additions and 3 deletions
|
@ -205,7 +205,12 @@ func (h *sentPacketHandler) ReceivedAck(ackFrame *wire.AckFrame, withPacketNumbe
|
||||||
|
|
||||||
// maybe update the RTT
|
// maybe update the RTT
|
||||||
if p := pnSpace.history.GetPacket(ackFrame.LargestAcked()); p != nil {
|
if p := pnSpace.history.GetPacket(ackFrame.LargestAcked()); p != nil {
|
||||||
h.rttStats.UpdateRTT(rcvTime.Sub(p.SendTime), ackFrame.DelayTime, rcvTime)
|
// don't use the ack delay for Initial and Handshake packets
|
||||||
|
var ackDelay time.Duration
|
||||||
|
if encLevel == protocol.Encryption1RTT {
|
||||||
|
ackDelay = ackFrame.DelayTime
|
||||||
|
}
|
||||||
|
h.rttStats.UpdateRTT(rcvTime.Sub(p.SendTime), ackDelay, rcvTime)
|
||||||
if h.logger.Debug() {
|
if h.logger.Debug() {
|
||||||
h.logger.Debugf("\tupdated RTT: %s (σ: %s)", h.rttStats.SmoothedRTT(), h.rttStats.MeanDeviation())
|
h.logger.Debugf("\tupdated RTT: %s (σ: %s)", h.rttStats.SmoothedRTT(), h.rttStats.MeanDeviation())
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,6 +292,20 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 1*time.Minute, 1*time.Second))
|
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 1*time.Minute, 1*time.Second))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("ignores the DelayTime for Initial and Handshake packets", func() {
|
||||||
|
handler.SentPacket(cryptoPacket(&Packet{PacketNumber: 1}))
|
||||||
|
now := time.Now()
|
||||||
|
// make sure the rttStats have a min RTT, so that the delay is used
|
||||||
|
handler.rttStats.UpdateRTT(5*time.Minute, 0, time.Now())
|
||||||
|
getPacket(1, protocol.EncryptionInitial).SendTime = now.Add(-10 * time.Minute)
|
||||||
|
ack := &wire.AckFrame{
|
||||||
|
AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}},
|
||||||
|
DelayTime: 5 * time.Minute,
|
||||||
|
}
|
||||||
|
Expect(handler.ReceivedAck(ack, 1, protocol.EncryptionInitial, time.Now())).To(Succeed())
|
||||||
|
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 10*time.Minute, 1*time.Second))
|
||||||
|
})
|
||||||
|
|
||||||
It("uses the DelayTime in the ACK frame", func() {
|
It("uses the DelayTime in the ACK frame", func() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
// make sure the rttStats have a min RTT, so that the delay is used
|
// make sure the rttStats have a min RTT, so that the delay is used
|
||||||
|
@ -301,8 +315,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}},
|
AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}},
|
||||||
DelayTime: 5 * time.Minute,
|
DelayTime: 5 * time.Minute,
|
||||||
}
|
}
|
||||||
err := handler.ReceivedAck(ack, 1, protocol.Encryption1RTT, time.Now())
|
Expect(handler.ReceivedAck(ack, 1, protocol.Encryption1RTT, time.Now())).To(Succeed())
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 5*time.Minute, 1*time.Second))
|
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 5*time.Minute, 1*time.Second))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue