forked from quic-go/quic-go
Merge pull request #2449 from lucas-clemente/qlog-loss-timer
implement the qlog loss timer events
This commit is contained in:
@@ -433,16 +433,23 @@ func (h *sentPacketHandler) hasOutstandingPackets() bool {
|
||||
}
|
||||
|
||||
func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||
if lossTime, _ := h.getEarliestLossTimeAndSpace(); !lossTime.IsZero() {
|
||||
oldAlarm := h.alarm // only needed in case qlog is enabled
|
||||
if lossTime, encLevel := h.getEarliestLossTimeAndSpace(); !lossTime.IsZero() {
|
||||
// Early retransmit timer or time loss detection.
|
||||
h.alarm = lossTime
|
||||
if h.qlogger != nil && h.alarm != oldAlarm {
|
||||
h.qlogger.SetLossTimer(qlog.TimerTypeACK, encLevel, h.alarm)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Cancel the alarm if no packets are outstanding
|
||||
if !h.hasOutstandingPackets() && h.peerCompletedAddressValidation {
|
||||
h.logger.Debugf("Canceling loss detection timer. No packets in flight.")
|
||||
h.alarm = time.Time{}
|
||||
h.logger.Debugf("Canceling loss detection timer. No packets in flight.")
|
||||
if h.qlogger != nil && !oldAlarm.IsZero() {
|
||||
h.qlogger.LossTimerCanceled()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -455,6 +462,9 @@ func (h *sentPacketHandler) setLossDetectionTimer() {
|
||||
sentTime = time.Now()
|
||||
}
|
||||
h.alarm = sentTime.Add(h.rttStats.PTO(encLevel == protocol.Encryption1RTT) << h.ptoCount)
|
||||
if h.qlogger != nil && h.alarm != oldAlarm {
|
||||
h.qlogger.SetLossTimer(qlog.TimerTypePTO, encLevel, h.alarm)
|
||||
}
|
||||
}
|
||||
|
||||
func (h *sentPacketHandler) detectAndRemoveLostPackets(now time.Time, encLevel protocol.EncryptionLevel) ([]*Packet, error) {
|
||||
@@ -551,6 +561,9 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error {
|
||||
if h.logger.Debug() {
|
||||
h.logger.Debugf("Loss detection alarm fired in loss timer mode. Loss time: %s", earliestLossTime)
|
||||
}
|
||||
if h.qlogger != nil {
|
||||
h.qlogger.LossTimerExpired(qlog.TimerTypeACK, encLevel)
|
||||
}
|
||||
// Early retransmit or time loss detection
|
||||
priorInFlight := h.bytesInFlight
|
||||
lostPackets, err := h.detectAndRemoveLostPackets(time.Now(), encLevel)
|
||||
@@ -569,6 +582,7 @@ func (h *sentPacketHandler) onVerifiedLossDetectionTimeout() error {
|
||||
}
|
||||
h.ptoCount++
|
||||
if h.qlogger != nil {
|
||||
h.qlogger.LossTimerExpired(qlog.TimerTypePTO, encLevel)
|
||||
h.qlogger.UpdatedPTOCount(h.ptoCount)
|
||||
}
|
||||
h.numProbesToSend += 2
|
||||
@@ -701,7 +715,11 @@ func (h *sentPacketHandler) ResetForRetry() error {
|
||||
|
||||
h.initialPackets = newPacketNumberSpace(h.initialPackets.pns.Pop())
|
||||
h.appDataPackets = newPacketNumberSpace(h.appDataPackets.pns.Pop())
|
||||
oldAlarm := h.alarm
|
||||
h.alarm = time.Time{}
|
||||
if h.qlogger != nil && !oldAlarm.IsZero() {
|
||||
h.qlogger.LossTimerCanceled()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user