From 1e425687d2b8255f1f21d8ad841a2a8cbae082e6 Mon Sep 17 00:00:00 2001 From: Ben Grewell Date: Mon, 8 Mar 2021 06:48:32 -0800 Subject: [PATCH] initial commit --- report.go | 1 + sample.json | 0 tests/client/client.go | 50 ++++++++++++++++++++++++++++++++++++++++++ tests/server/server.go | 5 +++++ 4 files changed, 56 insertions(+) create mode 100644 report.go create mode 100644 sample.json create mode 100644 tests/client/client.go create mode 100644 tests/server/server.go diff --git a/report.go b/report.go new file mode 100644 index 0000000..ed8358d --- /dev/null +++ b/report.go @@ -0,0 +1 @@ +package iperf diff --git a/sample.json b/sample.json new file mode 100644 index 0000000..e69de29 diff --git a/tests/client/client.go b/tests/client/client.go new file mode 100644 index 0000000..c5ef747 --- /dev/null +++ b/tests/client/client.go @@ -0,0 +1,50 @@ +package main + +import ( + "fmt" + "github.com/BGrewell/go-conversions" + "github.com/BGrewell/go-iperf" + "os" + "time" +) + +func main() { + + includeServer := true + proto := "tcp" + runTime := 30 + omitSec := 10 + length := "65500" + + c := iperf.NewClient("10.23.42.18") + c.SetIncludeServer(includeServer) + c.SetTimeSec(runTime) + c.SetOmitSec(omitSec) + c.SetProto((iperf.Protocol)(proto)) + c.SetLength(length) + + fmt.Printf("blockcount: %s\n", c.BlockCount()) + + err := c.Start() + if err != nil { + fmt.Println("failed to start client") + os.Exit(-1) + } + + for c.Running { + time.Sleep(100 * time.Millisecond) + } + + if c.Report().Error != "" { + fmt.Println(c.Report().Error) + } else { + for _, entry := range c.Report().End.Streams { + fmt.Println(entry.String()) + } + for _, entry := range c.Report().ServerOutputJson.End.Streams { + fmt.Println(entry.String()) + } + fmt.Printf("DL Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumReceived.BitsPerSecond))) + fmt.Printf("UL Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumSent.BitsPerSecond))) + } +} diff --git a/tests/server/server.go b/tests/server/server.go new file mode 100644 index 0000000..3e4cfe4 --- /dev/null +++ b/tests/server/server.go @@ -0,0 +1,5 @@ +package main + +func main() { + $END$ +}