split code paths for packing normal and ACK-only packets

This commit is contained in:
Marten Seemann 2023-04-30 13:30:05 +02:00
parent db4e929ccf
commit b0524c1241
5 changed files with 81 additions and 54 deletions

View file

@ -1873,7 +1873,7 @@ func (s *connection) maybeSendAckOnlyPacket() error {
}
now := time.Now()
p, buffer, err := s.packer.PackPacket(true, now, s.mtuDiscoverer.CurrentSize(), s.version)
p, buffer, err := s.packer.PackAckOnlyPacket(s.mtuDiscoverer.CurrentSize(), s.version)
if err != nil {
if err == errNothingToPack {
return nil
@ -1928,7 +1928,7 @@ func (s *connection) sendProbePacket(encLevel protocol.EncryptionLevel) error {
}
func (s *connection) sendPacket(now time.Time) (bool, error) {
p, buffer, err := s.packer.PackPacket(false, now, s.mtuDiscoverer.CurrentSize(), s.version)
p, buffer, err := s.packer.PackPacket(s.mtuDiscoverer.CurrentSize(), s.version)
if err != nil {
if err == errNothingToPack {
return false, nil

View file

@ -614,8 +614,8 @@ var _ = Describe("Connection", func() {
cryptoSetup.EXPECT().Close()
conn.sentPacketHandler = sph
p, buffer := getShortHeaderPacket(1)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
runConn()
conn.queueControlFrame(&wire.PingFrame{})
conn.scheduleSending()
@ -1209,8 +1209,8 @@ var _ = Describe("Connection", func() {
conn.sentPacketHandler = sph
runConn()
p, buffer := getShortHeaderPacket(1)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
sent := make(chan struct{})
sender.EXPECT().WouldBlock().AnyTimes()
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
@ -1227,7 +1227,7 @@ var _ = Describe("Connection", func() {
It("doesn't send packets if there's nothing to send", func() {
conn.handshakeConfirmed = true
runConn()
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
conn.receivedPacketHandler.ReceivedPacket(0x035e, protocol.ECNNon, protocol.Encryption1RTT, time.Now(), true)
conn.scheduleSending()
time.Sleep(50 * time.Millisecond) // make sure there are no calls to mconn.Write()
@ -1257,8 +1257,8 @@ var _ = Describe("Connection", func() {
fc := mocks.NewMockConnectionFlowController(mockCtrl)
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
p, buffer := getShortHeaderPacket(1)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
conn.connFlowController = fc
runConn()
sent := make(chan struct{})
@ -1397,9 +1397,9 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SendMode().Return(ackhandler.SendPacingLimited)
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
p, buffer := getShortHeaderPacket(10)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
p, buffer = getShortHeaderPacket(11)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
sender.EXPECT().WouldBlock().AnyTimes()
sender.EXPECT().Send(gomock.Any()).Times(2)
go func() {
@ -1415,8 +1415,8 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SentPacket(gomock.Any())
sph.EXPECT().SendMode().Return(ackhandler.SendAny).Times(2)
p, buffer := getShortHeaderPacket(10)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
sender.EXPECT().WouldBlock().AnyTimes()
sender.EXPECT().Send(gomock.Any())
go func() {
@ -1433,7 +1433,7 @@ var _ = Describe("Connection", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
sph.EXPECT().SendMode().Return(ackhandler.SendPacingLimited)
p, buffer := getShortHeaderPacket(10)
packer.EXPECT().PackPacket(true, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackAckOnlyPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
sender.EXPECT().WouldBlock().AnyTimes()
sender.EXPECT().Send(gomock.Any())
@ -1453,7 +1453,7 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SendMode().Return(ackhandler.SendAny)
sph.EXPECT().SendMode().Return(ackhandler.SendAck)
p, buffer := getShortHeaderPacket(100)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
sender.EXPECT().WouldBlock().AnyTimes()
sender.EXPECT().Send(gomock.Any())
go func() {
@ -1471,12 +1471,12 @@ var _ = Describe("Connection", func() {
p2, buffer2 := getShortHeaderPacket(101)
gomock.InOrder(
sph.EXPECT().SendMode().Return(ackhandler.SendAny),
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p1, buffer1, nil),
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p1, buffer1, nil),
sph.EXPECT().SentPacket(gomock.Any()),
sph.EXPECT().SendMode().Return(ackhandler.SendPacingLimited),
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(pacingDelay)),
sph.EXPECT().SendMode().Return(ackhandler.SendAny),
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p2, buffer2, nil),
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p2, buffer2, nil),
sph.EXPECT().SentPacket(gomock.Any()),
sph.EXPECT().SendMode().Return(ackhandler.SendPacingLimited),
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour)),
@ -1502,7 +1502,7 @@ var _ = Describe("Connection", func() {
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
for pn := protocol.PacketNumber(1000); pn < 1003; pn++ {
p, buffer := getShortHeaderPacket(pn)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
}
written := make(chan struct{}, 3)
sender.EXPECT().WouldBlock().AnyTimes()
@ -1533,8 +1533,8 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SentPacket(gomock.Any())
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
p, buffer := getShortHeaderPacket(1000)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
sender.EXPECT().Send(gomock.Any()).DoAndReturn(func(p *packetBuffer) { close(written) })
available <- struct{}{}
Eventually(written).Should(BeClosed())
@ -1556,8 +1556,8 @@ var _ = Describe("Connection", func() {
})
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
p, buffer := getShortHeaderPacket(1000)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
sender.EXPECT().Send(gomock.Any()).DoAndReturn(func(p *packetBuffer) { close(written) })
conn.scheduleSending()
@ -1570,7 +1570,7 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SentPacket(gomock.Any())
sph.EXPECT().SendMode().Return(ackhandler.SendAny)
p, buffer := getShortHeaderPacket(1000)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
written := make(chan struct{}, 1)
sender.EXPECT().WouldBlock()
sender.EXPECT().WouldBlock().Return(true).Times(2)
@ -1591,8 +1591,8 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
sender.EXPECT().WouldBlock().AnyTimes()
p, buffer = getShortHeaderPacket(1001)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
sender.EXPECT().Send(gomock.Any()).DoAndReturn(func(p *packetBuffer) { written <- struct{}{} })
available <- struct{}{}
Eventually(written).Should(Receive())
@ -1605,7 +1605,7 @@ var _ = Describe("Connection", func() {
It("doesn't set a pacing timer when there is no data to send", func() {
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
sender.EXPECT().WouldBlock().AnyTimes()
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
// don't EXPECT any calls to mconn.Write()
go func() {
defer GinkgoRecover()
@ -1676,8 +1676,8 @@ var _ = Describe("Connection", func() {
sph.EXPECT().SentPacket(gomock.Any())
conn.sentPacketHandler = sph
p, buffer := getShortHeaderPacket(1)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
go func() {
defer GinkgoRecover()
@ -1696,8 +1696,8 @@ var _ = Describe("Connection", func() {
It("sets the timer to the ack timer", func() {
p, buffer := getShortHeaderPacket(1234)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(p, buffer, nil)
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack)
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
sph.EXPECT().SendMode().Return(ackhandler.SendAny).AnyTimes()
@ -1912,14 +1912,14 @@ var _ = Describe("Connection", func() {
conn.sentPacketHandler = sph
done := make(chan struct{})
connRunner.EXPECT().Retire(clientDestConnID)
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).DoAndReturn(func(_ bool, _ time.Time, _ protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
packer.EXPECT().PackPacket(gomock.Any(), conn.version).DoAndReturn(func(_ protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
frames, _ := conn.framer.AppendControlFrames(nil, protocol.MaxByteCount, v)
Expect(frames).ToNot(BeEmpty())
Expect(frames[0].Frame).To(BeEquivalentTo(&wire.HandshakeDoneFrame{}))
defer close(done)
return shortHeaderPacket{Packet: &ackhandler.Packet{}}, getPacketBuffer(), nil
})
packer.EXPECT().PackPacket(false, gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
packer.EXPECT().PackPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{}, nil, errNothingToPack).AnyTimes()
go func() {
defer GinkgoRecover()
cryptoSetup.EXPECT().RunHandshake()

View file

@ -52,6 +52,22 @@ func (mr *MockPackerMockRecorder) MaybePackProbePacket(arg0, arg1, arg2 interfac
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "MaybePackProbePacket", reflect.TypeOf((*MockPacker)(nil).MaybePackProbePacket), arg0, arg1, arg2)
}
// PackAckOnlyPacket mocks base method.
func (m *MockPacker) PackAckOnlyPacket(arg0 protocol.ByteCount, arg1 protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PackAckOnlyPacket", arg0, arg1)
ret0, _ := ret[0].(shortHeaderPacket)
ret1, _ := ret[1].(*packetBuffer)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// PackAckOnlyPacket indicates an expected call of PackAckOnlyPacket.
func (mr *MockPackerMockRecorder) PackAckOnlyPacket(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackAckOnlyPacket", reflect.TypeOf((*MockPacker)(nil).PackAckOnlyPacket), arg0, arg1)
}
// PackApplicationClose mocks base method.
func (m *MockPacker) PackApplicationClose(arg0 *qerr.ApplicationError, arg1 protocol.ByteCount, arg2 protocol.VersionNumber) (*coalescedPacket, error) {
m.ctrl.T.Helper()
@ -114,9 +130,9 @@ func (mr *MockPackerMockRecorder) PackMTUProbePacket(arg0, arg1, arg2, arg3 inte
}
// PackPacket mocks base method.
func (m *MockPacker) PackPacket(arg0 bool, arg1 time.Time, arg2 protocol.ByteCount, arg3 protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
func (m *MockPacker) PackPacket(arg0 protocol.ByteCount, arg1 protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "PackPacket", arg0, arg1, arg2, arg3)
ret := m.ctrl.Call(m, "PackPacket", arg0, arg1)
ret0, _ := ret[0].(shortHeaderPacket)
ret1, _ := ret[1].(*packetBuffer)
ret2, _ := ret[2].(error)
@ -124,9 +140,9 @@ func (m *MockPacker) PackPacket(arg0 bool, arg1 time.Time, arg2 protocol.ByteCou
}
// PackPacket indicates an expected call of PackPacket.
func (mr *MockPackerMockRecorder) PackPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
func (mr *MockPackerMockRecorder) PackPacket(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackPacket", reflect.TypeOf((*MockPacker)(nil).PackPacket), arg0, arg1, arg2, arg3)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PackPacket", reflect.TypeOf((*MockPacker)(nil).PackPacket), arg0, arg1)
}
// SetToken mocks base method.

View file

@ -16,7 +16,8 @@ var errNothingToPack = errors.New("nothing to pack")
type packer interface {
PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (*coalescedPacket, error)
PackPacket(onlyAck bool, now time.Time, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
PackAckOnlyPacket(maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
PackPacket(maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error)
MaybePackProbePacket(protocol.EncryptionLevel, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error)
PackConnectionClose(*qerr.TransportError, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error)
PackApplicationClose(*qerr.ApplicationError, protocol.ByteCount, protocol.VersionNumber) (*coalescedPacket, error)
@ -468,9 +469,19 @@ func (p *packetPacker) PackCoalescedPacket(onlyAck bool, maxPacketSize protocol.
return packet, nil
}
// PackAckOnlyPacket packs a packet containing only an ACK in the application data packet number space.
// It should be called after the handshake is confirmed.
func (p *packetPacker) PackAckOnlyPacket(maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
return p.packPacket(true, maxPacketSize, v)
}
// PackPacket packs a packet in the application data packet number space.
// It should be called after the handshake is confirmed.
func (p *packetPacker) PackPacket(onlyAck bool, now time.Time, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
func (p *packetPacker) PackPacket(maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
return p.packPacket(false, maxPacketSize, v)
}
func (p *packetPacker) packPacket(onlyAck bool, maxPacketSize protocol.ByteCount, v protocol.VersionNumber) (shortHeaderPacket, *packetBuffer, error) {
sealer, err := p.cryptoSetup.Get1RTTSealer()
if err != nil {
return shortHeaderPacket{}, nil, err

View file

@ -272,7 +272,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 10}}}
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
p, buffer, err := packer.PackPacket(true, time.Now(), maxPacketSize, protocol.Version1)
p, buffer, err := packer.PackAckOnlyPacket(maxPacketSize, protocol.Version1)
Expect(err).NotTo(HaveOccurred())
Expect(p).ToNot(BeNil())
Expect(p.Ack).To(Equal(ack))
@ -493,7 +493,7 @@ var _ = Describe("Packet packer", func() {
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
framer.EXPECT().HasData()
_, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
_, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).To(MatchError(errNothingToPack))
})
@ -509,7 +509,7 @@ var _ = Describe("Packet packer", func() {
Data: []byte{0xde, 0xca, 0xfb, 0xad},
}
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
p, buffer, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, buffer, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(p).ToNot(BeNil())
b, err := f.Append(nil, protocol.Version1)
@ -527,7 +527,7 @@ var _ = Describe("Packet packer", func() {
framer.EXPECT().HasData()
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(ack)
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
p, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).NotTo(HaveOccurred())
Expect(p).ToNot(BeNil())
Expect(p.Ack).To(Equal(ack))
@ -545,7 +545,7 @@ var _ = Describe("Packet packer", func() {
}
expectAppendControlFrames(frames...)
expectAppendStreamFrames()
p, buffer, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, buffer, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.Frames).To(HaveLen(2))
@ -574,7 +574,7 @@ var _ = Describe("Packet packer", func() {
time.Sleep(scaleDuration(20 * time.Millisecond))
framer.EXPECT().HasData()
p, buffer, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, buffer, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.Frames).To(HaveLen(1))
@ -602,7 +602,7 @@ var _ = Describe("Packet packer", func() {
time.Sleep(scaleDuration(20 * time.Millisecond))
framer.EXPECT().HasData()
p, buffer, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, buffer, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.Ack).ToNot(BeNil())
@ -628,7 +628,7 @@ var _ = Describe("Packet packer", func() {
return fs, 0
}),
)
_, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
_, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).To(MatchError(errNothingToPack))
})
@ -685,7 +685,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
expectAppendControlFrames()
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f})
_, buffer, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
_, buffer, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
// cut off the tag that the mock sealer added
buffer.Data = buffer.Data[:buffer.Len()-protocol.ByteCount(sealer.Overhead())]
@ -734,7 +734,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
expectAppendControlFrames()
expectAppendStreamFrames(ackhandler.StreamFrame{Frame: f1}, ackhandler.StreamFrame{Frame: f2}, ackhandler.StreamFrame{Frame: f3})
p, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.Frames).To(BeEmpty())
@ -754,7 +754,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
expectAppendControlFrames()
expectAppendStreamFrames()
p, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.Ack).ToNot(BeNil())
@ -771,7 +771,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
expectAppendControlFrames()
expectAppendStreamFrames()
p, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
var hasPing bool
@ -790,7 +790,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}})
expectAppendControlFrames()
expectAppendStreamFrames()
p, _, err = packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err = packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(p).ToNot(BeNil())
Expect(err).ToNot(HaveOccurred())
Expect(p.Ack).ToNot(BeNil())
@ -806,7 +806,7 @@ var _ = Describe("Packet packer", func() {
expectAppendControlFrames()
expectAppendStreamFrames()
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
_, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
_, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).To(MatchError(errNothingToPack))
// now add some frame to send
expectAppendControlFrames()
@ -817,7 +817,7 @@ var _ = Describe("Packet packer", func() {
framer.EXPECT().HasData().Return(true)
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 1, Largest: 1}}}
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false).Return(ack)
p, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(p.Ack).To(Equal(ack))
var hasPing bool
@ -839,7 +839,7 @@ var _ = Describe("Packet packer", func() {
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, false)
expectAppendStreamFrames()
expectAppendControlFrames(ackhandler.Frame{Frame: &wire.MaxDataFrame{}})
p, _, err := packer.PackPacket(false, time.Now(), maxPacketSize, protocol.Version1)
p, _, err := packer.PackPacket(maxPacketSize, protocol.Version1)
Expect(err).ToNot(HaveOccurred())
Expect(p).ToNot(BeNil())
Expect(p.Frames).ToNot(ContainElement(&wire.PingFrame{}))