mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 04:37:36 +03:00
send and track packets with ECN markings
This commit is contained in:
parent
f919473598
commit
5dd6d91c11
21 changed files with 264 additions and 206 deletions
|
@ -454,7 +454,7 @@ var _ = Describe("Connection", func() {
|
|||
Expect(e.ErrorMessage).To(BeEmpty())
|
||||
return &coalescedPacket{buffer: buffer}, nil
|
||||
})
|
||||
mconn.EXPECT().Write([]byte("connection close"), gomock.Any())
|
||||
mconn.EXPECT().Write([]byte("connection close"), gomock.Any(), gomock.Any())
|
||||
gomock.InOrder(
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any()).Do(func(e error) {
|
||||
var appErr *ApplicationError
|
||||
|
@ -475,7 +475,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -494,7 +494,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackApplicationClose(expectedErr, gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
gomock.InOrder(
|
||||
tracer.EXPECT().ClosedConnection(expectedErr),
|
||||
tracer.EXPECT().Close(),
|
||||
|
@ -516,7 +516,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
packer.EXPECT().PackConnectionClose(expectedErr, gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
gomock.InOrder(
|
||||
tracer.EXPECT().ClosedConnection(expectedErr),
|
||||
tracer.EXPECT().Close(),
|
||||
|
@ -565,7 +565,7 @@ var _ = Describe("Connection", func() {
|
|||
close(returned)
|
||||
}()
|
||||
Consistently(returned).ShouldNot(BeClosed())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -609,13 +609,14 @@ var _ = Describe("Connection", func() {
|
|||
conn.handshakeConfirmed = true
|
||||
sconn := NewMockSendConn(mockCtrl)
|
||||
sconn.EXPECT().capabilities().AnyTimes()
|
||||
sconn.EXPECT().Write(gomock.Any(), gomock.Any()).Return(io.ErrClosedPipe).AnyTimes()
|
||||
sconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any()).Return(io.ErrClosedPipe).AnyTimes()
|
||||
conn.sendQueue = newSendQueue(sconn)
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().GetLossDetectionTimeout().Return(time.Now().Add(time.Hour)).AnyTimes()
|
||||
sph.EXPECT().ECNMode().Return(protocol.ECT1).AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
// only expect a single SentPacket() call
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
|
@ -837,7 +838,7 @@ var _ = Describe("Connection", func() {
|
|||
// make the go routine return
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.closeLocal(errors.New("close"))
|
||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||
})
|
||||
|
@ -872,7 +873,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.closeLocal(errors.New("close"))
|
||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||
})
|
||||
|
@ -908,7 +909,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.closeLocal(errors.New("close"))
|
||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||
})
|
||||
|
@ -930,7 +931,7 @@ var _ = Describe("Connection", func() {
|
|||
close(done)
|
||||
}()
|
||||
expectReplaceWithClosed()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
packet := getShortHeaderPacket(srcConnID, 0x42, nil)
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
|
@ -958,7 +959,7 @@ var _ = Describe("Connection", func() {
|
|||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.shutdown()
|
||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||
})
|
||||
|
@ -980,7 +981,7 @@ var _ = Describe("Connection", func() {
|
|||
close(done)
|
||||
}()
|
||||
expectReplaceWithClosed()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.handlePacket(getShortHeaderPacket(srcConnID, 0x42, nil))
|
||||
|
@ -1190,6 +1191,7 @@ var _ = Describe("Connection", func() {
|
|||
var (
|
||||
connDone chan struct{}
|
||||
sender *MockSender
|
||||
sph *mockackhandler.MockSentPacketHandler
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
|
@ -1198,14 +1200,17 @@ var _ = Describe("Connection", func() {
|
|||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
conn.sendQueue = sender
|
||||
connDone = make(chan struct{})
|
||||
sph = mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
conn.sentPacketHandler = sph
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
sph.EXPECT().ECNMode().Return(protocol.ECNCE).MaxTimes(1)
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
sender.EXPECT().Close()
|
||||
|
@ -1226,12 +1231,11 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
It("sends packets", func() {
|
||||
conn.handshakeConfirmed = true
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.sentPacketHandler = sph
|
||||
sph.EXPECT().ECNMode().Return(protocol.ECNNon).AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
runConn()
|
||||
p := shortHeaderPacket{
|
||||
DestConnID: protocol.ParseConnectionID([]byte{1, 2, 3}),
|
||||
|
@ -1243,7 +1247,7 @@ var _ = Describe("Connection", func() {
|
|||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||
sent := make(chan struct{})
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16) { close(sent) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16, protocol.ECN) { close(sent) })
|
||||
tracer.EXPECT().SentShortHeaderPacket(&logging.ShortHeader{
|
||||
DestConnectionID: p.DestConnID,
|
||||
PacketNumber: p.PacketNumber,
|
||||
|
@ -1256,6 +1260,9 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
It("doesn't send packets if there's nothing to send", func() {
|
||||
conn.handshakeConfirmed = true
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
runConn()
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack).AnyTimes()
|
||||
conn.receivedPacketHandler.ReceivedPacket(0x035e, protocol.ECNNon, protocol.Encryption1RTT, time.Now(), true)
|
||||
|
@ -1264,13 +1271,12 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("sends ACK only packets", func() {
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAck)
|
||||
sph.EXPECT().ECNMode().Return(protocol.ECT1).AnyTimes()
|
||||
done := make(chan struct{})
|
||||
packer.EXPECT().PackCoalescedPacket(true, gomock.Any(), conn.version).Do(func(bool, protocol.ByteCount, protocol.VersionNumber) { close(done) })
|
||||
conn.sentPacketHandler = sph
|
||||
runConn()
|
||||
conn.scheduleSending()
|
||||
Eventually(done).Should(BeClosed())
|
||||
|
@ -1278,12 +1284,11 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
It("adds a BLOCKED frame when it is connection-level flow control blocked", func() {
|
||||
conn.handshakeConfirmed = true
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.sentPacketHandler = sph
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
fc := mocks.NewMockConnectionFlowController(mockCtrl)
|
||||
fc.EXPECT().IsNewlyBlocked().Return(true, protocol.ByteCount(1337))
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 13}, []byte("foobar"))
|
||||
|
@ -1291,7 +1296,7 @@ var _ = Describe("Connection", func() {
|
|||
conn.connFlowController = fc
|
||||
runConn()
|
||||
sent := make(chan struct{})
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16) { close(sent) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16, protocol.ECN) { close(sent) })
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), nil, []logging.Frame{})
|
||||
conn.scheduleSending()
|
||||
Eventually(sent).Should(BeClosed())
|
||||
|
@ -1300,11 +1305,9 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("doesn't send when the SentPacketHandler doesn't allow it", func() {
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendNone).AnyTimes()
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
conn.sentPacketHandler = sph
|
||||
runConn()
|
||||
conn.scheduleSending()
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
|
@ -1333,21 +1336,19 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("sends a probe packet", func() {
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(sendMode)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendNone)
|
||||
sph.EXPECT().QueueProbePacket(encLevel)
|
||||
sph.EXPECT().ECNMode()
|
||||
p := getCoalescedPacket(123, enc != protocol.Encryption1RTT)
|
||||
packer.EXPECT().MaybePackProbePacket(encLevel, gomock.Any(), conn.version).Return(p, nil)
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(_ time.Time, pn, _ protocol.PacketNumber, _ []ackhandler.StreamFrame, _ []ackhandler.Frame, _ protocol.EncryptionLevel, _ protocol.ByteCount, _ bool) {
|
||||
Expect(pn).To(Equal(protocol.PacketNumber(123)))
|
||||
})
|
||||
sph.EXPECT().SentPacket(gomock.Any(), protocol.PacketNumber(123), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.sentPacketHandler = sph
|
||||
runConn()
|
||||
sent := make(chan struct{})
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16) { close(sent) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16, protocol.ECN) { close(sent) })
|
||||
if enc == protocol.Encryption1RTT {
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), p.shortHdrPacket.Length, gomock.Any(), gomock.Any())
|
||||
} else {
|
||||
|
@ -1358,21 +1359,18 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("sends a PING as a probe packet", func() {
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(sendMode)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendNone)
|
||||
sph.EXPECT().ECNMode()
|
||||
sph.EXPECT().QueueProbePacket(encLevel).Return(false)
|
||||
p := getCoalescedPacket(123, enc != protocol.Encryption1RTT)
|
||||
packer.EXPECT().MaybePackProbePacket(encLevel, gomock.Any(), conn.version).Return(p, nil)
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(_ time.Time, pn, _ protocol.PacketNumber, _ []ackhandler.StreamFrame, _ []ackhandler.Frame, _ protocol.EncryptionLevel, _ protocol.ByteCount, _ bool) {
|
||||
Expect(pn).To(Equal(protocol.PacketNumber(123)))
|
||||
})
|
||||
conn.sentPacketHandler = sph
|
||||
sph.EXPECT().SentPacket(gomock.Any(), protocol.PacketNumber(123), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
runConn()
|
||||
sent := make(chan struct{})
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16) { close(sent) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16, protocol.ECN) { close(sent) })
|
||||
if enc == protocol.Encryption1RTT {
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), p.shortHdrPacket.Length, gomock.Any(), gomock.Any())
|
||||
} else {
|
||||
|
@ -1409,10 +1407,11 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
AfterEach(func() {
|
||||
// make the go routine return
|
||||
sph.EXPECT().ECNMode().MaxTimes(1)
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
sender.EXPECT().Close()
|
||||
|
@ -1421,17 +1420,18 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("sends multiple packets one by one immediately", func() {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).Times(2)
|
||||
sph.EXPECT().ECNMode().Times(2)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendPacingLimited)
|
||||
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 10}, []byte("packet10"))
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 11}, []byte("packet11"))
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(b *packetBuffer, _ uint16) {
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(b *packetBuffer, _ uint16, _ protocol.ECN) {
|
||||
Expect(b.Data).To(Equal([]byte("packet10")))
|
||||
})
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(b *packetBuffer, _ uint16) {
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(b *packetBuffer, _ uint16, _ protocol.ECN) {
|
||||
Expect(b.Data).To(Equal([]byte("packet11")))
|
||||
})
|
||||
go func() {
|
||||
|
@ -1446,7 +1446,8 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
It("sends multiple packets one by one immediately, with GSO", func() {
|
||||
enableGSO()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)
|
||||
sph.EXPECT().ECNMode().Times(3)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).Times(3)
|
||||
payload1 := make([]byte, conn.mtuDiscoverer.CurrentSize())
|
||||
rand.Read(payload1)
|
||||
|
@ -1456,7 +1457,7 @@ var _ = Describe("Connection", func() {
|
|||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 11}, payload2)
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), gomock.Any()).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), uint16(conn.mtuDiscoverer.CurrentSize())).Do(func(b *packetBuffer, l uint16) {
|
||||
sender.EXPECT().Send(gomock.Any(), uint16(conn.mtuDiscoverer.CurrentSize()), gomock.Any()).Do(func(b *packetBuffer, _ uint16, _ protocol.ECN) {
|
||||
Expect(b.Data).To(Equal(append(payload1, payload2...)))
|
||||
})
|
||||
go func() {
|
||||
|
@ -1471,8 +1472,9 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
It("stops appending packets when a smaller packet is packed, with GSO", func() {
|
||||
enableGSO()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(2)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).Times(2)
|
||||
sph.EXPECT().ECNMode().Times(2)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendNone)
|
||||
payload1 := make([]byte, conn.mtuDiscoverer.CurrentSize())
|
||||
rand.Read(payload1)
|
||||
|
@ -1481,7 +1483,7 @@ var _ = Describe("Connection", func() {
|
|||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 10}, payload1)
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 11}, payload2)
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), uint16(conn.mtuDiscoverer.CurrentSize())).Do(func(b *packetBuffer, l uint16) {
|
||||
sender.EXPECT().Send(gomock.Any(), uint16(conn.mtuDiscoverer.CurrentSize()), gomock.Any()).Do(func(b *packetBuffer, _ uint16, _ protocol.ECN) {
|
||||
Expect(b.Data).To(Equal(append(payload1, payload2...)))
|
||||
})
|
||||
go func() {
|
||||
|
@ -1495,12 +1497,13 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("sends multiple packets, when the pacer allows immediate sending", func() {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).Times(2)
|
||||
sph.EXPECT().ECNMode().Times(2)
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 10}, []byte("packet10"))
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
cryptoSetup.EXPECT().StartHandshake().MaxTimes(1)
|
||||
|
@ -1512,13 +1515,14 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("allows an ACK to be sent when pacing limited", func() {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendPacingLimited)
|
||||
sph.EXPECT().ECNMode()
|
||||
packer.EXPECT().PackAckOnlyPacket(gomock.Any(), conn.version).Return(shortHeaderPacket{PacketNumber: 123}, getPacketBuffer(), nil)
|
||||
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
cryptoSetup.EXPECT().StartHandshake().MaxTimes(1)
|
||||
|
@ -1532,12 +1536,13 @@ var _ = Describe("Connection", func() {
|
|||
// when becoming congestion limited, at some point the SendMode will change from SendAny to SendAck
|
||||
// we shouldn't send the ACK in the same run
|
||||
It("doesn't send an ACK right after becoming congestion limited", func() {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAck)
|
||||
sph.EXPECT().ECNMode().Times(2)
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 100}, []byte("packet100"))
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any())
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
cryptoSetup.EXPECT().StartHandshake().MaxTimes(1)
|
||||
|
@ -1552,19 +1557,21 @@ var _ = Describe("Connection", func() {
|
|||
pacingDelay := scaleDuration(100 * time.Millisecond)
|
||||
gomock.InOrder(
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny),
|
||||
sph.EXPECT().ECNMode(),
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 100}, []byte("packet100")),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendPacingLimited),
|
||||
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(pacingDelay)),
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny),
|
||||
sph.EXPECT().ECNMode(),
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 101}, []byte("packet101")),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendPacingLimited),
|
||||
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour)),
|
||||
)
|
||||
written := make(chan struct{}, 2)
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { written <- struct{}{} }).Times(2)
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { written <- struct{}{} }).Times(2)
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
cryptoSetup.EXPECT().StartHandshake().MaxTimes(1)
|
||||
|
@ -1578,8 +1585,9 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("sends multiple packets at once", func() {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(3)
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Times(3)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).Times(3)
|
||||
sph.EXPECT().ECNMode().Times(3)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendPacingLimited)
|
||||
sph.EXPECT().TimeUntilSend().Return(time.Now().Add(time.Hour))
|
||||
for pn := protocol.PacketNumber(1000); pn < 1003; pn++ {
|
||||
|
@ -1587,7 +1595,7 @@ var _ = Describe("Connection", func() {
|
|||
}
|
||||
written := make(chan struct{}, 3)
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { written <- struct{}{} }).Times(3)
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { written <- struct{}{} }).Times(3)
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
cryptoSetup.EXPECT().StartHandshake().MaxTimes(1)
|
||||
|
@ -1618,11 +1626,12 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
written := make(chan struct{})
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 1000}, []byte("packet1000"))
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { close(written) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { close(written) })
|
||||
available <- struct{}{}
|
||||
Eventually(written).Should(BeClosed())
|
||||
})
|
||||
|
@ -1639,14 +1648,15 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
written := make(chan struct{})
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(time.Time, protocol.PacketNumber, protocol.PacketNumber, []ackhandler.StreamFrame, []ackhandler.Frame, protocol.EncryptionLevel, protocol.ByteCount, bool) {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(time.Time, protocol.PacketNumber, protocol.PacketNumber, []ackhandler.StreamFrame, []ackhandler.Frame, protocol.EncryptionLevel, protocol.ECN, protocol.ByteCount, bool) {
|
||||
sph.EXPECT().ReceivedBytes(gomock.Any())
|
||||
conn.handlePacket(receivedPacket{buffer: getPacketBuffer()})
|
||||
})
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 10}, []byte("packet10"))
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { close(written) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { close(written) })
|
||||
|
||||
conn.scheduleSending()
|
||||
time.Sleep(scaleDuration(50 * time.Millisecond))
|
||||
|
@ -1655,13 +1665,14 @@ var _ = Describe("Connection", func() {
|
|||
})
|
||||
|
||||
It("stops sending when the send queue is full", func() {
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny)
|
||||
sph.EXPECT().ECNMode()
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 1000}, []byte("packet1000"))
|
||||
written := make(chan struct{}, 1)
|
||||
sender.EXPECT().WouldBlock()
|
||||
sender.EXPECT().WouldBlock().Return(true).Times(2)
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { written <- struct{}{} })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { written <- struct{}{} })
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
cryptoSetup.EXPECT().StartHandshake().MaxTimes(1)
|
||||
|
@ -1675,12 +1686,13 @@ var _ = Describe("Connection", func() {
|
|||
time.Sleep(scaleDuration(50 * time.Millisecond))
|
||||
|
||||
// now make room in the send queue
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 1001}, []byte("packet1001"))
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { written <- struct{}{} })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { written <- struct{}{} })
|
||||
available <- struct{}{}
|
||||
Eventually(written).Should(Receive())
|
||||
|
||||
|
@ -1691,6 +1703,7 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
It("doesn't set a pacing timer when there is no data to send", func() {
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
// don't EXPECT any calls to mconn.Write()
|
||||
|
@ -1708,12 +1721,13 @@ var _ = Describe("Connection", func() {
|
|||
mtuDiscoverer := NewMockMTUDiscoverer(mockCtrl)
|
||||
conn.mtuDiscoverer = mtuDiscoverer
|
||||
conn.config.DisablePathMTUDiscovery = false
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny)
|
||||
sph.EXPECT().ECNMode()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendNone)
|
||||
written := make(chan struct{}, 1)
|
||||
sender.EXPECT().WouldBlock().AnyTimes()
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16) { written <- struct{}{} })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(*packetBuffer, uint16, protocol.ECN) { written <- struct{}{} })
|
||||
mtuDiscoverer.EXPECT().ShouldSendProbe(gomock.Any()).Return(true)
|
||||
ping := ackhandler.Frame{Frame: &wire.PingFrame{}}
|
||||
mtuDiscoverer.EXPECT().GetPing().Return(ping, protocol.ByteCount(1234))
|
||||
|
@ -1747,7 +1761,7 @@ var _ = Describe("Connection", func() {
|
|||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sender.EXPECT().Close()
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
|
@ -1760,8 +1774,9 @@ var _ = Describe("Connection", func() {
|
|||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.sentPacketHandler = sph
|
||||
expectAppendPacket(packer, shortHeaderPacket{PacketNumber: 1}, []byte("packet1"))
|
||||
packer.EXPECT().AppendPacket(gomock.Any(), gomock.Any(), conn.version).Return(shortHeaderPacket{}, errNothingToPack)
|
||||
|
@ -1776,7 +1791,7 @@ var _ = Describe("Connection", func() {
|
|||
time.Sleep(50 * time.Millisecond)
|
||||
// only EXPECT calls after scheduleSending is called
|
||||
written := make(chan struct{})
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16) { close(written) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16, protocol.ECN) { close(written) })
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
||||
conn.scheduleSending()
|
||||
Eventually(written).Should(BeClosed())
|
||||
|
@ -1788,9 +1803,8 @@ var _ = Describe("Connection", func() {
|
|||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(_ time.Time, pn, _ protocol.PacketNumber, _ []ackhandler.StreamFrame, _ []ackhandler.Frame, _ protocol.EncryptionLevel, _ protocol.ByteCount, _ bool) {
|
||||
Expect(pn).To(Equal(protocol.PacketNumber(1234)))
|
||||
})
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), protocol.PacketNumber(1234), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.sentPacketHandler = sph
|
||||
rph := mockackhandler.NewMockReceivedPacketHandler(mockCtrl)
|
||||
rph.EXPECT().GetAlarmTimeout().Return(time.Now().Add(10 * time.Millisecond))
|
||||
|
@ -1799,7 +1813,7 @@ var _ = Describe("Connection", func() {
|
|||
conn.receivedPacketHandler = rph
|
||||
|
||||
written := make(chan struct{})
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16) { close(written) })
|
||||
sender.EXPECT().Send(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(*packetBuffer, uint16, protocol.ECN) { close(written) })
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
|
@ -1841,18 +1855,11 @@ var _ = Describe("Connection", func() {
|
|||
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().Return(protocol.ECT1).AnyTimes()
|
||||
sph.EXPECT().TimeUntilSend().Return(time.Now()).AnyTimes()
|
||||
gomock.InOrder(
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(_ time.Time, pn, _ protocol.PacketNumber, _ []ackhandler.StreamFrame, _ []ackhandler.Frame, encLevel protocol.EncryptionLevel, size protocol.ByteCount, _ bool) {
|
||||
Expect(encLevel).To(Equal(protocol.EncryptionInitial))
|
||||
Expect(pn).To(Equal(protocol.PacketNumber(13)))
|
||||
Expect(size).To(BeEquivalentTo(123))
|
||||
}),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(_ time.Time, pn, _ protocol.PacketNumber, _ []ackhandler.StreamFrame, _ []ackhandler.Frame, encLevel protocol.EncryptionLevel, size protocol.ByteCount, _ bool) {
|
||||
Expect(encLevel).To(Equal(protocol.EncryptionHandshake))
|
||||
Expect(pn).To(Equal(protocol.PacketNumber(37)))
|
||||
Expect(size).To(BeEquivalentTo(1234))
|
||||
}),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), protocol.PacketNumber(13), gomock.Any(), gomock.Any(), gomock.Any(), protocol.EncryptionInitial, protocol.ECT1, protocol.ByteCount(123), gomock.Any()),
|
||||
sph.EXPECT().SentPacket(gomock.Any(), protocol.PacketNumber(37), gomock.Any(), gomock.Any(), gomock.Any(), protocol.EncryptionHandshake, protocol.ECT1, protocol.ByteCount(1234), gomock.Any()),
|
||||
)
|
||||
gomock.InOrder(
|
||||
tracer.EXPECT().SentLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []logging.Frame) {
|
||||
|
@ -1864,7 +1871,7 @@ var _ = Describe("Connection", func() {
|
|||
)
|
||||
|
||||
sent := make(chan struct{})
|
||||
mconn.EXPECT().Write([]byte("foobar"), uint16(0)).Do(func([]byte, uint16) { close(sent) })
|
||||
mconn.EXPECT().Write([]byte("foobar"), uint16(0), protocol.ECT1).Do(func([]byte, uint16, protocol.ECN) { close(sent) })
|
||||
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
|
@ -1881,7 +1888,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -1952,7 +1959,7 @@ var _ = Describe("Connection", func() {
|
|||
}()
|
||||
handshakeCtx := conn.HandshakeComplete()
|
||||
Consistently(handshakeCtx).ShouldNot(BeClosed())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.closeLocal(errors.New("handshake error"))
|
||||
Consistently(handshakeCtx).ShouldNot(BeClosed())
|
||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||
|
@ -1961,11 +1968,12 @@ var _ = Describe("Connection", func() {
|
|||
It("sends a HANDSHAKE_DONE frame when the handshake completes", func() {
|
||||
sph := mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
sph.EXPECT().SendMode(gomock.Any()).Return(ackhandler.SendAny).AnyTimes()
|
||||
sph.EXPECT().ECNMode().AnyTimes()
|
||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||
sph.EXPECT().TimeUntilSend().AnyTimes()
|
||||
sph.EXPECT().SetHandshakeConfirmed()
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
sph.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.sentPacketHandler = sph
|
||||
done := make(chan struct{})
|
||||
|
@ -1987,7 +1995,7 @@ var _ = Describe("Connection", func() {
|
|||
cryptoSetup.EXPECT().NextEvent().Return(handshake.Event{Kind: handshake.EventNoEvent})
|
||||
cryptoSetup.EXPECT().SetHandshakeConfirmed()
|
||||
cryptoSetup.EXPECT().GetSessionTicket()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
Expect(conn.handleHandshakeComplete()).To(Succeed())
|
||||
conn.run()
|
||||
}()
|
||||
|
@ -2016,7 +2024,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -2043,7 +2051,7 @@ var _ = Describe("Connection", func() {
|
|||
expectReplaceWithClosed()
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
Expect(conn.CloseWithError(0x1337, testErr.Error())).To(Succeed())
|
||||
|
@ -2102,7 +2110,7 @@ var _ = Describe("Connection", func() {
|
|||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -2255,7 +2263,7 @@ var _ = Describe("Connection", func() {
|
|||
// make the go routine return
|
||||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
conn.shutdown()
|
||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||
})
|
||||
|
@ -2338,7 +2346,7 @@ var _ = Describe("Connection", func() {
|
|||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
expectReplaceWithClosed()
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -2554,7 +2562,7 @@ var _ = Describe("Client Connection", func() {
|
|||
packer.EXPECT().PackApplicationClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||
cryptoSetup.EXPECT().Close()
|
||||
connRunner.EXPECT().ReplaceWithClosed([]protocol.ConnectionID{srcConnID}, gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any()).MaxTimes(1)
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any()).MaxTimes(1)
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any())
|
||||
tracer.EXPECT().Close()
|
||||
conn.shutdown()
|
||||
|
@ -2851,7 +2859,7 @@ var _ = Describe("Client Connection", func() {
|
|||
packer.EXPECT().PackConnectionClose(gomock.Any(), gomock.Any(), conn.version).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil).MaxTimes(1)
|
||||
}
|
||||
cryptoSetup.EXPECT().Close()
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any())
|
||||
mconn.EXPECT().Write(gomock.Any(), gomock.Any(), gomock.Any())
|
||||
gomock.InOrder(
|
||||
tracer.EXPECT().ClosedConnection(gomock.Any()),
|
||||
tracer.EXPECT().Close(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue