mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
rename AckFrame to AckFrameLegacy
This commit is contained in:
parent
c01e16da71
commit
288cb9e143
13 changed files with 110 additions and 110 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
// SentPacketHandler handles ACKs received for outgoing packets
|
||||
type SentPacketHandler interface {
|
||||
SentPacket(packet *Packet) error
|
||||
ReceivedAck(ackFrame *frames.AckFrame) error
|
||||
ReceivedAck(ackFrame *frames.AckFrameLegacy) 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.AckFrame, error)
|
||||
GetAckFrame(dequeue bool) (*frames.AckFrameLegacy, error)
|
||||
}
|
||||
|
||||
// StopWaitingManager manages StopWaitings for sent packets
|
||||
|
|
|
@ -41,7 +41,7 @@ func (p *Packet) GetControlFramesForRetransmission() []frames.Frame {
|
|||
continue
|
||||
}
|
||||
|
||||
_, isAck := frame.(*frames.AckFrame)
|
||||
_, isAck := frame.(*frames.AckFrameLegacy)
|
||||
_, 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.AckFrame
|
||||
var ackFrame1, ackFrame2 *frames.AckFrameLegacy
|
||||
var stopWaitingFrame *frames.StopWaitingFrame
|
||||
var rstStreamFrame *frames.RstStreamFrame
|
||||
var windowUpdateFrame *frames.WindowUpdateFrame
|
||||
|
@ -24,11 +24,11 @@ var _ = Describe("Packet", func() {
|
|||
StreamID: 6,
|
||||
Data: []byte{0xDE, 0xCA, 0xFB, 0xAD},
|
||||
}
|
||||
ackFrame1 = &frames.AckFrame{
|
||||
ackFrame1 = &frames.AckFrameLegacy{
|
||||
LargestObserved: 13,
|
||||
Entropy: 5,
|
||||
}
|
||||
ackFrame2 = &frames.AckFrame{
|
||||
ackFrame2 = &frames.AckFrameLegacy{
|
||||
LargestObserved: 333,
|
||||
Entropy: 17,
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ type receivedPacketHandler struct {
|
|||
highestInOrderObserved protocol.PacketNumber
|
||||
highestInOrderObservedEntropy EntropyAccumulator
|
||||
largestObserved protocol.PacketNumber
|
||||
currentAckFrame *frames.AckFrame
|
||||
currentAckFrame *frames.AckFrameLegacy
|
||||
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
|
||||
|
@ -117,7 +117,7 @@ func (h *receivedPacketHandler) getNackRanges() ([]frames.NackRange, EntropyAccu
|
|||
return ranges, entropy
|
||||
}
|
||||
|
||||
func (h *receivedPacketHandler) GetAckFrame(dequeue bool) (*frames.AckFrame, error) {
|
||||
func (h *receivedPacketHandler) GetAckFrame(dequeue bool) (*frames.AckFrameLegacy, error) {
|
||||
if !h.stateChanged {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ func (h *receivedPacketHandler) GetAckFrame(dequeue bool) (*frames.AckFrame, err
|
|||
packetReceivedTime := p.TimeReceived
|
||||
|
||||
nackRanges, entropy := h.getNackRanges()
|
||||
h.currentAckFrame = &frames.AckFrame{
|
||||
h.currentAckFrame = &frames.AckFrameLegacy{
|
||||
LargestObserved: h.largestObserved,
|
||||
Entropy: byte(entropy),
|
||||
NackRanges: nackRanges,
|
||||
|
|
|
@ -142,7 +142,7 @@ func (h *sentPacketHandler) SentPacket(packet *Packet) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (h *sentPacketHandler) calculateExpectedEntropy(ackFrame *frames.AckFrame) (EntropyAccumulator, error) {
|
||||
func (h *sentPacketHandler) calculateExpectedEntropy(ackFrame *frames.AckFrameLegacy) (EntropyAccumulator, error) {
|
||||
packet, ok := h.packetHistory[ackFrame.LargestObserved]
|
||||
if !ok {
|
||||
return 0, ErrMapAccess
|
||||
|
@ -172,7 +172,7 @@ func (h *sentPacketHandler) calculateExpectedEntropy(ackFrame *frames.AckFrame)
|
|||
}
|
||||
|
||||
// TODO: Simplify return types
|
||||
func (h *sentPacketHandler) ReceivedAck(ackFrame *frames.AckFrame) error {
|
||||
func (h *sentPacketHandler) ReceivedAck(ackFrame *frames.AckFrameLegacy) error {
|
||||
if ackFrame.LargestObserved > h.lastSentPacketNumber {
|
||||
return errAckForUnsentPacket
|
||||
}
|
||||
|
|
|
@ -138,7 +138,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(1)))
|
||||
entropy := EntropyAccumulator(0)
|
||||
entropy.Add(packet1.PacketNumber, packet1.EntropyBit)
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
Entropy: byte(entropy),
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
for i := 0; i < largestObserved; i++ {
|
||||
entropy.Add(packets[i].PacketNumber, packets[i].EntropyBit)
|
||||
}
|
||||
ack := frames.AckFrame{LargestObserved: protocol.PacketNumber(largestObserved)}
|
||||
ack := frames.AckFrameLegacy{LargestObserved: protocol.PacketNumber(largestObserved)}
|
||||
calculatedEntropy, err := handler.calculateExpectedEntropy(&ack)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(calculatedEntropy).To(Equal(entropy))
|
||||
|
@ -221,7 +221,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
}
|
||||
entropy.Add(packets[i].PacketNumber, packets[i].EntropyBit)
|
||||
}
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
NackRanges: []frames.NackRange{{FirstPacketNumber: 3, LastPacketNumber: 4}},
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
handler.ackPacket(1)
|
||||
handler.ackPacket(2)
|
||||
handler.ackPacket(5)
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
NackRanges: []frames.NackRange{{FirstPacketNumber: 3, LastPacketNumber: 4}},
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
}
|
||||
entropy.Add(packets[i].PacketNumber, packets[i].EntropyBit)
|
||||
}
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
NackRanges: []frames.NackRange{
|
||||
{FirstPacketNumber: 4, LastPacketNumber: 4},
|
||||
|
@ -271,7 +271,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
})
|
||||
|
||||
It("actually rejects an ACK with the wrong entropy", func() {
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 4,
|
||||
Entropy: 1,
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
for i := 0; i < largestObserved; i++ {
|
||||
entropy.Add(packets[i].PacketNumber, packets[i].EntropyBit)
|
||||
}
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
Entropy: byte(entropy),
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
}
|
||||
entropy.Add(packets[i].PacketNumber, packets[i].EntropyBit)
|
||||
}
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
Entropy: byte(entropy),
|
||||
NackRanges: []frames.NackRange{
|
||||
|
@ -350,7 +350,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
Context("ACK validation", func() {
|
||||
It("rejects duplicate ACKs", func() {
|
||||
largestObserved := 3
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack)
|
||||
|
@ -363,7 +363,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
|
||||
It("rejects out of order ACKs", func() {
|
||||
largestObserved := 3
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: protocol.PacketNumber(largestObserved),
|
||||
}
|
||||
err := handler.ReceivedAck(&ack)
|
||||
|
@ -377,7 +377,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
})
|
||||
|
||||
It("rejects ACKs with a too high LargestObserved packet number", func() {
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: packets[len(packets)-1].PacketNumber + 1337,
|
||||
}
|
||||
err := handler.ReceivedAck(&ack)
|
||||
|
@ -395,13 +395,13 @@ 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.AckFrame{LargestObserved: 1})
|
||||
err := handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 1})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 10*time.Minute, 1*time.Second))
|
||||
err = handler.ReceivedAck(&frames.AckFrame{LargestObserved: 2})
|
||||
err = handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 2})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 5*time.Minute, 1*time.Second))
|
||||
err = handler.ReceivedAck(&frames.AckFrame{LargestObserved: 6})
|
||||
err = handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 6})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 1*time.Minute, 1*time.Second))
|
||||
})
|
||||
|
@ -409,7 +409,7 @@ 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.AckFrame{LargestObserved: 1, DelayTime: 5 * time.Minute})
|
||||
err := handler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: 1, DelayTime: 5 * time.Minute})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(handler.rttStats.LatestRTT()).To(BeNumerically("~", 5*time.Minute, 1*time.Second))
|
||||
})
|
||||
|
@ -497,7 +497,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
})
|
||||
|
||||
It("does not change the highestInOrderAckedPacketNumber after queueing a retransmission", func() {
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 4,
|
||||
NackRanges: []frames.NackRange{{FirstPacketNumber: 3, LastPacketNumber: 3}},
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(3)))
|
||||
|
||||
// ACK 2, NACK 1
|
||||
ack := frames.AckFrame{
|
||||
ack := frames.AckFrameLegacy{
|
||||
LargestObserved: 2,
|
||||
NackRanges: []frames.NackRange{{FirstPacketNumber: 1, LastPacketNumber: 1}},
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(1)))
|
||||
|
||||
// ACK
|
||||
ack = frames.AckFrame{
|
||||
ack = frames.AckFrameLegacy{
|
||||
LargestObserved: 3,
|
||||
}
|
||||
err = handler.ReceivedAck(&ack)
|
||||
|
@ -593,7 +593,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1})
|
||||
handler.SentPacket(&Packet{PacketNumber: 2, Frames: []frames.Frame{}, Length: 2})
|
||||
handler.SentPacket(&Packet{PacketNumber: 3, Frames: []frames.Frame{}, Length: 3})
|
||||
err := handler.ReceivedAck(&frames.AckFrame{
|
||||
err := handler.ReceivedAck(&frames.AckFrameLegacy{
|
||||
LargestObserved: 3,
|
||||
NackRanges: []frames.NackRange{{2, 2}},
|
||||
})
|
||||
|
@ -610,7 +610,7 @@ var _ = Describe("SentPacketHandler", func() {
|
|||
for i := uint8(0); i < protocol.RetransmissionThreshold; i++ {
|
||||
packetNumber = protocol.PacketNumber(4 + i)
|
||||
handler.SentPacket(&Packet{PacketNumber: packetNumber, Frames: []frames.Frame{}, Length: protocol.ByteCount(packetNumber)})
|
||||
err = handler.ReceivedAck(&frames.AckFrame{
|
||||
err = handler.ReceivedAck(&frames.AckFrameLegacy{
|
||||
LargestObserved: packetNumber,
|
||||
NackRanges: []frames.NackRange{{2, 2}},
|
||||
})
|
||||
|
|
|
@ -14,8 +14,8 @@ var (
|
|||
errTooManyNackRanges = errors.New("AckFrame: Too many NACK ranges. Truncating not implemented.")
|
||||
)
|
||||
|
||||
// An AckFrame in QUIC
|
||||
type AckFrame struct {
|
||||
// An AckFrameLegacy is an ACK Frame in legacy format (ACK frame for QUIC <= 33)
|
||||
type AckFrameLegacy struct {
|
||||
LargestObserved protocol.PacketNumber
|
||||
Entropy byte
|
||||
NackRanges []NackRange // has to be ordered. The NACK range with the highest FirstPacketNumber goes first, the NACK range with the lowest FirstPacketNumber goes last
|
||||
|
@ -26,7 +26,7 @@ type AckFrame struct {
|
|||
}
|
||||
|
||||
// Write writes an ACK frame.
|
||||
func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
|
||||
func (f *AckFrameLegacy) Write(b *bytes.Buffer, version protocol.VersionNumber) error {
|
||||
largestObservedLen := protocol.GetPacketNumberLength(f.LargestObserved)
|
||||
|
||||
typeByte := uint8(0x40)
|
||||
|
@ -108,7 +108,7 @@ func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error
|
|||
}
|
||||
|
||||
// MinLength of a written frame
|
||||
func (f *AckFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error) {
|
||||
func (f *AckFrameLegacy) MinLength(version protocol.VersionNumber) (protocol.ByteCount, error) {
|
||||
l := 1 + 1 + 2 + 1 + 1 + 4 // 1 TypeByte, 1 Entropy, 2 ACK delay time, 1 Num Timestamp, 1 Delta Largest Observed, 4 FirstTimestamp
|
||||
l += int(protocol.GetPacketNumberLength(f.LargestObserved))
|
||||
l += (1 + 2) * 0 /* TODO: num_timestamps */
|
||||
|
@ -120,7 +120,7 @@ func (f *AckFrame) MinLength(version protocol.VersionNumber) (protocol.ByteCount
|
|||
}
|
||||
|
||||
// HasNACK returns if the frame has NACK ranges
|
||||
func (f *AckFrame) HasNACK() bool {
|
||||
func (f *AckFrameLegacy) HasNACK() bool {
|
||||
if len(f.NackRanges) > 0 {
|
||||
return true
|
||||
}
|
||||
|
@ -128,16 +128,16 @@ func (f *AckFrame) HasNACK() bool {
|
|||
}
|
||||
|
||||
// GetHighestInOrderPacketNumber gets the highest in order packet number that is confirmed by this ACK
|
||||
func (f *AckFrame) GetHighestInOrderPacketNumber() protocol.PacketNumber {
|
||||
func (f *AckFrameLegacy) GetHighestInOrderPacketNumber() protocol.PacketNumber {
|
||||
if f.HasNACK() {
|
||||
return (f.NackRanges[len(f.NackRanges)-1].FirstPacketNumber - 1)
|
||||
}
|
||||
return f.LargestObserved
|
||||
}
|
||||
|
||||
// ParseAckFrame reads an ACK frame
|
||||
func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame, error) {
|
||||
frame := &AckFrame{}
|
||||
// ParseAckFrameLegacy reads a legacy ACK frame
|
||||
func ParseAckFrameLegacy(r *bytes.Reader, version protocol.VersionNumber) (*AckFrameLegacy, error) {
|
||||
frame := &AckFrameLegacy{}
|
||||
|
||||
typeByte, err := r.ReadByte()
|
||||
if err != nil {
|
||||
|
@ -283,7 +283,7 @@ func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame,
|
|||
|
||||
// numWrittenNackRanges calculates the number of NackRanges that are about to be written
|
||||
// this number is different from len(f.NackRanges) for the case of contiguous NACK ranges
|
||||
func (f *AckFrame) numWrittenNackRanges() uint64 {
|
||||
func (f *AckFrameLegacy) numWrittenNackRanges() uint64 {
|
||||
var numRanges uint64
|
||||
for _, nackRange := range f.NackRanges {
|
||||
rangeLength := nackRange.Len()
|
||||
|
@ -296,7 +296,7 @@ func (f *AckFrame) numWrittenNackRanges() uint64 {
|
|||
return numRanges
|
||||
}
|
||||
|
||||
func (f *AckFrame) validateNackRanges() bool {
|
||||
func (f *AckFrameLegacy) validateNackRanges() bool {
|
||||
// check the validity of every single NACK range
|
||||
for _, nackRange := range f.NackRanges {
|
||||
if nackRange.FirstPacketNumber > nackRange.LastPacketNumber {
|
|
@ -14,7 +14,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Context("when parsing", func() {
|
||||
It("accepts sample frame", func() {
|
||||
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.Entropy).To(Equal(byte(0xA4)))
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0x03)))
|
||||
|
@ -25,7 +25,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("parses a frame with a 48 bit packet number", func() {
|
||||
b := bytes.NewReader([]byte{0x4C, 0xA4, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
||||
Expect(b.Len()).To(Equal(0))
|
||||
|
@ -33,14 +33,14 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("completely parses a frame with multiple timestamps", func() {
|
||||
b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x03, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0x12, 0x34, 0x56, 0x78, 0x90, 0xA0})
|
||||
_, err := ParseAckFrame(b, protocol.Version32)
|
||||
_, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(Equal(0))
|
||||
})
|
||||
|
||||
It("parses a frame containing one NACK range", func() {
|
||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
Expect(frame.NackRanges).To(HaveLen(1))
|
||||
|
@ -52,7 +52,7 @@ var _ = Describe("AckFrame", func() {
|
|||
It("parses a frame containing one NACK range with a 48 bit LargestObserved and missingPacketSequenceNumberDelta", func() {
|
||||
var rangeLength uint64 = 3
|
||||
b := bytes.NewReader([]byte{(0x4C | 0x20 | 0x03), 0x08, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, byte(rangeLength)})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337)))
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
|
@ -64,7 +64,7 @@ var _ = Describe("AckFrame", func() {
|
|||
It("parses a frame containing multiple NACK ranges", func() {
|
||||
// sent packets 1, 3, 7, 15
|
||||
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x3, 0x1, 0x6, 0x1, 0x2, 0x1, 0x0})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
Expect(frame.NackRanges).To(HaveLen(3))
|
||||
|
@ -77,13 +77,13 @@ var _ = Describe("AckFrame", func() {
|
|||
It("rejects a packet with an invalid NACK range", func() {
|
||||
// LargestObserved: 8, NackRange: (8-7-3) to (8-7)
|
||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x7, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x7, 0x3})
|
||||
_, err := ParseAckFrame(b, protocol.Version32)
|
||||
_, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).To(MatchError(errInvalidNackRanges))
|
||||
})
|
||||
|
||||
It("accepts truncated acks", func() {
|
||||
b := bytes.NewReader([]byte{0x50, 0xA4, 0x03, 0x23, 0x45})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.Truncated).To(BeTrue())
|
||||
Expect(b.Len()).To(BeZero())
|
||||
|
@ -91,7 +91,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("parses a frame with the largest observed missing", func() {
|
||||
b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x1, 0x0, 0x0})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
Expect(frame.NackRanges).To(HaveLen(1))
|
||||
|
@ -102,7 +102,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Context("support for version 31", func() {
|
||||
It("support a simple ACK with one NACK range, version 31", func() {
|
||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0})
|
||||
frame, err := ParseAckFrame(b, protocol.Version31)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version31)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
Expect(frame.NackRanges).To(HaveLen(1))
|
||||
|
@ -113,7 +113,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("support a simple ACK with multiple NACK ranges, version 31", func() {
|
||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x9, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x1, 0x2, 0x0, 0x0})
|
||||
frame, err := ParseAckFrame(b, protocol.Version31)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version31)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.HasNACK()).To(Equal(true))
|
||||
Expect(frame.NackRanges).To(HaveLen(2))
|
||||
|
@ -125,7 +125,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("reads the complete ACK frame if it contains revived packet numbers", func() {
|
||||
b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1, 0x3, 0x5, 0x6, 0x7})
|
||||
_, err := ParseAckFrame(b, protocol.Version31)
|
||||
_, err := ParseAckFrameLegacy(b, protocol.Version31)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(b.Len()).To(Equal(0))
|
||||
})
|
||||
|
@ -134,7 +134,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Context("contiguous NACK ranges", func() {
|
||||
It("parses a frame with a contiguous NACK range spanning two fields", func() {
|
||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x2E, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(302)))
|
||||
Expect(frame.NackRanges).To(HaveLen(1))
|
||||
|
@ -143,7 +143,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("parses a frame with a contiguous NACK range spanning more than two fields", func() {
|
||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x16, 0x05, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x6, 0x1, 0x13, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(1302)))
|
||||
Expect(frame.NackRanges).To(HaveLen(1))
|
||||
|
@ -152,7 +152,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("parses a frame with two contiguous NACK ranges", func() {
|
||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x23, 0x03, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x4, 0x1, 0x8f, 0x0, 0xff, 0x1, 0x8f, 0x0, 0xff})
|
||||
frame, err := ParseAckFrame(b, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(803)))
|
||||
Expect(frame.NackRanges).To(HaveLen(2))
|
||||
|
@ -163,7 +163,7 @@ var _ = Describe("AckFrame", func() {
|
|||
It("rejects a frame with an invalid NACK range", func() {
|
||||
// LargestObserved: 280, but NACK range is 301 packets long
|
||||
b := bytes.NewReader([]byte{0x64, 0x8, 0x18, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff})
|
||||
_, err := ParseAckFrame(b, protocol.Version32)
|
||||
_, err := ParseAckFrameLegacy(b, protocol.Version32)
|
||||
Expect(err).To(MatchError(errInvalidNackRanges))
|
||||
})
|
||||
})
|
||||
|
@ -171,13 +171,13 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
Context("GetHighestInOrderPacket", func() {
|
||||
It("gets the highest in order packet number for an ACK without NACK ranges", func() {
|
||||
frame := AckFrame{LargestObserved: 5}
|
||||
frame := AckFrameLegacy{LargestObserved: 5}
|
||||
Expect(frame.GetHighestInOrderPacketNumber()).To(Equal(protocol.PacketNumber(5)))
|
||||
})
|
||||
|
||||
It("gets the highest in order packet number for an ACK with one NACK ranges", func() {
|
||||
nackRange := NackRange{FirstPacketNumber: 3, LastPacketNumber: 4}
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
LargestObserved: 6,
|
||||
NackRanges: []NackRange{nackRange},
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ var _ = Describe("AckFrame", func() {
|
|||
{FirstPacketNumber: 7, LastPacketNumber: 7},
|
||||
{FirstPacketNumber: 4, LastPacketNumber: 5},
|
||||
}
|
||||
frame := &AckFrame{
|
||||
frame := &AckFrameLegacy{
|
||||
LargestObserved: 15,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ var _ = Describe("AckFrame", func() {
|
|||
Context("NACK range validator", func() {
|
||||
It("rejects NACKs with FirstPacketNumber greater than LastPacketNumber", func() {
|
||||
nackRange := NackRange{FirstPacketNumber: 7, LastPacketNumber: 6}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 10,
|
||||
NackRanges: []NackRange{nackRange},
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("rejects NACKs with FirstPacketNumber greater than LargestObserved", func() {
|
||||
nackRange := NackRange{FirstPacketNumber: 6, LastPacketNumber: 6}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 5,
|
||||
NackRanges: []NackRange{nackRange},
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
It("does not reject NACKs with LasterPacketNumber equal to LargestObserved", func() {
|
||||
nackRange := NackRange{FirstPacketNumber: 7, LastPacketNumber: 7}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 7,
|
||||
NackRanges: []NackRange{nackRange},
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ var _ = Describe("AckFrame", func() {
|
|||
{FirstPacketNumber: 2, LastPacketNumber: 2},
|
||||
{FirstPacketNumber: 6, LastPacketNumber: 6},
|
||||
}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 7,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ var _ = Describe("AckFrame", func() {
|
|||
{FirstPacketNumber: 5, LastPacketNumber: 6},
|
||||
{FirstPacketNumber: 2, LastPacketNumber: 5},
|
||||
}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 7,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
|
@ -251,13 +251,13 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("accepts an ACK without NACK Ranges", func() {
|
||||
ack := AckFrame{LargestObserved: 7}
|
||||
ack := AckFrameLegacy{LargestObserved: 7}
|
||||
Expect(ack.validateNackRanges()).To(BeTrue())
|
||||
})
|
||||
|
||||
It("accepts an ACK with one NACK Ranges", func() {
|
||||
nackRange := NackRange{FirstPacketNumber: 6, LastPacketNumber: 8}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 10,
|
||||
NackRanges: []NackRange{nackRange},
|
||||
}
|
||||
|
@ -269,7 +269,7 @@ var _ = Describe("AckFrame", func() {
|
|||
{FirstPacketNumber: 6, LastPacketNumber: 7},
|
||||
{FirstPacketNumber: 2, LastPacketNumber: 4},
|
||||
}
|
||||
ack := AckFrame{
|
||||
ack := AckFrameLegacy{
|
||||
LargestObserved: 10,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes simple frames without NACK ranges", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 1,
|
||||
}
|
||||
|
@ -296,7 +296,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("calculates the DelayTime", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
LargestObserved: 5,
|
||||
PacketReceivedTime: time.Now().Add(-750 * time.Millisecond),
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a frame with one NACK range", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 4,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||
|
@ -325,7 +325,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("supports version 31", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 4,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||
|
@ -344,7 +344,7 @@ var _ = Describe("AckFrame", func() {
|
|||
It("writes a frame with multiple NACK ranges", func() {
|
||||
nackRange1 := NackRange{FirstPacketNumber: 4, LastPacketNumber: 6}
|
||||
nackRange2 := NackRange{FirstPacketNumber: 2, LastPacketNumber: 2}
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 7,
|
||||
NackRanges: []NackRange{nackRange1, nackRange2},
|
||||
|
@ -365,7 +365,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
Context("contiguous NACK ranges", func() {
|
||||
It("writes the largest possible NACK range that does not require to be written in contiguous form", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 258,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 257}},
|
||||
|
@ -379,7 +379,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a frame with a contiguous NACK range", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 302,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 301}},
|
||||
|
@ -395,7 +395,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a frame with the smallest NACK ranges that requires a contiguous NACK range", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 259,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 258}},
|
||||
|
@ -411,7 +411,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a frame with a long contiguous NACK range", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 603,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 601}},
|
||||
|
@ -431,7 +431,7 @@ var _ = Describe("AckFrame", func() {
|
|||
It("writes a frame with two contiguous NACK range", func() {
|
||||
nackRange1 := NackRange{FirstPacketNumber: 2, LastPacketNumber: 351}
|
||||
nackRange2 := NackRange{FirstPacketNumber: 355, LastPacketNumber: 654}
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 655,
|
||||
NackRanges: []NackRange{nackRange2, nackRange1},
|
||||
|
@ -452,7 +452,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
Context("LargestObserved length", func() {
|
||||
It("writes a 1 byte LargestObserved value", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
LargestObserved: 7,
|
||||
}
|
||||
err := frame.Write(b, protocol.Version32)
|
||||
|
@ -462,7 +462,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a 2 byte LargestObserved value", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
LargestObserved: 0x1337,
|
||||
}
|
||||
err := frame.Write(b, protocol.Version32)
|
||||
|
@ -472,7 +472,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a 4 byte LargestObserved value", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
LargestObserved: 0xDECAFBAD,
|
||||
}
|
||||
err := frame.Write(b, protocol.Version32)
|
||||
|
@ -482,7 +482,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("writes a 6 byte LargestObserved value", func() {
|
||||
frame := AckFrame{
|
||||
frame := AckFrameLegacy{
|
||||
LargestObserved: 0xDEADBEEFCAFE,
|
||||
}
|
||||
err := frame.Write(b, protocol.Version32)
|
||||
|
@ -495,7 +495,7 @@ var _ = Describe("AckFrame", func() {
|
|||
|
||||
Context("min length", func() {
|
||||
It("has proper min length", func() {
|
||||
f := &AckFrame{
|
||||
f := &AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 1,
|
||||
}
|
||||
|
@ -504,7 +504,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("has proper min length with a large LargestObserved", func() {
|
||||
f := &AckFrame{
|
||||
f := &AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 0xDEADBEEFCAFE,
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("has proper min length with NACK ranges", func() {
|
||||
f := &AckFrame{
|
||||
f := &AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 4,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}},
|
||||
|
@ -524,7 +524,7 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("has proper min length with a continuous NACK ranges", func() {
|
||||
f := &AckFrame{
|
||||
f := &AckFrameLegacy{
|
||||
Entropy: 2,
|
||||
LargestObserved: 3000,
|
||||
NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2000}},
|
||||
|
@ -543,13 +543,13 @@ var _ = Describe("AckFrame", func() {
|
|||
})
|
||||
|
||||
It("is self-consistent for ACK frames without NACK ranges", func() {
|
||||
frameOrig := &AckFrame{
|
||||
frameOrig := &AckFrameLegacy{
|
||||
Entropy: 0xDE,
|
||||
LargestObserved: 6789,
|
||||
}
|
||||
err := frameOrig.Write(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
frame, err := ParseAckFrame(bytes.NewReader(b.Bytes()), protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(bytes.NewReader(b.Bytes()), protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.Entropy).To(Equal(frameOrig.Entropy))
|
||||
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
||||
|
@ -561,14 +561,14 @@ var _ = Describe("AckFrame", func() {
|
|||
{FirstPacketNumber: 7, LastPacketNumber: 7},
|
||||
{FirstPacketNumber: 2, LastPacketNumber: 3},
|
||||
}
|
||||
frameOrig := &AckFrame{
|
||||
frameOrig := &AckFrameLegacy{
|
||||
LargestObserved: 15,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
err := frameOrig.Write(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b.Bytes())
|
||||
frame, err := ParseAckFrame(r, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(r, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
||||
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
|
||||
|
@ -581,14 +581,14 @@ var _ = Describe("AckFrame", func() {
|
|||
{FirstPacketNumber: 350, LastPacketNumber: 351},
|
||||
{FirstPacketNumber: 2, LastPacketNumber: 306},
|
||||
}
|
||||
frameOrig := &AckFrame{
|
||||
frameOrig := &AckFrameLegacy{
|
||||
LargestObserved: 1600,
|
||||
NackRanges: nackRanges,
|
||||
}
|
||||
err := frameOrig.Write(b, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
r := bytes.NewReader(b.Bytes())
|
||||
frame, err := ParseAckFrame(r, protocol.Version32)
|
||||
frame, err := ParseAckFrameLegacy(r, protocol.Version32)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved))
|
||||
Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges)))
|
|
@ -16,13 +16,13 @@ type mockSentPacketHandler struct {
|
|||
retransmissionQueue []*ackhandler.Packet
|
||||
}
|
||||
|
||||
func (h *mockSentPacketHandler) SentPacket(packet *ackhandler.Packet) error { return nil }
|
||||
func (h *mockSentPacketHandler) ReceivedAck(ackFrame *frames.AckFrame) error { return nil }
|
||||
func (h *mockSentPacketHandler) BytesInFlight() protocol.ByteCount { return 0 }
|
||||
func (h *mockSentPacketHandler) GetLargestObserved() protocol.PacketNumber { return 1 }
|
||||
func (h *mockSentPacketHandler) CongestionAllowsSending() bool { return true }
|
||||
func (h *mockSentPacketHandler) CheckForError() error { return nil }
|
||||
func (h *mockSentPacketHandler) TimeOfFirstRTO() time.Time { panic("not implemented") }
|
||||
func (h *mockSentPacketHandler) SentPacket(packet *ackhandler.Packet) error { return nil }
|
||||
func (h *mockSentPacketHandler) ReceivedAck(ackFrame *frames.AckFrameLegacy) error { return nil }
|
||||
func (h *mockSentPacketHandler) BytesInFlight() protocol.ByteCount { return 0 }
|
||||
func (h *mockSentPacketHandler) GetLargestObserved() protocol.PacketNumber { return 1 }
|
||||
func (h *mockSentPacketHandler) CongestionAllowsSending() bool { return true }
|
||||
func (h *mockSentPacketHandler) CheckForError() error { return nil }
|
||||
func (h *mockSentPacketHandler) TimeOfFirstRTO() time.Time { panic("not implemented") }
|
||||
|
||||
func (h *mockSentPacketHandler) ProbablyHasPacketForRetransmission() bool {
|
||||
return len(h.retransmissionQueue) > 0
|
||||
|
@ -169,7 +169,7 @@ var _ = Describe("Packet packer", func() {
|
|||
})
|
||||
|
||||
It("packs many control frames into 1 packets", func() {
|
||||
f := &frames.AckFrame{LargestObserved: 1}
|
||||
f := &frames.AckFrameLegacy{LargestObserved: 1}
|
||||
b := &bytes.Buffer{}
|
||||
f.Write(b, protocol.Version32)
|
||||
maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / b.Len()
|
||||
|
|
|
@ -61,7 +61,7 @@ ReadLoop:
|
|||
err = qerr.Error(qerr.InvalidStreamData, err.Error())
|
||||
}
|
||||
} else if typeByte&0xc0 == 0x40 {
|
||||
frame, err = frames.ParseAckFrame(r, u.version)
|
||||
frame, err = frames.ParseAckFrameLegacy(r, u.version)
|
||||
if err != nil {
|
||||
err = qerr.Error(qerr.InvalidAckData, err.Error())
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ var _ = Describe("Packet unpacker", func() {
|
|||
})
|
||||
|
||||
It("unpacks ack frames", func() {
|
||||
f := &frames.AckFrame{
|
||||
f := &frames.AckFrameLegacy{
|
||||
LargestObserved: 0x13,
|
||||
Entropy: 0x37,
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ var _ = Describe("Packet unpacker", func() {
|
|||
packet, err := unpacker.Unpack(hdrBin, hdr, r)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(packet.frames).To(HaveLen(1))
|
||||
readFrame := packet.frames[0].(*frames.AckFrame)
|
||||
readFrame := packet.frames[0].(*frames.AckFrameLegacy)
|
||||
Expect(readFrame.LargestObserved).To(Equal(protocol.PacketNumber(0x13)))
|
||||
Expect(readFrame.Entropy).To(Equal(byte(0x37)))
|
||||
})
|
||||
|
|
|
@ -251,8 +251,8 @@ func (s *Session) handleFrames(fs []frames.Frame) error {
|
|||
case *frames.StreamFrame:
|
||||
err = s.handleStreamFrame(frame)
|
||||
// TODO: send RstStreamFrame
|
||||
case *frames.AckFrame:
|
||||
err = s.handleAckFrame(frame)
|
||||
case *frames.AckFrameLegacy:
|
||||
err = s.handleAckFrameLegacy(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) handleAckFrame(frame *frames.AckFrame) error {
|
||||
func (s *Session) handleAckFrameLegacy(frame *frames.AckFrameLegacy) error {
|
||||
if err := s.sentPacketHandler.ReceivedAck(frame); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -703,7 +703,7 @@ var _ = Describe("Session", func() {
|
|||
err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{PacketNumber: p, Length: 1})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
time.Sleep(time.Microsecond)
|
||||
err = session.sentPacketHandler.ReceivedAck(&frames.AckFrame{LargestObserved: p})
|
||||
err = session.sentPacketHandler.ReceivedAck(&frames.AckFrameLegacy{LargestObserved: p})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
// Now, we send a single packet, and expect that it was retransmitted later
|
||||
|
@ -755,11 +755,11 @@ var _ = Describe("Session", func() {
|
|||
PacketNumber: 1,
|
||||
Length: 1,
|
||||
})
|
||||
err := session.handleFrames([]frames.Frame{&frames.AckFrame{
|
||||
err := session.handleFrames([]frames.Frame{&frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
}})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
err = session.handleFrames([]frames.Frame{&frames.AckFrame{
|
||||
err = session.handleFrames([]frames.Frame{&frames.AckFrameLegacy{
|
||||
LargestObserved: 1,
|
||||
}})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue