diff options
| author | Will Hawkins <[email protected]> | 2022-06-13 19:53:44 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-06-13 19:53:44 -0400 |
| commit | 144a5dad1f30d538cefd1ed0904c00fc29c3d9c4 (patch) | |
| tree | 223491fac01200e49302b477e512b5f7ebccf2ae | |
| parent | c93a4dedc897f84992a6a34200fe954ba2ca435d (diff) | |
| parent | a32ace3c60721d1bae4ea77117ffd14a35b0f951 (diff) | |
Merge pull request #25 from network-quality/timeout-patch
Timeout patch
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | constants/constants.go | 2 | ||||
| -rw-r--r-- | networkQuality.go | 17 |
3 files changed, 16 insertions, 9 deletions
@@ -74,8 +74,10 @@ $./networkQuality --help Enable client runtime profiling and specify storage location. Disabled by default. -ssl-key-file string Store the per-session SSL key files in this file. - -timeout int - Maximum time to spend measuring. (default 20) + -sattimeout int + Maximum time to spend measuring saturation. (default 20) + -rpmtimeout int + Maximum time to spend calculating RPM. (default 10) ``` To facilitate testing, you may want to use the open-source RPM server available from [Apple on GitHub](https://github.com/network-quality/server/tree/main/go). diff --git a/constants/constants.go b/constants/constants.go index a015f14..635aef7 100644 --- a/constants/constants.go +++ b/constants/constants.go @@ -20,7 +20,7 @@ var ( // The number of probes to send when calculating RTT. MeasurementProbeCount int = 5 // The amount of time that we give ourselves to calculate the RPM. - RPMCalculationTime time.Duration = 10 * time.Second + RPMCalculationTime int = 10 // The default amount of time that a test will take to calculate the RPM. DefaultTestTime int = 20 diff --git a/networkQuality.go b/networkQuality.go index c7dd74b..3ba783d 100644 --- a/networkQuality.go +++ b/networkQuality.go @@ -63,10 +63,15 @@ var ( constants.DefaultStrict, "Whether to run the test in strict mode (measure HTTP get time on load-generating connection)", ) - timeout = flag.Int( - "timeout", + sattimeout = flag.Int( + "sattimeout", constants.DefaultTestTime, - "Maximum time to spend measuring.", + "Maximum time to spend measuring saturation.", + ) + rpmtimeout = flag.Int( + "rpmtimeout", + constants.RPMCalculationTime, + "Maximum time to spend calculating RPM.", ) sslKeyFileName = flag.String( "ssl-key-file", @@ -89,7 +94,7 @@ var ( func main() { flag.Parse() - timeoutDuration := time.Second * time.Duration(*timeout) + timeoutDuration := time.Second * time.Duration(*sattimeout) timeoutAbsoluteTime := time.Now().Add(timeoutDuration) configHostPort := fmt.Sprintf("%s:%d", *configHost, *configPort) operatingCtx, cancelOperatingCtx := context.WithCancel(context.Background()) @@ -273,7 +278,7 @@ func main() { // and then we will give ourselves some additional time in order // to calculate a provisional saturation. timeoutAbsoluteTime = time.Now(). - Add(constants.RPMCalculationTime) + Add(time.Second * time.Duration(*rpmtimeout)) timeoutChannel = timeoutat.TimeoutAt( operatingCtx, timeoutAbsoluteTime, @@ -293,7 +298,7 @@ func main() { // We did it up there so that we could also limit the amount of time waiting // for a conditional saturation calculation. if !saturationTimeout { - timeoutAbsoluteTime = time.Now().Add(constants.RPMCalculationTime) + timeoutAbsoluteTime = time.Now().Add(time.Second * time.Duration(*rpmtimeout)) timeoutChannel = timeoutat.TimeoutAt( operatingCtx, timeoutAbsoluteTime, |
