You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
931 B
Go

package main
import (
4 years ago
//"fmt"
"github.com/BGrewell/go-conversions"
4 years ago
//"github.com/BGrewell/go-iperf"
//"time"
3 years ago
"fmt"
"github.com/BGrewell/go-iperf"
"time"
)
func main() {
3 years ago
s := iperf.NewServer()
c := iperf.NewClient("127.0.0.1")
c.SetIncludeServer(true)
fmt.Println(s.Id)
fmt.Println(c.Id)
err := s.Start()
if err != nil {
fmt.Println(err)
}
err = c.Start()
if err != nil {
fmt.Println(err)
}
for c.Running {
time.Sleep(1 * time.Second)
}
fmt.Println("stopping server")
s.Stop()
fmt.Printf("Client exit code: %d\n", *c.ExitCode())
fmt.Printf("Server exit code: %d\n", *s.ExitCode)
iperf.Cleanup()
if c.Report().Error != "" {
fmt.Println(c.Report().Error)
} else {
fmt.Printf("Recv Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumReceived.BitsPerSecond)))
fmt.Printf("Send Rate: %s\n", conversions.IntBitRateToString(int64(c.Report().End.SumSent.BitsPerSecond)))
}
}