summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--constants/constants.go4
-rw-r--r--lgc/lgc.go (renamed from lbc/lbc.go)40
-rw-r--r--networkQuality.go92
-rw-r--r--utilities/utilities.go2
4 files changed, 69 insertions, 69 deletions
diff --git a/constants/constants.go b/constants/constants.go
index a94c777..1a060dd 100644
--- a/constants/constants.go
+++ b/constants/constants.go
@@ -4,14 +4,14 @@ import "time"
var (
// The initial number of connections on a LBC.
- StartingNumberOfLoadBearingConnections uint64 = 4
+ StartingNumberOfLoadGeneratingConnections uint64 = 4
// The number of intervals for which to account in a moving-average
// calculation.
MovingAverageIntervalCount int = 4
// The number of intervals across which to consider a moving average stable.
MovingAverageStabilitySpan int = 4
// The number of connections to add to a LBC when unsaturated.
- AdditiveNumberOfLoadBearingConnections uint64 = 4
+ AdditiveNumberOfLoadGeneratingConnections uint64 = 4
// The cutoff of the percent difference that defines instability.
InstabilityDelta float64 = 5
diff --git a/lbc/lbc.go b/lgc/lgc.go
index 50a4caa..dd454c1 100644
--- a/lbc/lbc.go
+++ b/lgc/lgc.go
@@ -12,7 +12,7 @@
* with Foobar. If not, see <https://www.gnu.org/licenses/>.
*/
-package lbc
+package lgc
import (
"context"
@@ -29,14 +29,14 @@ import (
var chunkSize int = 5000
-type LoadBearingConnection interface {
+type LoadGeneratingConnection interface {
Start(context.Context, bool) bool
Transferred() uint64
Client() *http.Client
IsValid() bool
}
-type LoadBearingConnectionDownload struct {
+type LoadGeneratingConnectionDownload struct {
Path string
downloaded uint64
client *http.Client
@@ -45,7 +45,7 @@ type LoadBearingConnectionDownload struct {
KeyLogger io.Writer
}
-func (lbd *LoadBearingConnectionDownload) Transferred() uint64 {
+func (lbd *LoadGeneratingConnectionDownload) Transferred() uint64 {
transferred := atomic.LoadUint64(&lbd.downloaded)
if lbd.debug {
fmt.Printf("download: Transferred: %v\n", transferred)
@@ -53,7 +53,7 @@ func (lbd *LoadBearingConnectionDownload) Transferred() uint64 {
return transferred
}
-func (lbd *LoadBearingConnectionDownload) Client() *http.Client {
+func (lbd *LoadGeneratingConnectionDownload) Client() *http.Client {
return lbd.client
}
@@ -72,7 +72,7 @@ func (cr *countingReader) Read(p []byte) (n int, err error) {
return
}
-func (lbd *LoadBearingConnectionDownload) Start(
+func (lbd *LoadGeneratingConnectionDownload) Start(
ctx context.Context,
debug bool,
) bool {
@@ -82,7 +82,7 @@ func (lbd *LoadBearingConnectionDownload) Start(
if !utilities.IsInterfaceNil(lbd.KeyLogger) {
if debug {
fmt.Printf(
- "Using an SSL Key Logger for this load-bearing download.\n",
+ "Using an SSL Key Logger for this load-generating download.\n",
)
}
@@ -104,16 +104,16 @@ func (lbd *LoadBearingConnectionDownload) Start(
lbd.valid = true
if debug {
- fmt.Printf("Started a load-bearing download.\n")
+ fmt.Printf("Started a load-generating download.\n")
}
go lbd.doDownload(ctx)
return true
}
-func (lbd *LoadBearingConnectionDownload) IsValid() bool {
+func (lbd *LoadGeneratingConnectionDownload) IsValid() bool {
return lbd.valid
}
-func (lbd *LoadBearingConnectionDownload) doDownload(ctx context.Context) {
+func (lbd *LoadGeneratingConnectionDownload) doDownload(ctx context.Context) {
get, err := lbd.client.Get(lbd.Path)
if err != nil {
lbd.valid = false
@@ -123,11 +123,11 @@ func (lbd *LoadBearingConnectionDownload) doDownload(ctx context.Context) {
_, _ = io.Copy(ioutil.Discard, cr)
get.Body.Close()
if lbd.debug {
- fmt.Printf("Ending a load-bearing download.\n")
+ fmt.Printf("Ending a load-generating download.\n")
}
}
-type LoadBearingConnectionUpload struct {
+type LoadGeneratingConnectionUpload struct {
Path string
uploaded uint64
client *http.Client
@@ -136,7 +136,7 @@ type LoadBearingConnectionUpload struct {
KeyLogger io.Writer
}
-func (lbu *LoadBearingConnectionUpload) Transferred() uint64 {
+func (lbu *LoadGeneratingConnectionUpload) Transferred() uint64 {
transferred := atomic.LoadUint64(&lbu.uploaded)
if lbu.debug {
fmt.Printf("upload: Transferred: %v\n", transferred)
@@ -144,11 +144,11 @@ func (lbu *LoadBearingConnectionUpload) Transferred() uint64 {
return transferred
}
-func (lbu *LoadBearingConnectionUpload) Client() *http.Client {
+func (lbu *LoadGeneratingConnectionUpload) Client() *http.Client {
return lbu.client
}
-func (lbu *LoadBearingConnectionUpload) IsValid() bool {
+func (lbu *LoadGeneratingConnectionUpload) IsValid() bool {
return lbu.valid
}
@@ -168,7 +168,7 @@ func (s *syntheticCountingReader) Read(p []byte) (n int, err error) {
return
}
-func (lbu *LoadBearingConnectionUpload) doUpload(ctx context.Context) bool {
+func (lbu *LoadGeneratingConnectionUpload) doUpload(ctx context.Context) bool {
lbu.uploaded = 0
s := &syntheticCountingReader{n: &lbu.uploaded, ctx: ctx}
var resp *http.Response = nil
@@ -179,12 +179,12 @@ func (lbu *LoadBearingConnectionUpload) doUpload(ctx context.Context) bool {
}
resp.Body.Close()
if lbu.debug {
- fmt.Printf("Ending a load-bearing upload.\n")
+ fmt.Printf("Ending a load-generating upload.\n")
}
return true
}
-func (lbu *LoadBearingConnectionUpload) Start(
+func (lbu *LoadGeneratingConnectionUpload) Start(
ctx context.Context,
debug bool,
) bool {
@@ -197,7 +197,7 @@ func (lbu *LoadBearingConnectionUpload) Start(
if !utilities.IsInterfaceNil(lbu.KeyLogger) {
if debug {
fmt.Printf(
- "Using an SSL Key Logger for this load-bearing upload.\n",
+ "Using an SSL Key Logger for this load-generating upload.\n",
)
}
transport.TLSClientConfig = &tls.Config{
@@ -211,7 +211,7 @@ func (lbu *LoadBearingConnectionUpload) Start(
lbu.valid = true
if debug {
- fmt.Printf("Started a load-bearing upload.\n")
+ fmt.Printf("Started a load-generating upload.\n")
}
go lbu.doUpload(ctx)
return true
diff --git a/networkQuality.go b/networkQuality.go
index 41caa4c..135a10f 100644
--- a/networkQuality.go
+++ b/networkQuality.go
@@ -33,7 +33,7 @@ import (
"github.com/network-quality/goresponsiveness/ccw"
"github.com/network-quality/goresponsiveness/constants"
- "github.com/network-quality/goresponsiveness/lbc"
+ "github.com/network-quality/goresponsiveness/lgc"
"github.com/network-quality/goresponsiveness/ma"
"github.com/network-quality/goresponsiveness/timeoutat"
"github.com/network-quality/goresponsiveness/utilities"
@@ -196,16 +196,16 @@ func (c *Config) IsValid() error {
func addFlows(
ctx context.Context,
toAdd uint64,
- lbcs *[]lbc.LoadBearingConnection,
- lbcsPreviousTransferred *[]uint64,
- lbcGenerator func() lbc.LoadBearingConnection,
+ lgcs *[]lgc.LoadGeneratingConnection,
+ lgcsPreviousTransferred *[]uint64,
+ lgcGenerator func() lgc.LoadGeneratingConnection,
debug bool,
) {
for i := uint64(0); i < toAdd; i++ {
- *lbcs = append(*lbcs, lbcGenerator())
- *lbcsPreviousTransferred = append(*lbcsPreviousTransferred, 0)
- if !(*lbcs)[len(*lbcs)-1].Start(ctx, debug) {
- fmt.Printf("Error starting %dth LBC!\n", i)
+ *lgcs = append(*lgcs, lgcGenerator())
+ *lgcsPreviousTransferred = append(*lgcsPreviousTransferred, 0)
+ if !(*lgcs)[len(*lgcs)-1].Start(ctx, debug) {
+ fmt.Printf("Error starting %dth lgc!\n", i)
return
}
}
@@ -213,7 +213,7 @@ func addFlows(
type SaturationResult struct {
RateBps float64
- Lbcs []lbc.LoadBearingConnection
+ lgcs []lgc.LoadGeneratingConnection
}
type Debugging struct {
@@ -231,21 +231,21 @@ func (d *Debugging) String() string {
func saturate(
saturationCtx context.Context,
operatingCtx context.Context,
- lbcGenerator func() lbc.LoadBearingConnection,
+ lgcGenerator func() lgc.LoadGeneratingConnection,
debug *Debugging,
) (saturated chan SaturationResult) {
saturated = make(chan SaturationResult)
go func() {
- lbcs := make([]lbc.LoadBearingConnection, 0)
- lbcsPreviousTransferred := make([]uint64, 0)
+ lgcs := make([]lgc.LoadGeneratingConnection, 0)
+ lgcsPreviousTransferred := make([]uint64, 0)
addFlows(
saturationCtx,
- constants.StartingNumberOfLoadBearingConnections,
- &lbcs,
- &lbcsPreviousTransferred,
- lbcGenerator,
+ constants.StartingNumberOfLoadGeneratingConnections,
+ &lgcs,
+ &lgcsPreviousTransferred,
+ lgcGenerator,
debug != nil,
)
@@ -293,11 +293,11 @@ func saturate(
// bytes transferred within the last second.
totalTransfer := uint64(0)
allInvalid := true
- for i := range lbcs {
- if !lbcs[i].IsValid() {
+ for i := range lgcs {
+ if !lgcs[i].IsValid() {
if debug != nil {
fmt.Printf(
- "%v: Load-bearing connection at index %d is invalid ... skipping.\n",
+ "%v: Load-generating connection at index %d is invalid ... skipping.\n",
debug,
i,
)
@@ -305,18 +305,18 @@ func saturate(
continue
}
allInvalid = false
- previousTransferred := lbcsPreviousTransferred[i]
- currentTransferred := lbcs[i].Transferred()
+ previousTransferred := lgcsPreviousTransferred[i]
+ currentTransferred := lgcs[i].Transferred()
totalTransfer += (currentTransferred - previousTransferred)
- lbcsPreviousTransferred[i] = currentTransferred
+ lgcsPreviousTransferred[i] = currentTransferred
}
- // For some reason, all the LBCs are invalid. This likely means that
+ // For some reason, all the lgcs are invalid. This likely means that
// the network/server went away.
if allInvalid {
if debug != nil {
fmt.Printf(
- "%v: All LBCs were invalid. Assuming that network/server went away.\n",
+ "%v: All lgcs were invalid. Assuming that network/server went away.\n",
debug,
)
}
@@ -380,10 +380,10 @@ func saturate(
}
addFlows(
saturationCtx,
- constants.AdditiveNumberOfLoadBearingConnections,
- &lbcs,
- &lbcsPreviousTransferred,
- lbcGenerator,
+ constants.AdditiveNumberOfLoadGeneratingConnections,
+ &lgcs,
+ &lgcsPreviousTransferred,
+ lgcGenerator,
debug != nil,
)
previousFlowIncreaseIteration = currentIteration
@@ -408,13 +408,13 @@ func saturate(
if debug != nil {
fmt.Printf("%v: New flows to add to try to increase our saturation!\n", debug)
}
- addFlows(saturationCtx, constants.AdditiveNumberOfLoadBearingConnections, &lbcs, &lbcsPreviousTransferred, lbcGenerator, debug != nil)
+ addFlows(saturationCtx, constants.AdditiveNumberOfLoadGeneratingConnections, &lgcs, &lgcsPreviousTransferred, lgcGenerator, debug != nil)
previousFlowIncreaseIteration = currentIteration
}
}
}
- saturated <- SaturationResult{RateBps: movingAverage.CalculateAverage(), Lbcs: lbcs}
+ saturated <- SaturationResult{RateBps: movingAverage.CalculateAverage(), lgcs: lgcs}
}()
return
}
@@ -499,14 +499,14 @@ func main() {
}
}
- generate_lbd := func() lbc.LoadBearingConnection {
- return &lbc.LoadBearingConnectionDownload{
+ generate_lbd := func() lgc.LoadGeneratingConnection {
+ return &lgc.LoadGeneratingConnectionDownload{
Path: config.Urls.LargeUrl,
KeyLogger: sslKeyFileConcurrentWriter,
}
}
- generate_lbu := func() lbc.LoadBearingConnection {
- return &lbc.LoadBearingConnectionUpload{
+ generate_lbu := func() lgc.LoadGeneratingConnection {
+ return &lgc.LoadGeneratingConnectionUpload{
Path: config.Urls.UploadUrl,
KeyLogger: sslKeyFileConcurrentWriter,
}
@@ -552,7 +552,7 @@ func main() {
"",
),
utilities.ToMBps(downloadSaturation.RateBps),
- len(downloadSaturation.Lbcs),
+ len(downloadSaturation.lgcs),
)
}
}
@@ -568,7 +568,7 @@ func main() {
"",
),
utilities.ToMBps(uploadSaturation.RateBps),
- len(uploadSaturation.Lbcs),
+ len(uploadSaturation.lgcs),
)
}
}
@@ -629,20 +629,20 @@ func main() {
rttTimeout := false
for i := 0; i < constants.RPMProbeCount && !rttTimeout; i++ {
- if len(downloadSaturation.Lbcs) == 0 {
+ if len(downloadSaturation.lgcs) == 0 {
continue
}
- randomLbcsIndex := rand.New(rand.NewSource(int64(time.Now().Nanosecond()))).
+ randomlgcsIndex := rand.New(rand.NewSource(int64(time.Now().Nanosecond()))).
Int() %
len(
- downloadSaturation.Lbcs,
+ downloadSaturation.lgcs,
)
- if !downloadSaturation.Lbcs[randomLbcsIndex].IsValid() {
+ if !downloadSaturation.lgcs[randomlgcsIndex].IsValid() {
if *debug {
fmt.Printf(
- "%v: The randomly selected download LBC (at index %d) was invalid. Skipping.\n",
+ "%v: The randomly selected download lgc (at index %d) was invalid. Skipping.\n",
debug,
- randomLbcsIndex,
+ randomlgcsIndex,
)
}
@@ -652,7 +652,7 @@ func main() {
if time.Since(timeoutAbsoluteTime) > 0 {
if *debug {
fmt.Printf(
- "Pathologically could not find valid LBCs to use for measurement.\n",
+ "Pathologically could not find valid lgcs to use for measurement.\n",
)
}
break
@@ -674,7 +674,7 @@ func main() {
{
rttTimeout = true
}
- case sequentialRTTimes := <-utilities.CalculateSequentialRTTsTime(operatingCtx, downloadSaturation.Lbcs[randomLbcsIndex].Client(), &newClient, config.Urls.SmallUrl):
+ case sequentialRTTimes := <-utilities.CalculateSequentialRTTsTime(operatingCtx, downloadSaturation.lgcs[randomlgcsIndex].Client(), &newClient, config.Urls.SmallUrl):
{
if sequentialRTTimes.Err != nil {
fmt.Printf(
@@ -700,13 +700,13 @@ func main() {
"Download: %7.3f Mbps (%7.3f MBps), using %d parallel connections.\n",
utilities.ToMbps(downloadSaturation.RateBps),
utilities.ToMBps(downloadSaturation.RateBps),
- len(downloadSaturation.Lbcs),
+ len(downloadSaturation.lgcs),
)
fmt.Printf(
"Upload: %7.3f Mbps (%7.3f MBps), using %d parallel connections.\n",
utilities.ToMbps(uploadSaturation.RateBps),
utilities.ToMBps(uploadSaturation.RateBps),
- len(uploadSaturation.Lbcs),
+ len(uploadSaturation.lgcs),
)
if totalRTsCount != 0 {
diff --git a/utilities/utilities.go b/utilities/utilities.go
index 8b64da4..46d5766 100644
--- a/utilities/utilities.go
+++ b/utilities/utilities.go
@@ -79,7 +79,7 @@ func CalculateSequentialRTTsTime(
roundTripCount := uint16(0)
before := time.Now()
/*
- TODO: We are not going to measure round-trip times on the load-bearing connection
+ TODO: We are not going to measure round-trip times on the load-generating connection
right now because we are dealing with a massive amount of buffer bloat on the
Apple CDN.