handle Retry packets in the session

This commit is contained in:
Marten Seemann
2019-02-02 12:44:43 +08:00
parent 7a7e7ca6eb
commit 17f4ebad64
11 changed files with 199 additions and 194 deletions

View File

@@ -578,3 +578,22 @@ func (h *sentPacketHandler) computePTOTimeout() time.Duration {
duration := utils.MaxDuration(h.rttStats.SmoothedOrInitialRTT()+4*h.rttStats.MeanDeviation(), granularity)
return duration << h.ptoCount
}
func (h *sentPacketHandler) ResetForRetry() error {
h.cryptoCount = 0
h.bytesInFlight = 0
var packets []*Packet
h.packetHistory.Iterate(func(p *Packet) (bool, error) {
if p.canBeRetransmitted {
packets = append(packets, p)
}
return true, nil
})
for _, p := range packets {
h.logger.Debugf("Queueing packet %#x for retransmission.", p.PacketNumber)
h.retransmissionQueue = append(h.retransmissionQueue, p)
}
h.packetHistory = newSentPacketHistory()
h.updateLossDetectionAlarm()
return nil
}