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$ +}