mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-07 06:07:36 +03:00
reset the loss detection timer when the client's address is validated
This commit is contained in:
parent
a695bae019
commit
b6634fe124
2 changed files with 30 additions and 9 deletions
|
@ -201,9 +201,10 @@ func (h *sentPacketHandler) ReceivedBytes(n protocol.ByteCount) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *sentPacketHandler) ReceivedPacket(encLevel protocol.EncryptionLevel) {
|
func (h *sentPacketHandler) ReceivedPacket(l protocol.EncryptionLevel) {
|
||||||
if h.perspective == protocol.PerspectiveServer && encLevel == protocol.EncryptionHandshake {
|
if h.perspective == protocol.PerspectiveServer && l == protocol.EncryptionHandshake && !h.peerAddressValidated {
|
||||||
h.peerAddressValidated = true
|
h.peerAddressValidated = true
|
||||||
|
h.setLossDetectionTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,7 +486,8 @@ func (h *sentPacketHandler) hasOutstandingPackets() bool {
|
||||||
|
|
||||||
func (h *sentPacketHandler) setLossDetectionTimer() {
|
func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||||
oldAlarm := h.alarm // only needed in case tracing is enabled
|
oldAlarm := h.alarm // only needed in case tracing is enabled
|
||||||
if lossTime, encLevel := h.getLossTimeAndSpace(); !lossTime.IsZero() {
|
lossTime, encLevel := h.getLossTimeAndSpace()
|
||||||
|
if !lossTime.IsZero() {
|
||||||
// Early retransmit timer or time loss detection.
|
// Early retransmit timer or time loss detection.
|
||||||
h.alarm = lossTime
|
h.alarm = lossTime
|
||||||
if h.tracer != nil && h.alarm != oldAlarm {
|
if h.tracer != nil && h.alarm != oldAlarm {
|
||||||
|
@ -497,9 +499,11 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||||
// Cancel the alarm if amplification limited.
|
// Cancel the alarm if amplification limited.
|
||||||
if h.isAmplificationLimited() {
|
if h.isAmplificationLimited() {
|
||||||
h.alarm = time.Time{}
|
h.alarm = time.Time{}
|
||||||
h.logger.Debugf("Canceling loss detection timer. Amplification limited.")
|
if !oldAlarm.IsZero() {
|
||||||
if h.tracer != nil && !oldAlarm.IsZero() {
|
h.logger.Debugf("Canceling loss detection timer. Amplification limited.")
|
||||||
h.tracer.LossTimerCanceled()
|
if h.tracer != nil {
|
||||||
|
h.tracer.LossTimerCanceled()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -507,9 +511,11 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||||
// Cancel the alarm if no packets are outstanding
|
// Cancel the alarm if no packets are outstanding
|
||||||
if !h.hasOutstandingPackets() && h.peerCompletedAddressValidation {
|
if !h.hasOutstandingPackets() && h.peerCompletedAddressValidation {
|
||||||
h.alarm = time.Time{}
|
h.alarm = time.Time{}
|
||||||
h.logger.Debugf("Canceling loss detection timer. No packets in flight.")
|
if !oldAlarm.IsZero() {
|
||||||
if h.tracer != nil && !oldAlarm.IsZero() {
|
h.logger.Debugf("Canceling loss detection timer. No packets in flight.")
|
||||||
h.tracer.LossTimerCanceled()
|
if h.tracer != nil {
|
||||||
|
h.tracer.LossTimerCanceled()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -843,6 +843,21 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.ReceivedBytes(1)
|
handler.ReceivedBytes(1)
|
||||||
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
|
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("resets the loss detection timer when the client's address is validated", func() {
|
||||||
|
handler.ReceivedBytes(300)
|
||||||
|
handler.SentPacket(&Packet{
|
||||||
|
PacketNumber: 1,
|
||||||
|
Length: 900,
|
||||||
|
EncryptionLevel: protocol.EncryptionHandshake,
|
||||||
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
|
SendTime: time.Now(),
|
||||||
|
})
|
||||||
|
// Amplification limited. We don't need to set a timer now.
|
||||||
|
Expect(handler.GetLossDetectionTimeout()).To(BeZero())
|
||||||
|
handler.ReceivedPacket(protocol.EncryptionHandshake)
|
||||||
|
Expect(handler.GetLossDetectionTimeout()).ToNot(BeZero())
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Context("amplification limit, for the client", func() {
|
Context("amplification limit, for the client", func() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue