mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-04 12:47:36 +03:00
introduce separate tracing calls for sent long and short header packets
This commit is contained in:
parent
9e5f92b561
commit
24be84cd00
14 changed files with 127 additions and 61 deletions
|
@ -1971,7 +1971,21 @@ func (s *connection) logPacketContents(p *packetContents) {
|
||||||
if p.ack != nil {
|
if p.ack != nil {
|
||||||
ack = logutils.ConvertAckFrame(p.ack)
|
ack = logutils.ConvertAckFrame(p.ack)
|
||||||
}
|
}
|
||||||
s.tracer.SentPacket(p.header, p.length, ack, frames)
|
if p.header.IsLongHeader {
|
||||||
|
s.tracer.SentLongHeaderPacket(p.header, p.length, ack, frames)
|
||||||
|
} else {
|
||||||
|
s.tracer.SentShortHeaderPacket(
|
||||||
|
&logging.ShortHeader{
|
||||||
|
DestConnectionID: p.header.DestConnectionID,
|
||||||
|
PacketNumber: p.header.PacketNumber,
|
||||||
|
PacketNumberLen: p.header.PacketNumberLen,
|
||||||
|
KeyPhase: p.header.KeyPhase,
|
||||||
|
},
|
||||||
|
p.length,
|
||||||
|
ack,
|
||||||
|
frames,
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// quic-go logging
|
// quic-go logging
|
||||||
|
|
|
@ -605,7 +605,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().HasPacingBudget().Return(true).AnyTimes()
|
sph.EXPECT().HasPacingBudget().Return(true).AnyTimes()
|
||||||
// only expect a single SentPacket() call
|
// only expect a single SentPacket() call
|
||||||
sph.EXPECT().SentPacket(gomock.Any())
|
sph.EXPECT().SentPacket(gomock.Any())
|
||||||
tracer.EXPECT().SentPacket(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().ClosedConnection(gomock.Any())
|
||||||
tracer.EXPECT().Close()
|
tracer.EXPECT().Close()
|
||||||
streamManager.EXPECT().CloseWithError(gomock.Any())
|
streamManager.EXPECT().CloseWithError(gomock.Any())
|
||||||
|
@ -1245,7 +1245,12 @@ var _ = Describe("Connection", func() {
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
sender.EXPECT().WouldBlock().AnyTimes()
|
sender.EXPECT().WouldBlock().AnyTimes()
|
||||||
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
||||||
tracer.EXPECT().SentPacket(p.header, p.buffer.Len(), nil, []logging.Frame{})
|
tracer.EXPECT().SentShortHeaderPacket(&logging.ShortHeader{
|
||||||
|
DestConnectionID: p.header.DestConnectionID,
|
||||||
|
PacketNumber: p.header.PacketNumber,
|
||||||
|
PacketNumberLen: p.header.PacketNumberLen,
|
||||||
|
KeyPhase: p.header.KeyPhase,
|
||||||
|
}, p.buffer.Len(), nil, []logging.Frame{})
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
Eventually(sent).Should(BeClosed())
|
Eventually(sent).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
@ -1291,7 +1296,7 @@ var _ = Describe("Connection", func() {
|
||||||
runConn()
|
runConn()
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
||||||
tracer.EXPECT().SentPacket(p.header, p.length, nil, []logging.Frame{})
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), p.length, nil, []logging.Frame{})
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
Eventually(sent).Should(BeClosed())
|
Eventually(sent).Should(BeClosed())
|
||||||
frames, _ := conn.framer.AppendControlFrames(nil, 1000)
|
frames, _ := conn.framer.AppendControlFrames(nil, 1000)
|
||||||
|
@ -1347,7 +1352,7 @@ var _ = Describe("Connection", func() {
|
||||||
runConn()
|
runConn()
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
||||||
tracer.EXPECT().SentPacket(p.packets[0].header, p.packets[0].length, gomock.Any(), gomock.Any())
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), p.packets[0].length, gomock.Any(), gomock.Any())
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
Eventually(sent).Should(BeClosed())
|
Eventually(sent).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
@ -1368,7 +1373,7 @@ var _ = Describe("Connection", func() {
|
||||||
runConn()
|
runConn()
|
||||||
sent := make(chan struct{})
|
sent := make(chan struct{})
|
||||||
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
sender.EXPECT().Send(gomock.Any()).Do(func(packet *packetBuffer) { close(sent) })
|
||||||
tracer.EXPECT().SentPacket(p.packets[0].header, p.packets[0].length, gomock.Any(), gomock.Any())
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), p.packets[0].length, gomock.Any(), gomock.Any())
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
Eventually(sent).Should(BeClosed())
|
Eventually(sent).Should(BeClosed())
|
||||||
// We're using a mock packet packer in this test.
|
// We're using a mock packet packer in this test.
|
||||||
|
@ -1386,7 +1391,7 @@ var _ = Describe("Connection", func() {
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
||||||
sph = mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
sph = mockackhandler.NewMockSentPacketHandler(mockCtrl)
|
||||||
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
sph.EXPECT().GetLossDetectionTimeout().AnyTimes()
|
||||||
conn.handshakeConfirmed = true
|
conn.handshakeConfirmed = true
|
||||||
|
@ -1705,7 +1710,7 @@ var _ = Describe("Connection", func() {
|
||||||
// only EXPECT calls after scheduleSending is called
|
// only EXPECT calls after scheduleSending is called
|
||||||
written := make(chan struct{})
|
written := make(chan struct{})
|
||||||
sender.EXPECT().Send(gomock.Any()).Do(func(*packetBuffer) { close(written) })
|
sender.EXPECT().Send(gomock.Any()).Do(func(*packetBuffer) { close(written) })
|
||||||
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
||||||
conn.scheduleSending()
|
conn.scheduleSending()
|
||||||
Eventually(written).Should(BeClosed())
|
Eventually(written).Should(BeClosed())
|
||||||
})
|
})
|
||||||
|
@ -1729,7 +1734,7 @@ var _ = Describe("Connection", func() {
|
||||||
|
|
||||||
written := make(chan struct{})
|
written := make(chan struct{})
|
||||||
sender.EXPECT().Send(gomock.Any()).Do(func(*packetBuffer) { close(written) })
|
sender.EXPECT().Send(gomock.Any()).Do(func(*packetBuffer) { close(written) })
|
||||||
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).AnyTimes()
|
||||||
go func() {
|
go func() {
|
||||||
defer GinkgoRecover()
|
defer GinkgoRecover()
|
||||||
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
|
cryptoSetup.EXPECT().RunHandshake().MaxTimes(1)
|
||||||
|
@ -1789,10 +1794,10 @@ var _ = Describe("Connection", func() {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
gomock.InOrder(
|
gomock.InOrder(
|
||||||
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []logging.Frame) {
|
tracer.EXPECT().SentLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []logging.Frame) {
|
||||||
Expect(hdr.Type).To(Equal(protocol.PacketTypeInitial))
|
Expect(hdr.Type).To(Equal(protocol.PacketTypeInitial))
|
||||||
}),
|
}),
|
||||||
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []logging.Frame) {
|
tracer.EXPECT().SentLongHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any()).Do(func(hdr *wire.ExtendedHeader, _ protocol.ByteCount, _ *wire.AckFrame, _ []logging.Frame) {
|
||||||
Expect(hdr.Type).To(Equal(protocol.PacketTypeHandshake))
|
Expect(hdr.Type).To(Equal(protocol.PacketTypeHandshake))
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
@ -1931,7 +1936,7 @@ var _ = Describe("Connection", func() {
|
||||||
sph.EXPECT().SetHandshakeConfirmed()
|
sph.EXPECT().SetHandshakeConfirmed()
|
||||||
sph.EXPECT().SentPacket(gomock.Any())
|
sph.EXPECT().SentPacket(gomock.Any())
|
||||||
mconn.EXPECT().Write(gomock.Any())
|
mconn.EXPECT().Write(gomock.Any())
|
||||||
tracer.EXPECT().SentPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
tracer.EXPECT().SentShortHeaderPacket(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any())
|
||||||
conn.sentPacketHandler = sph
|
conn.sentPacketHandler = sph
|
||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
connRunner.EXPECT().Retire(clientDestConnID)
|
connRunner.EXPECT().Retire(clientDestConnID)
|
||||||
|
|
|
@ -16,16 +16,13 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sentHeaders []*logging.ExtendedHeader
|
sentHeaders []*logging.ShortHeader
|
||||||
receivedHeaders []*logging.ShortHeader
|
receivedHeaders []*logging.ShortHeader
|
||||||
)
|
)
|
||||||
|
|
||||||
func countKeyPhases() (sent, received int) {
|
func countKeyPhases() (sent, received int) {
|
||||||
lastKeyPhase := protocol.KeyPhaseOne
|
lastKeyPhase := protocol.KeyPhaseOne
|
||||||
for _, hdr := range sentHeaders {
|
for _, hdr := range sentHeaders {
|
||||||
if hdr.IsLongHeader {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if hdr.KeyPhase != lastKeyPhase {
|
if hdr.KeyPhase != lastKeyPhase {
|
||||||
sent++
|
sent++
|
||||||
lastKeyPhase = hdr.KeyPhase
|
lastKeyPhase = hdr.KeyPhase
|
||||||
|
@ -45,7 +42,7 @@ type keyUpdateConnTracer struct {
|
||||||
logging.NullConnectionTracer
|
logging.NullConnectionTracer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *keyUpdateConnTracer) SentPacket(hdr *logging.ExtendedHeader, size logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
func (t *keyUpdateConnTracer) SentShortHeaderPacket(hdr *logging.ShortHeader, _ logging.ByteCount, _ *logging.AckFrame, _ []logging.Frame) {
|
||||||
sentHeaders = append(sentHeaders, hdr)
|
sentHeaders = append(sentHeaders, hdr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -358,9 +358,9 @@ type shortHeaderPacket struct {
|
||||||
|
|
||||||
type packetTracer struct {
|
type packetTracer struct {
|
||||||
logging.NullConnectionTracer
|
logging.NullConnectionTracer
|
||||||
closed chan struct{}
|
closed chan struct{}
|
||||||
rcvdShortHdr []shortHeaderPacket
|
sentShortHdr, rcvdShortHdr []shortHeaderPacket
|
||||||
sent, rcvdLongHdr []packet
|
rcvdLongHdr []packet
|
||||||
}
|
}
|
||||||
|
|
||||||
func newPacketTracer() *packetTracer {
|
func newPacketTracer() *packetTracer {
|
||||||
|
@ -375,16 +375,18 @@ func (t *packetTracer) ReceivedShortHeaderPacket(hdr *logging.ShortHeader, _ log
|
||||||
t.rcvdShortHdr = append(t.rcvdShortHdr, shortHeaderPacket{time: time.Now(), hdr: hdr, frames: frames})
|
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) SentShortHeaderPacket(hdr *logging.ShortHeader, _ logging.ByteCount, ack *wire.AckFrame, frames []logging.Frame) {
|
||||||
if ack != nil {
|
if ack != nil {
|
||||||
frames = append(frames, ack)
|
frames = append(frames, ack)
|
||||||
}
|
}
|
||||||
t.sent = append(t.sent, packet{time: time.Now(), hdr: hdr, frames: frames})
|
t.sentShortHdr = append(t.sentShortHdr, shortHeaderPacket{time: time.Now(), hdr: hdr, frames: frames})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *packetTracer) Close() { close(t.closed) }
|
func (t *packetTracer) Close() { close(t.closed) }
|
||||||
func (t *packetTracer) getSentPackets() []packet {
|
|
||||||
|
func (t *packetTracer) getSentShortHeaderPackets() []shortHeaderPacket {
|
||||||
<-t.closed
|
<-t.closed
|
||||||
return t.sent
|
return t.sentShortHdr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *packetTracer) getRcvdLongHeaderPackets() []packet {
|
func (t *packetTracer) getRcvdLongHeaderPackets() []packet {
|
||||||
|
|
|
@ -213,7 +213,7 @@ var _ = Describe("Timeout tests", func() {
|
||||||
}()
|
}()
|
||||||
Eventually(done, 2*idleTimeout).Should(BeClosed())
|
Eventually(done, 2*idleTimeout).Should(BeClosed())
|
||||||
var lastAckElicitingPacketSentAt time.Time
|
var lastAckElicitingPacketSentAt time.Time
|
||||||
for _, p := range tr.getSentPackets() {
|
for _, p := range tr.getSentShortHeaderPackets() {
|
||||||
var hasAckElicitingFrame bool
|
var hasAckElicitingFrame bool
|
||||||
for _, f := range p.frames {
|
for _, f := range p.frames {
|
||||||
if _, ok := f.(*logging.AckFrame); ok {
|
if _, ok := f.(*logging.AckFrame); ok {
|
||||||
|
|
|
@ -255,16 +255,28 @@ func (mr *MockConnectionTracerMockRecorder) RestoredTransportParameters(arg0 int
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestoredTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).RestoredTransportParameters), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestoredTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).RestoredTransportParameters), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SentPacket mocks base method.
|
// SentLongHeaderPacket mocks base method.
|
||||||
func (m *MockConnectionTracer) SentPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []logging.Frame) {
|
func (m *MockConnectionTracer) SentLongHeaderPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []logging.Frame) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "SentPacket", arg0, arg1, arg2, arg3)
|
m.ctrl.Call(m, "SentLongHeaderPacket", arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SentPacket indicates an expected call of SentPacket.
|
// SentLongHeaderPacket indicates an expected call of SentLongHeaderPacket.
|
||||||
func (mr *MockConnectionTracerMockRecorder) SentPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
func (mr *MockConnectionTracerMockRecorder) SentLongHeaderPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentPacket), arg0, arg1, arg2, arg3)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentLongHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentLongHeaderPacket), arg0, arg1, arg2, arg3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SentShortHeaderPacket mocks base method.
|
||||||
|
func (m *MockConnectionTracer) SentShortHeaderPacket(arg0 *logging.ShortHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []logging.Frame) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "SentShortHeaderPacket", arg0, arg1, arg2, arg3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SentShortHeaderPacket indicates an expected call of SentShortHeaderPacket.
|
||||||
|
func (mr *MockConnectionTracerMockRecorder) SentShortHeaderPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentShortHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentShortHeaderPacket), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SentTransportParameters mocks base method.
|
// SentTransportParameters mocks base method.
|
||||||
|
|
|
@ -121,7 +121,8 @@ type ConnectionTracer interface {
|
||||||
SentTransportParameters(*TransportParameters)
|
SentTransportParameters(*TransportParameters)
|
||||||
ReceivedTransportParameters(*TransportParameters)
|
ReceivedTransportParameters(*TransportParameters)
|
||||||
RestoredTransportParameters(parameters *TransportParameters) // for 0-RTT
|
RestoredTransportParameters(parameters *TransportParameters) // for 0-RTT
|
||||||
SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
|
SentLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame)
|
||||||
|
SentShortHeaderPacket(hdr *ShortHeader, size ByteCount, ack *AckFrame, frames []Frame)
|
||||||
ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber)
|
ReceivedVersionNegotiationPacket(dest, src ArbitraryLenConnectionID, _ []VersionNumber)
|
||||||
ReceivedRetry(*Header)
|
ReceivedRetry(*Header)
|
||||||
ReceivedLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
|
ReceivedLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, frames []Frame)
|
||||||
|
|
|
@ -254,16 +254,28 @@ func (mr *MockConnectionTracerMockRecorder) RestoredTransportParameters(arg0 int
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestoredTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).RestoredTransportParameters), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RestoredTransportParameters", reflect.TypeOf((*MockConnectionTracer)(nil).RestoredTransportParameters), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SentPacket mocks base method.
|
// SentLongHeaderPacket mocks base method.
|
||||||
func (m *MockConnectionTracer) SentPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []Frame) {
|
func (m *MockConnectionTracer) SentLongHeaderPacket(arg0 *wire.ExtendedHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []Frame) {
|
||||||
m.ctrl.T.Helper()
|
m.ctrl.T.Helper()
|
||||||
m.ctrl.Call(m, "SentPacket", arg0, arg1, arg2, arg3)
|
m.ctrl.Call(m, "SentLongHeaderPacket", arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SentPacket indicates an expected call of SentPacket.
|
// SentLongHeaderPacket indicates an expected call of SentLongHeaderPacket.
|
||||||
func (mr *MockConnectionTracerMockRecorder) SentPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
func (mr *MockConnectionTracerMockRecorder) SentLongHeaderPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
mr.mock.ctrl.T.Helper()
|
mr.mock.ctrl.T.Helper()
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentPacket), arg0, arg1, arg2, arg3)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentLongHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentLongHeaderPacket), arg0, arg1, arg2, arg3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SentShortHeaderPacket mocks base method.
|
||||||
|
func (m *MockConnectionTracer) SentShortHeaderPacket(arg0 *ShortHeader, arg1 protocol.ByteCount, arg2 *wire.AckFrame, arg3 []Frame) {
|
||||||
|
m.ctrl.T.Helper()
|
||||||
|
m.ctrl.Call(m, "SentShortHeaderPacket", arg0, arg1, arg2, arg3)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SentShortHeaderPacket indicates an expected call of SentShortHeaderPacket.
|
||||||
|
func (mr *MockConnectionTracerMockRecorder) SentShortHeaderPacket(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
||||||
|
mr.mock.ctrl.T.Helper()
|
||||||
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SentShortHeaderPacket", reflect.TypeOf((*MockConnectionTracer)(nil).SentShortHeaderPacket), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SentTransportParameters mocks base method.
|
// SentTransportParameters mocks base method.
|
||||||
|
|
|
@ -104,9 +104,15 @@ func (m *connTracerMultiplexer) RestoredTransportParameters(tp *TransportParamet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *connTracerMultiplexer) SentPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame) {
|
func (m *connTracerMultiplexer) SentLongHeaderPacket(hdr *ExtendedHeader, size ByteCount, ack *AckFrame, frames []Frame) {
|
||||||
for _, t := range m.tracers {
|
for _, t := range m.tracers {
|
||||||
t.SentPacket(hdr, size, ack, frames)
|
t.SentLongHeaderPacket(hdr, size, ack, frames)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *connTracerMultiplexer) SentShortHeaderPacket(hdr *ShortHeader, size ByteCount, ack *AckFrame, frames []Frame) {
|
||||||
|
for _, t := range m.tracers {
|
||||||
|
t.SentShortHeaderPacket(hdr, size, ack, frames)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,13 +157,22 @@ var _ = Describe("Tracing", func() {
|
||||||
tracer.RestoredTransportParameters(tp)
|
tracer.RestoredTransportParameters(tp)
|
||||||
})
|
})
|
||||||
|
|
||||||
It("traces the SentPacket event", func() {
|
It("traces the SentLongHeaderPacket event", func() {
|
||||||
hdr := &ExtendedHeader{Header: Header{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3})}}
|
hdr := &ExtendedHeader{Header: Header{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3})}}
|
||||||
ack := &AckFrame{AckRanges: []AckRange{{Smallest: 1, Largest: 10}}}
|
ack := &AckFrame{AckRanges: []AckRange{{Smallest: 1, Largest: 10}}}
|
||||||
ping := &PingFrame{}
|
ping := &PingFrame{}
|
||||||
tr1.EXPECT().SentPacket(hdr, ByteCount(1337), ack, []Frame{ping})
|
tr1.EXPECT().SentLongHeaderPacket(hdr, ByteCount(1337), ack, []Frame{ping})
|
||||||
tr2.EXPECT().SentPacket(hdr, ByteCount(1337), ack, []Frame{ping})
|
tr2.EXPECT().SentLongHeaderPacket(hdr, ByteCount(1337), ack, []Frame{ping})
|
||||||
tracer.SentPacket(hdr, 1337, ack, []Frame{ping})
|
tracer.SentLongHeaderPacket(hdr, 1337, ack, []Frame{ping})
|
||||||
|
})
|
||||||
|
|
||||||
|
It("traces the SentShortHeaderPacket event", func() {
|
||||||
|
hdr := &ShortHeader{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3})}
|
||||||
|
ack := &AckFrame{AckRanges: []AckRange{{Smallest: 1, Largest: 10}}}
|
||||||
|
ping := &PingFrame{}
|
||||||
|
tr1.EXPECT().SentShortHeaderPacket(hdr, ByteCount(1337), ack, []Frame{ping})
|
||||||
|
tr2.EXPECT().SentShortHeaderPacket(hdr, ByteCount(1337), ack, []Frame{ping})
|
||||||
|
tracer.SentShortHeaderPacket(hdr, 1337, ack, []Frame{ping})
|
||||||
})
|
})
|
||||||
|
|
||||||
It("traces the ReceivedVersionNegotiationPacket event", func() {
|
It("traces the ReceivedVersionNegotiationPacket event", func() {
|
||||||
|
|
|
@ -31,11 +31,12 @@ func (n NullConnectionTracer) StartedConnection(local, remote net.Addr, srcConnI
|
||||||
|
|
||||||
func (n NullConnectionTracer) NegotiatedVersion(chosen VersionNumber, clientVersions, serverVersions []VersionNumber) {
|
func (n NullConnectionTracer) NegotiatedVersion(chosen VersionNumber, clientVersions, serverVersions []VersionNumber) {
|
||||||
}
|
}
|
||||||
func (n NullConnectionTracer) ClosedConnection(err error) {}
|
func (n NullConnectionTracer) ClosedConnection(err error) {}
|
||||||
func (n NullConnectionTracer) SentTransportParameters(*TransportParameters) {}
|
func (n NullConnectionTracer) SentTransportParameters(*TransportParameters) {}
|
||||||
func (n NullConnectionTracer) ReceivedTransportParameters(*TransportParameters) {}
|
func (n NullConnectionTracer) ReceivedTransportParameters(*TransportParameters) {}
|
||||||
func (n NullConnectionTracer) RestoredTransportParameters(*TransportParameters) {}
|
func (n NullConnectionTracer) RestoredTransportParameters(*TransportParameters) {}
|
||||||
func (n NullConnectionTracer) SentPacket(*ExtendedHeader, ByteCount, *AckFrame, []Frame) {}
|
func (n NullConnectionTracer) SentLongHeaderPacket(*ExtendedHeader, ByteCount, *AckFrame, []Frame) {}
|
||||||
|
func (n NullConnectionTracer) SentShortHeaderPacket(*ShortHeader, ByteCount, *AckFrame, []Frame) {}
|
||||||
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) {}
|
||||||
|
|
|
@ -154,7 +154,7 @@ func (e eventConnectionClosed) MarshalJSONObject(enc *gojay.Encoder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
type eventPacketSent struct {
|
type eventPacketSent 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
|
||||||
|
|
15
qlog/qlog.go
15
qlog/qlog.go
|
@ -274,7 +274,15 @@ func (t *connectionTracer) toTransportParameters(tp *wire.TransportParameters) *
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *connectionTracer) SentPacket(hdr *wire.ExtendedHeader, packetSize logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
func (t *connectionTracer) SentLongHeaderPacket(hdr *logging.ExtendedHeader, packetSize logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
||||||
|
t.sentPacket(*transformLongHeader(hdr), packetSize, hdr.Length, ack, frames)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *connectionTracer) SentShortHeaderPacket(hdr *logging.ShortHeader, packetSize logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
||||||
|
t.sentPacket(*transformShortHeader(hdr), packetSize, 0, ack, frames)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *connectionTracer) sentPacket(hdr gojay.MarshalerJSONObject, packetSize, payloadLen logging.ByteCount, ack *logging.AckFrame, frames []logging.Frame) {
|
||||||
numFrames := len(frames)
|
numFrames := len(frames)
|
||||||
if ack != nil {
|
if ack != nil {
|
||||||
numFrames++
|
numFrames++
|
||||||
|
@ -286,12 +294,11 @@ 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 := *transformLongHeader(hdr)
|
|
||||||
t.mutex.Lock()
|
t.mutex.Lock()
|
||||||
t.recordEvent(time.Now(), &eventPacketSent{
|
t.recordEvent(time.Now(), &eventPacketSent{
|
||||||
Header: header,
|
Header: hdr,
|
||||||
Length: packetSize,
|
Length: packetSize,
|
||||||
PayloadLength: hdr.Length,
|
PayloadLength: payloadLen,
|
||||||
Frames: fs,
|
Frames: fs,
|
||||||
})
|
})
|
||||||
t.mutex.Unlock()
|
t.mutex.Unlock()
|
||||||
|
|
|
@ -420,8 +420,8 @@ var _ = Describe("Tracing", func() {
|
||||||
Expect(ev).To(HaveKeyWithValue("initial_max_stream_data_uni", float64(300)))
|
Expect(ev).To(HaveKeyWithValue("initial_max_stream_data_uni", float64(300)))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records a sent packet, without an ACK", func() {
|
It("records a sent long header packet, without an ACK", func() {
|
||||||
tracer.SentPacket(
|
tracer.SentLongHeaderPacket(
|
||||||
&logging.ExtendedHeader{
|
&logging.ExtendedHeader{
|
||||||
Header: logging.Header{
|
Header: logging.Header{
|
||||||
IsLongHeader: true,
|
IsLongHeader: true,
|
||||||
|
@ -460,11 +460,11 @@ var _ = Describe("Tracing", func() {
|
||||||
Expect(frames[1].(map[string]interface{})).To(HaveKeyWithValue("frame_type", "stream"))
|
Expect(frames[1].(map[string]interface{})).To(HaveKeyWithValue("frame_type", "stream"))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("records a sent packet, without an ACK", func() {
|
It("records a sent short header packet, without an ACK", func() {
|
||||||
tracer.SentPacket(
|
tracer.SentShortHeaderPacket(
|
||||||
&logging.ExtendedHeader{
|
&logging.ShortHeader{
|
||||||
Header: logging.Header{DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3, 4})},
|
DestConnectionID: protocol.ParseConnectionID([]byte{1, 2, 3, 4}),
|
||||||
PacketNumber: 1337,
|
PacketNumber: 1337,
|
||||||
},
|
},
|
||||||
123,
|
123,
|
||||||
&logging.AckFrame{AckRanges: []logging.AckRange{{Smallest: 1, Largest: 10}}},
|
&logging.AckFrame{AckRanges: []logging.AckRange{{Smallest: 1, Largest: 10}}},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue