From 809e3bd648eaa29354803974ad370af4ef1b6772 Mon Sep 17 00:00:00 2001 From: Giovanni Harting <539@idlegandalf.com> Date: Wed, 3 Aug 2022 14:16:30 +0200 Subject: [PATCH] mark everything above ThrottlePingThreshold/2 as "unstable" --- main.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index 1e50715..2d6eb33 100644 --- a/main.go +++ b/main.go @@ -136,7 +136,7 @@ outerLoop: continue } - if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold { + if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 { m.LastOver = time.Now() lastStep := conf.Bandwidth.Step * 0.5 up, err := m.Upload() @@ -144,8 +144,8 @@ outerLoop: return err } - log.Infof("ping %s over threshold detected, starting extended pings...", stats.AvgRtt) - for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold { + log.Infof("ping %s±%s over threshold detected, starting extended pings...", stats.AvgRtt, stats.StdDevRtt) + for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 { stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second) if err != nil { log.Warningf("ping to %s failed: %v", conf.Host, err) @@ -153,7 +153,7 @@ outerLoop: continue outerLoop } - if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold { + if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 { lastStep *= 2 newUp := up - lastStep @@ -161,7 +161,7 @@ outerLoop: newUp = conf.Bandwidth.Min } - log.Infof("extended ping %s, adjusting upload TC %f->%f", stats.AvgRtt, up, newUp) + log.Infof("extended ping %s±%s, adjusting upload TC %f->%f", stats.AvgRtt, stats.StdDevRtt, up, newUp) up, err = m.SetUpload(newUp) if err != nil { return err @@ -181,7 +181,7 @@ outerLoop: return err } if m.isBWInRange(up + conf.Bandwidth.Step) { - log.Infof("short ping %s, trying to increase upload TC %f->%f", stats.AvgRtt, up, up+conf.Bandwidth.Step) + log.Infof("short ping %s±%s, trying to increase upload TC %f->%f", stats.AvgRtt, stats.StdDevRtt, up, up+conf.Bandwidth.Step) up, err = m.SetUpload(up + conf.Bandwidth.Step) if err != nil { return err @@ -198,14 +198,14 @@ outerLoop: continue } - if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold { + if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 { log.Infof("increase failed with %s ping, reverting to %f", stats.AvgRtt, up-conf.Bandwidth.Step) _, err = m.SetUpload(up - conf.Bandwidth.Step) if err != nil { return err } } else { - log.Infof("extended ping %s seems stable", stats.AvgRtt) + log.Infof("extended ping %s±%s seems stable", stats.AvgRtt, stats.StdDevRtt) } } }