netperf

package
v0.0.0-...-9474aff Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package netperf is used for running performance tests using linux netperf/netserver suite. Example usage: netperfSession := netperf.NewSession(

clientHost.conn,
clientHost.IP, // DUT IP
serverHost.conn,
serverHost.IP) // Router IP
defer func(ctx context.Context) {
	netperfSession.Close(ctx)
}(ctx)
ret, err = netperfSession.Run(ctx, netperf.Config{
	TestTime:         10*time.Second,
	TestType:         netperf.TestTypeTCPStream})

Index

Constants

View Source
const (
	// TestTypeTCPCRR measures how many times we can connect, request a byte,
	// and receive a byte per second.
	TestTypeTCPCRR TestType = "TCP_CRR"
	// TestTypeTCPMaerts : maerts is stream backwards. Like TCP_STREAM, except
	// it measures stream's bitrate in opposite direction: from the netperf server
	// to the client.
	TestTypeTCPMaerts = "TCP_MAERTS"
	// TestTypeTCPRR measures how many times we can request a byte and receive
	// a byte per second.
	TestTypeTCPRR = "TCP_RR"
	// TestTypeTCPSendfile is like a TCP_STREAM test except that the netperf client
	// will use a platform dependent call like sendfile() rather than the simple
	// send() call. This can result in better performance.
	TestTypeTCPSendfile = "TCP_SENDFILE"
	// TestTypeTCPStream measures throughput sending bytes from the client
	// to the server in a TCP stream.
	TestTypeTCPStream = "TCP_STREAM"
	// TestTypeUDPRR measures how many times we can request a byte from the client
	// and receive a byte from the server. If any datagram is dropped, the client
	// or server will block indefinitely. This failure is not evident except
	// as a low transaction rate.
	TestTypeUDPRR = "UDP_RR"
	// TestTypeUDPStream tests UDP throughput sending from the client to the server.
	// There is no flow control here, and generally sending is easier that receiving,
	// so there will be two types of throughput, both receiving and sending.
	TestTypeUDPStream = "UDP_STREAM"
	// TestTypeUDPMaerts isn't a real test type, but we can emulate a UDP stream
	// from the server to the DUT by running the netperf server on the DUT and the
	// client on the server and then doing a UDP_STREAM test.
	TestTypeUDPMaerts = "UDP_MAERTS"
)
View Source
const (
	// CategoryThroughput measures throughput in Mbps.
	CategoryThroughput Category = "throughput"
	// CategoryTransactionRate measures transaction rate per s.
	CategoryTransactionRate = "transaction rate"
	// CategoryErrors measures transmission errors.
	CategoryErrors = "errors"
	// CategoryThroughputDev st. deviation of throughput.
	CategoryThroughputDev = "throughput dev"
	// CategoryTransactionRateDev st. deviation of transaction rate.
	CategoryTransactionRateDev = "transaction rate dev"
	// CategoryErrorsDev st. deviation of errors.
	CategoryErrorsDev = "errors dev"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category string

Category is a measurement category, used as the key in measurements map. Its value is also used as a human-readable tag.

type Config

type Config struct {
	// TestTime how long the test should be run.
	TestTime time.Duration
	// TestType is literally this: test type.
	TestType TestType
	// Reverse: reverse client and server roles.
	Reverse bool
}

Config defines configuration for netperf run.

func (*Config) HumanReadableTag

func (c *Config) HumanReadableTag() string

HumanReadableTag returns human readable tag describing the configuration.

func (*Config) ShortTag

func (c *Config) ShortTag() string

ShortTag returns shortened tag representative to the configuration.

type History

type History []*Result

History is a set of netperf results.

type Result

type Result struct {
	TestType TestType
	Duration time.Duration
	// Measurements: throughput, transactionRate, errors or their st.deviations.
	Measurements map[Category]float64
}

Result is used to carry either single result or its derivative (mean/st.dev).

func AggregateSamples

func AggregateSamples(ctx context.Context, samples []*Result) (*Result, error)

AggregateSamples creates aggregate result out of slice of results

func NewResult

func NewResult(testType TestType, duration time.Duration) *Result

NewResult returns initialized Result.

func (*Result) String

func (r *Result) String() string

String returns string representation of the result.

type RunnerHost

type RunnerHost struct {
	// contains filtered or unexported fields
}

RunnerHost defines host's IP and SSH connection.

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session contains session data for running Runner.

func NewSession

func NewSession(
	clientConn *ssh.Conn,
	clientIP string,
	serverConn *ssh.Conn,
	serverIP string) *Session

NewSession creates a new netperf session. In each session, various tests with different configurations can be run.

func (*Session) Close

func (s *Session) Close(ctx context.Context)

Close closes the session.

func (*Session) Run

func (s *Session) Run(ctx context.Context, cfg Config) (History, error)

Run runs netperf runner with a particular test configuration.

func (*Session) WarmupStations

func (s *Session) WarmupStations(ctx context.Context) error

WarmupStations is running short netperf bursts in both directions to make sure both station are "warmed up" - have a stable, maximum throughput.

type TestType

type TestType string

TestType defines type of tests possible to run in netperf.

Jump to

Keyboard shortcuts

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