summaryrefslogtreecommitdiff
path: root/extendedstats/unix.go
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2022-08-17 22:07:35 -0400
committerWill Hawkins <[email protected]>2022-08-17 22:07:35 -0400
commit18bcc4fe73bd8245cde001c939b400693a0d9410 (patch)
tree1d38cdb6271153d0bc1ba4ddfc3218722b12ccf7 /extendedstats/unix.go
parent8d7b3f43988f40976c540e64f955fabe3d14d755 (diff)
[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.
Diffstat (limited to 'extendedstats/unix.go')
-rw-r--r--extendedstats/unix.go29
1 files changed, 11 insertions, 18 deletions
diff --git a/extendedstats/unix.go b/extendedstats/unix.go
index a2d4d30..3db94fc 100644
--- a/extendedstats/unix.go
+++ b/extendedstats/unix.go
@@ -27,20 +27,8 @@ func ExtendedStatsAvailable() bool {
return true
}
-func (es *ExtendedStats) IncorporateConnectionStats(rawConn net.Conn) error {
- tlsConn, ok := rawConn.(*tls.Conn)
- if !ok {
- return fmt.Errorf(
- "OOPS: Could not get the TCP info for the connection (not a TLS connection)",
- )
- }
- tcpConn, ok := tlsConn.NetConn().(*net.TCPConn)
- if !ok {
- return fmt.Errorf(
- "OOPS: Could not get the TCP info for the connection (not a TCP connection)",
- )
- }
- if info, err := getTCPInfo(tcpConn); err != nil {
+func (es *ExtendedStats) IncorporateConnectionStats(basicConn net.Conn) error {
+ if info, err := GetTCPInfo(basicConn); err != nil {
return fmt.Errorf("OOPS: Could not get the TCP info for the connection: %v", err)
} else {
es.MaxPathMtu = utilities.Max(es.MaxPathMtu, uint64(info.Pmtu))
@@ -67,16 +55,21 @@ func (es *ExtendedStats) Repr() string {
`, es.MaxPathMtu, es.MaxSendMss, es.MaxRecvMss, es.TotalRetransmissions, es.TotalReorderings, es.AverageRtt)
}
-func getTCPInfo(connection net.Conn) (*unix.TCPInfo, error) {
- tcpConn, ok := connection.(*net.TCPConn)
+func GetTCPInfo(basicConn net.Conn) (*unix.TCPInfo, error) {
+ tlsConn, ok := basicConn.(*tls.Conn)
if !ok {
- return nil, fmt.Errorf("connection is not a net.TCPConn")
+ return nil, fmt.Errorf("OOPS: Outermost connection is not a TLS connection")
+ }
+ tcpConn, ok := tlsConn.NetConn().(*net.TCPConn)
+ if !ok {
+ return nil, fmt.Errorf(
+ "OOPS: Could not get the TCP info for the connection (not a TCP connection)",
+ )
}
rawConn, err := tcpConn.SyscallConn()
if err != nil {
return nil, err
}
-
var info *unix.TCPInfo = nil
rawConn.Control(func(fd uintptr) {
info, err = unix.GetsockoptTCPInfo(int(fd), unix.SOL_TCP, unix.TCP_INFO)