move ackhandler.Packet and PacketList shared types to new ackhandler

This commit is contained in:
Lucas Clemente 2016-08-30 21:14:57 +02:00
parent 05127e5c20
commit a8b3e1ef8e
10 changed files with 440 additions and 76 deletions

7
ackhandler/_gen.go Normal file
View file

@ -0,0 +1,7 @@
package main
import (
_ "github.com/clipperhouse/linkedlist"
_ "github.com/clipperhouse/slice"
_ "github.com/clipperhouse/stringer"
)

View file

@ -3,20 +3,19 @@ package ackhandler
import ( import (
"time" "time"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/frames" "github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/protocol" "github.com/lucas-clemente/quic-go/protocol"
) )
// SentPacketHandler handles ACKs received for outgoing packets // SentPacketHandler handles ACKs received for outgoing packets
type SentPacketHandler interface { type SentPacketHandler interface {
SentPacket(packet *ackhandlerlegacy.Packet) error SentPacket(packet *Packet) error
ReceivedAck(ackFrame *frames.AckFrame, withPacketNumber protocol.PacketNumber) error ReceivedAck(ackFrame *frames.AckFrame, withPacketNumber protocol.PacketNumber) error
GetStopWaitingFrame(force bool) *frames.StopWaitingFrame GetStopWaitingFrame(force bool) *frames.StopWaitingFrame
MaybeQueueRTOs() MaybeQueueRTOs()
DequeuePacketForRetransmission() (packet *ackhandlerlegacy.Packet) DequeuePacketForRetransmission() (packet *Packet)
BytesInFlight() protocol.ByteCount BytesInFlight() protocol.ByteCount
GetLeastUnacked() protocol.PacketNumber GetLeastUnacked() protocol.PacketNumber
@ -39,7 +38,7 @@ type ReceivedPacketHandler interface {
// StopWaitingManager manages StopWaitings for sent packets // StopWaitingManager manages StopWaitings for sent packets
// TODO: remove once we drop support for QUIC 33 // TODO: remove once we drop support for QUIC 33
type StopWaitingManager interface { type StopWaitingManager interface {
RegisterPacketForRetransmission(packet *ackhandlerlegacy.Packet) RegisterPacketForRetransmission(packet *Packet)
GetStopWaitingFrame() *frames.StopWaitingFrame GetStopWaitingFrame() *frames.StopWaitingFrame
SentStopWaitingWithPacket(packetNumber protocol.PacketNumber) SentStopWaitingWithPacket(packetNumber protocol.PacketNumber)
ReceivedAckForPacketNumber(packetNumber protocol.PacketNumber) ReceivedAckForPacketNumber(packetNumber protocol.PacketNumber)

49
ackhandler/packet.go Normal file
View file

@ -0,0 +1,49 @@
package ackhandler
import (
"time"
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/protocol"
)
// A Packet is a packet
// +gen linkedlist
type Packet struct {
PacketNumber protocol.PacketNumber
Frames []frames.Frame
Length protocol.ByteCount
MissingReports uint8
SendTime time.Time
}
// GetStreamFramesForRetransmission gets all the streamframes for retransmission
func (p *Packet) GetStreamFramesForRetransmission() []*frames.StreamFrame {
var streamFrames []*frames.StreamFrame
for _, frame := range p.Frames {
if streamFrame, isStreamFrame := frame.(*frames.StreamFrame); isStreamFrame {
streamFrames = append(streamFrames, streamFrame)
}
}
return streamFrames
}
// GetControlFramesForRetransmission gets all the control frames for retransmission
func (p *Packet) GetControlFramesForRetransmission() []frames.Frame {
var controlFrames []frames.Frame
for _, frame := range p.Frames {
// omit ACKs
if _, isStreamFrame := frame.(*frames.StreamFrame); isStreamFrame {
continue
}
_, isAck := frame.(*frames.AckFrame)
_, isStopWaiting := frame.(*frames.StopWaitingFrame)
if !isAck && !isStopWaiting {
controlFrames = append(controlFrames, frame)
}
}
return controlFrames
}

View file

@ -0,0 +1,214 @@
// Generated by: main
// TypeWriter: linkedlist
// Directive: +gen on Packet
package ackhandler
// List is a modification of http://golang.org/pkg/container/list/
// Copyright 2009 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// PacketElement is an element of a linked list.
type PacketElement struct {
// Next and previous pointers in the doubly-linked list of elements.
// To simplify the implementation, internally a list l is implemented
// as a ring, such that &l.root is both the next element of the last
// list element (l.Back()) and the previous element of the first list
// element (l.Front()).
next, prev *PacketElement
// The list to which this element belongs.
list *PacketList
// The value stored with this element.
Value Packet
}
// Next returns the next list element or nil.
func (e *PacketElement) Next() *PacketElement {
if p := e.next; e.list != nil && p != &e.list.root {
return p
}
return nil
}
// Prev returns the previous list element or nil.
func (e *PacketElement) Prev() *PacketElement {
if p := e.prev; e.list != nil && p != &e.list.root {
return p
}
return nil
}
// PacketList represents a doubly linked list.
// The zero value for PacketList is an empty list ready to use.
type PacketList struct {
root PacketElement // sentinel list element, only &root, root.prev, and root.next are used
len int // current list length excluding (this) sentinel element
}
// Init initializes or clears list l.
func (l *PacketList) Init() *PacketList {
l.root.next = &l.root
l.root.prev = &l.root
l.len = 0
return l
}
// NewPacketList returns an initialized list.
func NewPacketList() *PacketList { return new(PacketList).Init() }
// Len returns the number of elements of list l.
// The complexity is O(1).
func (l *PacketList) Len() int { return l.len }
// Front returns the first element of list l or nil.
func (l *PacketList) Front() *PacketElement {
if l.len == 0 {
return nil
}
return l.root.next
}
// Back returns the last element of list l or nil.
func (l *PacketList) Back() *PacketElement {
if l.len == 0 {
return nil
}
return l.root.prev
}
// lazyInit lazily initializes a zero PacketList value.
func (l *PacketList) lazyInit() {
if l.root.next == nil {
l.Init()
}
}
// insert inserts e after at, increments l.len, and returns e.
func (l *PacketList) insert(e, at *PacketElement) *PacketElement {
n := at.next
at.next = e
e.prev = at
e.next = n
n.prev = e
e.list = l
l.len++
return e
}
// insertValue is a convenience wrapper for insert(&PacketElement{Value: v}, at).
func (l *PacketList) insertValue(v Packet, at *PacketElement) *PacketElement {
return l.insert(&PacketElement{Value: v}, at)
}
// remove removes e from its list, decrements l.len, and returns e.
func (l *PacketList) remove(e *PacketElement) *PacketElement {
e.prev.next = e.next
e.next.prev = e.prev
e.next = nil // avoid memory leaks
e.prev = nil // avoid memory leaks
e.list = nil
l.len--
return e
}
// Remove removes e from l if e is an element of list l.
// It returns the element value e.Value.
func (l *PacketList) Remove(e *PacketElement) Packet {
if e.list == l {
// if e.list == l, l must have been initialized when e was inserted
// in l or l == nil (e is a zero PacketElement) and l.remove will crash
l.remove(e)
}
return e.Value
}
// PushFront inserts a new element e with value v at the front of list l and returns e.
func (l *PacketList) PushFront(v Packet) *PacketElement {
l.lazyInit()
return l.insertValue(v, &l.root)
}
// PushBack inserts a new element e with value v at the back of list l and returns e.
func (l *PacketList) PushBack(v Packet) *PacketElement {
l.lazyInit()
return l.insertValue(v, l.root.prev)
}
// InsertBefore inserts a new element e with value v immediately before mark and returns e.
// If mark is not an element of l, the list is not modified.
func (l *PacketList) InsertBefore(v Packet, mark *PacketElement) *PacketElement {
if mark.list != l {
return nil
}
// see comment in PacketList.Remove about initialization of l
return l.insertValue(v, mark.prev)
}
// InsertAfter inserts a new element e with value v immediately after mark and returns e.
// If mark is not an element of l, the list is not modified.
func (l *PacketList) InsertAfter(v Packet, mark *PacketElement) *PacketElement {
if mark.list != l {
return nil
}
// see comment in PacketList.Remove about initialization of l
return l.insertValue(v, mark)
}
// MoveToFront moves element e to the front of list l.
// If e is not an element of l, the list is not modified.
func (l *PacketList) MoveToFront(e *PacketElement) {
if e.list != l || l.root.next == e {
return
}
// see comment in PacketList.Remove about initialization of l
l.insert(l.remove(e), &l.root)
}
// MoveToBack moves element e to the back of list l.
// If e is not an element of l, the list is not modified.
func (l *PacketList) MoveToBack(e *PacketElement) {
if e.list != l || l.root.prev == e {
return
}
// see comment in PacketList.Remove about initialization of l
l.insert(l.remove(e), l.root.prev)
}
// MoveBefore moves element e to its new position before mark.
// If e or mark is not an element of l, or e == mark, the list is not modified.
func (l *PacketList) MoveBefore(e, mark *PacketElement) {
if e.list != l || e == mark || mark.list != l {
return
}
l.insert(l.remove(e), mark.prev)
}
// MoveAfter moves element e to its new position after mark.
// If e is not an element of l, or e == mark, the list is not modified.
func (l *PacketList) MoveAfter(e, mark *PacketElement) {
if e.list != l || e == mark || mark.list != l {
return
}
l.insert(l.remove(e), mark)
}
// PushBackList inserts a copy of an other list at the back of list l.
// The lists l and other may be the same.
func (l *PacketList) PushBackList(other *PacketList) {
l.lazyInit()
for i, e := other.Len(), other.Front(); i > 0; i, e = i-1, e.Next() {
l.insertValue(e.Value, l.root.prev)
}
}
// PushFrontList inserts a copy of an other list at the front of list l.
// The lists l and other may be the same.
func (l *PacketList) PushFrontList(other *PacketList) {
l.lazyInit()
for i, e := other.Len(), other.Back(); i > 0; i, e = i-1, e.Prev() {
l.insertValue(e.Value, &l.root)
}
}

101
ackhandler/packet_test.go Normal file
View file

@ -0,0 +1,101 @@
package ackhandler
import (
"github.com/lucas-clemente/quic-go/frames"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Packet", func() {
Context("getFramesForRetransmission", func() {
var packet Packet
var streamFrame1, streamFrame2 *frames.StreamFrame
var ackFrame1, ackFrame2 *frames.AckFrame
var stopWaitingFrame *frames.StopWaitingFrame
var rstStreamFrame *frames.RstStreamFrame
var windowUpdateFrame *frames.WindowUpdateFrame
BeforeEach(func() {
streamFrame1 = &frames.StreamFrame{
StreamID: 5,
Data: []byte{0x13, 0x37},
}
streamFrame2 = &frames.StreamFrame{
StreamID: 6,
Data: []byte{0xDE, 0xCA, 0xFB, 0xAD},
}
ackFrame1 = &frames.AckFrame{
AckFrameLegacy: &frames.AckFrameLegacy{
LargestObserved: 13,
Entropy: 5,
},
}
ackFrame2 = &frames.AckFrame{
AckFrameLegacy: &frames.AckFrameLegacy{
LargestObserved: 333,
Entropy: 17,
},
}
rstStreamFrame = &frames.RstStreamFrame{
StreamID: 555,
ErrorCode: 1337,
}
stopWaitingFrame = &frames.StopWaitingFrame{
LeastUnacked: 7331,
Entropy: 10,
}
windowUpdateFrame = &frames.WindowUpdateFrame{
StreamID: 999,
}
packet = Packet{
PacketNumber: 1337,
Frames: []frames.Frame{windowUpdateFrame, streamFrame1, ackFrame1, streamFrame2, rstStreamFrame, ackFrame2, stopWaitingFrame},
}
})
It("gets all StreamFrames", func() {
streamFrames := packet.GetStreamFramesForRetransmission()
Expect(streamFrames).To(HaveLen(2))
Expect(streamFrames).To(ContainElement(streamFrame1))
Expect(streamFrames).To(ContainElement(streamFrame2))
})
It("gets all control frames", func() {
controlFrames := packet.GetControlFramesForRetransmission()
Expect(controlFrames).To(HaveLen(2))
Expect(controlFrames).To(ContainElement(rstStreamFrame))
Expect(controlFrames).To(ContainElement(windowUpdateFrame))
})
It("does not return any ACK frames", func() {
controlFrames := packet.GetControlFramesForRetransmission()
Expect(controlFrames).ToNot(ContainElement(ackFrame1))
Expect(controlFrames).ToNot(ContainElement(ackFrame2))
})
It("does not return any ACK frames", func() {
controlFrames := packet.GetControlFramesForRetransmission()
Expect(controlFrames).ToNot(ContainElement(stopWaitingFrame))
})
It("returns an empty slice of StreamFrames if no StreamFrames are queued", func() {
// overwrite the globally defined packet here
packet := Packet{
PacketNumber: 1337,
Frames: []frames.Frame{ackFrame1, rstStreamFrame},
}
streamFrames := packet.GetStreamFramesForRetransmission()
Expect(streamFrames).To(BeEmpty())
})
It("returns an empty slice of control frames if no applicable control frames are queued", func() {
// overwrite the globally defined packet here
packet := Packet{
PacketNumber: 1337,
Frames: []frames.Frame{streamFrame1, ackFrame1, stopWaitingFrame},
}
controlFrames := packet.GetControlFramesForRetransmission()
Expect(controlFrames).To(BeEmpty())
})
})
})

View file

@ -5,7 +5,6 @@ import (
"fmt" "fmt"
"time" "time"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/congestion" "github.com/lucas-clemente/quic-go/congestion"
"github.com/lucas-clemente/quic-go/frames" "github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/protocol" "github.com/lucas-clemente/quic-go/protocol"
@ -34,10 +33,10 @@ type sentPacketHandler struct {
largestReceivedPacketWithAck protocol.PacketNumber largestReceivedPacketWithAck protocol.PacketNumber
packetHistory *ackhandlerlegacy.PacketList packetHistory *PacketList
stopWaitingManager stopWaitingManager stopWaitingManager stopWaitingManager
retransmissionQueue []*ackhandlerlegacy.Packet retransmissionQueue []*Packet
bytesInFlight protocol.ByteCount bytesInFlight protocol.ByteCount
@ -58,14 +57,14 @@ func NewSentPacketHandler() SentPacketHandler {
) )
return &sentPacketHandler{ return &sentPacketHandler{
packetHistory: ackhandlerlegacy.NewPacketList(), packetHistory: NewPacketList(),
stopWaitingManager: stopWaitingManager{}, stopWaitingManager: stopWaitingManager{},
rttStats: rttStats, rttStats: rttStats,
congestion: congestion, congestion: congestion,
} }
} }
func (h *sentPacketHandler) ackPacket(packetElement *ackhandlerlegacy.PacketElement) { func (h *sentPacketHandler) ackPacket(packetElement *PacketElement) {
packet := &packetElement.Value packet := &packetElement.Value
h.bytesInFlight -= packet.Length h.bytesInFlight -= packet.Length
h.packetHistory.Remove(packetElement) h.packetHistory.Remove(packetElement)
@ -73,7 +72,7 @@ func (h *sentPacketHandler) ackPacket(packetElement *ackhandlerlegacy.PacketElem
// nackPacket NACKs a packet // nackPacket NACKs a packet
// it returns true if a FastRetransmissions was triggered // it returns true if a FastRetransmissions was triggered
func (h *sentPacketHandler) nackPacket(packetElement *ackhandlerlegacy.PacketElement) bool { func (h *sentPacketHandler) nackPacket(packetElement *PacketElement) bool {
packet := &packetElement.Value packet := &packetElement.Value
packet.MissingReports++ packet.MissingReports++
@ -87,7 +86,7 @@ func (h *sentPacketHandler) nackPacket(packetElement *ackhandlerlegacy.PacketEle
} }
// does NOT set packet.Retransmitted. This variable is not needed anymore // does NOT set packet.Retransmitted. This variable is not needed anymore
func (h *sentPacketHandler) queuePacketForRetransmission(packetElement *ackhandlerlegacy.PacketElement) { func (h *sentPacketHandler) queuePacketForRetransmission(packetElement *PacketElement) {
packet := &packetElement.Value packet := &packetElement.Value
h.bytesInFlight -= packet.Length h.bytesInFlight -= packet.Length
h.retransmissionQueue = append(h.retransmissionQueue, packet) h.retransmissionQueue = append(h.retransmissionQueue, packet)
@ -106,7 +105,7 @@ func (h *sentPacketHandler) largestInOrderAcked() protocol.PacketNumber {
return h.LargestAcked return h.LargestAcked
} }
func (h *sentPacketHandler) SentPacket(packet *ackhandlerlegacy.Packet) error { func (h *sentPacketHandler) SentPacket(packet *Packet) error {
if packet.PacketNumber <= h.lastSentPacketNumber { if packet.PacketNumber <= h.lastSentPacketNumber {
return errPacketNumberNotIncreasing return errPacketNumberNotIncreasing
} }
@ -171,7 +170,7 @@ func (h *sentPacketHandler) ReceivedAck(ackFrame *frames.AckFrame, withPacketNum
var lostPackets congestion.PacketVector var lostPackets congestion.PacketVector
ackRangeIndex := 0 ackRangeIndex := 0
var el, elNext *ackhandlerlegacy.PacketElement var el, elNext *PacketElement
for el = h.packetHistory.Front(); el != nil; el = elNext { for el = h.packetHistory.Front(); el != nil; el = elNext {
// determine the next list element right at the beginning, because el.Next() is not avaible anymore, when the list element is deleted (i.e. when the packet is ACKed) // determine the next list element right at the beginning, because el.Next() is not avaible anymore, when the list element is deleted (i.e. when the packet is ACKed)
elNext = el.Next() elNext = el.Next()
@ -241,7 +240,7 @@ func (h *sentPacketHandler) ReceivedAck(ackFrame *frames.AckFrame, withPacketNum
return nil return nil
} }
func (h *sentPacketHandler) DequeuePacketForRetransmission() *ackhandlerlegacy.Packet { func (h *sentPacketHandler) DequeuePacketForRetransmission() *Packet {
if len(h.retransmissionQueue) == 0 { if len(h.retransmissionQueue) == 0 {
return nil return nil
} }

View file

@ -3,7 +3,6 @@ package ackhandler
import ( import (
"time" "time"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/congestion" "github.com/lucas-clemente/quic-go/congestion"
"github.com/lucas-clemente/quic-go/frames" "github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/protocol" "github.com/lucas-clemente/quic-go/protocol"
@ -65,7 +64,7 @@ var _ = Describe("SentPacketHandler", func() {
} }
}) })
getPacketElement := func(p protocol.PacketNumber) *ackhandlerlegacy.PacketElement { getPacketElement := func(p protocol.PacketNumber) *PacketElement {
for el := handler.packetHistory.Front(); el != nil; el = el.Next() { for el := handler.packetHistory.Front(); el != nil; el = el.Next() {
if el.Value.PacketNumber == p { if el.Value.PacketNumber == p {
return el return el
@ -81,8 +80,8 @@ var _ = Describe("SentPacketHandler", func() {
Context("registering sent packets", func() { Context("registering sent packets", func() {
It("accepts two consecutive packets", func() { It("accepts two consecutive packets", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 2}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -95,8 +94,8 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("rejects packets with the same packet number", func() { It("rejects packets with the same packet number", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 2}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -108,8 +107,8 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("rejects packets with decreasing packet number", func() { It("rejects packets with decreasing packet number", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 2}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -120,14 +119,14 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("stores the sent time", func() { It("stores the sent time", func() {
packet := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
err := handler.SentPacket(&packet) err := handler.SentPacket(&packet)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(handler.packetHistory.Front().Value.SendTime.Unix()).To(BeNumerically("~", time.Now().Unix(), 1)) Expect(handler.packetHistory.Front().Value.SendTime.Unix()).To(BeNumerically("~", time.Now().Unix(), 1))
}) })
It("updates the last sent time", func() { It("updates the last sent time", func() {
packet := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
err := handler.SentPacket(&packet) err := handler.SentPacket(&packet)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
Expect(handler.lastSentPacketTime.Unix()).To(BeNumerically("~", time.Now().Unix(), 1)) Expect(handler.lastSentPacketTime.Unix()).To(BeNumerically("~", time.Now().Unix(), 1))
@ -135,8 +134,8 @@ var _ = Describe("SentPacketHandler", func() {
Context("skipped packet numbers", func() { Context("skipped packet numbers", func() {
It("works with non-consecutive packet numbers", func() { It("works with non-consecutive packet numbers", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 2}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -152,9 +151,9 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("recognizes multiple skipped packets", func() { It("recognizes multiple skipped packets", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 2}
packet3 := ackhandlerlegacy.Packet{PacketNumber: 5, Frames: []frames.Frame{&streamFrame}, Length: 2} packet3 := Packet{PacketNumber: 5, Frames: []frames.Frame{&streamFrame}, Length: 2}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -166,8 +165,8 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("recognizes multiple consecutive skipped packets", func() { It("recognizes multiple consecutive skipped packets", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 4, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 4, Frames: []frames.Frame{&streamFrame}, Length: 2}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -178,7 +177,7 @@ var _ = Describe("SentPacketHandler", func() {
It("limits the lengths of the skipped packet slice", func() { It("limits the lengths of the skipped packet slice", func() {
for i := 0; i < protocol.MaxTrackedSkippedPackets+5; i++ { for i := 0; i < protocol.MaxTrackedSkippedPackets+5; i++ {
packet := ackhandlerlegacy.Packet{PacketNumber: protocol.PacketNumber(2*i + 1), Frames: []frames.Frame{&streamFrame}, Length: 1} packet := Packet{PacketNumber: protocol.PacketNumber(2*i + 1), Frames: []frames.Frame{&streamFrame}, Length: 1}
err := handler.SentPacket(&packet) err := handler.SentPacket(&packet)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }
@ -215,7 +214,7 @@ var _ = Describe("SentPacketHandler", func() {
Context("DOS mitigation", func() { Context("DOS mitigation", func() {
It("checks the size of the packet history, for unacked packets", func() { It("checks the size of the packet history, for unacked packets", func() {
for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ { for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ {
packet := ackhandlerlegacy.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1} packet := Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1}
err := handler.SentPacket(&packet) err := handler.SentPacket(&packet)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }
@ -227,10 +226,10 @@ var _ = Describe("SentPacketHandler", func() {
}) })
Context("ACK processing", func() { Context("ACK processing", func() {
var packets []*ackhandlerlegacy.Packet var packets []*Packet
BeforeEach(func() { BeforeEach(func() {
packets = []*ackhandlerlegacy.Packet{ packets = []*Packet{
{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}, {PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1},
{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 1}, {PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 1},
{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 1}, {PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 1},
@ -537,10 +536,10 @@ var _ = Describe("SentPacketHandler", func() {
}) })
Context("Retransmission handler", func() { Context("Retransmission handler", func() {
var packets []*ackhandlerlegacy.Packet var packets []*Packet
BeforeEach(func() { BeforeEach(func() {
packets = []*ackhandlerlegacy.Packet{ packets = []*Packet{
{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}, {PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1},
{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 1}, {PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 1},
{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 1}, {PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 1},
@ -626,9 +625,9 @@ var _ = Describe("SentPacketHandler", func() {
Context("calculating bytes in flight", func() { Context("calculating bytes in flight", func() {
It("works in a typical retransmission scenarios", func() { It("works in a typical retransmission scenarios", func() {
packet1 := ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1} packet1 := Packet{PacketNumber: 1, Frames: []frames.Frame{&streamFrame}, Length: 1}
packet2 := ackhandlerlegacy.Packet{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 2} packet2 := Packet{PacketNumber: 2, Frames: []frames.Frame{&streamFrame}, Length: 2}
packet3 := ackhandlerlegacy.Packet{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 3} packet3 := Packet{PacketNumber: 3, Frames: []frames.Frame{&streamFrame}, Length: 3}
err := handler.SentPacket(&packet1) err := handler.SentPacket(&packet1)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
err = handler.SentPacket(&packet2) err = handler.SentPacket(&packet2)
@ -659,7 +658,7 @@ var _ = Describe("SentPacketHandler", func() {
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(0))) Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(0)))
// Retransmission // Retransmission
packet4 := ackhandlerlegacy.Packet{PacketNumber: 4, Length: 2} packet4 := Packet{PacketNumber: 4, Length: 2}
err = handler.SentPacket(&packet4) err = handler.SentPacket(&packet4)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(2))) Expect(handler.BytesInFlight()).To(Equal(protocol.ByteCount(2)))
@ -686,7 +685,7 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("should call OnSent", func() { It("should call OnSent", func() {
p := &ackhandlerlegacy.Packet{ p := &Packet{
PacketNumber: 1, PacketNumber: 1,
Frames: []frames.Frame{&frames.StreamFrame{StreamID: 5}}, Frames: []frames.Frame{&frames.StreamFrame{StreamID: 5}},
Length: 42, Length: 42,
@ -701,9 +700,9 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("should call OnCongestionEvent", func() { It("should call OnCongestionEvent", func() {
handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1}) handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1})
handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 2, Frames: []frames.Frame{}, Length: 2}) handler.SentPacket(&Packet{PacketNumber: 2, Frames: []frames.Frame{}, Length: 2})
handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 3, Frames: []frames.Frame{}, Length: 3}) handler.SentPacket(&Packet{PacketNumber: 3, Frames: []frames.Frame{}, Length: 3})
ack := frames.AckFrame{ ack := frames.AckFrame{
LargestAcked: 3, LargestAcked: 3,
LowestAcked: 1, LowestAcked: 1,
@ -725,7 +724,7 @@ var _ = Describe("SentPacketHandler", func() {
var packetNumber protocol.PacketNumber var packetNumber protocol.PacketNumber
for i := uint8(0); i < protocol.RetransmissionThreshold; i++ { for i := uint8(0); i < protocol.RetransmissionThreshold; i++ {
packetNumber = protocol.PacketNumber(4 + i) packetNumber = protocol.PacketNumber(4 + i)
handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: packetNumber, Frames: []frames.Frame{}, Length: protocol.ByteCount(packetNumber)}) handler.SentPacket(&Packet{PacketNumber: packetNumber, Frames: []frames.Frame{}, Length: protocol.ByteCount(packetNumber)})
ack := frames.AckFrame{ ack := frames.AckFrame{
LargestAcked: packetNumber, LargestAcked: packetNumber,
LowestAcked: 1, LowestAcked: 1,
@ -744,13 +743,13 @@ var _ = Describe("SentPacketHandler", func() {
It("allows or denies sending", func() { It("allows or denies sending", func() {
Expect(handler.CongestionAllowsSending()).To(BeTrue()) Expect(handler.CongestionAllowsSending()).To(BeTrue())
err := handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: protocol.DefaultTCPMSS + 1}) err := handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: protocol.DefaultTCPMSS + 1})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(handler.CongestionAllowsSending()).To(BeFalse()) Expect(handler.CongestionAllowsSending()).To(BeFalse())
}) })
It("should call OnRetransmissionTimeout", func() { It("should call OnRetransmissionTimeout", func() {
err := handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1}) err := handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
handler.lastSentPacketTime = time.Now().Add(-time.Second) handler.lastSentPacketTime = time.Now().Add(-time.Second)
handler.MaybeQueueRTOs() handler.MaybeQueueRTOs()
@ -790,7 +789,7 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("returns time to RTO", func() { It("returns time to RTO", func() {
err := handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1}) err := handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
Expect(handler.TimeOfFirstRTO().Sub(time.Now())).To(BeNumerically("~", protocol.DefaultRetransmissionTime, time.Millisecond)) Expect(handler.TimeOfFirstRTO().Sub(time.Now())).To(BeNumerically("~", protocol.DefaultRetransmissionTime, time.Millisecond))
}) })
@ -798,14 +797,14 @@ var _ = Describe("SentPacketHandler", func() {
Context("queuing packets due to RTO", func() { Context("queuing packets due to RTO", func() {
It("does nothing if not required", func() { It("does nothing if not required", func() {
err := handler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1}) err := handler.SentPacket(&Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
handler.MaybeQueueRTOs() handler.MaybeQueueRTOs()
Expect(handler.retransmissionQueue).To(BeEmpty()) Expect(handler.retransmissionQueue).To(BeEmpty())
}) })
It("queues a packet if RTO expired", func() { It("queues a packet if RTO expired", func() {
p := &ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1} p := &Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1}
err := handler.SentPacket(p) err := handler.SentPacket(p)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
handler.lastSentPacketTime = time.Now().Add(-time.Second) handler.lastSentPacketTime = time.Now().Add(-time.Second)
@ -817,7 +816,7 @@ var _ = Describe("SentPacketHandler", func() {
}) })
It("works with DequeuePacketForRetransmission", func() { It("works with DequeuePacketForRetransmission", func() {
p := &ackhandlerlegacy.Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1} p := &Packet{PacketNumber: 1, Frames: []frames.Frame{}, Length: 1}
err := handler.SentPacket(p) err := handler.SentPacket(p)
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
handler.lastSentPacketTime = time.Now().Add(-time.Second) handler.lastSentPacketTime = time.Now().Add(-time.Second)

View file

@ -1,7 +1,7 @@
coverage: coverage:
round: nearest round: nearest
ignore: ignore:
- ackhandlerlegacy/packet_linkedlist.go - ackhandler/packet_linkedlist.go
- utils/byteinterval_linkedlist.go - utils/byteinterval_linkedlist.go
- utils/packetinterval_linkedlist.go - utils/packetinterval_linkedlist.go
status: status:

View file

@ -9,7 +9,6 @@ import (
"time" "time"
"github.com/lucas-clemente/quic-go/ackhandler" "github.com/lucas-clemente/quic-go/ackhandler"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy"
"github.com/lucas-clemente/quic-go/flowcontrol" "github.com/lucas-clemente/quic-go/flowcontrol"
"github.com/lucas-clemente/quic-go/frames" "github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake" "github.com/lucas-clemente/quic-go/handshake"
@ -256,12 +255,12 @@ func (s *Session) handlePacketImpl(remoteAddr interface{}, hdr *PublicHeader, da
err = s.receivedPacketHandler.ReceivedPacket(hdr.PacketNumber, packet.entropyBit) err = s.receivedPacketHandler.ReceivedPacket(hdr.PacketNumber, packet.entropyBit)
// ignore duplicate packets // ignore duplicate packets
if err == ackhandlerlegacy.ErrDuplicatePacket || err == ackhandler.ErrDuplicatePacket { if err == ackhandler.ErrDuplicatePacket {
utils.Infof("Ignoring packet 0x%x due to ErrDuplicatePacket", hdr.PacketNumber) utils.Infof("Ignoring packet 0x%x due to ErrDuplicatePacket", hdr.PacketNumber)
return nil return nil
} }
// ignore packets with packet numbers smaller than the LeastUnacked of a StopWaiting // ignore packets with packet numbers smaller than the LeastUnacked of a StopWaiting
if err == ackhandlerlegacy.ErrPacketSmallerThanLastStopWaiting || err == ackhandler.ErrPacketSmallerThanLastStopWaiting { if err == ackhandler.ErrPacketSmallerThanLastStopWaiting {
utils.Infof("Ignoring packet 0x%x due to ErrPacketSmallerThanLastStopWaiting", hdr.PacketNumber) utils.Infof("Ignoring packet 0x%x due to ErrPacketSmallerThanLastStopWaiting", hdr.PacketNumber)
return nil return nil
} }
@ -301,8 +300,6 @@ func (s *Session) handleFrames(fs []frames.Frame) error {
if err != nil { if err != nil {
switch err { switch err {
case ackhandlerlegacy.ErrDuplicateOrOutOfOrderAck:
// Can happen e.g. when packets thought missing arrive late
case ackhandler.ErrDuplicateOrOutOfOrderAck: case ackhandler.ErrDuplicateOrOutOfOrderAck:
// Can happen e.g. when packets thought missing arrive late // Can happen e.g. when packets thought missing arrive late
case errRstStreamOnInvalidStream: case errRstStreamOnInvalidStream:
@ -517,10 +514,9 @@ func (s *Session) sendPacket() error {
s.packer.QueueControlFrameForNextPacket(f) s.packer.QueueControlFrameForNextPacket(f)
} }
err = s.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{ err = s.sentPacketHandler.SentPacket(&ackhandler.Packet{
PacketNumber: packet.number, PacketNumber: packet.number,
Frames: packet.frames, Frames: packet.frames,
EntropyBit: packet.entropyBit,
Length: protocol.ByteCount(len(packet.raw)), Length: protocol.ByteCount(len(packet.raw)),
}) })
if err != nil { if err != nil {

View file

@ -14,7 +14,7 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/lucas-clemente/quic-go/ackhandlerlegacy" "github.com/lucas-clemente/quic-go/ackhandler"
"github.com/lucas-clemente/quic-go/crypto" "github.com/lucas-clemente/quic-go/crypto"
"github.com/lucas-clemente/quic-go/frames" "github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake" "github.com/lucas-clemente/quic-go/handshake"
@ -48,14 +48,14 @@ func (m *mockUnpacker) Unpack(publicHeaderBinary []byte, hdr *PublicHeader, data
} }
type mockSentPacketHandler struct { type mockSentPacketHandler struct {
retransmissionQueue []*ackhandlerlegacy.Packet retransmissionQueue []*ackhandler.Packet
sentPackets []*ackhandlerlegacy.Packet sentPackets []*ackhandler.Packet
congestionLimited bool congestionLimited bool
maybeQueueRTOsCalled bool maybeQueueRTOsCalled bool
requestedStopWaiting bool requestedStopWaiting bool
} }
func (h *mockSentPacketHandler) SentPacket(packet *ackhandlerlegacy.Packet) error { func (h *mockSentPacketHandler) SentPacket(packet *ackhandler.Packet) error {
h.sentPackets = append(h.sentPackets, packet) h.sentPackets = append(h.sentPackets, packet)
return nil return nil
} }
@ -76,7 +76,7 @@ func (h *mockSentPacketHandler) MaybeQueueRTOs() {
h.maybeQueueRTOsCalled = true h.maybeQueueRTOsCalled = true
} }
func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandlerlegacy.Packet { func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandler.Packet {
if len(h.retransmissionQueue) > 0 { if len(h.retransmissionQueue) > 0 {
packet := h.retransmissionQueue[0] packet := h.retransmissionQueue[0]
h.retransmissionQueue = h.retransmissionQueue[1:] h.retransmissionQueue = h.retransmissionQueue[1:]
@ -85,7 +85,7 @@ func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandlerlega
return nil return nil
} }
func newMockSentPacketHandler() ackhandlerlegacy.SentPacketHandler { func newMockSentPacketHandler() ackhandler.SentPacketHandler {
return &mockSentPacketHandler{} return &mockSentPacketHandler{}
} }
@ -542,12 +542,12 @@ var _ = Describe("Session", func() {
StreamID: 0x5, StreamID: 0x5,
Data: []byte("foobar1234567"), Data: []byte("foobar1234567"),
} }
p := ackhandlerlegacy.Packet{ p := ackhandler.Packet{
PacketNumber: 0x1337, PacketNumber: 0x1337,
Frames: []frames.Frame{&f}, Frames: []frames.Frame{&f},
} }
sph := newMockSentPacketHandler() sph := newMockSentPacketHandler()
sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandlerlegacy.Packet{&p} sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandler.Packet{&p}
session.sentPacketHandler = sph session.sentPacketHandler = sph
err := session.sendPacket() err := session.sendPacket()
@ -574,16 +574,16 @@ var _ = Describe("Session", func() {
StreamID: 0x7, StreamID: 0x7,
Data: []byte("loremipsum"), Data: []byte("loremipsum"),
} }
p1 := ackhandlerlegacy.Packet{ p1 := ackhandler.Packet{
PacketNumber: 0x1337, PacketNumber: 0x1337,
Frames: []frames.Frame{&f1}, Frames: []frames.Frame{&f1},
} }
p2 := ackhandlerlegacy.Packet{ p2 := ackhandler.Packet{
PacketNumber: 0x1338, PacketNumber: 0x1338,
Frames: []frames.Frame{&f2}, Frames: []frames.Frame{&f2},
} }
sph := newMockSentPacketHandler() sph := newMockSentPacketHandler()
sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandlerlegacy.Packet{&p1, &p2} sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandler.Packet{&p1, &p2}
session.sentPacketHandler = sph session.sentPacketHandler = sph
err := session.sendPacket() err := session.sendPacket()
@ -773,13 +773,13 @@ var _ = Describe("Session", func() {
It("errors when the SentPacketHandler has too many packets tracked", func() { It("errors when the SentPacketHandler has too many packets tracked", func() {
streamFrame := frames.StreamFrame{StreamID: 5, Data: []byte("foobar")} streamFrame := frames.StreamFrame{StreamID: 5, Data: []byte("foobar")}
for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ { for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ {
packet := ackhandlerlegacy.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1} packet := ackhandler.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1}
err := session.sentPacketHandler.SentPacket(&packet) err := session.sentPacketHandler.SentPacket(&packet)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
} }
// now session.sentPacketHandler.CheckForError will return an error // now session.sentPacketHandler.CheckForError will return an error
err := session.sendPacket() err := session.sendPacket()
Expect(err).To(MatchError(ackhandlerlegacy.ErrTooManyTrackedSentPackets)) Expect(err).To(MatchError(ackhandler.ErrTooManyTrackedSentPackets))
}) })
It("stores up to MaxSessionUnprocessedPackets packets", func(done Done) { It("stores up to MaxSessionUnprocessedPackets packets", func(done Done) {
@ -794,7 +794,7 @@ var _ = Describe("Session", func() {
// We simulate consistently low RTTs, so that the test works faster // We simulate consistently low RTTs, so that the test works faster
n := protocol.PacketNumber(10) n := protocol.PacketNumber(10)
for p := protocol.PacketNumber(1); p < n; p++ { for p := protocol.PacketNumber(1); p < n; p++ {
err := session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{PacketNumber: p, Length: 1}) err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{PacketNumber: p, Length: 1})
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
time.Sleep(time.Microsecond) time.Sleep(time.Microsecond)
ack := &frames.AckFrame{} ack := &frames.AckFrame{}
@ -804,7 +804,7 @@ var _ = Describe("Session", func() {
} }
session.packer.packetNumberGenerator.next = n + 1 session.packer.packetNumberGenerator.next = n + 1
// Now, we send a single packet, and expect that it was retransmitted later // Now, we send a single packet, and expect that it was retransmitted later
err := session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{ err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{
PacketNumber: n, PacketNumber: n,
Length: 1, Length: 1,
Frames: []frames.Frame{&frames.StreamFrame{ Frames: []frames.Frame{&frames.StreamFrame{
@ -845,7 +845,7 @@ var _ = Describe("Session", func() {
Context("ignoring errors", func() { Context("ignoring errors", func() {
It("ignores duplicate acks", func() { It("ignores duplicate acks", func() {
session.sentPacketHandler.SentPacket(&ackhandlerlegacy.Packet{ session.sentPacketHandler.SentPacket(&ackhandler.Packet{
PacketNumber: 1, PacketNumber: 1,
Length: 1, Length: 1,
}) })