mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
parent
516500e156
commit
ef194015de
11 changed files with 102 additions and 69 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
// SentPacketHandler handles ACKs received for outgoing packets
|
||||
type SentPacketHandler interface {
|
||||
SentPacket(packet *Packet) error
|
||||
ReceivedAck(ackFrame *frames.AckFrameLegacy, withPacketNumber protocol.PacketNumber) error
|
||||
ReceivedAck(ackFrame *frames.AckFrame, withPacketNumber protocol.PacketNumber) error
|
||||
|
||||
ProbablyHasPacketForRetransmission() bool
|
||||
DequeuePacketForRetransmission() (packet *Packet)
|
||||
|
@ -29,7 +29,7 @@ type ReceivedPacketHandler interface {
|
|||
ReceivedPacket(packetNumber protocol.PacketNumber, entropyBit bool) error
|
||||
ReceivedStopWaiting(*frames.StopWaitingFrame) error
|
||||
|
||||
GetAckFrame(dequeue bool) (*frames.AckFrameLegacy, error)
|
||||
GetAckFrame(dequeue bool) (*frames.AckFrame, error)
|
||||
}
|
||||
|
||||
// StopWaitingManager manages StopWaitings for sent packets
|
||||
|
|
|
@ -41,7 +41,7 @@ func (p *Packet) GetControlFramesForRetransmission() []frames.Frame {
|
|||
continue
|
||||
}
|
||||
|
||||
_, isAck := frame.(*frames.AckFrameLegacy)
|
||||
_, isAck := frame.(*frames.AckFrame)
|
||||
_, isStopWaiting := frame.(*frames.StopWaitingFrame)
|
||||
if !isAck && !isStopWaiting {
|
||||
controlFrames = append(controlFrames, frame)
|
||||
|
|
|
@ -10,7 +10,7 @@ var _ = Describe("Packet", func() {
|
|||
Context("getFramesForRetransmission", func() {
|
||||
var packet Packet
|
||||
var streamFrame1, streamFrame2 *frames.StreamFrame
|
||||
var ackFrame1, ackFrame2 *frames.AckFrameLegacy
|
||||
var ackFrame1, ackFrame2 *frames.AckFrame
|
||||
var stopWaitingFrame *frames.StopWaitingFrame
|
||||
var rstStreamFrame *frames.RstStreamFrame
|
||||
var windowUpdateFrame *frames.WindowUpdateFrame
|
||||
|
@ -24,13 +24,17 @@ var _ = Describe("Packet", func() {
|
|||
StreamID: 6,
|
||||
Data: []byte{0xDE, 0xCA, 0xFB, 0xAD},
|
||||
}
|
||||
ackFrame1 = &frames.AckFrameLegacy{
|
||||
LargestObserved: 13,
|
||||
Entropy: 5,
|
||||
ackFrame1 = &frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: 13,
|
||||
Entropy: 5,
|
||||
},
|
||||
}
|
||||
ackFrame2 = &frames.AckFrameLegacy{
|
||||
LargestObserved: 333,
|
||||
Entropy: 17,
|
||||
ackFrame2 = &frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: 333,
|
||||
Entropy: 17,
|
||||
},
|
||||
}
|
||||
rstStreamFrame = &frames.RstStreamFrame{
|
||||
StreamID: 555,
|
||||
|
|
|
@ -31,7 +31,7 @@ type receivedPacketHandler struct {
|
|||
highestInOrderObservedEntropy EntropyAccumulator
|
||||
largestObserved protocol.PacketNumber
|
||||
ignorePacketsBelow protocol.PacketNumber
|
||||
currentAckFrame *frames.AckFrameLegacy
|
||||
currentAckFrame *frames.AckFrame
|
||||
stateChanged bool // has an ACK for this state already been sent? Will be set to false every time a new packet arrives, and to false every time an ACK is sent
|
||||
|
||||
packetHistory map[protocol.PacketNumber]packetHistoryEntry
|
||||
|
@ -136,7 +136,7 @@ func (h *receivedPacketHandler) getNackRanges() ([]frames.NackRange, EntropyAccu
|
|||
return ranges, entropy
|
||||
}
|
||||
|
||||
func (h *receivedPacketHandler) GetAckFrame(dequeue bool) (*frames.AckFrameLegacy, error) {
|
||||
func (h *receivedPacketHandler) GetAckFrame(dequeue bool) (*frames.AckFrame, error) {
|
||||
if !h.stateChanged {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -156,12 +156,15 @@ func (h *receivedPacketHandler) GetAckFrame(dequeue bool) (*frames.AckFrameLegac
|
|||
packetReceivedTime := p.TimeReceived
|
||||
|
||||
nackRanges, entropy := h.getNackRanges()
|
||||
h.currentAckFrame = &frames.AckFrameLegacy{
|
||||
LargestObserved: h.largestObserved,
|
||||
Entropy: byte(entropy),
|
||||
NackRanges: nackRanges,
|
||||
PacketReceivedTime: packetReceivedTime,
|
||||
h.currentAckFrame = &frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: h.largestObserved,
|
||||
Entropy: byte(entropy),
|
||||
NackRanges: nackRanges,
|
||||
PacketReceivedTime: packetReceivedTime,
|
||||
},
|
||||
}
|
||||
|
||||
return h.currentAckFrame, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -304,8 +304,9 @@ var _ = Describe("receivedPacketHandler", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
ack, err := handler.GetAckFrame(true)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(ack.LargestObserved).To(Equal(protocol.PacketNumber(2)))
|
||||
Expect(ack.Entropy).To(Equal(byte(entropy)))
|
||||
Expect(ack.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(ack.AckFrameLegacy.LargestObserved).To(Equal(protocol.PacketNumber(2)))
|
||||
Expect(ack.AckFrameLegacy.Entropy).To(Equal(byte(entropy)))
|
||||
})
|
||||
|
||||
It("generates an ACK frame with a NACK range", func() {
|
||||
|
@ -318,9 +319,10 @@ var _ = Describe("receivedPacketHandler", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
ack, err := handler.GetAckFrame(true)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(ack.LargestObserved).To(Equal(protocol.PacketNumber(4)))
|
||||
Expect(ack.Entropy).To(Equal(byte(entropy)))
|
||||
Expect(ack.NackRanges).To(Equal([]frames.NackRange{{FirstPacketNumber: 2, LastPacketNumber: 3}}))
|
||||
Expect(ack.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(ack.AckFrameLegacy.LargestObserved).To(Equal(protocol.PacketNumber(4)))
|
||||
Expect(ack.AckFrameLegacy.Entropy).To(Equal(byte(entropy)))
|
||||
Expect(ack.AckFrameLegacy.NackRanges).To(Equal([]frames.NackRange{{FirstPacketNumber: 2, LastPacketNumber: 3}}))
|
||||
})
|
||||
|
||||
It("does not generate an ACK if an ACK has already been sent for the largest Packet", func() {
|
||||
|
@ -367,12 +369,14 @@ var _ = Describe("receivedPacketHandler", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
ack, _ := handler.GetAckFrame(true)
|
||||
Expect(ack).ToNot(BeNil())
|
||||
Expect(ack.LargestObserved).To(Equal(protocol.PacketNumber(1)))
|
||||
Expect(ack.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(ack.AckFrameLegacy.LargestObserved).To(Equal(protocol.PacketNumber(1)))
|
||||
err = handler.ReceivedPacket(protocol.PacketNumber(3), false)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
ack, _ = handler.GetAckFrame(true)
|
||||
Expect(ack).ToNot(BeNil())
|
||||
Expect(ack.LargestObserved).To(Equal(protocol.PacketNumber(3)))
|
||||
Expect(ack.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(ack.AckFrameLegacy.LargestObserved).To(Equal(protocol.PacketNumber(3)))
|
||||
})
|
||||
|
||||
It("generates a new ACK when an out-of-order packet arrives", func() {
|
||||
|
@ -382,12 +386,14 @@ var _ = Describe("receivedPacketHandler", func() {
|
|||
Expect(err).ToNot(HaveOccurred())
|
||||
ack, _ := handler.GetAckFrame(true)
|
||||
Expect(ack).ToNot(BeNil())
|
||||
Expect(ack.NackRanges).To(HaveLen(1))
|
||||
Expect(ack.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(ack.AckFrameLegacy.NackRanges).To(HaveLen(1))
|
||||
err = handler.ReceivedPacket(protocol.PacketNumber(2), false)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
ack, _ = handler.GetAckFrame(true)
|
||||
Expect(ack).ToNot(BeNil())
|
||||
Expect(ack.NackRanges).To(BeEmpty())
|
||||
Expect(ack.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(ack.AckFrameLegacy.NackRanges).To(BeEmpty())
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -178,7 +178,8 @@ func (h *sentPacketHandler) calculateExpectedEntropy(ackFrame *frames.AckFrameLe
|
|||
}
|
||||
|
||||
// TODO: Simplify return types
|
||||
func (h *sentPacketHandler) ReceivedAck(ackFrame *frames.AckFrameLegacy, withPacketNumber protocol.PacketNumber) error {
|
||||
func (h *sentPacketHandler) ReceivedAck(ackFrameOrig *frames.AckFrame, withPacketNumber protocol.PacketNumber) error {
|
||||
ackFrame := ackFrameOrig.AckFrameLegacy
|
||||
if ackFrame.LargestObserved > h.lastSentPacketNumber {
|
||||
return errAckForUnsentPacket
|
||||
}
|
||||
|
|
|
@ -138,9 +138,11 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(1)))
|
||||
entropy := EntropyAccumulator(0)
|
||||
entropy.Add(packet1.PacketNumber, packet1.EntropyBit)
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
Entropy: byte(entropy),
|
||||
ack := frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
Entropy: byte(entropy),
|
||||
},
|
||||
}
|
||||
err = handler.ReceivedAck(&ack, 1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
@ -275,7 +277,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
LargestObserved: 4,
|
||||
Entropy: 1,
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).To(MatchError(ErrEntropy))
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(6)))
|
||||
})
|
||||
|
@ -290,7 +292,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
Entropy: byte(entropy),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(2)))
|
||||
Expect(handler.LargestObserved).To(Equal(protocol.PacketNumber(largestObserved)))
|
||||
|
@ -319,7 +321,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
{FirstPacketNumber: 3, LastPacketNumber: 3},
|
||||
},
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(2)))
|
||||
Expect(handler.LargestObserved).To(Equal(protocol.PacketNumber(largestObserved)))
|
||||
|
@ -348,7 +350,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
{FirstPacketNumber: 3, LastPacketNumber: 4},
|
||||
},
|
||||
}
|
||||
err := handler.ReceivedAck(&ack1, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack1}, 1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(2)))
|
||||
entropy.Add(packets[2].PacketNumber, packets[2].EntropyBit)
|
||||
|
@ -360,7 +362,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
{FirstPacketNumber: 4, LastPacketNumber: 4},
|
||||
},
|
||||
}
|
||||
err = handler.ReceivedAck(&ack2, 2)
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack2}, 2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(1)))
|
||||
Expect(handler.packetHistory).To(HaveKey(protocol.PacketNumber(4)))
|
||||
|
@ -391,10 +393,10 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
err = handler.ReceivedAck(&ack, 1)
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).To(MatchError(ErrDuplicateOrOutOfOrderAck))
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
})
|
||||
|
@ -404,10 +406,10 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 2)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 2)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
err = handler.ReceivedAck(&ack, 1)
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).To(MatchError(ErrDuplicateOrOutOfOrderAck))
|
||||
Expect(handler.LargestObserved).To(Equal(protocol.PacketNumber(largestObserved)))
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
|
@ -417,10 +419,10 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 3,
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1337)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1337)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
err = handler.ReceivedAck(&ack, 1337+1)
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1337+1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.LargestObserved).To(Equal(protocol.PacketNumber(3)))
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
|
@ -430,7 +432,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: packets[len(packets)-1].PacketNumber + 1337,
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).To(MatchError(errAckForUnsentPacket))
|
||||
Expect(handler.highestInOrderAckedPacketNumber).To(Equal(protocol.PacketNumber(0)))
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(6)))
|
||||
|
@ -445,7 +447,8 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
packet := handler.DequeuePacketForRetransmission()
|
||||
Expect(packet).ToNot(BeNil())
|
||||
// this is the belated ACK
|
||||
err := handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 3}, 1)
|
||||
ack := frames.AckFrameLegacy{LargestObserved: 3}
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(handler.LargestObserved).To(Equal(protocol.PacketNumber(3)))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
})
|
||||
|
@ -459,13 +462,16 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
handler.packetHistory[2].sendTime = now.Add(-5 * time.Minute)
|
||||
handler.packetHistory[6].sendTime = now.Add(-1 * time.Minute)
|
||||
// Now, check that the proper times are used when calculating the deltas
|
||||
err := handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 1}, 1)
|
||||
ack := frames.AckFrameLegacy{LargestObserved: 1}
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 10*time.Minute, 1*time.Second))
|
||||
err = handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 2}, 2)
|
||||
ack = frames.AckFrameLegacy{LargestObserved: 2}
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 2)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 5*time.Minute, 1*time.Second))
|
||||
err = handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 6}, 3)
|
||||
ack = frames.AckFrameLegacy{LargestObserved: 6}
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 3)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 1*time.Minute, 1*time.Second))
|
||||
})
|
||||
|
@ -473,7 +479,11 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
It("uses the DelayTime in the ack frame", func() {
|
||||
now := time.Now()
|
||||
handler.packetHistory[1].sendTime = now.Add(-10 * time.Minute)
|
||||
err := handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 1, DelayTime: 5 * time.Minute}, 1)
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
DelayTime: 5 * time.Minute,
|
||||
}
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 5*time.Minute, 1*time.Second))
|
||||
})
|
||||
|
@ -569,7 +579,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
LargestObserved: 4,
|
||||
NackRanges: []frames.NackRange{{FirstPacketNumber: 3, LastPacketNumber: 3}},
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(handler.highestInOrderAckedPacketNumber).To(Equal(protocol.PacketNumber(2)))
|
||||
handler.nackPacket(3) // this is the second NACK for this packet
|
||||
|
@ -605,7 +615,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
LargestObserved: 2,
|
||||
NackRanges: []frames.NackRange{{FirstPacketNumber: 1, LastPacketNumber: 1}},
|
||||
}
|
||||
err = handler.ReceivedAck(&ack, 1)
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(1)))
|
||||
|
||||
|
@ -626,7 +636,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
ack = frames.AckFrameLegacy{
|
||||
LargestObserved: 3,
|
||||
}
|
||||
err = handler.ReceivedAck(&ack, 2)
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 2)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(0)))
|
||||
})
|
||||
|
@ -665,7 +675,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
LargestObserved: 3,
|
||||
NackRanges: []frames.NackRange{{2, 2}},
|
||||
}
|
||||
err := handler.ReceivedAck(&ack, 1)
|
||||
err := handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, 1)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cong.nCalls).To(Equal(4)) // 3 * SentPacket + 1 * ReceivedAck
|
||||
// rttUpdated, bytesInFlight, ackedPackets, lostPackets
|
||||
|
@ -683,7 +693,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
LargestObserved: packetNumber,
|
||||
NackRanges: []frames.NackRange{{2, 2}},
|
||||
}
|
||||
err = handler.ReceivedAck(&ack, protocol.PacketNumber(2+i))
|
||||
err = handler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, protocol.PacketNumber(2+i))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ ReadLoop:
|
|||
err = qerr.Error(qerr.InvalidStreamData, err.Error())
|
||||
}
|
||||
} else if typeByte&0xc0 == 0x40 {
|
||||
frame, err = frames.ParseAckFrameLegacy(r, u.version)
|
||||
frame, err = frames.ParseAckFrame(r, u.version)
|
||||
if err != nil {
|
||||
err = qerr.Error(qerr.InvalidAckData, err.Error())
|
||||
}
|
||||
|
|
|
@ -80,20 +80,24 @@ var _ = Describe("Packet unpacker", func() {
|
|||
Expect(packet.frames).To(Equal([]frames.Frame{f}))
|
||||
})
|
||||
|
||||
It("unpacks ack frames", func() {
|
||||
f := &frames.AckFrameLegacy{
|
||||
LargestObserved: 0x13,
|
||||
Entropy: 0x37,
|
||||
It("unpacks ACK frames", func() {
|
||||
f := &frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: 0x13,
|
||||
Entropy: 0x37,
|
||||
},
|
||||
}
|
||||
err := f.Write(buf, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
setReader(buf.Bytes())
|
||||
unpacker.version = protocol.Version32
|
||||
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.frames).To(HaveLen(1))
|
||||
readFrame := packet.frames[0].(*frames.AckFrameLegacy)
|
||||
Expect(readFrame.LargestObserved).To(Equal(protocol.PacketNumber(0x13)))
|
||||
Expect(readFrame.Entropy).To(Equal(byte(0x37)))
|
||||
readFrame := packet.frames[0].(*frames.AckFrame)
|
||||
Expect(readFrame.AckFrameLegacy).ToNot(BeNil())
|
||||
Expect(readFrame.AckFrameLegacy.LargestObserved).To(Equal(protocol.PacketNumber(0x13)))
|
||||
Expect(readFrame.AckFrameLegacy.Entropy).To(Equal(byte(0x37)))
|
||||
})
|
||||
|
||||
It("errors on CONGESTION_FEEDBACK frames", func() {
|
||||
|
|
|
@ -266,8 +266,8 @@ func (s *Session) handleFrames(fs []frames.Frame) error {
|
|||
case *frames.StreamFrame:
|
||||
err = s.handleStreamFrame(frame)
|
||||
// TODO: send RstStreamFrame
|
||||
case *frames.AckFrameLegacy:
|
||||
err = s.handleAckFrameLegacy(frame)
|
||||
case *frames.AckFrame:
|
||||
err = s.handleAckFrame(frame)
|
||||
case *frames.ConnectionCloseFrame:
|
||||
s.closeImpl(qerr.Error(frame.ErrorCode, frame.ReasonPhrase), true)
|
||||
case *frames.GoawayFrame:
|
||||
|
@ -376,7 +376,7 @@ func (s *Session) handleRstStreamFrame(frame *frames.RstStreamFrame) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *Session) handleAckFrameLegacy(frame *frames.AckFrameLegacy) error {
|
||||
func (s *Session) handleAckFrame(frame *frames.AckFrame) error {
|
||||
if err := s.sentPacketHandler.ReceivedAck(frame, s.lastRcvdPacketNumber); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ type mockSentPacketHandler struct {
|
|||
}
|
||||
|
||||
func (h *mockSentPacketHandler) SentPacket(packet *ackhandlerlegacy.Packet) error { return nil }
|
||||
func (h *mockSentPacketHandler) ReceivedAck(ackFrame *frames.AckFrameLegacy, withPacketNumber protocol.PacketNumber) error {
|
||||
func (h *mockSentPacketHandler) ReceivedAck(ackFrame *frames.AckFrame, withPacketNumber protocol.PacketNumber) error {
|
||||
return nil
|
||||
}
|
||||
func (h *mockSentPacketHandler) BytesInFlight() protocol.ByteCount { return 0 }
|
||||
|
@ -674,7 +674,8 @@ var _ = Describe("Session", func() {
|
|||
err := session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: p, Length: 1})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
time.Sleep(time.Microsecond)
|
||||
err = session.sentPacketHandler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: p}, p)
|
||||
ack := frames.AckFrameLegacy{LargestObserved: p}
|
||||
err = session.sentPacketHandler.ReceivedAck(&frames.AckFrame{AckFrameLegacy: &ack}, p)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
// Now, we send a single packet, and expect that it was retransmitted later
|
||||
|
@ -727,12 +728,16 @@ var _ = Describe("Session", func() {
|
|||
PacketNumber: 1,
|
||||
Length: 1,
|
||||
})
|
||||
err := session.handleFrames([]frames.Frame{&frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
err := session.handleFrames([]frames.Frame{&frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
},
|
||||
}})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err = session.handleFrames([]frames.Frame{&frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
err = session.handleFrames([]frames.Frame{&frames.AckFrame{
|
||||
AckFrameLegacy: &frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
},
|
||||
}})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue