mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
ackhandler: rename variables to follow RFC 9002 terminology (#4062)
This commit is contained in:
parent
6cde43785f
commit
96b1943cf5
4 changed files with 35 additions and 35 deletions
|
@ -44,7 +44,7 @@ type sentPacketTracker interface {
|
||||||
// ReceivedPacketHandler handles ACKs needed to send for incoming packets
|
// ReceivedPacketHandler handles ACKs needed to send for incoming packets
|
||||||
type ReceivedPacketHandler interface {
|
type ReceivedPacketHandler interface {
|
||||||
IsPotentiallyDuplicate(protocol.PacketNumber, protocol.EncryptionLevel) bool
|
IsPotentiallyDuplicate(protocol.PacketNumber, protocol.EncryptionLevel) bool
|
||||||
ReceivedPacket(pn protocol.PacketNumber, ecn protocol.ECN, encLevel protocol.EncryptionLevel, rcvTime time.Time, shouldInstigateAck bool) error
|
ReceivedPacket(pn protocol.PacketNumber, ecn protocol.ECN, encLevel protocol.EncryptionLevel, rcvTime time.Time, ackEliciting bool) error
|
||||||
DropPackets(protocol.EncryptionLevel)
|
DropPackets(protocol.EncryptionLevel)
|
||||||
|
|
||||||
GetAlarmTimeout() time.Time
|
GetAlarmTimeout() time.Time
|
||||||
|
|
|
@ -40,29 +40,29 @@ func (h *receivedPacketHandler) ReceivedPacket(
|
||||||
ecn protocol.ECN,
|
ecn protocol.ECN,
|
||||||
encLevel protocol.EncryptionLevel,
|
encLevel protocol.EncryptionLevel,
|
||||||
rcvTime time.Time,
|
rcvTime time.Time,
|
||||||
shouldInstigateAck bool,
|
ackEliciting bool,
|
||||||
) error {
|
) error {
|
||||||
h.sentPackets.ReceivedPacket(encLevel)
|
h.sentPackets.ReceivedPacket(encLevel)
|
||||||
switch encLevel {
|
switch encLevel {
|
||||||
case protocol.EncryptionInitial:
|
case protocol.EncryptionInitial:
|
||||||
return h.initialPackets.ReceivedPacket(pn, ecn, rcvTime, shouldInstigateAck)
|
return h.initialPackets.ReceivedPacket(pn, ecn, rcvTime, ackEliciting)
|
||||||
case protocol.EncryptionHandshake:
|
case protocol.EncryptionHandshake:
|
||||||
// The Handshake packet number space might already have been dropped as a result
|
// The Handshake packet number space might already have been dropped as a result
|
||||||
// of processing the CRYPTO frame that was contained in this packet.
|
// of processing the CRYPTO frame that was contained in this packet.
|
||||||
if h.handshakePackets == nil {
|
if h.handshakePackets == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return h.handshakePackets.ReceivedPacket(pn, ecn, rcvTime, shouldInstigateAck)
|
return h.handshakePackets.ReceivedPacket(pn, ecn, rcvTime, ackEliciting)
|
||||||
case protocol.Encryption0RTT:
|
case protocol.Encryption0RTT:
|
||||||
if h.lowest1RTTPacket != protocol.InvalidPacketNumber && pn > h.lowest1RTTPacket {
|
if h.lowest1RTTPacket != protocol.InvalidPacketNumber && pn > h.lowest1RTTPacket {
|
||||||
return fmt.Errorf("received packet number %d on a 0-RTT packet after receiving %d on a 1-RTT packet", pn, h.lowest1RTTPacket)
|
return fmt.Errorf("received packet number %d on a 0-RTT packet after receiving %d on a 1-RTT packet", pn, h.lowest1RTTPacket)
|
||||||
}
|
}
|
||||||
return h.appDataPackets.ReceivedPacket(pn, ecn, rcvTime, shouldInstigateAck)
|
return h.appDataPackets.ReceivedPacket(pn, ecn, rcvTime, ackEliciting)
|
||||||
case protocol.Encryption1RTT:
|
case protocol.Encryption1RTT:
|
||||||
if h.lowest1RTTPacket == protocol.InvalidPacketNumber || pn < h.lowest1RTTPacket {
|
if h.lowest1RTTPacket == protocol.InvalidPacketNumber || pn < h.lowest1RTTPacket {
|
||||||
h.lowest1RTTPacket = pn
|
h.lowest1RTTPacket = pn
|
||||||
}
|
}
|
||||||
if err := h.appDataPackets.ReceivedPacket(pn, ecn, rcvTime, shouldInstigateAck); err != nil {
|
if err := h.appDataPackets.ReceivedPacket(pn, ecn, rcvTime, ackEliciting); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
h.appDataPackets.IgnoreBelow(h.sentPackets.GetLowestPacketNotConfirmedAcked())
|
h.appDataPackets.IgnoreBelow(h.sentPackets.GetLowestPacketNotConfirmedAcked())
|
||||||
|
|
|
@ -13,10 +13,10 @@ import (
|
||||||
const packetsBeforeAck = 2
|
const packetsBeforeAck = 2
|
||||||
|
|
||||||
type receivedPacketTracker struct {
|
type receivedPacketTracker struct {
|
||||||
largestObserved protocol.PacketNumber
|
largestObserved protocol.PacketNumber
|
||||||
ignoreBelow protocol.PacketNumber
|
ignoreBelow protocol.PacketNumber
|
||||||
largestObservedReceivedTime time.Time
|
largestObservedRcvdTime time.Time
|
||||||
ect0, ect1, ecnce uint64
|
ect0, ect1, ecnce uint64
|
||||||
|
|
||||||
packetHistory *receivedPacketHistory
|
packetHistory *receivedPacketHistory
|
||||||
|
|
||||||
|
@ -45,22 +45,22 @@ func newReceivedPacketTracker(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *receivedPacketTracker) ReceivedPacket(packetNumber protocol.PacketNumber, ecn protocol.ECN, rcvTime time.Time, shouldInstigateAck bool) error {
|
func (h *receivedPacketTracker) ReceivedPacket(pn protocol.PacketNumber, ecn protocol.ECN, rcvTime time.Time, ackEliciting bool) error {
|
||||||
if isNew := h.packetHistory.ReceivedPacket(packetNumber); !isNew {
|
if isNew := h.packetHistory.ReceivedPacket(pn); !isNew {
|
||||||
return fmt.Errorf("recevedPacketTracker BUG: ReceivedPacket called for old / duplicate packet %d", packetNumber)
|
return fmt.Errorf("recevedPacketTracker BUG: ReceivedPacket called for old / duplicate packet %d", pn)
|
||||||
}
|
}
|
||||||
|
|
||||||
isMissing := h.isMissing(packetNumber)
|
isMissing := h.isMissing(pn)
|
||||||
if packetNumber >= h.largestObserved {
|
if pn >= h.largestObserved {
|
||||||
h.largestObserved = packetNumber
|
h.largestObserved = pn
|
||||||
h.largestObservedReceivedTime = rcvTime
|
h.largestObservedRcvdTime = rcvTime
|
||||||
}
|
}
|
||||||
|
|
||||||
if shouldInstigateAck {
|
if ackEliciting {
|
||||||
h.hasNewAck = true
|
h.hasNewAck = true
|
||||||
}
|
}
|
||||||
if shouldInstigateAck {
|
if ackEliciting {
|
||||||
h.maybeQueueAck(packetNumber, rcvTime, isMissing)
|
h.maybeQueueACK(pn, rcvTime, isMissing)
|
||||||
}
|
}
|
||||||
switch ecn {
|
switch ecn {
|
||||||
case protocol.ECNNon:
|
case protocol.ECNNon:
|
||||||
|
@ -76,14 +76,14 @@ func (h *receivedPacketTracker) ReceivedPacket(packetNumber protocol.PacketNumbe
|
||||||
|
|
||||||
// IgnoreBelow sets a lower limit for acknowledging packets.
|
// IgnoreBelow sets a lower limit for acknowledging packets.
|
||||||
// Packets with packet numbers smaller than p will not be acked.
|
// Packets with packet numbers smaller than p will not be acked.
|
||||||
func (h *receivedPacketTracker) IgnoreBelow(p protocol.PacketNumber) {
|
func (h *receivedPacketTracker) IgnoreBelow(pn protocol.PacketNumber) {
|
||||||
if p <= h.ignoreBelow {
|
if pn <= h.ignoreBelow {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
h.ignoreBelow = p
|
h.ignoreBelow = pn
|
||||||
h.packetHistory.DeleteBelow(p)
|
h.packetHistory.DeleteBelow(pn)
|
||||||
if h.logger.Debug() {
|
if h.logger.Debug() {
|
||||||
h.logger.Debugf("\tIgnoring all packets below %d.", p)
|
h.logger.Debugf("\tIgnoring all packets below %d.", pn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,8 @@ func (h *receivedPacketTracker) hasNewMissingPackets() bool {
|
||||||
return highestRange.Smallest > h.lastAck.LargestAcked()+1 && highestRange.Len() == 1
|
return highestRange.Smallest > h.lastAck.LargestAcked()+1 && highestRange.Len() == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// maybeQueueAck queues an ACK, if necessary.
|
// maybeQueueACK queues an ACK, if necessary.
|
||||||
func (h *receivedPacketTracker) maybeQueueAck(pn protocol.PacketNumber, rcvTime time.Time, wasMissing bool) {
|
func (h *receivedPacketTracker) maybeQueueACK(pn protocol.PacketNumber, rcvTime time.Time, wasMissing bool) {
|
||||||
// always acknowledge the first packet
|
// always acknowledge the first packet
|
||||||
if h.lastAck == nil {
|
if h.lastAck == nil {
|
||||||
if !h.ackQueued {
|
if !h.ackQueued {
|
||||||
|
@ -175,7 +175,7 @@ func (h *receivedPacketTracker) GetAckFrame(onlyIfQueued bool) *wire.AckFrame {
|
||||||
ack = &wire.AckFrame{}
|
ack = &wire.AckFrame{}
|
||||||
}
|
}
|
||||||
ack.Reset()
|
ack.Reset()
|
||||||
ack.DelayTime = utils.Max(0, now.Sub(h.largestObservedReceivedTime))
|
ack.DelayTime = utils.Max(0, now.Sub(h.largestObservedRcvdTime))
|
||||||
ack.ECT0 = h.ect0
|
ack.ECT0 = h.ect0
|
||||||
ack.ECT1 = h.ect1
|
ack.ECT1 = h.ect1
|
||||||
ack.ECNCE = h.ecnce
|
ack.ECNCE = h.ecnce
|
||||||
|
|
|
@ -25,26 +25,26 @@ var _ = Describe("Received Packet Tracker", func() {
|
||||||
Context("accepting packets", func() {
|
Context("accepting packets", func() {
|
||||||
It("saves the time when each packet arrived", func() {
|
It("saves the time when each packet arrived", func() {
|
||||||
Expect(tracker.ReceivedPacket(protocol.PacketNumber(3), protocol.ECNNon, time.Now(), true)).To(Succeed())
|
Expect(tracker.ReceivedPacket(protocol.PacketNumber(3), protocol.ECNNon, time.Now(), true)).To(Succeed())
|
||||||
Expect(tracker.largestObservedReceivedTime).To(BeTemporally("~", time.Now(), 10*time.Millisecond))
|
Expect(tracker.largestObservedRcvdTime).To(BeTemporally("~", time.Now(), 10*time.Millisecond))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("updates the largestObserved and the largestObservedReceivedTime", func() {
|
It("updates the largestObserved and the largestObservedRcvdTime", func() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
tracker.largestObserved = 3
|
tracker.largestObserved = 3
|
||||||
tracker.largestObservedReceivedTime = now.Add(-1 * time.Second)
|
tracker.largestObservedRcvdTime = now.Add(-1 * time.Second)
|
||||||
Expect(tracker.ReceivedPacket(5, protocol.ECNNon, now, true)).To(Succeed())
|
Expect(tracker.ReceivedPacket(5, protocol.ECNNon, now, true)).To(Succeed())
|
||||||
Expect(tracker.largestObserved).To(Equal(protocol.PacketNumber(5)))
|
Expect(tracker.largestObserved).To(Equal(protocol.PacketNumber(5)))
|
||||||
Expect(tracker.largestObservedReceivedTime).To(Equal(now))
|
Expect(tracker.largestObservedRcvdTime).To(Equal(now))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("doesn't update the largestObserved and the largestObservedReceivedTime for a belated packet", func() {
|
It("doesn't update the largestObserved and the largestObservedRcvdTime for a belated packet", func() {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
timestamp := now.Add(-1 * time.Second)
|
timestamp := now.Add(-1 * time.Second)
|
||||||
tracker.largestObserved = 5
|
tracker.largestObserved = 5
|
||||||
tracker.largestObservedReceivedTime = timestamp
|
tracker.largestObservedRcvdTime = timestamp
|
||||||
Expect(tracker.ReceivedPacket(4, protocol.ECNNon, now, true)).To(Succeed())
|
Expect(tracker.ReceivedPacket(4, protocol.ECNNon, now, true)).To(Succeed())
|
||||||
Expect(tracker.largestObserved).To(Equal(protocol.PacketNumber(5)))
|
Expect(tracker.largestObserved).To(Equal(protocol.PacketNumber(5)))
|
||||||
Expect(tracker.largestObservedReceivedTime).To(Equal(timestamp))
|
Expect(tracker.largestObservedRcvdTime).To(Equal(timestamp))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue