-
Notifications
You must be signed in to change notification settings - Fork 10
/
main.go
48 lines (39 loc) · 931 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
//"fmt"
"github.com/BGrewell/go-conversions"
//"github.com/BGrewell/go-iperf"
//"time"
"fmt"
"github.com/BGrewell/go-iperf"
"time"
)
func main() {
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)))
}
}