Categorygithub.com/willfantom/go-iperf
repositorypackage
0.1.0
Repository: https://github.com/willfantom/go-iperf.git
Documentation: pkg.go.dev

# Packages

No description provided by the author
No description provided by the author
No description provided by the author

# README

go-iperf

A Go based wrapper around iperf3

This fork removes the embedded iperf3 binary. Whilst the idea is nice, its easier and more convenient when using multiple platforms and architectures etc, to use an external binary.

Basic Usage

basic client setup

func main() {
	
	c := iperf.NewClient("192.168.0.10")
	c.SetJSON(true)
	c.SetIncludeServer(true)
	c.SetStreams(4)
	c.SetTimeSec(30)
	c.SetInterval(1)
	
	err := c.Start()
	if err != nil {
        fmt.Printf("failed to start client: %v\n", err)
        os.Exit(-1)
	}
	
	<- c.Done
	
	fmt.Println(c.Report().String())
}

basic server setup

func main() {
	
	s := iperf.NewServer()
	err := s.Start()
	if err != nil {
        fmt.Printf("failed to start server: %v\n", err)
        os.Exit(-1)
    }
    
    for s.Running {
    	time.Sleep(100 * time.Millisecond)
    }
    
    fmt.Println("server finished")
}

client with live results printing

func main() {
	
	c := iperf.NewClient("192.168.0.10")
	c.SetJSON(true)
	c.SetIncludeServer(true)
	c.SetStreams(4)
	c.SetTimeSec(30)
	c.SetInterval(1)
	liveReports := c.SetModeLive()
	
	go func() {
	    for report := range liveReports {
	        fmt.Println(report.String())	
            }   	
        }   
	
	err := c.Start()
	if err != nil {
            fmt.Printf("failed to start client: %v\n", err)
            os.Exit(-1)
	}
	
	<- c.Done
	
	fmt.Println(c.Report().String())
}