mark everything above ThrottlePingThreshold/2 as "unstable"
This commit is contained in:
16
main.go
16
main.go
@@ -136,7 +136,7 @@ outerLoop:
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 {
|
||||||
m.LastOver = time.Now()
|
m.LastOver = time.Now()
|
||||||
lastStep := conf.Bandwidth.Step * 0.5
|
lastStep := conf.Bandwidth.Step * 0.5
|
||||||
up, err := m.Upload()
|
up, err := m.Upload()
|
||||||
@@ -144,8 +144,8 @@ outerLoop:
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("ping %s over threshold detected, starting extended pings...", stats.AvgRtt)
|
log.Infof("ping %s±%s over threshold detected, starting extended pings...", stats.AvgRtt, stats.StdDevRtt)
|
||||||
for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
for stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 {
|
||||||
stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second)
|
stats, err = doPing(conf.Host, conf.ConformationPPP, time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warningf("ping to %s failed: %v", conf.Host, err)
|
log.Warningf("ping to %s failed: %v", conf.Host, err)
|
||||||
@@ -153,7 +153,7 @@ outerLoop:
|
|||||||
continue outerLoop
|
continue outerLoop
|
||||||
}
|
}
|
||||||
|
|
||||||
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold {
|
if stats.AvgRtt.Milliseconds() >= conf.ThrottlePingThreshold || stats.StdDevRtt.Milliseconds() > conf.ThrottlePingThreshold/2 {
|
||||||
lastStep *= 2
|
lastStep *= 2
|
||||||
newUp := up - lastStep
|
newUp := up - lastStep
|
||||||
|
|
||||||
@@ -161,7 +161,7 @@ outerLoop:
|
|||||||
newUp = conf.Bandwidth.Min
|
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)
|
up, err = m.SetUpload(newUp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -181,7 +181,7 @@ outerLoop:
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if m.isBWInRange(up + conf.Bandwidth.Step) {
|
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)
|
up, err = m.SetUpload(up + conf.Bandwidth.Step)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -198,14 +198,14 @@ outerLoop:
|
|||||||
continue
|
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)
|
log.Infof("increase failed with %s ping, reverting to %f", stats.AvgRtt, up-conf.Bandwidth.Step)
|
||||||
_, err = m.SetUpload(up - conf.Bandwidth.Step)
|
_, err = m.SetUpload(up - conf.Bandwidth.Step)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else {
|
} 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