mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
use ackhandler.Frame directly, not as a pointer, remove its sync.Pool (#3835)
This commit is contained in:
parent
f8d24ef1e9
commit
0438eada95
12 changed files with 74 additions and 103 deletions
|
@ -1988,7 +1988,7 @@ func (s *connection) logLongHeaderPacket(p *longHeaderPacket) {
|
||||||
func (s *connection) logShortHeaderPacket(
|
func (s *connection) logShortHeaderPacket(
|
||||||
destConnID protocol.ConnectionID,
|
destConnID protocol.ConnectionID,
|
||||||
ackFrame *wire.AckFrame,
|
ackFrame *wire.AckFrame,
|
||||||
frames []*ackhandler.Frame,
|
frames []ackhandler.Frame,
|
||||||
streamFrames []ackhandler.StreamFrame,
|
streamFrames []ackhandler.StreamFrame,
|
||||||
pn protocol.PacketNumber,
|
pn protocol.PacketNumber,
|
||||||
pnLen protocol.PacketNumberLen,
|
pnLen protocol.PacketNumberLen,
|
||||||
|
|
|
@ -310,7 +310,7 @@ var _ = Describe("Connection", func() {
|
||||||
err := conn.handleFrame(&wire.PathChallengeFrame{Data: data}, protocol.Encryption1RTT, protocol.ConnectionID{})
|
err := conn.handleFrame(&wire.PathChallengeFrame{Data: data}, protocol.Encryption1RTT, protocol.ConnectionID{})
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
frames, _ := conn.framer.AppendControlFrames(nil, 1000, protocol.Version1)
|
frames, _ := conn.framer.AppendControlFrames(nil, 1000, protocol.Version1)
|
||||||
Expect(frames).To(Equal([]*ackhandler.Frame{{Frame: &wire.PathResponseFrame{Data: data}}}))
|
Expect(frames).To(Equal([]ackhandler.Frame{{Frame: &wire.PathResponseFrame{Data: data}}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects NEW_TOKEN frames", func() {
|
It("rejects NEW_TOKEN frames", func() {
|
||||||
|
@ -1271,7 +1271,7 @@ var _ = Describe("Connection", func() {
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
Eventually(sent).Should(BeClosed())
|
Eventually(sent).Should(BeClosed())
|
||||||
frames, _ := conn.framer.AppendControlFrames(nil, 1000, protocol.Version1)
|
frames, _ := conn.framer.AppendControlFrames(nil, 1000, protocol.Version1)
|
||||||
Expect(frames).To(Equal([]*ackhandler.Frame{{Frame: &logging.DataBlockedFrame{MaximumData: 1337}}}))
|
Expect(frames).To(Equal([]ackhandler.Frame{{Frame: &logging.DataBlockedFrame{MaximumData: 1337}}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("doesn't send when the SentPacketHandler doesn't allow it", func() {
|
It("doesn't send when the SentPacketHandler doesn't allow it", func() {
|
||||||
|
@ -1868,8 +1868,8 @@ var _ = Describe("Connection", func() {
|
||||||
handshakeCtx := conn.HandshakeComplete()
|
handshakeCtx := conn.HandshakeComplete()
|
||||||
Consistently(handshakeCtx).ShouldNot(BeClosed())
|
Consistently(handshakeCtx).ShouldNot(BeClosed())
|
||||||
close(finishHandshake)
|
close(finishHandshake)
|
||||||
var frames []*ackhandler.Frame
|
var frames []ackhandler.Frame
|
||||||
Eventually(func() []*ackhandler.Frame {
|
Eventually(func() []ackhandler.Frame {
|
||||||
frames, _ = conn.framer.AppendControlFrames(nil, protocol.MaxByteCount, protocol.Version1)
|
frames, _ = conn.framer.AppendControlFrames(nil, protocol.MaxByteCount, protocol.Version1)
|
||||||
return frames
|
return frames
|
||||||
}).ShouldNot(BeEmpty())
|
}).ShouldNot(BeEmpty())
|
||||||
|
@ -1879,7 +1879,7 @@ var _ = Describe("Connection", func() {
|
||||||
if cf, ok := f.Frame.(*wire.CryptoFrame); ok {
|
if cf, ok := f.Frame.(*wire.CryptoFrame); ok {
|
||||||
count++
|
count++
|
||||||
s += len(cf.Data)
|
s += len(cf.Data)
|
||||||
Expect(f.Length(conn.version)).To(BeNumerically("<=", protocol.MaxPostHandshakeCryptoFrameSize))
|
Expect(f.Frame.Length(conn.version)).To(BeNumerically("<=", protocol.MaxPostHandshakeCryptoFrameSize))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Expect(size).To(BeEquivalentTo(s))
|
Expect(size).To(BeEquivalentTo(s))
|
||||||
|
|
|
@ -15,7 +15,7 @@ type framer interface {
|
||||||
HasData() bool
|
HasData() bool
|
||||||
|
|
||||||
QueueControlFrame(wire.Frame)
|
QueueControlFrame(wire.Frame)
|
||||||
AppendControlFrames([]*ackhandler.Frame, protocol.ByteCount, protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount)
|
AppendControlFrames([]ackhandler.Frame, protocol.ByteCount, protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount)
|
||||||
|
|
||||||
AddActiveStream(protocol.StreamID)
|
AddActiveStream(protocol.StreamID)
|
||||||
AppendStreamFrames([]ackhandler.StreamFrame, protocol.ByteCount, protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount)
|
AppendStreamFrames([]ackhandler.StreamFrame, protocol.ByteCount, protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount)
|
||||||
|
@ -63,7 +63,7 @@ func (f *framerI) QueueControlFrame(frame wire.Frame) {
|
||||||
f.controlFrameMutex.Unlock()
|
f.controlFrameMutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *framerI) AppendControlFrames(frames []*ackhandler.Frame, maxLen protocol.ByteCount, v protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
func (f *framerI) AppendControlFrames(frames []ackhandler.Frame, maxLen protocol.ByteCount, v protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
var length protocol.ByteCount
|
var length protocol.ByteCount
|
||||||
f.controlFrameMutex.Lock()
|
f.controlFrameMutex.Lock()
|
||||||
for len(f.controlFrames) > 0 {
|
for len(f.controlFrames) > 0 {
|
||||||
|
@ -72,9 +72,7 @@ func (f *framerI) AppendControlFrames(frames []*ackhandler.Frame, maxLen protoco
|
||||||
if length+frameLen > maxLen {
|
if length+frameLen > maxLen {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
af := ackhandler.GetFrame()
|
frames = append(frames, ackhandler.Frame{Frame: frame})
|
||||||
af.Frame = frame
|
|
||||||
frames = append(frames, af)
|
|
||||||
length += frameLen
|
length += frameLen
|
||||||
f.controlFrames = f.controlFrames[:len(f.controlFrames)-1]
|
f.controlFrames = f.controlFrames[:len(f.controlFrames)-1]
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ var _ = Describe("Framer", func() {
|
||||||
ping := &wire.PingFrame{}
|
ping := &wire.PingFrame{}
|
||||||
mdf := &wire.MaxDataFrame{MaximumData: 0x42}
|
mdf := &wire.MaxDataFrame{MaximumData: 0x42}
|
||||||
framer.QueueControlFrame(mdf)
|
framer.QueueControlFrame(mdf)
|
||||||
frames, length := framer.AppendControlFrames([]*ackhandler.Frame{{Frame: ping}}, 1000, protocol.Version1)
|
frames, length := framer.AppendControlFrames([]ackhandler.Frame{{Frame: ping}}, 1000, protocol.Version1)
|
||||||
Expect(frames).To(HaveLen(2))
|
Expect(frames).To(HaveLen(2))
|
||||||
Expect(frames[0].Frame).To(Equal(ping))
|
Expect(frames[0].Frame).To(Equal(ping))
|
||||||
Expect(frames[1].Frame).To(Equal(mdf))
|
Expect(frames[1].Frame).To(Equal(mdf))
|
||||||
|
|
|
@ -10,7 +10,7 @@ func IsFrameAckEliciting(f wire.Frame) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasAckElicitingFrames returns true if at least one frame is ack-eliciting.
|
// HasAckElicitingFrames returns true if at least one frame is ack-eliciting.
|
||||||
func HasAckElicitingFrames(fs []*Frame) bool {
|
func HasAckElicitingFrames(fs []Frame) bool {
|
||||||
for _, f := range fs {
|
for _, f := range fs {
|
||||||
if IsFrameAckEliciting(f.Frame) {
|
if IsFrameAckEliciting(f.Frame) {
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -29,7 +29,7 @@ var _ = Describe("ack-eliciting frames", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("HasAckElicitingFrames works for "+fName, func() {
|
It("HasAckElicitingFrames works for "+fName, func() {
|
||||||
Expect(HasAckElicitingFrames([]*Frame{{Frame: f}})).To(Equal(e))
|
Expect(HasAckElicitingFrames([]Frame{{Frame: f}})).To(Equal(e))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,31 +1,13 @@
|
||||||
package ackhandler
|
package ackhandler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/quic-go/quic-go/internal/wire"
|
"github.com/quic-go/quic-go/internal/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Frame struct {
|
type Frame struct {
|
||||||
wire.Frame // nil if the frame has already been acknowledged in another packet
|
Frame wire.Frame // nil if the frame has already been acknowledged in another packet
|
||||||
OnLost func(wire.Frame)
|
OnLost func(wire.Frame)
|
||||||
OnAcked func(wire.Frame)
|
OnAcked func(wire.Frame)
|
||||||
}
|
|
||||||
|
|
||||||
var framePool = sync.Pool{New: func() any { return &Frame{} }}
|
|
||||||
|
|
||||||
func GetFrame() *Frame {
|
|
||||||
f := framePool.Get().(*Frame)
|
|
||||||
f.OnLost = nil
|
|
||||||
f.OnAcked = nil
|
|
||||||
return f
|
|
||||||
}
|
|
||||||
|
|
||||||
func putFrame(f *Frame) {
|
|
||||||
f.Frame = nil
|
|
||||||
f.OnLost = nil
|
|
||||||
f.OnAcked = nil
|
|
||||||
framePool.Put(f)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StreamFrame struct {
|
type StreamFrame struct {
|
||||||
|
|
|
@ -12,7 +12,7 @@ type Packet struct {
|
||||||
SendTime time.Time
|
SendTime time.Time
|
||||||
PacketNumber protocol.PacketNumber
|
PacketNumber protocol.PacketNumber
|
||||||
StreamFrames []StreamFrame
|
StreamFrames []StreamFrame
|
||||||
Frames []*Frame
|
Frames []Frame
|
||||||
LargestAcked protocol.PacketNumber // InvalidPacketNumber if the packet doesn't contain an ACK
|
LargestAcked protocol.PacketNumber // InvalidPacketNumber if the packet doesn't contain an ACK
|
||||||
Length protocol.ByteCount
|
Length protocol.ByteCount
|
||||||
EncryptionLevel protocol.EncryptionLevel
|
EncryptionLevel protocol.EncryptionLevel
|
||||||
|
@ -49,9 +49,6 @@ func GetPacket() *Packet {
|
||||||
// We currently only return Packets back into the pool when they're acknowledged (not when they're lost).
|
// We currently only return Packets back into the pool when they're acknowledged (not when they're lost).
|
||||||
// This simplifies the code, and gives the vast majority of the performance benefit we can gain from using the pool.
|
// This simplifies the code, and gives the vast majority of the performance benefit we can gain from using the pool.
|
||||||
func putPacket(p *Packet) {
|
func putPacket(p *Packet) {
|
||||||
for _, f := range p.Frames {
|
|
||||||
putFrame(f)
|
|
||||||
}
|
|
||||||
p.Frames = nil
|
p.Frames = nil
|
||||||
p.StreamFrames = nil
|
p.StreamFrames = nil
|
||||||
packetPool.Put(p)
|
packetPool.Put(p)
|
||||||
|
|
|
@ -54,7 +54,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
p.SendTime = time.Now()
|
p.SendTime = time.Now()
|
||||||
}
|
}
|
||||||
if len(p.Frames) == 0 {
|
if len(p.Frames) == 0 {
|
||||||
p.Frames = []*Frame{
|
p.Frames = []Frame{
|
||||||
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, p.PacketNumber) }},
|
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, p.PacketNumber) }},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
ping := &wire.PingFrame{}
|
ping := &wire.PingFrame{}
|
||||||
handler.SentPacket(ackElicitingPacket(&Packet{
|
handler.SentPacket(ackElicitingPacket(&Packet{
|
||||||
PacketNumber: 13,
|
PacketNumber: 13,
|
||||||
Frames: []*Frame{{
|
Frames: []Frame{{
|
||||||
Frame: ping, OnAcked: func(f wire.Frame) {
|
Frame: ping, OnAcked: func(f wire.Frame) {
|
||||||
Expect(f).To(Equal(ping))
|
Expect(f).To(Equal(ping))
|
||||||
acked = true
|
acked = true
|
||||||
|
@ -428,20 +428,20 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
{
|
{
|
||||||
PacketNumber: 13,
|
PacketNumber: 13,
|
||||||
LargestAcked: 100,
|
LargestAcked: 100,
|
||||||
Frames: []*Frame{{Frame: &streamFrame, OnLost: func(wire.Frame) {}}},
|
Frames: []Frame{{Frame: &streamFrame, OnLost: func(wire.Frame) {}}},
|
||||||
Length: 1,
|
Length: 1,
|
||||||
EncryptionLevel: protocol.Encryption1RTT,
|
EncryptionLevel: protocol.Encryption1RTT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PacketNumber: 14,
|
PacketNumber: 14,
|
||||||
LargestAcked: 200,
|
LargestAcked: 200,
|
||||||
Frames: []*Frame{{Frame: &streamFrame, OnLost: func(wire.Frame) {}}},
|
Frames: []Frame{{Frame: &streamFrame, OnLost: func(wire.Frame) {}}},
|
||||||
Length: 1,
|
Length: 1,
|
||||||
EncryptionLevel: protocol.Encryption1RTT,
|
EncryptionLevel: protocol.Encryption1RTT,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PacketNumber: 15,
|
PacketNumber: 15,
|
||||||
Frames: []*Frame{{Frame: &streamFrame, OnLost: func(wire.Frame) {}}},
|
Frames: []Frame{{Frame: &streamFrame, OnLost: func(wire.Frame) {}}},
|
||||||
Length: 1,
|
Length: 1,
|
||||||
EncryptionLevel: protocol.Encryption1RTT,
|
EncryptionLevel: protocol.Encryption1RTT,
|
||||||
},
|
},
|
||||||
|
@ -501,7 +501,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.SentPacket(&Packet{
|
handler.SentPacket(&Packet{
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
Length: 42,
|
Length: 42,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) {}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) {}}},
|
||||||
EncryptionLevel: protocol.Encryption1RTT,
|
EncryptionLevel: protocol.Encryption1RTT,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -548,7 +548,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
SendTime: time.Now().Add(-time.Hour),
|
SendTime: time.Now().Add(-time.Hour),
|
||||||
IsPathMTUProbePacket: true,
|
IsPathMTUProbePacket: true,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { mtuPacketDeclaredLost = true }}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { mtuPacketDeclaredLost = true }}},
|
||||||
}))
|
}))
|
||||||
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2}))
|
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2}))
|
||||||
// lose packet 1, but don't EXPECT any calls to OnPacketLost()
|
// lose packet 1, but don't EXPECT any calls to OnPacketLost()
|
||||||
|
@ -595,7 +595,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.SentPacket(&Packet{
|
handler.SentPacket(&Packet{
|
||||||
Length: 42,
|
Length: 42,
|
||||||
EncryptionLevel: protocol.EncryptionInitial,
|
EncryptionLevel: protocol.EncryptionInitial,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
SendTime: time.Now(),
|
SendTime: time.Now(),
|
||||||
})
|
})
|
||||||
cong.EXPECT().CanSend(protocol.ByteCount(42)).Return(true)
|
cong.EXPECT().CanSend(protocol.ByteCount(42)).Return(true)
|
||||||
|
@ -755,7 +755,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.SentPacket(ackElicitingPacket(&Packet{
|
handler.SentPacket(ackElicitingPacket(&Packet{
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
SendTime: time.Now().Add(-time.Hour),
|
SendTime: time.Now().Add(-time.Hour),
|
||||||
Frames: []*Frame{
|
Frames: []Frame{
|
||||||
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, 1) }},
|
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, 1) }},
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
@ -775,7 +775,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.SentPacket(ackElicitingPacket(&Packet{
|
handler.SentPacket(ackElicitingPacket(&Packet{
|
||||||
PacketNumber: pn,
|
PacketNumber: pn,
|
||||||
SendTime: time.Now().Add(-time.Hour),
|
SendTime: time.Now().Add(-time.Hour),
|
||||||
Frames: []*Frame{
|
Frames: []Frame{
|
||||||
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, 1) }},
|
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { lostPackets = append(lostPackets, 1) }},
|
||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
@ -895,7 +895,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
Length: 599,
|
Length: 599,
|
||||||
EncryptionLevel: protocol.EncryptionInitial,
|
EncryptionLevel: protocol.EncryptionInitial,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
SendTime: time.Now(),
|
SendTime: time.Now(),
|
||||||
})
|
})
|
||||||
Expect(handler.SendMode()).To(Equal(SendAny))
|
Expect(handler.SendMode()).To(Equal(SendAny))
|
||||||
|
@ -903,7 +903,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
Length: 1,
|
Length: 1,
|
||||||
EncryptionLevel: protocol.EncryptionInitial,
|
EncryptionLevel: protocol.EncryptionInitial,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
SendTime: time.Now(),
|
SendTime: time.Now(),
|
||||||
})
|
})
|
||||||
Expect(handler.SendMode()).To(Equal(SendNone))
|
Expect(handler.SendMode()).To(Equal(SendNone))
|
||||||
|
@ -915,7 +915,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
Length: 900,
|
Length: 900,
|
||||||
EncryptionLevel: protocol.EncryptionInitial,
|
EncryptionLevel: protocol.EncryptionInitial,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
SendTime: time.Now(),
|
SendTime: time.Now(),
|
||||||
})
|
})
|
||||||
// Amplification limited. We don't need to set a timer now.
|
// Amplification limited. We don't need to set a timer now.
|
||||||
|
@ -931,7 +931,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
Length: 900,
|
Length: 900,
|
||||||
EncryptionLevel: protocol.EncryptionHandshake,
|
EncryptionLevel: protocol.EncryptionHandshake,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
SendTime: time.Now(),
|
SendTime: time.Now(),
|
||||||
})
|
})
|
||||||
// Amplification limited. We don't need to set a timer now.
|
// Amplification limited. We don't need to set a timer now.
|
||||||
|
@ -965,7 +965,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
Length: 900,
|
Length: 900,
|
||||||
EncryptionLevel: protocol.EncryptionInitial,
|
EncryptionLevel: protocol.EncryptionInitial,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}}},
|
||||||
SendTime: time.Now(),
|
SendTime: time.Now(),
|
||||||
})
|
})
|
||||||
Expect(handler.SendMode()).To(Equal(SendAny))
|
Expect(handler.SendMode()).To(Equal(SendAny))
|
||||||
|
@ -1158,7 +1158,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
SendTime: now.Add(-3 * time.Second),
|
SendTime: now.Add(-3 * time.Second),
|
||||||
IsPathMTUProbePacket: true,
|
IsPathMTUProbePacket: true,
|
||||||
Frames: []*Frame{{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { mtuPacketDeclaredLost = true }}},
|
Frames: []Frame{{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { mtuPacketDeclaredLost = true }}},
|
||||||
}))
|
}))
|
||||||
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2, SendTime: now.Add(-3 * time.Second)}))
|
handler.SentPacket(ackElicitingPacket(&Packet{PacketNumber: 2, SendTime: now.Add(-3 * time.Second)}))
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 2, Largest: 2}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 2, Largest: 2}}}
|
||||||
|
@ -1341,7 +1341,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.SentPacket(&Packet{
|
handler.SentPacket(&Packet{
|
||||||
PacketNumber: 13,
|
PacketNumber: 13,
|
||||||
EncryptionLevel: protocol.EncryptionInitial,
|
EncryptionLevel: protocol.EncryptionInitial,
|
||||||
Frames: []*Frame{
|
Frames: []Frame{
|
||||||
{Frame: &wire.CryptoFrame{Data: []byte("foobar")}, OnLost: func(wire.Frame) { lostInitial = true }},
|
{Frame: &wire.CryptoFrame{Data: []byte("foobar")}, OnLost: func(wire.Frame) { lostInitial = true }},
|
||||||
},
|
},
|
||||||
Length: 100,
|
Length: 100,
|
||||||
|
@ -1350,7 +1350,7 @@ var _ = Describe("SentPacketHandler", func() {
|
||||||
handler.SentPacket(&Packet{
|
handler.SentPacket(&Packet{
|
||||||
PacketNumber: pn,
|
PacketNumber: pn,
|
||||||
EncryptionLevel: protocol.Encryption0RTT,
|
EncryptionLevel: protocol.Encryption0RTT,
|
||||||
Frames: []*Frame{
|
Frames: []Frame{
|
||||||
{Frame: &wire.StreamFrame{Data: []byte("foobar")}, OnLost: func(wire.Frame) { lost0RTT = true }},
|
{Frame: &wire.StreamFrame{Data: []byte("foobar")}, OnLost: func(wire.Frame) { lost0RTT = true }},
|
||||||
},
|
},
|
||||||
Length: 999,
|
Length: 999,
|
||||||
|
|
|
@ -36,10 +36,10 @@ func (m *MockFrameSource) EXPECT() *MockFrameSourceMockRecorder {
|
||||||
}
|
}
|
||||||
|
|
||||||
// AppendControlFrames mocks base method.
|
// AppendControlFrames mocks base method.
|
||||||
func (m *MockFrameSource) AppendControlFrames(arg0 []*ackhandler.Frame, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
func (m *MockFrameSource) AppendControlFrames(arg0 []ackhandler.Frame, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
ret := m.ctrl.Call(m, "AppendControlFrames", arg0, arg1, arg2)
|
ret := m.ctrl.Call(m, "AppendControlFrames", arg0, arg1, arg2)
|
||||||
ret0, _ := ret[0].([]*ackhandler.Frame)
|
ret0, _ := ret[0].([]ackhandler.Frame)
|
||||||
ret1, _ := ret[1].(protocol.ByteCount)
|
ret1, _ := ret[1].(protocol.ByteCount)
|
||||||
return ret0, ret1
|
return ret0, ret1
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ type sealer interface {
|
||||||
|
|
||||||
type payload struct {
|
type payload struct {
|
||||||
streamFrames []ackhandler.StreamFrame
|
streamFrames []ackhandler.StreamFrame
|
||||||
frames []*ackhandler.Frame
|
frames []ackhandler.Frame
|
||||||
ack *wire.AckFrame
|
ack *wire.AckFrame
|
||||||
length protocol.ByteCount
|
length protocol.ByteCount
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ type payload struct {
|
||||||
type longHeaderPacket struct {
|
type longHeaderPacket struct {
|
||||||
header *wire.ExtendedHeader
|
header *wire.ExtendedHeader
|
||||||
ack *wire.AckFrame
|
ack *wire.AckFrame
|
||||||
frames []*ackhandler.Frame
|
frames []ackhandler.Frame
|
||||||
streamFrames []ackhandler.StreamFrame // only used for 0-RTT packets
|
streamFrames []ackhandler.StreamFrame // only used for 0-RTT packets
|
||||||
|
|
||||||
length protocol.ByteCount
|
length protocol.ByteCount
|
||||||
|
@ -147,7 +147,7 @@ type sealingManager interface {
|
||||||
type frameSource interface {
|
type frameSource interface {
|
||||||
HasData() bool
|
HasData() bool
|
||||||
AppendStreamFrames([]ackhandler.StreamFrame, protocol.ByteCount, protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount)
|
AppendStreamFrames([]ackhandler.StreamFrame, protocol.ByteCount, protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount)
|
||||||
AppendControlFrames([]*ackhandler.Frame, protocol.ByteCount, protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount)
|
AppendControlFrames([]ackhandler.Frame, protocol.ByteCount, protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ackFrameSource interface {
|
type ackFrameSource interface {
|
||||||
|
@ -244,7 +244,7 @@ func (p *packetPacker) packConnectionClose(
|
||||||
ccf.ReasonPhrase = ""
|
ccf.ReasonPhrase = ""
|
||||||
}
|
}
|
||||||
pl := payload{
|
pl := payload{
|
||||||
frames: []*ackhandler.Frame{{Frame: ccf}},
|
frames: []ackhandler.Frame{{Frame: ccf}},
|
||||||
length: ccf.Length(v),
|
length: ccf.Length(v),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ func (p *packetPacker) shortHeaderPacketLength(connID protocol.ConnectionID, pnL
|
||||||
}
|
}
|
||||||
|
|
||||||
// size is the expected size of the packet, if no padding was applied.
|
// size is the expected size of the packet, if no padding was applied.
|
||||||
func (p *packetPacker) initialPaddingLen(frames []*ackhandler.Frame, size protocol.ByteCount) protocol.ByteCount {
|
func (p *packetPacker) initialPaddingLen(frames []ackhandler.Frame, size protocol.ByteCount) protocol.ByteCount {
|
||||||
// For the server, only ack-eliciting Initial packets need to be padded.
|
// For the server, only ack-eliciting Initial packets need to be padded.
|
||||||
if p.perspective == protocol.PerspectiveServer && !ackhandler.HasAckElicitingFrames(frames) {
|
if p.perspective == protocol.PerspectiveServer && !ackhandler.HasAckElicitingFrames(frames) {
|
||||||
return 0
|
return 0
|
||||||
|
@ -564,16 +564,14 @@ func (p *packetPacker) maybeGetCryptoPacket(maxPacketSize protocol.ByteCount, en
|
||||||
if f == nil {
|
if f == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
af := ackhandler.GetFrame()
|
pl.frames = append(pl.frames, ackhandler.Frame{Frame: f})
|
||||||
af.Frame = f
|
|
||||||
pl.frames = append(pl.frames, af)
|
|
||||||
frameLen := f.Length(v)
|
frameLen := f.Length(v)
|
||||||
pl.length += frameLen
|
pl.length += frameLen
|
||||||
maxPacketSize -= frameLen
|
maxPacketSize -= frameLen
|
||||||
}
|
}
|
||||||
} else if s.HasData() {
|
} else if s.HasData() {
|
||||||
cf := s.PopCryptoFrame(maxPacketSize)
|
cf := s.PopCryptoFrame(maxPacketSize)
|
||||||
pl.frames = []*ackhandler.Frame{{Frame: cf}}
|
pl.frames = []ackhandler.Frame{{Frame: cf}}
|
||||||
pl.length += cf.Length(v)
|
pl.length += cf.Length(v)
|
||||||
}
|
}
|
||||||
return hdr, pl
|
return hdr, pl
|
||||||
|
@ -605,11 +603,10 @@ func (p *packetPacker) maybeGetAppDataPacket(maxPayloadSize protocol.ByteCount,
|
||||||
// the packet only contains an ACK
|
// the packet only contains an ACK
|
||||||
if p.numNonAckElicitingAcks >= protocol.MaxNonAckElicitingAcks {
|
if p.numNonAckElicitingAcks >= protocol.MaxNonAckElicitingAcks {
|
||||||
ping := &wire.PingFrame{}
|
ping := &wire.PingFrame{}
|
||||||
// don't retransmit the PING frame when it is lost
|
pl.frames = append(pl.frames, ackhandler.Frame{
|
||||||
af := ackhandler.GetFrame()
|
Frame: ping,
|
||||||
af.Frame = ping
|
OnLost: func(wire.Frame) {}, // don't retransmit the PING frame when it is lost
|
||||||
af.OnLost = func(wire.Frame) {}
|
})
|
||||||
pl.frames = append(pl.frames, af)
|
|
||||||
pl.length += ping.Length(v)
|
pl.length += ping.Length(v)
|
||||||
p.numNonAckElicitingAcks = 0
|
p.numNonAckElicitingAcks = 0
|
||||||
} else {
|
} else {
|
||||||
|
@ -650,11 +647,10 @@ func (p *packetPacker) composeNextPacket(maxFrameSize protocol.ByteCount, onlyAc
|
||||||
if f := p.datagramQueue.Peek(); f != nil {
|
if f := p.datagramQueue.Peek(); f != nil {
|
||||||
size := f.Length(v)
|
size := f.Length(v)
|
||||||
if size <= maxFrameSize-pl.length {
|
if size <= maxFrameSize-pl.length {
|
||||||
af := ackhandler.GetFrame()
|
pl.frames = append(pl.frames, ackhandler.Frame{
|
||||||
af.Frame = f
|
Frame: f,
|
||||||
// set it to a no-op. Then we won't set the default callback, which would retransmit the frame.
|
OnLost: func(wire.Frame) {}, // set it to a no-op. Then we won't set the default callback, which would retransmit the frame.
|
||||||
af.OnLost = func(wire.Frame) {}
|
})
|
||||||
pl.frames = append(pl.frames, af)
|
|
||||||
pl.length += size
|
pl.length += size
|
||||||
p.datagramQueue.Pop()
|
p.datagramQueue.Pop()
|
||||||
}
|
}
|
||||||
|
@ -675,9 +671,7 @@ func (p *packetPacker) composeNextPacket(maxFrameSize protocol.ByteCount, onlyAc
|
||||||
if f == nil {
|
if f == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
af := ackhandler.GetFrame()
|
pl.frames = append(pl.frames, ackhandler.Frame{Frame: f})
|
||||||
af.Frame = f
|
|
||||||
pl.frames = append(pl.frames, af)
|
|
||||||
pl.length += f.Length(v)
|
pl.length += f.Length(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -767,8 +761,8 @@ func (p *packetPacker) MaybePackProbePacket(encLevel protocol.EncryptionLevel, v
|
||||||
|
|
||||||
func (p *packetPacker) PackMTUProbePacket(ping ackhandler.Frame, size protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
|
func (p *packetPacker) PackMTUProbePacket(ping ackhandler.Frame, size protocol.ByteCount, now time.Time, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
|
||||||
pl := payload{
|
pl := payload{
|
||||||
frames: []*ackhandler.Frame{&ping},
|
frames: []ackhandler.Frame{ping},
|
||||||
length: ping.Length(v),
|
length: ping.Frame.Length(v),
|
||||||
}
|
}
|
||||||
buffer := getPacketBuffer()
|
buffer := getPacketBuffer()
|
||||||
s, err := p.cryptoSetup.Get1RTTSealer()
|
s, err := p.cryptoSetup.Get1RTTSealer()
|
||||||
|
@ -934,7 +928,7 @@ func (p *packetPacker) appendPacketPayload(raw []byte, pl payload, paddingLen pr
|
||||||
}
|
}
|
||||||
for _, f := range pl.frames {
|
for _, f := range pl.frames {
|
||||||
var err error
|
var err error
|
||||||
raw, err = f.Append(raw, v)
|
raw, err = f.Frame.Append(raw, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,8 @@ var _ = Describe("Packet packer", func() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
expectAppendControlFrames := func(frames ...*ackhandler.Frame) {
|
expectAppendControlFrames := func(frames ...ackhandler.Frame) {
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(fs []*ackhandler.Frame, _ protocol.ByteCount, v protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(fs []ackhandler.Frame, _ protocol.ByteCount, v protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
var length protocol.ByteCount
|
var length protocol.ByteCount
|
||||||
for _, f := range frames {
|
for _, f := range frames {
|
||||||
length += f.Frame.Length(v)
|
length += f.Frame.Length(v)
|
||||||
|
@ -299,11 +299,11 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get0RTTSealer().Return(getSealer(), nil).AnyTimes()
|
sealingManager.EXPECT().Get0RTTSealer().Return(getSealer(), nil).AnyTimes()
|
||||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption0RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption0RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption0RTT).Return(protocol.PacketNumber(0x42))
|
pnManager.EXPECT().PopPacketNumber(protocol.Encryption0RTT).Return(protocol.PacketNumber(0x42))
|
||||||
cf := &ackhandler.Frame{Frame: &wire.MaxDataFrame{MaximumData: 0x1337}}
|
cf := ackhandler.Frame{Frame: &wire.MaxDataFrame{MaximumData: 0x1337}}
|
||||||
framer.EXPECT().HasData().Return(true)
|
framer.EXPECT().HasData().Return(true)
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(frames []*ackhandler.Frame, _ protocol.ByteCount, v protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(frames []ackhandler.Frame, _ protocol.ByteCount, v protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
Expect(frames).To(BeEmpty())
|
Expect(frames).To(BeEmpty())
|
||||||
return append(frames, cf), cf.Length(v)
|
return append(frames, cf), cf.Frame.Length(v)
|
||||||
})
|
})
|
||||||
// TODO: check sizes
|
// TODO: check sizes
|
||||||
framer.EXPECT().AppendStreamFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(frames []ackhandler.StreamFrame, _ protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount) {
|
framer.EXPECT().AppendStreamFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(frames []ackhandler.StreamFrame, _ protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.StreamFrame, protocol.ByteCount) {
|
||||||
|
@ -315,7 +315,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].header.Type).To(Equal(protocol.PacketType0RTT))
|
Expect(p.longHdrPackets[0].header.Type).To(Equal(protocol.PacketType0RTT))
|
||||||
Expect(p.longHdrPackets[0].EncryptionLevel()).To(Equal(protocol.Encryption0RTT))
|
Expect(p.longHdrPackets[0].EncryptionLevel()).To(Equal(protocol.Encryption0RTT))
|
||||||
Expect(p.longHdrPackets[0].frames).To(Equal([]*ackhandler.Frame{cf}))
|
Expect(p.longHdrPackets[0].frames).To(Equal([]ackhandler.Frame{cf}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("doesn't add an ACK-only 0-RTT packet", func() { // ACK frames cannot be sent in 0-RTT packets
|
It("doesn't add an ACK-only 0-RTT packet", func() { // ACK frames cannot be sent in 0-RTT packets
|
||||||
|
@ -540,7 +540,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||||
framer.EXPECT().HasData().Return(true)
|
framer.EXPECT().HasData().Return(true)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
||||||
frames := []*ackhandler.Frame{
|
frames := []ackhandler.Frame{
|
||||||
{Frame: &wire.ResetStreamFrame{}},
|
{Frame: &wire.ResetStreamFrame{}},
|
||||||
{Frame: &wire.MaxDataFrame{}},
|
{Frame: &wire.MaxDataFrame{}},
|
||||||
}
|
}
|
||||||
|
@ -620,7 +620,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
||||||
var maxSize protocol.ByteCount
|
var maxSize protocol.ByteCount
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(fs []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).DoAndReturn(func(fs []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
maxSize = maxLen
|
maxSize = maxLen
|
||||||
return fs, 444
|
return fs, 444
|
||||||
}),
|
}),
|
||||||
|
@ -839,7 +839,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().HasData().Return(true)
|
framer.EXPECT().HasData().Return(true)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
|
||||||
expectAppendStreamFrames()
|
expectAppendStreamFrames()
|
||||||
expectAppendControlFrames(&ackhandler.Frame{Frame: &wire.MaxDataFrame{}})
|
expectAppendControlFrames(ackhandler.Frame{Frame: &wire.MaxDataFrame{}})
|
||||||
p, _, err := packer.PackPacket(false, time.Now(), protocol.Version1)
|
p, _, err := packer.PackPacket(false, time.Now(), protocol.Version1)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p).ToNot(BeNil())
|
Expect(p).ToNot(BeNil())
|
||||||
|
@ -854,7 +854,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().HasData().Return(true).Times(2)
|
framer.EXPECT().HasData().Return(true).Times(2)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Times(2)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Times(2)
|
||||||
var initialMaxPacketSize protocol.ByteCount
|
var initialMaxPacketSize protocol.ByteCount
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
initialMaxPacketSize = maxLen
|
initialMaxPacketSize = maxLen
|
||||||
return nil, 0
|
return nil, 0
|
||||||
})
|
})
|
||||||
|
@ -865,7 +865,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
packer.HandleTransportParameters(&wire.TransportParameters{
|
packer.HandleTransportParameters(&wire.TransportParameters{
|
||||||
MaxUDPPayloadSize: maxPacketSize - 10,
|
MaxUDPPayloadSize: maxPacketSize - 10,
|
||||||
})
|
})
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
Expect(maxLen).To(Equal(initialMaxPacketSize - 10))
|
Expect(maxLen).To(Equal(initialMaxPacketSize - 10))
|
||||||
return nil, 0
|
return nil, 0
|
||||||
})
|
})
|
||||||
|
@ -880,7 +880,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().HasData().Return(true).Times(2)
|
framer.EXPECT().HasData().Return(true).Times(2)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Times(2)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Times(2)
|
||||||
var initialMaxPacketSize protocol.ByteCount
|
var initialMaxPacketSize protocol.ByteCount
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
initialMaxPacketSize = maxLen
|
initialMaxPacketSize = maxLen
|
||||||
return nil, 0
|
return nil, 0
|
||||||
})
|
})
|
||||||
|
@ -891,7 +891,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
packer.HandleTransportParameters(&wire.TransportParameters{
|
packer.HandleTransportParameters(&wire.TransportParameters{
|
||||||
MaxUDPPayloadSize: maxPacketSize + 10,
|
MaxUDPPayloadSize: maxPacketSize + 10,
|
||||||
})
|
})
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
Expect(maxLen).To(Equal(initialMaxPacketSize))
|
Expect(maxLen).To(Equal(initialMaxPacketSize))
|
||||||
return nil, 0
|
return nil, 0
|
||||||
})
|
})
|
||||||
|
@ -908,7 +908,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
framer.EXPECT().HasData().Return(true).Times(2)
|
framer.EXPECT().HasData().Return(true).Times(2)
|
||||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Times(2)
|
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Times(2)
|
||||||
var initialMaxPacketSize protocol.ByteCount
|
var initialMaxPacketSize protocol.ByteCount
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
initialMaxPacketSize = maxLen
|
initialMaxPacketSize = maxLen
|
||||||
return nil, 0
|
return nil, 0
|
||||||
})
|
})
|
||||||
|
@ -918,7 +918,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
// now reduce the maxPacketSize
|
// now reduce the maxPacketSize
|
||||||
const packetSizeIncrease = 50
|
const packetSizeIncrease = 50
|
||||||
packer.SetMaxPacketSize(maxPacketSize + packetSizeIncrease)
|
packer.SetMaxPacketSize(maxPacketSize + packetSizeIncrease)
|
||||||
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []*ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]*ackhandler.Frame, protocol.ByteCount) {
|
framer.EXPECT().AppendControlFrames(gomock.Any(), gomock.Any(), protocol.Version1).Do(func(_ []ackhandler.Frame, maxLen protocol.ByteCount, _ protocol.VersionNumber) ([]ackhandler.Frame, protocol.ByteCount) {
|
||||||
Expect(maxLen).To(Equal(initialMaxPacketSize + packetSizeIncrease))
|
Expect(maxLen).To(Equal(initialMaxPacketSize + packetSizeIncrease))
|
||||||
return nil, 0
|
return nil, 0
|
||||||
})
|
})
|
||||||
|
@ -1287,7 +1287,7 @@ var _ = Describe("Packet packer", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(p.longHdrPackets).To(HaveLen(1))
|
Expect(p.longHdrPackets).To(HaveLen(1))
|
||||||
Expect(p.longHdrPackets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
|
Expect(p.longHdrPackets[0].EncryptionLevel()).To(Equal(protocol.EncryptionInitial))
|
||||||
Expect(p.longHdrPackets[0].frames).To(Equal([]*ackhandler.Frame{{Frame: f}}))
|
Expect(p.longHdrPackets[0].frames).To(Equal([]ackhandler.Frame{{Frame: f}}))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("sends an Initial packet containing only an ACK", func() {
|
It("sends an Initial packet containing only an ACK", func() {
|
||||||
|
@ -1558,7 +1558,7 @@ var _ = Describe("Converting to ackhandler.Packet", func() {
|
||||||
It("convert a packet", func() {
|
It("convert a packet", func() {
|
||||||
packet := &longHeaderPacket{
|
packet := &longHeaderPacket{
|
||||||
header: &wire.ExtendedHeader{Header: wire.Header{Type: protocol.PacketTypeInitial}},
|
header: &wire.ExtendedHeader{Header: wire.Header{Type: protocol.PacketTypeInitial}},
|
||||||
frames: []*ackhandler.Frame{{Frame: &wire.MaxDataFrame{}}, {Frame: &wire.PingFrame{}}},
|
frames: []ackhandler.Frame{{Frame: &wire.MaxDataFrame{}}, {Frame: &wire.PingFrame{}}},
|
||||||
ack: &wire.AckFrame{AckRanges: []wire.AckRange{{Largest: 100, Smallest: 80}}},
|
ack: &wire.AckFrame{AckRanges: []wire.AckRange{{Largest: 100, Smallest: 80}}},
|
||||||
length: 42,
|
length: 42,
|
||||||
}
|
}
|
||||||
|
@ -1573,7 +1573,7 @@ var _ = Describe("Converting to ackhandler.Packet", func() {
|
||||||
It("sets the LargestAcked to invalid, if the packet doesn't have an ACK frame", func() {
|
It("sets the LargestAcked to invalid, if the packet doesn't have an ACK frame", func() {
|
||||||
packet := &longHeaderPacket{
|
packet := &longHeaderPacket{
|
||||||
header: &wire.ExtendedHeader{Header: wire.Header{Type: protocol.PacketTypeHandshake}},
|
header: &wire.ExtendedHeader{Header: wire.Header{Type: protocol.PacketTypeHandshake}},
|
||||||
frames: []*ackhandler.Frame{{Frame: &wire.MaxDataFrame{}}, {Frame: &wire.PingFrame{}}},
|
frames: []ackhandler.Frame{{Frame: &wire.MaxDataFrame{}}, {Frame: &wire.PingFrame{}}},
|
||||||
}
|
}
|
||||||
p := packet.ToAckHandlerPacket(time.Now(), nil)
|
p := packet.ToAckHandlerPacket(time.Now(), nil)
|
||||||
Expect(p.LargestAcked).To(Equal(protocol.InvalidPacketNumber))
|
Expect(p.LargestAcked).To(Equal(protocol.InvalidPacketNumber))
|
||||||
|
@ -1585,7 +1585,7 @@ var _ = Describe("Converting to ackhandler.Packet", func() {
|
||||||
var pingLost bool
|
var pingLost bool
|
||||||
packet := &longHeaderPacket{
|
packet := &longHeaderPacket{
|
||||||
header: &wire.ExtendedHeader{Header: hdr},
|
header: &wire.ExtendedHeader{Header: hdr},
|
||||||
frames: []*ackhandler.Frame{
|
frames: []ackhandler.Frame{
|
||||||
{Frame: &wire.MaxDataFrame{}},
|
{Frame: &wire.MaxDataFrame{}},
|
||||||
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { pingLost = true }},
|
{Frame: &wire.PingFrame{}, OnLost: func(wire.Frame) { pingLost = true }},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue