forked from quic-go/quic-go
Merge pull request #2083 from lucas-clemente/simplify-largest-acked-tracking
simplify ackhandler.Packet
This commit is contained in:
@@ -10,15 +10,12 @@ import (
|
||||
// A Packet is a packet
|
||||
type Packet struct {
|
||||
PacketNumber protocol.PacketNumber
|
||||
PacketType protocol.PacketType
|
||||
Ack *wire.AckFrame
|
||||
Frames []wire.Frame
|
||||
LargestAcked protocol.PacketNumber // InvalidPacketNumber if the packet doesn't contain an ACK
|
||||
Length protocol.ByteCount
|
||||
EncryptionLevel protocol.EncryptionLevel
|
||||
SendTime time.Time
|
||||
|
||||
largestAcked protocol.PacketNumber // if the packet contains an ACK, the LargestAcked value of that ACK
|
||||
|
||||
// There are two reasons why a packet cannot be retransmitted:
|
||||
// * it was already retransmitted
|
||||
// * this packet is a retransmission, and we already received an ACK for the original packet
|
||||
|
||||
@@ -172,13 +172,6 @@ func (h *sentPacketHandler) sentPacketImpl(packet *Packet) bool /* is ack-elicit
|
||||
}
|
||||
|
||||
pnSpace.largestSent = packet.PacketNumber
|
||||
|
||||
packet.largestAcked = protocol.InvalidPacketNumber
|
||||
if packet.Ack != nil {
|
||||
packet.largestAcked = packet.Ack.LargestAcked()
|
||||
}
|
||||
packet.Ack = nil // no need to save the ACK
|
||||
|
||||
isAckEliciting := len(packet.Frames) > 0
|
||||
|
||||
if isAckEliciting {
|
||||
@@ -237,8 +230,8 @@ func (h *sentPacketHandler) ReceivedAck(ackFrame *wire.AckFrame, withPacketNumbe
|
||||
|
||||
priorInFlight := h.bytesInFlight
|
||||
for _, p := range ackedPackets {
|
||||
if p.largestAcked != protocol.InvalidPacketNumber && encLevel == protocol.Encryption1RTT {
|
||||
h.lowestNotConfirmedAcked = utils.MaxPacketNumber(h.lowestNotConfirmedAcked, p.largestAcked+1)
|
||||
if p.LargestAcked != protocol.InvalidPacketNumber && encLevel == protocol.Encryption1RTT {
|
||||
h.lowestNotConfirmedAcked = utils.MaxPacketNumber(h.lowestNotConfirmedAcked, p.LargestAcked+1)
|
||||
}
|
||||
if err := h.onPacketAcked(p, rcvTime); err != nil {
|
||||
return err
|
||||
|
||||
@@ -31,7 +31,7 @@ func ackElicitingPacket(p *Packet) *Packet {
|
||||
func nonAckElicitingPacket(p *Packet) *Packet {
|
||||
p = ackElicitingPacket(p)
|
||||
p.Frames = nil
|
||||
p.Ack = &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}}
|
||||
p.LargestAcked = 1
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -332,11 +332,9 @@ var _ = Describe("SentPacketHandler", func() {
|
||||
|
||||
Context("determining which ACKs we have received an ACK for", func() {
|
||||
BeforeEach(func() {
|
||||
ack1 := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 80, Largest: 100}}}
|
||||
ack2 := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 50, Largest: 200}}}
|
||||
morePackets := []*Packet{
|
||||
{PacketNumber: 13, Ack: ack1, Frames: []wire.Frame{&streamFrame}, Length: 1, EncryptionLevel: protocol.Encryption1RTT},
|
||||
{PacketNumber: 14, Ack: ack2, Frames: []wire.Frame{&streamFrame}, Length: 1, EncryptionLevel: protocol.Encryption1RTT},
|
||||
{PacketNumber: 13, LargestAcked: 100, Frames: []wire.Frame{&streamFrame}, Length: 1, EncryptionLevel: protocol.Encryption1RTT},
|
||||
{PacketNumber: 14, LargestAcked: 200, Frames: []wire.Frame{&streamFrame}, Length: 1, EncryptionLevel: protocol.Encryption1RTT},
|
||||
{PacketNumber: 15, Frames: []wire.Frame{&streamFrame}, Length: 1, EncryptionLevel: protocol.Encryption1RTT},
|
||||
}
|
||||
for _, packet := range morePackets {
|
||||
|
||||
Reference in New Issue
Block a user