mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 05:07:36 +03:00
split the tracing function for received short and long header packets
This commit is contained in:
parent
3a12a898a5
commit
ed15a94703
18 changed files with 222 additions and 89 deletions
|
@ -1199,7 +1199,16 @@ func (s *connection) handleUnpackedPacket(
|
||||||
for i, frame := range frames {
|
for i, frame := range frames {
|
||||||
fs[i] = logutils.ConvertFrame(frame)
|
fs[i] = logutils.ConvertFrame(frame)
|
||||||
}
|
}
|
||||||
s.tracer.ReceivedPacket(packet.hdr, packetSize, fs)
|
if packet.hdr.IsLongHeader {
|
||||||
|
s.tracer.ReceivedLongHeaderPacket(packet.hdr, packetSize, fs)
|
||||||
|
} else {
|
||||||
|
s.tracer.ReceivedShortHeaderPacket(&wire.ShortHeader{
|
||||||
|
DestConnectionID: packet.hdr.DestConnectionID,
|
||||||
|
PacketNumber: packet.hdr.PacketNumber,
|
||||||
|
PacketNumberLen: packet.hdr.PacketNumberLen,
|
||||||
|
KeyPhase: packet.hdr.KeyPhase,
|
||||||
|
}, packetSize, fs)
|
||||||
|
}
|
||||||
for _, frame := range frames {
|
for _, frame := range frames {
|
||||||
if err := s.handleFrame(frame, packet.encryptionLevel, packet.hdr.DestConnectionID); err != nil {
|
if err := s.handleFrame(frame, packet.encryptionLevel, packet.hdr.DestConnectionID); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -572,7 +572,7 @@ var _ = Describe("Connection", func() {
|
||||||
})
|
})
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()),
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()),
|
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()),
|
||||||
tracer.EXPECT().ClosedConnection(gomock.Any()),
|
tracer.EXPECT().ClosedConnection(gomock.Any()),
|
||||||
tracer.EXPECT().Close(),
|
tracer.EXPECT().Close(),
|
||||||
)
|
)
|
||||||
|
@ -749,7 +749,7 @@ var _ = Describe("Connection", func() {
|
||||||
conn.receivedPacketHandler = rph
|
conn.receivedPacketHandler = rph
|
||||||
packet.rcvTime = rcvTime
|
packet.rcvTime = rcvTime
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ReceivedPacket(&unpackedHdr, protocol.ByteCount(len(packet.data)), []logging.Frame{})
|
tracer.EXPECT().ReceivedShortHeaderPacket(&wire.ShortHeader{PacketNumber: 0x1337, PacketNumberLen: 1, DestConnectionID: srcConnID}, protocol.ByteCount(len(packet.data)), []logging.Frame{})
|
||||||
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ var _ = Describe("Connection", func() {
|
||||||
conn.receivedPacketHandler = rph
|
conn.receivedPacketHandler = rph
|
||||||
packet.rcvTime = rcvTime
|
packet.rcvTime = rcvTime
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ReceivedPacket(&unpackedHdr, protocol.ByteCount(len(packet.data)), []logging.Frame{&logging.PingFrame{}})
|
tracer.EXPECT().ReceivedShortHeaderPacket(&wire.ShortHeader{PacketNumber: 0x1337, PacketNumberLen: 1, DestConnectionID: srcConnID}, protocol.ByteCount(len(packet.data)), []logging.Frame{&logging.PingFrame{}})
|
||||||
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -854,7 +854,7 @@ var _ = Describe("Connection", func() {
|
||||||
}, nil
|
}, nil
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ShortHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
packer.EXPECT().PackCoalescedPacket() // only expect a single call
|
packer.EXPECT().PackCoalescedPacket() // only expect a single call
|
||||||
|
|
||||||
|
@ -901,7 +901,7 @@ var _ = Describe("Connection", func() {
|
||||||
}, nil
|
}, nil
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ShortHeader, _ protocol.ByteCount, _ []logging.Frame) {
|
||||||
}).Times(3)
|
}).Times(3)
|
||||||
packer.EXPECT().PackCoalescedPacket().Times(3) // only expect a single call
|
packer.EXPECT().PackCoalescedPacket().Times(3) // only expect a single call
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ var _ = Describe("Connection", func() {
|
||||||
}, nil)
|
}, nil)
|
||||||
p1 := getPacket(hdr1, nil)
|
p1 := getPacket(hdr1, nil)
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(p1.data)), gomock.Any())
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), protocol.ByteCount(len(p1.data)), gomock.Any())
|
||||||
Expect(conn.handlePacketImpl(p1)).To(BeTrue())
|
Expect(conn.handlePacketImpl(p1)).To(BeTrue())
|
||||||
// The next packet has to be ignored, since the source connection ID doesn't match.
|
// The next packet has to be ignored, since the source connection ID doesn't match.
|
||||||
p2 := getPacket(hdr2, nil)
|
p2 := getPacket(hdr2, nil)
|
||||||
|
@ -1090,7 +1090,7 @@ var _ = Describe("Connection", func() {
|
||||||
}, nil)
|
}, nil)
|
||||||
packet.remoteAddr = &net.IPAddr{IP: net.IPv4(192, 168, 0, 100)}
|
packet.remoteAddr = &net.IPAddr{IP: net.IPv4(192, 168, 0, 100)}
|
||||||
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().StartedConnection(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any())
|
tracer.EXPECT().ReceivedShortHeaderPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any())
|
||||||
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1125,10 +1125,10 @@ var _ = Describe("Connection", func() {
|
||||||
return &unpackedPacket{
|
return &unpackedPacket{
|
||||||
encryptionLevel: protocol.EncryptionHandshake,
|
encryptionLevel: protocol.EncryptionHandshake,
|
||||||
data: []byte{0},
|
data: []byte{0},
|
||||||
hdr: &wire.ExtendedHeader{},
|
hdr: &wire.ExtendedHeader{Header: wire.Header{IsLongHeader: true}},
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any())
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), protocol.ByteCount(len(packet.data)), gomock.Any())
|
||||||
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
Expect(conn.handlePacketImpl(packet)).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1141,7 +1141,7 @@ var _ = Describe("Connection", func() {
|
||||||
data: []byte{0},
|
data: []byte{0},
|
||||||
hdr: &wire.ExtendedHeader{
|
hdr: &wire.ExtendedHeader{
|
||||||
PacketNumber: 1,
|
PacketNumber: 1,
|
||||||
Header: wire.Header{SrcConnectionID: destConnID},
|
Header: wire.Header{SrcConnectionID: destConnID, IsLongHeader: true},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
|
@ -1153,13 +1153,13 @@ var _ = Describe("Connection", func() {
|
||||||
data: []byte{0},
|
data: []byte{0},
|
||||||
hdr: &wire.ExtendedHeader{
|
hdr: &wire.ExtendedHeader{
|
||||||
PacketNumber: 2,
|
PacketNumber: 2,
|
||||||
Header: wire.Header{SrcConnectionID: destConnID},
|
Header: wire.Header{SrcConnectionID: destConnID, IsLongHeader: true},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()),
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()),
|
||||||
)
|
)
|
||||||
packet1.data = append(packet1.data, packet2.data...)
|
packet1.data = append(packet1.data, packet2.data...)
|
||||||
Expect(conn.handlePacketImpl(packet1)).To(BeTrue())
|
Expect(conn.handlePacketImpl(packet1)).To(BeTrue())
|
||||||
|
@ -1176,13 +1176,13 @@ var _ = Describe("Connection", func() {
|
||||||
return &unpackedPacket{
|
return &unpackedPacket{
|
||||||
encryptionLevel: protocol.EncryptionHandshake,
|
encryptionLevel: protocol.EncryptionHandshake,
|
||||||
data: []byte{0},
|
data: []byte{0},
|
||||||
hdr: &wire.ExtendedHeader{},
|
hdr: &wire.ExtendedHeader{Header: wire.Header{IsLongHeader: true}},
|
||||||
}, nil
|
}, nil
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().BufferedPacket(gomock.Any()),
|
tracer.EXPECT().BufferedPacket(gomock.Any()),
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()),
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), gomock.Any()),
|
||||||
)
|
)
|
||||||
packet1.data = append(packet1.data, packet2.data...)
|
packet1.data = append(packet1.data, packet2.data...)
|
||||||
Expect(conn.handlePacketImpl(packet1)).To(BeTrue())
|
Expect(conn.handlePacketImpl(packet1)).To(BeTrue())
|
||||||
|
@ -1200,13 +1200,13 @@ var _ = Describe("Connection", func() {
|
||||||
return &unpackedPacket{
|
return &unpackedPacket{
|
||||||
encryptionLevel: protocol.EncryptionHandshake,
|
encryptionLevel: protocol.EncryptionHandshake,
|
||||||
data: []byte{0},
|
data: []byte{0},
|
||||||
hdr: &wire.ExtendedHeader{},
|
hdr: &wire.ExtendedHeader{Header: wire.Header{IsLongHeader: true}},
|
||||||
}, nil
|
}, nil
|
||||||
})
|
})
|
||||||
_, packet2 := getPacketWithLength(wrongConnID, 123)
|
_, packet2 := getPacketWithLength(wrongConnID, 123)
|
||||||
// don't EXPECT any more calls to unpacker.Unpack()
|
// don't EXPECT any more calls to unpacker.Unpack()
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), protocol.ByteCount(len(packet1.data)), gomock.Any()),
|
||||||
tracer.EXPECT().DroppedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), logging.PacketDropUnknownConnectionID),
|
tracer.EXPECT().DroppedPacket(gomock.Any(), protocol.ByteCount(len(packet2.data)), logging.PacketDropUnknownConnectionID),
|
||||||
)
|
)
|
||||||
packet1.data = append(packet1.data, packet2.data...)
|
packet1.data = append(packet1.data, packet2.data...)
|
||||||
|
@ -2481,7 +2481,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
},
|
},
|
||||||
PacketNumberLen: protocol.PacketNumberLen2,
|
PacketNumberLen: protocol.PacketNumberLen2,
|
||||||
}, []byte("foobar"))
|
}, []byte("foobar"))
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), p.Size(), []logging.Frame{})
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), p.Size(), []logging.Frame{})
|
||||||
Expect(conn.handlePacketImpl(p)).To(BeTrue())
|
Expect(conn.handlePacketImpl(p)).To(BeTrue())
|
||||||
// make sure the go routine returns
|
// make sure the go routine returns
|
||||||
packer.EXPECT().PackApplicationClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
packer.EXPECT().PackApplicationClose(gomock.Any()).Return(&coalescedPacket{buffer: getPacketBuffer()}, nil)
|
||||||
|
@ -2518,7 +2518,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
DestConnectionID: srcConnID,
|
DestConnectionID: srcConnID,
|
||||||
SrcConnectionID: destConnID,
|
SrcConnectionID: destConnID,
|
||||||
}
|
}
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
Expect(conn.handleSinglePacket(&receivedPacket{buffer: getPacketBuffer()}, hdr)).To(BeTrue())
|
Expect(conn.handleSinglePacket(&receivedPacket{buffer: getPacketBuffer()}, hdr)).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2951,7 +2951,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
hdr: hdr1,
|
hdr: hdr1,
|
||||||
data: []byte{0}, // one PADDING frame
|
data: []byte{0}, // one PADDING frame
|
||||||
}, nil)
|
}, nil)
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
Expect(conn.handlePacketImpl(getPacket(hdr1, nil))).To(BeTrue())
|
Expect(conn.handlePacketImpl(getPacket(hdr1, nil))).To(BeTrue())
|
||||||
// The next packet has to be ignored, since the source connection ID doesn't match.
|
// The next packet has to be ignored, since the source connection ID doesn't match.
|
||||||
tracer.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().DroppedPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
|
@ -2979,7 +2979,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
It("fails on Initial-level ACK for unsent packet", func() {
|
It("fails on Initial-level ACK for unsent packet", func() {
|
||||||
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 2, Largest: 2}}}
|
ack := &wire.AckFrame{AckRanges: []wire.AckRange{{Smallest: 2, Largest: 2}}}
|
||||||
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, conn.version, destConnID, []wire.Frame{ack})
|
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, conn.version, destConnID, []wire.Frame{ack})
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
Expect(conn.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse())
|
Expect(conn.handlePacketImpl(wrapPacket(initialPacket))).To(BeFalse())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -2991,7 +2991,7 @@ var _ = Describe("Client Connection", func() {
|
||||||
ReasonPhrase: "mitm attacker",
|
ReasonPhrase: "mitm attacker",
|
||||||
}
|
}
|
||||||
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, conn.version, destConnID, []wire.Frame{connCloseFrame})
|
initialPacket := testutils.ComposeInitialPacket(destConnID, srcConnID, conn.version, destConnID, []wire.Frame{connCloseFrame})
|
||||||
tracer.EXPECT().ReceivedPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().ReceivedLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
Expect(conn.handlePacketImpl(wrapPacket(initialPacket))).To(BeTrue())
|
Expect(conn.handlePacketImpl(wrapPacket(initialPacket))).To(BeTrue())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sentHeaders []*logging.ExtendedHeader
|
sentHeaders []*logging.ExtendedHeader
|
||||||
receivedHeaders []*logging.ExtendedHeader
|
receivedHeaders []*logging.ShortHeader
|
||||||
)
|
)
|
||||||
|
|
||||||
func countKeyPhases() (sent, received int) {
|
func countKeyPhases() (sent, received int) {
|
||||||
|
@ -33,9 +33,6 @@ func countKeyPhases() (sent, received int) {
|
||||||
}
|
}
|
||||||
lastKeyPhase = protocol.KeyPhaseOne
|
lastKeyPhase = protocol.KeyPhaseOne
|
||||||
for _, hdr := range receivedHeaders {
|
for _, hdr := range receivedHeaders {
|
||||||
if hdr.IsLongHeader {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if hdr.KeyPhase != lastKeyPhase {
|
if hdr.KeyPhase != lastKeyPhase {
|
||||||
received++
|
received++
|
||||||
lastKeyPhase = hdr.KeyPhase
|
lastKeyPhase = hdr.KeyPhase
|
||||||
|
@ -52,7 +49,7 @@ func (t *keyUpdateConnTracer) SentPacket(hdr *logging.ExtendedHeader, size loggi
|
||||||
sentHeaders = append(sentHeaders, hdr)
|
sentHeaders = append(sentHeaders, hdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *keyUpdateConnTracer) ReceivedPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, frames []logging.Frame) {
|
func (t *keyUpdateConnTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, size logging.ByteCount, frames []logging.Frame) {
|
||||||
receivedHeaders = append(receivedHeaders, hdr)
|
receivedHeaders = append(receivedHeaders, hdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,11 +84,8 @@ var _ = Describe("Packetization", func() {
|
||||||
}
|
}
|
||||||
Expect(conn.CloseWithError(0, "")).To(Succeed())
|
Expect(conn.CloseWithError(0, "")).To(Succeed())
|
||||||
|
|
||||||
countBundledPackets := func(packets []packet) (numBundled int) {
|
countBundledPackets := func(packets []shortHeaderPacket) (numBundled int) {
|
||||||
for _, p := range packets {
|
for _, p := range packets {
|
||||||
if p.hdr.IsLongHeader {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var hasAck, hasStreamFrame bool
|
var hasAck, hasStreamFrame bool
|
||||||
for _, f := range p.frames {
|
for _, f := range p.frames {
|
||||||
switch f.(type) {
|
switch f.(type) {
|
||||||
|
@ -105,8 +102,8 @@ var _ = Describe("Packetization", func() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
numBundledIncoming := countBundledPackets(clientTracer.getRcvdPackets())
|
numBundledIncoming := countBundledPackets(clientTracer.getRcvdShortHeaderPackets())
|
||||||
numBundledOutgoing := countBundledPackets(serverTracer.getRcvdPackets())
|
numBundledOutgoing := countBundledPackets(serverTracer.getRcvdShortHeaderPackets())
|
||||||
fmt.Fprintf(GinkgoWriter, "bundled incoming packets: %d / %d\n", numBundledIncoming, numMsg)
|
fmt.Fprintf(GinkgoWriter, "bundled incoming packets: %d / %d\n", numBundledIncoming, numMsg)
|
||||||
fmt.Fprintf(GinkgoWriter, "bundled outgoing packets: %d / %d\n", numBundledOutgoing, numMsg)
|
fmt.Fprintf(GinkgoWriter, "bundled outgoing packets: %d / %d\n", numBundledOutgoing, numMsg)
|
||||||
Expect(numBundledIncoming).To(And(
|
Expect(numBundledIncoming).To(And(
|
||||||
|
|
|
@ -347,18 +347,29 @@ type packet struct {
|
||||||
frames []logging.Frame
|
frames []logging.Frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type shortHeaderPacket struct {
|
||||||
|
time time.Time
|
||||||
|
hdr *logging.ShortHeader
|
||||||
|
frames []logging.Frame
|
||||||
|
}
|
||||||
|
|
||||||
type packetTracer struct {
|
type packetTracer struct {
|
||||||
logging.NullConnectionTracer
|
logging.NullConnectionTracer
|
||||||
closed chan struct{}
|
closed chan struct{}
|
||||||
sent, rcvd []packet
|
rcvdShortHdr []shortHeaderPacket
|
||||||
|
sent, rcvdLongHdr []packet
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPacketTracer() *packetTracer {
|
func newPacketTracer() *packetTracer {
|
||||||
return &packetTracer{closed: make(chan struct{})}
|
return &packetTracer{closed: make(chan struct{})}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *packetTracer) ReceivedPacket(hdr *logging.ExtendedHeader, _ logging.ByteCount, frames []logging.Frame) {
|
func (t *packetTracer) ReceivedLongHeaderPacket(hdr *logging.ExtendedHeader, _ logging.ByteCount, frames []logging.Frame) {
|
||||||
t.rcvd = append(t.rcvd, packet{time: time.Now(), hdr: hdr, frames: frames})
|
t.rcvdLongHdr = append(t.rcvdLongHdr, packet{time: time.Now(), hdr: hdr, frames: frames})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *packetTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, _ logging.ByteCount, frames []logging.Frame) {
|
||||||
|
t.rcvdShortHdr = append(t.rcvdShortHdr, shortHeaderPacket{time: time.Now(), hdr: hdr, frames: frames})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *packetTracer) SentPacket(hdr *logging.ExtendedHeader, _ logging.ByteCount, ack *wire.AckFrame, frames []logging.Frame) {
|
func (t *packetTracer) SentPacket(hdr *logging.ExtendedHeader, _ logging.ByteCount, ack *wire.AckFrame, frames []logging.Frame) {
|
||||||
|
@ -373,9 +384,14 @@ func (t *packetTracer) getSentPackets() []packet {
|
||||||
return t.sent
|
return t.sent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *packetTracer) getRcvdPackets() []packet {
|
func (t *packetTracer) getRcvdLongHeaderPackets() []packet {
|
||||||
<-t.closed
|
<-t.closed
|
||||||
return t.rcvd
|
return t.rcvdLongHdr
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *packetTracer) getRcvdShortHeaderPackets() []shortHeaderPacket {
|
||||||
|
<-t.closed
|
||||||
|
return t.rcvdShortHdr
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestSelf(t *testing.T) {
|
func TestSelf(t *testing.T) {
|
||||||
|
|
|
@ -226,7 +226,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
lastAckElicitingPacketSentAt = p.time
|
lastAckElicitingPacketSentAt = p.time
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rcvdPackets := tr.getRcvdPackets()
|
rcvdPackets := tr.getRcvdShortHeaderPackets()
|
||||||
lastPacketRcvdAt := rcvdPackets[len(rcvdPackets)-1].time
|
lastPacketRcvdAt := rcvdPackets[len(rcvdPackets)-1].time
|
||||||
// We're ignoring here that only the first ack-eliciting packet sent resets the idle timeout.
|
// We're ignoring here that only the first ack-eliciting packet sent resets the idle timeout.
|
||||||
// This is ok since we're dealing with a lossless connection here,
|
// This is ok since we're dealing with a lossless connection here,
|
||||||
|
|
|
@ -217,7 +217,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
)
|
)
|
||||||
|
|
||||||
var numNewConnIDs int
|
var numNewConnIDs int
|
||||||
for _, p := range tracer.getRcvdPackets() {
|
for _, p := range tracer.getRcvdLongHeaderPackets() {
|
||||||
for _, f := range p.frames {
|
for _, f := range p.frames {
|
||||||
if _, ok := f.(*logging.NewConnectionIDFrame); ok {
|
if _, ok := f.(*logging.NewConnectionIDFrame); ok {
|
||||||
numNewConnIDs++
|
numNewConnIDs++
|
||||||
|
@ -233,7 +233,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
||||||
Expect(num0RTT).ToNot(BeZero())
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
zeroRTTPackets := get0RTTPackets(tracer.getRcvdPackets())
|
zeroRTTPackets := get0RTTPackets(tracer.getRcvdLongHeaderPackets())
|
||||||
Expect(len(zeroRTTPackets)).To(BeNumerically(">", 10))
|
Expect(len(zeroRTTPackets)).To(BeNumerically(">", 10))
|
||||||
sort.Slice(zeroRTTPackets, func(i, j int) bool { return zeroRTTPackets[i] < zeroRTTPackets[j] })
|
sort.Slice(zeroRTTPackets, func(i, j int) bool { return zeroRTTPackets[i] < zeroRTTPackets[j] })
|
||||||
Expect(zeroRTTPackets[0]).To(Equal(protocol.PacketNumber(0)))
|
Expect(zeroRTTPackets[0]).To(Equal(protocol.PacketNumber(0)))
|
||||||
|
@ -310,7 +310,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
||||||
Expect(num0RTT).To(Or(BeEquivalentTo(2), BeEquivalentTo(3))) // the FIN might be sent in a separate packet
|
Expect(num0RTT).To(Or(BeEquivalentTo(2), BeEquivalentTo(3))) // the FIN might be sent in a separate packet
|
||||||
Expect(get0RTTPackets(tracer.getRcvdPackets())).To(HaveLen(int(num0RTT)))
|
Expect(get0RTTPackets(tracer.getRcvdLongHeaderPackets())).To(HaveLen(int(num0RTT)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("transfers 0-RTT data, when 0-RTT packets are lost", func() {
|
It("transfers 0-RTT data, when 0-RTT packets are lost", func() {
|
||||||
|
@ -367,7 +367,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets. Dropped %d of those.", num0RTT, numDropped)
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets. Dropped %d of those.", num0RTT, numDropped)
|
||||||
Expect(numDropped).ToNot(BeZero())
|
Expect(numDropped).ToNot(BeZero())
|
||||||
Expect(num0RTT).ToNot(BeZero())
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
Expect(get0RTTPackets(tracer.getRcvdPackets())).ToNot(BeEmpty())
|
Expect(get0RTTPackets(tracer.getRcvdLongHeaderPackets())).ToNot(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("retransmits all 0-RTT data when the server performs a Retry", func() {
|
It("retransmits all 0-RTT data when the server performs a Retry", func() {
|
||||||
|
@ -441,7 +441,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
defer mutex.Unlock()
|
defer mutex.Unlock()
|
||||||
Expect(firstCounter).To(BeNumerically("~", 5000+100 /* framing overhead */, 100)) // the FIN bit might be sent extra
|
Expect(firstCounter).To(BeNumerically("~", 5000+100 /* framing overhead */, 100)) // the FIN bit might be sent extra
|
||||||
Expect(secondCounter).To(BeNumerically("~", firstCounter, 20))
|
Expect(secondCounter).To(BeNumerically("~", firstCounter, 20))
|
||||||
zeroRTTPackets := get0RTTPackets(tracer.getRcvdPackets())
|
zeroRTTPackets := get0RTTPackets(tracer.getRcvdLongHeaderPackets())
|
||||||
Expect(len(zeroRTTPackets)).To(BeNumerically(">=", 5))
|
Expect(len(zeroRTTPackets)).To(BeNumerically(">=", 5))
|
||||||
Expect(zeroRTTPackets[0]).To(BeNumerically(">=", protocol.PacketNumber(5)))
|
Expect(zeroRTTPackets[0]).To(BeNumerically(">=", protocol.PacketNumber(5)))
|
||||||
})
|
})
|
||||||
|
@ -516,7 +516,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
||||||
Expect(num0RTT).ToNot(BeZero())
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
Expect(get0RTTPackets(tracer.getRcvdPackets())).To(BeEmpty())
|
Expect(get0RTTPackets(tracer.getRcvdLongHeaderPackets())).To(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
It("rejects 0-RTT when the ALPN changed", func() {
|
It("rejects 0-RTT when the ALPN changed", func() {
|
||||||
|
@ -545,7 +545,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
||||||
Expect(num0RTT).ToNot(BeZero())
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
Expect(get0RTTPackets(tracer.getRcvdPackets())).To(BeEmpty())
|
Expect(get0RTTPackets(tracer.getRcvdLongHeaderPackets())).To(BeEmpty())
|
||||||
})
|
})
|
||||||
|
|
||||||
DescribeTable("flow control limits",
|
DescribeTable("flow control limits",
|
||||||
|
@ -603,7 +603,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
Eventually(conn.Context().Done()).Should(BeClosed())
|
Eventually(conn.Context().Done()).Should(BeClosed())
|
||||||
|
|
||||||
var processedFirst bool
|
var processedFirst bool
|
||||||
for _, p := range tracer.getRcvdPackets() {
|
for _, p := range tracer.getRcvdLongHeaderPackets() {
|
||||||
for _, f := range p.frames {
|
for _, f := range p.frames {
|
||||||
if sf, ok := f.(*logging.StreamFrame); ok {
|
if sf, ok := f.(*logging.StreamFrame); ok {
|
||||||
if !processedFirst {
|
if !processedFirst {
|
||||||
|
@ -613,9 +613,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
Expect(sf.Length).To(BeEquivalentTo(3))
|
Expect(sf.Length).To(BeEquivalentTo(3))
|
||||||
processedFirst = true
|
processedFirst = true
|
||||||
} else {
|
} else {
|
||||||
// All other STREAM frames can only be sent after handshake completion.
|
Fail("STREAM was shouldn't have been sent in 0-RTT")
|
||||||
Expect(p.hdr.IsLongHeader).To(BeFalse())
|
|
||||||
Expect(sf.Offset).ToNot(BeZero())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -700,7 +698,7 @@ var _ = Describe("0-RTT", func() {
|
||||||
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
num0RTT := atomic.LoadUint32(num0RTTPackets)
|
||||||
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
fmt.Fprintf(GinkgoWriter, "Sent %d 0-RTT packets.", num0RTT)
|
||||||
Expect(num0RTT).ToNot(BeZero())
|
Expect(num0RTT).ToNot(BeZero())
|
||||||
Expect(get0RTTPackets(tracer.getRcvdPackets())).To(BeEmpty())
|
Expect(get0RTTPackets(tracer.getRcvdLongHeaderPackets())).To(BeEmpty())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -732,8 +730,8 @@ var _ = Describe("0-RTT", func() {
|
||||||
|
|
||||||
transfer0RTTData(ln, proxy.LocalPort(), clientConf, nil, PRData)
|
transfer0RTTData(ln, proxy.LocalPort(), clientConf, nil, PRData)
|
||||||
|
|
||||||
Expect(tracer.getRcvdPackets()[0].hdr.Type).To(Equal(protocol.PacketTypeInitial))
|
Expect(tracer.getRcvdLongHeaderPackets()[0].hdr.Type).To(Equal(protocol.PacketTypeInitial))
|
||||||
zeroRTTPackets := get0RTTPackets(tracer.getRcvdPackets())
|
zeroRTTPackets := get0RTTPackets(tracer.getRcvdLongHeaderPackets())
|
||||||
Expect(len(zeroRTTPackets)).To(BeNumerically(">", 10))
|
Expect(len(zeroRTTPackets)).To(BeNumerically(">", 10))
|
||||||
Expect(zeroRTTPackets[0]).To(Equal(protocol.PacketNumber(0)))
|
Expect(zeroRTTPackets[0]).To(Equal(protocol.PacketNumber(0)))
|
||||||
})
|
})
|
||||||
|
|
|
@ -183,16 +183,16 @@ func (mr *MockConnectionTracerMockRecorder) NegotiatedVersion(arg0, arg1, arg2 i
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NegotiatedVersion", reflect.TypeOf((*MockConnectionTracer)(nil).NegotiatedVersion), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NegotiatedVersion", reflect.TypeOf((*MockConnectionTracer)(nil).NegotiatedVersion), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceivedPacket mocks base method.
|
// ReceivedLongHeaderPacket mocks base method.
|
||||||
func (m *MockConnectionTracer) ReceivedPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 []logging.Frame) {
|
func (m *MockConnectionTracer) ReceivedLongHeaderPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 []logging.Frame) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "ReceivedPacket", arg0, arg1, arg2)
|
m.ctrl.Call(m, "ReceivedLongHeaderPacket", arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceivedPacket indicates an expected call of ReceivedPacket.
|
// ReceivedLongHeaderPacket indicates an expected call of ReceivedLongHeaderPacket.
|
||||||
func (mr *MockConnectionTracerMockRecorder) ReceivedPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockConnectionTracerMockRecorder) ReceivedLongHeaderPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedPacket), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedLongHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedLongHeaderPacket), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceivedRetry mocks base method.
|
// ReceivedRetry mocks base method.
|
||||||
|
@ -207,6 +207,18 @@ func (mr *MockConnectionTracerMockRecorder) ReceivedRetry(arg0 interface{}) *gom
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedRetry", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedRetry), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedRetry", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedRetry), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReceivedShortHeaderPacket mocks base method.
|
||||||
|
func (m *MockConnectionTracer) ReceivedShortHeaderPacket(arg0 *wire.ShortHeader, arg1 protocol.ByteCount, arg2 []logging.Frame) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "ReceivedShortHeaderPacket", arg0, arg1, arg2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReceivedShortHeaderPacket indicates an expected call of ReceivedShortHeaderPacket.
|
||||||
|
func (mr *MockConnectionTracerMockRecorder) ReceivedShortHeaderPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedShortHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedShortHeaderPacket), arg0, arg1, arg2)
|
||||||
|
}
|
||||||
|
|
||||||
// ReceivedTransportParameters mocks base method.
|
// ReceivedTransportParameters mocks base method.
|
||||||
func (m *MockConnectionTracer) ReceivedTransportParameters(arg0 *wire.TransportParameters) {
|
func (m *MockConnectionTracer) ReceivedTransportParameters(arg0 *wire.TransportParameters) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -44,8 +44,10 @@ type (
|
||||||
|
|
||||||
// The Header is the QUIC packet header, before removing header protection.
|
// The Header is the QUIC packet header, before removing header protection.
|
||||||
Header = wire.Header
|
Header = wire.Header
|
||||||
// The ExtendedHeader is the QUIC packet header, after removing header protection.
|
// The ExtendedHeader is the QUIC Long Header packet header, after removing header protection.
|
||||||
ExtendedHeader = wire.ExtendedHeader
|
ExtendedHeader = wire.ExtendedHeader
|
||||||
|
// The ShortHeader is the QUIC Short Header packet header, after removing header protection.
|
||||||
|
ShortHeader = wire.ShortHeader
|
||||||
// The TransportParameters are QUIC transport parameters.
|
// The TransportParameters are QUIC transport parameters.
|
||||||
TransportParameters = wire.TransportParameters
|
TransportParameters = wire.TransportParameters
|
||||||
// The PreferredAddress is the preferred address sent in the transport parameters.
|
// The PreferredAddress is the preferred address sent in the transport parameters.
|
||||||
|
@ -116,7 +118,8 @@ type ConnectionTracer interface {
|
||||||
SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
|
SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
|
||||||
ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber)
|
ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber)
|
||||||
ReceivedRetry(*Header)
|
ReceivedRetry(*Header)
|
||||||
ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
|
ReceivedLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
|
||||||
|
ReceivedShortHeaderPacket(hdr *ShortHeader, size ByteCount, frames []Frame)
|
||||||
BufferedPacket(PacketType)
|
BufferedPacket(PacketType)
|
||||||
DroppedPacket(PacketType, ByteCount, PacketDropReason)
|
DroppedPacket(PacketType, ByteCount, PacketDropReason)
|
||||||
UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int)
|
UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int)
|
||||||
|
|
|
@ -182,16 +182,16 @@ func (mr *MockConnectionTracerMockRecorder) NegotiatedVersion(arg0, arg1, arg2 i
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NegotiatedVersion", reflect.TypeOf((*MockConnectionTracer)(nil).NegotiatedVersion), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "NegotiatedVersion", reflect.TypeOf((*MockConnectionTracer)(nil).NegotiatedVersion), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceivedPacket mocks base method.
|
// ReceivedLongHeaderPacket mocks base method.
|
||||||
func (m *MockConnectionTracer) ReceivedPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 []Frame) {
|
func (m *MockConnectionTracer) ReceivedLongHeaderPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 []Frame) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "ReceivedPacket", arg0, arg1, arg2)
|
m.ctrl.Call(m, "ReceivedLongHeaderPacket", arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceivedPacket indicates an expected call of ReceivedPacket.
|
// ReceivedLongHeaderPacket indicates an expected call of ReceivedLongHeaderPacket.
|
||||||
func (mr *MockConnectionTracerMockRecorder) ReceivedPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *MockConnectionTracerMockRecorder) ReceivedLongHeaderPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedPacket), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedLongHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedLongHeaderPacket), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReceivedRetry mocks base method.
|
// ReceivedRetry mocks base method.
|
||||||
|
@ -206,6 +206,18 @@ func (mr *MockConnectionTracerMockRecorder) ReceivedRetry(arg0 interface{}) *gom
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedRetry", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedRetry), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedRetry", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedRetry), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ReceivedShortHeaderPacket mocks base method.
|
||||||
|
func (m *MockConnectionTracer) ReceivedShortHeaderPacket(arg0 *wire.ShortHeader, arg1 protocol.ByteCount, arg2 []Frame) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "ReceivedShortHeaderPacket", arg0, arg1, arg2)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReceivedShortHeaderPacket indicates an expected call of ReceivedShortHeaderPacket.
|
||||||
|
func (mr *MockConnectionTracerMockRecorder) ReceivedShortHeaderPacket(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReceivedShortHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).ReceivedShortHeaderPacket), arg0, arg1, arg2)
|
||||||
|
}
|
||||||
|
|
||||||
// ReceivedTransportParameters mocks base method.
|
// ReceivedTransportParameters mocks base method.
|
||||||
func (m *MockConnectionTracer) ReceivedTransportParameters(arg0 *wire.TransportParameters) {
|
func (m *MockConnectionTracer) ReceivedTransportParameters(arg0 *wire.TransportParameters) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
|
|
|
@ -122,9 +122,15 @@ func (m *connTracerMultiplexer) ReceivedRetry(hdr *Header) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *connTracerMultiplexer) ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) {
|
func (m *connTracerMultiplexer) ReceivedLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) {
|
||||||
for _, t := range m.tracers {
|
for _, t := range m.tracers {
|
||||||
t.ReceivedPacket(hdr, size, frames)
|
t.ReceivedLongHeaderPacket(hdr, size, frames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *connTracerMultiplexer) ReceivedShortHeaderPacket(hdr *ShortHeader, size ByteCount, frames []Frame) {
|
||||||
|
for _, t := range m.tracers {
|
||||||
|
t.ReceivedShortHeaderPacket(hdr, size, frames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,12 +181,20 @@ var _ = Describe("Tracing", func() {
|
||||||
tracer.ReceivedRetry(hdr)
|
tracer.ReceivedRetry(hdr)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("traces the ReceivedPacket event", func() {
|
It("traces the ReceivedLongHeaderPacket event", func() {
|
||||||
hdr := &ExtendedHeader{Header: Header{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3})}}
|
hdr := &ExtendedHeader{Header: Header{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3})}}
|
||||||
ping := &PingFrame{}
|
ping := &PingFrame{}
|
||||||
tr1.EXPECT().ReceivedPacket(hdr, ByteCount(1337), []Frame{ping})
|
tr1.EXPECT().ReceivedLongHeaderPacket(hdr, ByteCount(1337), []Frame{ping})
|
||||||
tr2.EXPECT().ReceivedPacket(hdr, ByteCount(1337), []Frame{ping})
|
tr2.EXPECT().ReceivedLongHeaderPacket(hdr, ByteCount(1337), []Frame{ping})
|
||||||
tracer.ReceivedPacket(hdr, 1337, []Frame{ping})
|
tracer.ReceivedLongHeaderPacket(hdr, 1337, []Frame{ping})
|
||||||
|
})
|
||||||
|
|
||||||
|
It("traces the ReceivedShortHeaderPacket event", func() {
|
||||||
|
hdr := &ShortHeader{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3})}
|
||||||
|
ping := &PingFrame{}
|
||||||
|
tr1.EXPECT().ReceivedShortHeaderPacket(hdr, ByteCount(1337), []Frame{ping})
|
||||||
|
tr2.EXPECT().ReceivedShortHeaderPacket(hdr, ByteCount(1337), []Frame{ping})
|
||||||
|
tracer.ReceivedShortHeaderPacket(hdr, 1337, []Frame{ping})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("traces the BufferedPacket event", func() {
|
It("traces the BufferedPacket event", func() {
|
||||||
|
|
|
@ -39,9 +39,11 @@ func (n NullConnectionTracer) SentPacket(*ExtendedHeader, ByteCount, *AckFrame,
|
||||||
func (n NullConnectionTracer) ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber) {
|
func (n NullConnectionTracer) ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber) {
|
||||||
}
|
}
|
||||||
func (n NullConnectionTracer) ReceivedRetry(*Header) {}
|
func (n NullConnectionTracer) ReceivedRetry(*Header) {}
|
||||||
func (n NullConnectionTracer) ReceivedPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame) {}
|
func (n NullConnectionTracer) ReceivedLongHeaderPacket(*ExtendedHeader, ByteCount, []Frame) {}
|
||||||
|
func (n NullConnectionTracer) ReceivedShortHeaderPacket(*ShortHeader, ByteCount, []Frame) {}
|
||||||
func (n NullConnectionTracer) BufferedPacket(PacketType) {}
|
func (n NullConnectionTracer) BufferedPacket(PacketType) {}
|
||||||
func (n NullConnectionTracer) DroppedPacket(PacketType, ByteCount, PacketDropReason) {}
|
func (n NullConnectionTracer) DroppedPacket(PacketType, ByteCount, PacketDropReason) {}
|
||||||
|
|
||||||
func (n NullConnectionTracer) UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int) {
|
func (n NullConnectionTracer) UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int) {
|
||||||
}
|
}
|
||||||
func (n NullConnectionTracer) AcknowledgedPacket(EncryptionLevel, PacketNumber) {}
|
func (n NullConnectionTracer) AcknowledgedPacket(EncryptionLevel, PacketNumber) {}
|
||||||
|
|
|
@ -177,7 +177,7 @@ func (e eventPacketSent) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketReceived struct {
|
type eventPacketReceived struct {
|
||||||
Header packetHeader
|
Header gojay.MarshalerJSONObject // either a shortHeader or a packetHeader
|
||||||
Length logging.ByteCount
|
Length logging.ByteCount
|
||||||
PayloadLength logging.ByteCount
|
PayloadLength logging.ByteCount
|
||||||
Frames frames
|
Frames frames
|
||||||
|
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/wire"
|
|
||||||
"github.com/lucas-clemente/quic-go/logging"
|
"github.com/lucas-clemente/quic-go/logging"
|
||||||
|
|
||||||
"github.com/francoispqt/gojay"
|
"github.com/francoispqt/gojay"
|
||||||
|
@ -37,6 +36,7 @@ func (t token) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// PacketHeader is a QUIC packet header.
|
// PacketHeader is a QUIC packet header.
|
||||||
|
// TODO: make this a long header
|
||||||
type packetHeader struct {
|
type packetHeader struct {
|
||||||
PacketType logging.PacketType
|
PacketType logging.PacketType
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ type packetHeader struct {
|
||||||
Token *token
|
Token *token
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformHeader(hdr *wire.Header) *packetHeader {
|
func transformHeader(hdr *logging.Header) *packetHeader {
|
||||||
h := &packetHeader{
|
h := &packetHeader{
|
||||||
PacketType: logging.PacketTypeFromHeader(hdr),
|
PacketType: logging.PacketTypeFromHeader(hdr),
|
||||||
SrcConnectionID: hdr.SrcConnectionID,
|
SrcConnectionID: hdr.SrcConnectionID,
|
||||||
|
@ -63,7 +63,7 @@ func transformHeader(hdr *wire.Header) *packetHeader {
|
||||||
return h
|
return h
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformExtendedHeader(hdr *wire.ExtendedHeader) *packetHeader {
|
func transformLongHeader(hdr *logging.ExtendedHeader) *packetHeader {
|
||||||
h := transformHeader(&hdr.Header)
|
h := transformHeader(&hdr.Header)
|
||||||
h.PacketNumber = hdr.PacketNumber
|
h.PacketNumber = hdr.PacketNumber
|
||||||
h.KeyPhaseBit = hdr.KeyPhase
|
h.KeyPhaseBit = hdr.KeyPhase
|
||||||
|
@ -131,3 +131,27 @@ func (h packetHeaderWithTypeAndPacketNumber) MarshalJSONObject(enc *gojay.Encode
|
||||||
enc.StringKey("packet_type", packetType(h.PacketType).String())
|
enc.StringKey("packet_type", packetType(h.PacketType).String())
|
||||||
enc.Int64Key("packet_number", int64(h.PacketNumber))
|
enc.Int64Key("packet_number", int64(h.PacketNumber))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type shortHeader struct {
|
||||||
|
DestConnectionID logging.ConnectionID
|
||||||
|
PacketNumber logging.PacketNumber
|
||||||
|
KeyPhaseBit logging.KeyPhaseBit
|
||||||
|
}
|
||||||
|
|
||||||
|
func transformShortHeader(hdr *logging.ShortHeader) *shortHeader {
|
||||||
|
return &shortHeader{
|
||||||
|
DestConnectionID: hdr.DestConnectionID,
|
||||||
|
PacketNumber: hdr.PacketNumber,
|
||||||
|
KeyPhaseBit: hdr.KeyPhase,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h shortHeader) IsNil() bool { return false }
|
||||||
|
func (h shortHeader) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
|
enc.StringKey("packet_type", packetType(logging.PacketType1RTT).String())
|
||||||
|
if h.DestConnectionID.Len() > 0 {
|
||||||
|
enc.StringKey("dcid", h.DestConnectionID.String())
|
||||||
|
}
|
||||||
|
enc.Int64Key("packet_number", int64(h.PacketNumber))
|
||||||
|
enc.StringKey("key_phase_bit", h.KeyPhaseBit.String())
|
||||||
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ var _ = Describe("Packet Header", func() {
|
||||||
check := func(hdr *wire.ExtendedHeader, expected map[string]interface{}) {
|
check := func(hdr *wire.ExtendedHeader, expected map[string]interface{}) {
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
enc := gojay.NewEncoder(buf)
|
enc := gojay.NewEncoder(buf)
|
||||||
ExpectWithOffset(1, enc.Encode(transformExtendedHeader(hdr))).To(Succeed())
|
ExpectWithOffset(1, enc.Encode(transformLongHeader(hdr))).To(Succeed())
|
||||||
data := buf.Bytes()
|
data := buf.Bytes()
|
||||||
ExpectWithOffset(1, json.Valid(data)).To(BeTrue())
|
ExpectWithOffset(1, json.Valid(data)).To(BeTrue())
|
||||||
checkEncoding(data, expected)
|
checkEncoding(data, expected)
|
||||||
|
|
22
qlog/qlog.go
22
qlog/qlog.go
|
@ -286,7 +286,7 @@ func (t *connectionTracer) SentPacket(hdr *wire.ExtendedHeader, packetSize loggi
|
||||||
for _, f := range frames {
|
for _, f := range frames {
|
||||||
fs = append(fs, frame{Frame: f})
|
fs = append(fs, frame{Frame: f})
|
||||||
}
|
}
|
||||||
header := *transformExtendedHeader(hdr)
|
header := *transformLongHeader(hdr)
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketSent{
|
t.recordEvent(time.Now(), &eventPacketSent{
|
||||||
Header: header,
|
Header: header,
|
||||||
|
@ -297,12 +297,12 @@ func (t *connectionTracer) SentPacket(hdr *wire.ExtendedHeader, packetSize loggi
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *connectionTracer) ReceivedPacket(hdr *wire.ExtendedHeader, packetSize logging.ByteCount, frames []logging.Frame) {
|
func (t *connectionTracer) ReceivedLongHeaderPacket(hdr *logging.ExtendedHeader, packetSize logging.ByteCount, frames []logging.Frame) {
|
||||||
fs := make([]frame, len(frames))
|
fs := make([]frame, len(frames))
|
||||||
for i, f := range frames {
|
for i, f := range frames {
|
||||||
fs[i] = frame{Frame: f}
|
fs[i] = frame{Frame: f}
|
||||||
}
|
}
|
||||||
header := *transformExtendedHeader(hdr)
|
header := *transformLongHeader(hdr)
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketReceived{
|
t.recordEvent(time.Now(), &eventPacketReceived{
|
||||||
Header: header,
|
Header: header,
|
||||||
|
@ -313,6 +313,22 @@ func (t *connectionTracer) ReceivedPacket(hdr *wire.ExtendedHeader, packetSize l
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *connectionTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, packetSize logging.ByteCount, frames []logging.Frame) {
|
||||||
|
fs := make([]frame, len(frames))
|
||||||
|
for i, f := range frames {
|
||||||
|
fs[i] = frame{Frame: f}
|
||||||
|
}
|
||||||
|
header := *transformShortHeader(hdr)
|
||||||
|
t.mutex.Lock()
|
||||||
|
t.recordEvent(time.Now(), &eventPacketReceived{
|
||||||
|
Header: header,
|
||||||
|
Length: packetSize,
|
||||||
|
PayloadLength: packetSize - hdr.Len(),
|
||||||
|
Frames: fs,
|
||||||
|
})
|
||||||
|
t.mutex.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
func (t *connectionTracer) ReceivedRetry(hdr *wire.Header) {
|
func (t *connectionTracer) ReceivedRetry(hdr *wire.Header) {
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventRetryReceived{
|
t.recordEvent(time.Now(), &eventRetryReceived{
|
||||||
|
|
|
@ -11,6 +11,8 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/lucas-clemente/quic-go/internal/wire"
|
||||||
|
|
||||||
"github.com/lucas-clemente/quic-go"
|
"github.com/lucas-clemente/quic-go"
|
||||||
"github.com/lucas-clemente/quic-go/internal/protocol"
|
"github.com/lucas-clemente/quic-go/internal/protocol"
|
||||||
"github.com/lucas-clemente/quic-go/internal/qerr"
|
"github.com/lucas-clemente/quic-go/internal/qerr"
|
||||||
|
@ -486,8 +488,8 @@ var _ = Describe("Tracing", func() {
|
||||||
Expect(frames[1].(map[string]interface{})).To(HaveKeyWithValue("frame_type", "max_data"))
|
Expect(frames[1].(map[string]interface{})).To(HaveKeyWithValue("frame_type", "max_data"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records a received packet", func() {
|
It("records a received Long Header packet", func() {
|
||||||
tracer.ReceivedPacket(
|
tracer.ReceivedLongHeaderPacket(
|
||||||
&logging.ExtendedHeader{
|
&logging.ExtendedHeader{
|
||||||
Header: logging.Header{
|
Header: logging.Header{
|
||||||
IsLongHeader: true,
|
IsLongHeader: true,
|
||||||
|
@ -526,6 +528,37 @@ var _ = Describe("Tracing", func() {
|
||||||
Expect(ev["frames"].([]interface{})).To(HaveLen(2))
|
Expect(ev["frames"].([]interface{})).To(HaveLen(2))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("records a received Short Header packet", func() {
|
||||||
|
shdr := &wire.ShortHeader{
|
||||||
|
DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3, 4, 5, 6, 7, 8}),
|
||||||
|
PacketNumber: 1337,
|
||||||
|
KeyPhase: protocol.KeyPhaseZero,
|
||||||
|
}
|
||||||
|
tracer.ReceivedShortHeaderPacket(
|
||||||
|
shdr,
|
||||||
|
789,
|
||||||
|
[]logging.Frame{
|
||||||
|
&logging.MaxStreamDataFrame{StreamID: 42, MaximumStreamData: 987},
|
||||||
|
&logging.StreamFrame{StreamID: 123, Offset: 1234, Length: 6, Fin: true},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
entry := exportAndParseSingle()
|
||||||
|
Expect(entry.Time).To(BeTemporally("~", time.Now(), scaleDuration(10*time.Millisecond)))
|
||||||
|
Expect(entry.Name).To(Equal("transport:packet_received"))
|
||||||
|
ev := entry.Event
|
||||||
|
Expect(ev).To(HaveKey("raw"))
|
||||||
|
raw := ev["raw"].(map[string]interface{})
|
||||||
|
Expect(raw).To(HaveKeyWithValue("length", float64(789)))
|
||||||
|
Expect(raw).To(HaveKeyWithValue("payload_length", float64(789-shdr.Len())))
|
||||||
|
Expect(ev).To(HaveKey("header"))
|
||||||
|
hdr := ev["header"].(map[string]interface{})
|
||||||
|
Expect(hdr).To(HaveKeyWithValue("packet_type", "1RTT"))
|
||||||
|
Expect(hdr).To(HaveKeyWithValue("packet_number", float64(1337)))
|
||||||
|
Expect(hdr).To(HaveKeyWithValue("key_phase_bit", "0"))
|
||||||
|
Expect(ev).To(HaveKey("frames"))
|
||||||
|
Expect(ev["frames"].([]interface{})).To(HaveLen(2))
|
||||||
|
})
|
||||||
|
|
||||||
It("records a received Retry packet", func() {
|
It("records a received Retry packet", func() {
|
||||||
tracer.ReceivedRetry(
|
tracer.ReceivedRetry(
|
||||||
&logging.Header{
|
&logging.Header{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue