add a function to trace acknowledged packets

This commit is contained in:
Marten Seemann 2021-04-02 11:24:54 +07:00
parent e098ccd2b3
commit 875692ea10
9 changed files with 44 additions and 0 deletions

View file

@ -115,6 +115,7 @@ type ConnectionTracer interface {
BufferedPacket(PacketType)
DroppedPacket(PacketType, ByteCount, PacketDropReason)
UpdatedMetrics(rttStats *RTTStats, cwnd, bytesInFlight ByteCount, packetsInFlight int)
AcknowledgedPacket(EncryptionLevel, PacketNumber)
LostPacket(EncryptionLevel, PacketNumber, PacketLossReason)
UpdatedCongestionState(CongestionState)
UpdatedPTOCount(value uint32)

View file

@ -38,6 +38,18 @@ func (m *MockConnectionTracer) EXPECT() *MockConnectionTracerMockRecorder {
return m.recorder
}
// AcknowledgedPacket mocks base method.
func (m *MockConnectionTracer) AcknowledgedPacket(arg0 protocol.EncryptionLevel, arg1 protocol.PacketNumber) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "AcknowledgedPacket", arg0, arg1)
}
// AcknowledgedPacket indicates an expected call of AcknowledgedPacket.
func (mr *MockConnectionTracerMockRecorder) AcknowledgedPacket(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AcknowledgedPacket", reflect.TypeOf((*MockConnectionTracer)(nil).AcknowledgedPacket), arg0, arg1)
}
// BufferedPacket mocks base method.
func (m *MockConnectionTracer) BufferedPacket(arg0 protocol.PacketType) {
m.ctrl.T.Helper()

View file

@ -139,6 +139,12 @@ func (m *connTracerMultiplexer) UpdatedMetrics(rttStats *RTTStats, cwnd, bytesIn
}
}
func (m *connTracerMultiplexer) AcknowledgedPacket(encLevel EncryptionLevel, pn PacketNumber) {
for _, t := range m.tracers {
t.AcknowledgedPacket(encLevel, pn)
}
}
func (m *connTracerMultiplexer) LostPacket(encLevel EncryptionLevel, pn PacketNumber, reason PacketLossReason) {
for _, t := range m.tracers {
t.LostPacket(encLevel, pn, reason)

View file

@ -190,6 +190,12 @@ var _ = Describe("Tracing", func() {
tracer.UpdatedMetrics(rttStats, 1337, 42, 13)
})
It("traces the AcknowledgedPacket event", func() {
tr1.EXPECT().AcknowledgedPacket(EncryptionHandshake, PacketNumber(42))
tr2.EXPECT().AcknowledgedPacket(EncryptionHandshake, PacketNumber(42))
tracer.AcknowledgedPacket(EncryptionHandshake, 42)
})
It("traces the LostPacket event", func() {
tr1.EXPECT().LostPacket(EncryptionHandshake, PacketNumber(42), PacketLossReorderingThreshold)
tr2.EXPECT().LostPacket(EncryptionHandshake, PacketNumber(42), PacketLossReorderingThreshold)