summaryrefslogtreecommitdiff
path: root/networkQuality.go
diff options
context:
space:
mode:
Diffstat (limited to 'networkQuality.go')
-rw-r--r--networkQuality.go54
1 files changed, 28 insertions, 26 deletions
diff --git a/networkQuality.go b/networkQuality.go
index d9bdc94..217ee6a 100644
--- a/networkQuality.go
+++ b/networkQuality.go
@@ -19,9 +19,6 @@ import (
"crypto/tls"
"flag"
"fmt"
- _ "io"
- _ "log"
- "net"
"net/http"
"os"
"runtime/pprof"
@@ -31,6 +28,7 @@ import (
"github.com/network-quality/goresponsiveness/config"
"github.com/network-quality/goresponsiveness/constants"
"github.com/network-quality/goresponsiveness/debug"
+ "github.com/network-quality/goresponsiveness/extendedstats"
"github.com/network-quality/goresponsiveness/lgc"
"github.com/network-quality/goresponsiveness/rpm"
"github.com/network-quality/goresponsiveness/timeoutat"
@@ -80,6 +78,12 @@ var (
"",
"Enable client runtime profiling and specify storage location. Disabled by default.",
)
+
+ calculateExtendedStats = flag.Bool(
+ "extended-stats",
+ false,
+ "Enable the collection and display of extended statistics -- may not be available on certain platforms.",
+ )
)
func main() {
@@ -99,6 +103,11 @@ func main() {
debugLevel = debug.Debug
}
+ if *calculateExtendedStats && !extendedstats.ExtendedStatsAvailable() {
+ *calculateExtendedStats = false
+ fmt.Printf("Warning: Calculation of extended statics was requested but they are not supported on this platform.\n")
+ }
+
if err := config.Get(configHostPort, *configPath); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
return
@@ -295,6 +304,18 @@ func main() {
totalMeasurements := uint64(0)
totalMeasurementTimes := float64(0)
measurementTimeout := false
+ extendedStats := extendedstats.ExtendedStats{}
+
+ for i := 0; i < len(downloadSaturation.LGCs); i++ {
+ // Assume that extended statistics are available -- the check was done explicitly at
+ // program startup if the calculateExtendedStats flag was set by the user on the command line.
+ if *calculateExtendedStats {
+ if !extendedstats.ExtendedStatsAvailable() {
+ panic("Extended stats are not available but the user requested their calculation.")
+ }
+ extendedStats.IncorporateConnectionStats(downloadSaturation.LGCs[i].Stats().ConnInfo.Conn)
+ }
+ }
for i := 0; i < constants.MeasurementProbeCount && !measurementTimeout; i++ {
if len(downloadSaturation.LGCs) == 0 {
@@ -324,29 +345,6 @@ func main() {
continue
}
- if *debugCliFlag {
- // Note: This code is just an example of how to use utilities.GetTCPInfo.
- rawConn := downloadSaturation.LGCs[randomLGCsIndex].Stats().ConnInfo.Conn
- tlsConn, ok := rawConn.(*tls.Conn)
- if !ok {
- fmt.Printf("OOPS: Could not get the TCP info for the connection (not a TLS connection)!\n")
- }
- tcpConn, ok := tlsConn.NetConn().(*net.TCPConn)
- if !ok {
- fmt.Printf("OOPS: Could not get the TCP info for the connection (not a TCP connection)!\n")
- }
- if info, err := utilities.GetTCPInfo(tcpConn); err != nil {
- switch err.(type) {
- case *utilities.NotImplemented:
- fmt.Printf("GetTCPInfo not implemented on this platform.\n")
- default:
- fmt.Printf("OOPS: Could not get the TCP info for the connection: %v!\n", err)
- }
- } else {
- utilities.PrintTCPInfo(info)
- }
- }
-
unsaturatedMeasurementTransport := http2.Transport{}
unsaturatedMeasurementTransport.TLSClientConfig = &tls.Config{}
if sslKeyFileConcurrentWriter != nil {
@@ -428,6 +426,10 @@ func main() {
fmt.Printf("Error occurred calculating RPM -- no probe measurements received.\n")
}
+ if *calculateExtendedStats {
+ fmt.Printf(extendedStats.Repr())
+ }
+
cancelOperatingCtx()
if *debugCliFlag {
fmt.Printf("In debugging mode, we will cool down.\n")