From 18bcc4fe73bd8245cde001c939b400693a0d9410 Mon Sep 17 00:00:00 2001 From: Will Hawkins Date: Wed, 17 Aug 2022 22:07:35 -0400 Subject: [Feature] Add TCP information (RTT and Cwnd) to Logging This patch adds support for logging the underlying RTT and Cwnd of the TCP connection used when doing probes. More work to follow in order to add support for this information on Windows and Darwin. --- rpm/rpm.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'rpm') diff --git a/rpm/rpm.go b/rpm/rpm.go index 19da8f5..fe8184e 100644 --- a/rpm/rpm.go +++ b/rpm/rpm.go @@ -27,6 +27,7 @@ import ( "github.com/network-quality/goresponsiveness/constants" "github.com/network-quality/goresponsiveness/datalogger" "github.com/network-quality/goresponsiveness/debug" + "github.com/network-quality/goresponsiveness/extendedstats" "github.com/network-quality/goresponsiveness/lgc" "github.com/network-quality/goresponsiveness/ma" "github.com/network-quality/goresponsiveness/stats" @@ -63,7 +64,9 @@ type ProbeConfiguration struct { type ProbeDataPoint struct { Time time.Time `Description:"Time of the generation of the data point." Formatter:"Format" FormatterArgument:"01-02-2006-15-04-05.000"` RoundTripCount uint64 `Description:"The number of round trips measured by this data point."` - Duration time.Duration `Description:"The duration for this measurement."` + Duration time.Duration `Description:"The duration for this measurement." Formatter:"Seconds"` + TCPRtt time.Duration `Description:"The underlying connection's RTT at probe time." Formatter:"Seconds"` + TCPCwnd uint32 `Description:"The underlying connection's congestion window at probe time."` } type ThroughputDataPoint struct { @@ -186,7 +189,18 @@ func Probe( ) } }() - dataPoint := ProbeDataPoint{Time: time_before_probe, RoundTripCount: roundTripCount, Duration: totalDelay} + tcpRtt := time.Duration(0 * time.Second) + tcpCwnd := uint32(0) + if extendedstats.ExtendedStatsAvailable() { + tcpInfo, err := extendedstats.GetTCPInfo(probeTracer.stats.ConnInfo.Conn) + if err == nil { + tcpRtt = time.Duration(tcpInfo.Rtt) * time.Microsecond + tcpCwnd = tcpInfo.Snd_cwnd + } else { + fmt.Printf("Warning: Could not fetch the extended stats for a probe: %v\n", err) + } + } + dataPoint := ProbeDataPoint{Time: time_before_probe, RoundTripCount: roundTripCount, Duration: totalDelay, TCPRtt: tcpRtt, TCPCwnd: tcpCwnd} if !utilities.IsInterfaceNil(logger) { logger.LogRecord(dataPoint) } -- cgit v1.2.3