common

package
v0.0.0-...-4950795 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BE   = 0x00
	CS1  = 0x20
	AF11 = 0x28
	AF12 = 0x30
	AF13 = 0x38
	CS2  = 0x40
	AF21 = 0x48
	AF22 = 0x50
	AF23 = 0x58
	CS3  = 0x60
	AF31 = 0x68
	AF32 = 0x70
	AF33 = 0x78
	CS4  = 0x80
	AF41 = 0x88
	AF42 = 0x90
	AF43 = 0x98
	CS5  = 0xA0
	EF   = 0xB8
	CS6  = 0xC0
	CS7  = 0xE0
)

Variables

This section is empty.

Functions

func NewTimestamp

func NewTimestamp(twampTimestamp TwampTimestamp) time.Time

func ReadFromSocket

func ReadFromSocket(reader io.Reader, size int) (bytes.Buffer, error)

Types

type MeasurementPacket

type MeasurementPacket struct {
	Sequence            uint32
	Timestamp           TwampTimestamp
	ErrorEstimate       uint16
	MBZ                 uint16
	ReceiveTimeStamp    TwampTimestamp
	SenderSequence      uint32
	SenderTimeStamp     TwampTimestamp
	SenderErrorEstimate uint16
	Mbz                 uint16
	SenderTtl           byte
}

type PingResultStats

type PingResultStats struct {
	Min         time.Duration `json:"min"`
	Max         time.Duration `json:"max"`
	Avg         time.Duration `json:"avg"`
	StdDev      time.Duration `json:"stddev"`
	Transmitted int           `json:"tx"`
	Received    int           `json:"rx"`
	Loss        float64       `json:"loss"`
}

type PingResults

type PingResults struct {
	Results []*TwampResults  `json:"results"`
	Stat    *PingResultStats `json:"stats"`
}

func (*PingResults) StdDev

func (r *PingResults) StdDev(mean time.Duration) time.Duration

type TwampResults

type TwampResults struct {
	SeqNum              uint32    `json:"seqnum"`
	Timestamp           time.Time `json:"timestamp"`
	ErrorEstimate       uint16    `json:"errorEstimate"`
	ReceiveTimestamp    time.Time `json:"receiveTimestamp"`
	SenderSeqNum        uint32    `json:"senderSeqnum"`
	SenderTimestamp     time.Time `json:"senderTimestamp"`
	SenderErrorEstimate uint16    `json:"senderErrorEstimate"`
	SenderTTL           byte      `json:"senderTTL"`
	FinishedTimestamp   time.Time `json:"finishedTimestamp"`
	SenderSize          int       `json:"senderSize"`
}

TWAMP test result timestamps have been normalized to UNIX epoch time.

func (*TwampResults) GetRTT

func (r *TwampResults) GetRTT() time.Duration

func (*TwampResults) GetWait

func (r *TwampResults) GetWait() time.Duration

func (*TwampResults) PrintResults

func (r *TwampResults) PrintResults()

type TwampSession

type TwampSession struct {
	Port   uint16
	Config TwampSessionConfig
}

type TwampSessionConfig

type TwampSessionConfig struct {
	// According to RFC 4656, if Conf-Receiver is not set, Receiver port
	// is the UDP port OWAMP-Test to which packets are
	// requested to be sent.
	ReceiverPort int
	// According to RFC 4656, if Conf-Sender is not set, Sender port is the
	// UDP port from which OWAMP-Test packets will be sent.
	SenderPort int
	// According to RFC 4656, Padding length is the number of octets to be
	// appended to the normal OWAMP-Test packet (see more on
	// padding in discussion of OWAMP-Test).
	Padding int
	// According to RFC 4656, Timeout (or a loss threshold) is an interval of time
	// (expressed as a timestamp). A packet belonging to the test session
	// that is being set up by the current Request-Session command will
	// be considered lost if it is not received during Timeout seconds
	// after it is sent.
	Timeout int
	TOS     int
	// If true, padding will be filled with zeros instead of random data.
	UseAllZeros bool
	// Interval between sending out two measurement packet
	Interval time.Duration
}

type TwampTestCallbackFunction

type TwampTestCallbackFunction func(targetPackets int, result *TwampResults, stats PingResultStats)

Function header called when a test package arrived back. Can be used to show some progress

type TwampTimestamp

type TwampTimestamp struct {
	Integer  uint32
	Fraction uint32
}

func NewTwampTimestamp

func NewTwampTimestamp(t time.Time) *TwampTimestamp

Converts a UNIX epoch time time.Time object into an RFC 1305 compliant time.

func (*TwampTimestamp) GetTime

func (t *TwampTimestamp) GetTime() time.Time

Return a time.Time object representing Unix Epoch time since January 1st, 1970.

func (*TwampTimestamp) String

func (t *TwampTimestamp) String() string

Jump to

Keyboard shortcuts

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