GoIPerf

package module
v0.0.0-...-d55a720 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2021 License: AGPL-3.0 Imports: 4 Imported by: 0

README

GoIPerf

An easier way to run an IPerf3 test from your Go application.

Why GoIPerf executes commands on CLI?

Since I wanted to use the official binary to run the tests, I've preferred to use this solution.

Requirements

In order to use GoIPerf you'll need to have IPerf3 installed on your system available under the command "iperf3".
If you want/need to use a custom binary is it possible to change the location by setting the variable Location to the bin path like in the example below.

GoIPerf.Location = "/usr/bin/iperf3"

How to install?

go get github.com/LucaTheHacker/GoIPerf

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Location = "iperf3"

Functions

This section is empty.

Types

type CPU

type CPU struct {
	HostTotal    float64 `json:"host_total"`
	HostUser     float64 `json:"host_user"`
	HostSystem   float64 `json:"host_system"`
	RemoteTotal  float64 `json:"remote_total"`
	RemoteUser   float64 `json:"remote_user"`
	RemoteSystem float64 `json:"remote_system"`
}

CPU contains data about the server/client CPU usage

func (*CPU) IsOverLoaded

func (c *CPU) IsOverLoaded() bool

IsOverLoaded returns true if the server or the host had too high CPU usage during the tests

type FinalResult

type FinalResult struct {
	Streams               *[]Measure `json:"streams"`
	Sent                  *Summary   `json:"sum_sent"`
	Received              *Summary   `json:"sum_received"`
	CPU                   *CPU       `json:"cpu_utilization_percent"`
	SenderTCPCongestion   string     `json:"sender_tcp_congestion"`
	ReceiverTCPCongestion string     `json:"receiver_tcp_congestion"`
}

FinalResult contains all the necessary infos of the test

type Initial

type Initial struct {
	Connected             []map[string]interface{} `json:"connected"`
	Version               string                   `json:"version"`
	SystemInfo            string                   `json:"system_info"`
	TimeStamp             *TimeStamp               `json:"timestamp"`
	Server                *Server                  `json:"connecting_to"`
	Cookie                string                   `json:"cookie"`
	TCPMSegmentSize       int                      `json:"tcp_mss_default"`
	SocketBufferSize      int                      `json:"sock_bufsize"`
	SenderBufferCurrent   int                      `json:"sndbuf_actual"`
	ReceiverBufferCurrent int                      `json:"rcvbuf_actual"`
	Test                  *Test                    `json:"test_start"`
}

Initial contains data about the IPerf3 initialization

type Measure

type Measure struct {
	Streams *[]Stream `json:"streams"`
	Summary *Summary  `json:"sum"`
}

Measure contains data about the test Measurements

type Result

type Result struct {
	Initial  *Initial     `json:"start"`
	Measures *[]Measure   `json:"intervals"`
	Result   *FinalResult `json:"end"`
	Error    string       `json:"error"`
}

Result contains the result of the IPerf3 test

func Download

func Download(server, port string) (result *Result, err error)

Download runs an IPerf3 download test

func Upload

func Upload(server, port string) (result *Result, err error)

Upload runs an IPerf3 upload test

func (*Result) IsBusy

func (r *Result) IsBusy() bool

IsBusy is a shortcut for error handling, it returns true if the server is busy

func (*Result) IsDown

func (r *Result) IsDown() bool

IsDown is a shortcut for error handling, it returns true if the server is down or unreachable Intended for long outages that can't autorecover in a small timespan

func (*Result) IsTemporarilyDown

func (r *Result) IsTemporarilyDown() bool

IsTemporarilyDown is a shortcut for error handling, it returns true if the server didn't reply to the control message Intended for short outages that could be fixed in a few seconds of with another try

type Server

type Server struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

Server contains data about the destination server

type Stream

type Stream struct {
	Socket        int     `json:"socket"`
	Start         float64 `json:"start"`
	End           float64 `json:"end"`
	Seconds       float64 `json:"seconds"`
	BitsPerSecond float64 `json:"bits_per_second"`
	Retransmits   int     `json:"retransmits"`
	SenderCWND    int     `json:"snd_cwnd"`
	RTT           int     `json:"rtt"`
	RTTVar        int     `json:"rttvar"`
	PMTU          int     `json:"pmtu"`
	Omitted       bool    `json:"omitted"`
}

Stream contains data about the streams used in the test

type Summary

type Summary struct {
	Start         float64 `json:"start"`
	End           float64 `json:"end"`
	Seconds       float64 `json:"seconds"`
	Bytes         int     `json:"bytes"`
	BitsPerSecond float64 `json:"bits_per_second"`
	Retransmits   int     `json:"retransmits"`
	Omitted       bool    `json:"omitted"`
}

Summary contains a recap of the whole test

func (*Summary) GetMegabits

func (s *Summary) GetMegabits() float64

GetMegabits returns the result speed in Megabits instead of bits

type Test

type Test struct {
	Protocol      string `json:"protocol"`
	StreamsNumber int    `json:"num_streams"`
	BlockSize     int    `json:"blksize"`
	Omit          int    `json:"omit"`
	Duration      int    `json:"duration"`
	Bytes         int    `json:"bytes"`
	Blocks        int    `json:"blocks"`
	Reverse       int    `json:"reverse"`
	ToS           int    `json:"tos"`
}

Test contains data about the IPerf3 test

type TimeStamp

type TimeStamp struct {
	TimeStamp string `json:"time"`
	Time      int    `json:"timesecs"`
}

TimeStamp contains the timestamp of the test in different formats

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL