diff --git a/internal/ackhandler/interfaces.go b/internal/ackhandler/interfaces.go index 372c59a4..c7006f7d 100644 --- a/internal/ackhandler/interfaces.go +++ b/internal/ackhandler/interfaces.go @@ -5,6 +5,7 @@ import ( "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" + "github.com/lucas-clemente/quic-go/quictrace" ) // SentPacketHandler handles ACKs received for outgoing packets @@ -41,7 +42,7 @@ type SentPacketHandler interface { OnAlarm() error // report some congestion statistics. For tracing only. - GetStats() *State + GetStats() *quictrace.TransportState } // ReceivedPacketHandler handles ACKs needed to send for incoming packets @@ -53,12 +54,3 @@ type ReceivedPacketHandler interface { GetAlarmTimeout() time.Time GetAckFrame(protocol.EncryptionLevel) *wire.AckFrame } - -type State struct { - MinRTT time.Duration - SmoothedRTT time.Duration - LatestRTT time.Duration - - BytesInFlight protocol.ByteCount - CongestionWindow protocol.ByteCount -} diff --git a/internal/ackhandler/sent_packet_handler.go b/internal/ackhandler/sent_packet_handler.go index 30842c41..2a8564a0 100644 --- a/internal/ackhandler/sent_packet_handler.go +++ b/internal/ackhandler/sent_packet_handler.go @@ -11,6 +11,7 @@ import ( "github.com/lucas-clemente/quic-go/internal/qerr" "github.com/lucas-clemente/quic-go/internal/utils" "github.com/lucas-clemente/quic-go/internal/wire" + "github.com/lucas-clemente/quic-go/quictrace" ) const ( @@ -671,8 +672,8 @@ func (h *sentPacketHandler) ResetForRetry() error { return nil } -func (h *sentPacketHandler) GetStats() *State { - return &State{ +func (h *sentPacketHandler) GetStats() *quictrace.TransportState { + return &quictrace.TransportState{ MinRTT: h.rttStats.MinRTT(), SmoothedRTT: h.rttStats.SmoothedOrInitialRTT(), LatestRTT: h.rttStats.LatestRTT(), diff --git a/internal/mockgen_internal.sh b/internal/mockgen_internal.sh index a0f9112b..240611ee 100755 --- a/internal/mockgen_internal.sh +++ b/internal/mockgen_internal.sh @@ -7,13 +7,14 @@ # Afterwards, it corrects the import paths (replaces internalpackage back to internal). TEMP_DIR=$(mktemp -d) -mkdir -p $TEMP_DIR/src/github.com/lucas-clemente/quic-go/internalpackage +mkdir -p $TEMP_DIR/src/github.com/lucas-clemente/quic-go/ # uppercase the name of the interface (only has an effect for private interfaces) INTERFACE_NAME="$(tr '[:lower:]' '[:upper:]' <<< ${4:0:1})${4:1}" PACKAGE_NAME=`echo $3 | sed 's/.*\///'` -cp -r $GOPATH/src/github.com/lucas-clemente/quic-go/internal/* $TEMP_DIR/src/github.com/lucas-clemente/quic-go/internalpackage +rsync -a $GOPATH/src/github.com/lucas-clemente/quic-go/* $TEMP_DIR/src/github.com/lucas-clemente/quic-go/ --exclude example +mv $TEMP_DIR/src/github.com/lucas-clemente/quic-go/internal $TEMP_DIR/src/github.com/lucas-clemente/quic-go/internalpackage find $TEMP_DIR -type f -name "*.go" -exec sed -i '' 's/internal/internalpackage/g' {} \; export GOPATH="$TEMP_DIR:$GOPATH" diff --git a/internal/mocks/ackhandler/sent_packet_handler.go b/internal/mocks/ackhandler/sent_packet_handler.go index 34a5ee61..82f7bcaa 100644 --- a/internal/mocks/ackhandler/sent_packet_handler.go +++ b/internal/mocks/ackhandler/sent_packet_handler.go @@ -12,6 +12,7 @@ import ( ackhandler "github.com/lucas-clemente/quic-go/internal/ackhandler" protocol "github.com/lucas-clemente/quic-go/internal/protocol" wire "github.com/lucas-clemente/quic-go/internal/wire" + quictrace "github.com/lucas-clemente/quic-go/quictrace" ) // MockSentPacketHandler is a mock of SentPacketHandler interface @@ -107,10 +108,10 @@ func (mr *MockSentPacketHandlerMockRecorder) GetLowestPacketNotConfirmedAcked() } // GetStats mocks base method -func (m *MockSentPacketHandler) GetStats() *ackhandler.State { +func (m *MockSentPacketHandler) GetStats() *quictrace.TransportState { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetStats") - ret0, _ := ret[0].(*ackhandler.State) + ret0, _ := ret[0].(*quictrace.TransportState) return ret0 } diff --git a/quictrace/interface.go b/quictrace/interface.go index 3e71a443..83781bd2 100644 --- a/quictrace/interface.go +++ b/quictrace/interface.go @@ -3,7 +3,6 @@ package quictrace import ( "time" - "github.com/lucas-clemente/quic-go/internal/ackhandler" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" ) @@ -31,9 +30,19 @@ type Event struct { Time time.Time EventType EventType - TransportState *ackhandler.State + TransportState *TransportState EncryptionLevel protocol.EncryptionLevel PacketNumber protocol.PacketNumber PacketSize protocol.ByteCount Frames []wire.Frame } + +// TransportState contains some transport and congestion statistics +type TransportState struct { + MinRTT time.Duration + SmoothedRTT time.Duration + LatestRTT time.Duration + + BytesInFlight protocol.ByteCount + CongestionWindow protocol.ByteCount +} diff --git a/quictrace/tracer.go b/quictrace/tracer.go index 96135951..4bcc706a 100644 --- a/quictrace/tracer.go +++ b/quictrace/tracer.go @@ -6,7 +6,6 @@ import ( "github.com/golang/protobuf/proto" - "github.com/lucas-clemente/quic-go/internal/ackhandler" "github.com/lucas-clemente/quic-go/internal/protocol" "github.com/lucas-clemente/quic-go/internal/wire" "github.com/lucas-clemente/quic-go/quictrace/pb" @@ -171,7 +170,7 @@ func getFrames(wframes []wire.Frame) []*pb.Frame { return frames } -func getTransportState(state *ackhandler.State) *pb.TransportState { +func getTransportState(state *TransportState) *pb.TransportState { bytesInFlight := uint64(state.BytesInFlight) congestionWindow := uint64(state.CongestionWindow) return &pb.TransportState{