|  |  | @ -2,10 +2,8 @@ package main | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | import ( |  |  |  | import ( | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"fmt" |  |  |  | 	"fmt" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"github.com/BGrewell/go-conversions" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"github.com/BGrewell/go-iperf" |  |  |  | 	"github.com/BGrewell/go-iperf" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"os" |  |  |  | 	"os" | 
			
		
	
		
		
			
				
					
					|  |  |  | 	"time" |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | ) |  |  |  | ) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | func main() { |  |  |  | func main() { | 
			
		
	
	
		
		
			
				
					|  |  | @ -22,8 +20,17 @@ func main() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 	c.SetOmitSec(omitSec) |  |  |  | 	c.SetOmitSec(omitSec) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	c.SetProto((iperf.Protocol)(proto)) |  |  |  | 	c.SetProto((iperf.Protocol)(proto)) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	c.SetLength(length) |  |  |  | 	c.SetLength(length) | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 	c.SetJSON(false) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	fmt.Printf("blockcount: %s\n", c.BlockCount()) |  |  |  | 	c.SetIncludeServer(false) | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	c.SetTimeSec(20) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	c.SetStreams(2) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	reports := c.SetModeLive() | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	go func() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		for report := range reports { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 			fmt.Println(report.String()) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 		} | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	}() | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	err := c.Start() |  |  |  | 	err := c.Start() | 
			
		
	
		
		
			
				
					
					|  |  |  | 	if err != nil { |  |  |  | 	if err != nil { | 
			
		
	
	
		
		
			
				
					|  |  | @ -31,20 +38,24 @@ func main() { | 
			
		
	
		
		
			
				
					
					|  |  |  | 		os.Exit(-1) |  |  |  | 		os.Exit(-1) | 
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 	} | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | 	for c.Running { |  |  |  | 	// Method 1: Wait for the test to finish by pulling from the 'Done' channel which will block until something is put in or it's closed
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		time.Sleep(100 * time.Millisecond) |  |  |  | 	<- c.Done | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	} |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 	// Method 2: Poll the c.Running state and wait for it to be 'false'
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	if c.Report().Error != "" { |  |  |  | 	//for c.Running {
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		fmt.Println(c.Report().Error) |  |  |  | 	//	time.Sleep(100 * time.Millisecond)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 	} else { |  |  |  | 	//}
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		for _, entry := range c.Report().End.Streams { |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			fmt.Println(entry.String()) |  |  |  | 	//if c.Report().Error != "" {
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		} |  |  |  | 	//	fmt.Println(c.Report().Error)
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 		for _, entry := range c.Report().ServerOutputJson.End.Streams { |  |  |  | 	//} else {
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 			fmt.Println(entry.String()) |  |  |  | 	//	for _, entry := range c.Report().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))) |  |  |  | 	//	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)))
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 	//}
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |