mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
prioritize sending ACKs over sending new DATAGRAM frames (#3544)
This commit is contained in:
parent
62b82789c0
commit
c57ea6f276
5 changed files with 92 additions and 32 deletions
|
@ -91,7 +91,7 @@ var _ = Describe("Packet packer", func() {
|
|||
ackFramer = NewMockAckFrameSource(mockCtrl)
|
||||
sealingManager = NewMockSealingManager(mockCtrl)
|
||||
pnManager = mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||
datagramQueue = newDatagramQueue(func() {}, utils.DefaultLogger)
|
||||
datagramQueue = newDatagramQueue(func() {}, utils.DefaultLogger, version)
|
||||
|
||||
packer = newPacketPacker(
|
||||
protocol.ParseConnectionID([]byte{1, 2, 3, 4, 5, 6, 7, 8}),
|
||||
|
@ -554,6 +554,7 @@ var _ = Describe("Packet packer", func() {
|
|||
})
|
||||
|
||||
It("packs DATAGRAM frames", func() {
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true)
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||
|
@ -580,6 +581,36 @@ var _ = Describe("Packet packer", func() {
|
|||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
It("doesn't pack a DATAGRAM frame if the ACK frame is too large", func() {
|
||||
ackFramer.EXPECT().GetAckFrame(protocol.Encryption1RTT, true).Return(&wire.AckFrame{AckRanges: []wire.AckRange{{Largest: 100}}})
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
pnManager.EXPECT().PopPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42))
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||
f := &wire.DatagramFrame{
|
||||
DataLenPresent: true,
|
||||
Data: make([]byte, maxPacketSize-10),
|
||||
}
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
defer GinkgoRecover()
|
||||
defer close(done)
|
||||
datagramQueue.AddAndWait(f)
|
||||
}()
|
||||
// make sure the DATAGRAM has actually been queued
|
||||
time.Sleep(scaleDuration(20 * time.Millisecond))
|
||||
|
||||
framer.EXPECT().HasData()
|
||||
p, err := packer.PackPacket()
|
||||
Expect(p).ToNot(BeNil())
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(p.ack).ToNot(BeNil())
|
||||
Expect(p.frames).To(BeEmpty())
|
||||
Expect(p.buffer.Data).ToNot(BeEmpty())
|
||||
Expect(done).ToNot(BeClosed())
|
||||
datagramQueue.CloseWithError(nil)
|
||||
Eventually(done).Should(BeClosed())
|
||||
})
|
||||
|
||||
It("accounts for the space consumed by control frames", func() {
|
||||
pnManager.EXPECT().PeekPacketNumber(protocol.Encryption1RTT).Return(protocol.PacketNumber(0x42), protocol.PacketNumberLen2)
|
||||
sealingManager.EXPECT().Get1RTTSealer().Return(getSealer(), nil)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue