speedtest

package
v1.104.5 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: BSD-3-Clause Imports: 7 Imported by: 8 modules, 14 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package speedtest contains both server and client code for running speedtests between tailscale nodes.

Index

Constants

View Source
const (
	MinDuration     = 5 * time.Second  // minimum duration for a test
	DefaultDuration = MinDuration      // default duration for a test
	MaxDuration     = 30 * time.Second // maximum duration for a test

	DefaultPort = 20333
)

Variables

This section is empty.

Functions

func Serve

func Serve(ln net.Listener) error

Serve starts up the server on a given host and port pair. It starts to listen for connections and handles each one in a goroutine. Because it runs in an infinite loop, this function only returns if any of the speedtests return with errors, or if the listener is closed.

Types

type Direction

type Direction int
const (
	Download Direction = iota
	Upload
)

func (*Direction) Reverse

func (d *Direction) Reverse()

func (Direction) String

func (d Direction) String() string

type Result

type Result struct {
	Bytes         int       // number of bytes sent/received during the interval
	IntervalStart time.Time // start of the interval
	IntervalEnd   time.Time // end of the interval
	Total         bool      // if true, this result struct represents the entire test, rather than a segment of the test
}

This represents the Result of a speedtest within a specific interval

func RunClient

func RunClient(direction Direction, duration time.Duration, host string) ([]Result, error)

RunClient dials the given address and starts a speedtest. It returns any errors that come up in the tests. If there are no errors in the test, it returns a slice of results.

func (Result) Interval

func (r Result) Interval() time.Duration

func (Result) MBitsPerSecond

func (r Result) MBitsPerSecond() float64

func (Result) MegaBits

func (r Result) MegaBits() float64

func (Result) MegaBytes

func (r Result) MegaBytes() float64

Jump to

Keyboard shortcuts

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