mark everything above ThrottlePingThreshold/2 as "unstable"
This commit is contained in:
16
main.go
16
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user