Documentation ¶
Index ¶
- Constants
- Variables
- func AbsDuration(d time.Duration) time.Duration
- func RegisterAverager(fn func(string) (Averager, error), usage string)
- func RegisterFiller(fn func(string) (Filler, error), usage string)
- func RegisterTimer(fn func(string, Averager) (Timer, error), usage string)
- func RegisterWaiter(fn func(string) (Waiter, error), usage string)
- func RunCLI(args []string)
- type AllowStamp
- type Averager
- type AveragerFactory
- type Bitrate
- type BusyTimer
- type Client
- type ClientConfig
- type ClientHandler
- type Clock
- type Code
- type CompTimer
- type CumulativeAverager
- type DF
- type DurationStats
- type Durations
- type Error
- type Event
- type ExponentialAverager
- type Filler
- type FillerFactory
- type GCMode
- type Handler
- type HybridTimer
- type IPVersion
- type Lost
- type Params
- type PatternFiller
- type RandFiller
- type ReceivedCount
- type ReceivedStats
- type ReceivedWindow
- type Recorder
- type RecorderHandler
- type Result
- type RoundTrip
- type RoundTripData
- func (ts *RoundTripData) IPDVSince(pts *RoundTripData) time.Duration
- func (ts *RoundTripData) IsBothTimestamped() bool
- func (ts *RoundTripData) IsMonoTimestamped() bool
- func (ts *RoundTripData) IsReceiveTimestamped() bool
- func (ts *RoundTripData) IsSendTimestamped() bool
- func (ts *RoundTripData) IsTimestamped() bool
- func (ts *RoundTripData) IsWallTimestamped() bool
- func (ts *RoundTripData) RTT() (rtt time.Duration)
- func (ts *RoundTripData) ReceiveDelay() time.Duration
- func (ts *RoundTripData) ReceiveIPDVSince(pts *RoundTripData) (d time.Duration)
- func (ts *RoundTripData) ReceiveMonoDiff() time.Duration
- func (ts *RoundTripData) ReceiveWallDiff() time.Duration
- func (ts *RoundTripData) ReplyReceived() bool
- func (ts *RoundTripData) SendDelay() time.Duration
- func (ts *RoundTripData) SendIPDVSince(pts *RoundTripData) (d time.Duration)
- func (ts *RoundTripData) SendMonoDiff() time.Duration
- func (ts *RoundTripData) SendWallDiff() time.Duration
- func (ts *RoundTripData) ServerProcessingTime() (d time.Duration)
- type Seqno
- type Server
- type ServerConfig
- type SimpleTimer
- type StampAt
- type Stats
- type SystemInfo
- type Time
- type Timer
- type TimerFactory
- type Timestamp
- type VersionInfo
- type WaitDuration
- type WaitMaxRTT
- type WaitMeanRTT
- type Waiter
- type WaiterFactory
- type WindowAverager
Constants ¶
const ( DefaultIPVersion = DualStack DefaultPort = "2112" DefaultPortInt = 2112 DefaultTTL = 0 DefaultThreadLock = false )
Common defaults.
const ( DefaultDuration = 1 * time.Minute DefaultInterval = 1 * time.Second DefaultLength = 0 DefaultReceivedStats = ReceivedStatsBoth DefaultStampAt = AtBoth DefaultClock = BothClocks DefaultDSCP = 0 DefaultLoose = false DefaultLocalAddress = ":0" DefaultLocalPort = "0" DefaultDF = DFDefault DefaultCompTimerMinErrorFactor = 0.0 DefaultCompTimerMaxErrorFactor = 2.0 DefaultHybridTimerSleepFactor = 0.95 DefaultAverageWindow = 5 DefaultExponentialAverageAlpha = 0.1 )
Client defaults.
const ( DefaultMaxDuration = time.Duration(0) DefaultMinInterval = 10 * time.Millisecond DefaultMaxLength = 0 DefaultServerTimeout = 1 * time.Minute DefaultPacketBurst = 5 DefaultAllowStamp = DualStamps DefaultAllowDSCP = true DefaultSetSrcIP = false DefaultGCMode = GCOn )
Server defaults.
const InvalidDuration = time.Duration(math.MaxInt64)
InvalidDuration indicates a duration that is not valid.
const InvalidSeqno = Seqno(math.MaxUint32)
InvalidSeqno indicates a sequence number that is not valid.
Variables ¶
var AveragerFactories = make([]AveragerFactory, 0)
AveragerFactories are the registered Averager factories.
var DefaultAllowFills = []string{"rand"}
DefaultAllowFills are the default allowed fill prefixes.
var DefaultBindAddrs = []string{":2112"}
DefaultBindAddrs are the default bind addresses.
var DefaultCompTimerAverage = NewDefaultExponentialAverager()
DefaultCompTimerAverage is the default timer error averaging algorithm for the CompTimer.
var DefaultFillPattern = []byte("irtt")
DefaultFillPattern is the default fill pattern.
var DefaultOpenTimeouts = Durations([]time.Duration{ 1 * time.Second, 2 * time.Second, 4 * time.Second, 8 * time.Second, })
DefaultOpenTimeouts are the default timeouts used when the client opens a connection to the server.
var DefaultServerFiller = NewDefaultPatternFiller()
DefaultServerFiller it the default filler for the server, PatternFiller.
var DefaultTimer = NewCompTimer(DefaultCompTimerAverage)
DefaultTimer is the default timer implementation, CompTimer.
var DefaultWait = &WaitMaxRTT{time.Duration(4) * time.Second, 3}
DefaultWait is the default client wait time for the final responses after all packets have been sent.
var FillerFactories = make([]FillerFactory, 0)
FillerFactories are the registered Filler factories.
var JSONFormatVersion = 1
JSONFormatVersion is the JSON format number.
var ProtocolVersion = 1
ProtocolVersion is the protocol version number, which must match between client and server.
var TimerFactories = make([]TimerFactory, 0)
TimerFactories are the registered Timer factories.
var Version = "0.9.0"
Version is the IRTT version number (replaced during build).
var WaiterFactories = make([]WaiterFactory, 0)
WaiterFactories are the registered Waiter factories.
Functions ¶
func AbsDuration ¶
AbsDuration returns the absolute value of a duration.
func RegisterAverager ¶
RegisterAverager registers a new Averager.
func RegisterFiller ¶
RegisterFiller registers a new Filler.
func RegisterTimer ¶
RegisterTimer registers a new Timer.
func RegisterWaiter ¶
RegisterWaiter registers a new Waiter.
Types ¶
type AllowStamp ¶
type AllowStamp int
AllowStamp selects the timestamps that are allowed by the server.
const ( NoStamp AllowStamp = iota SingleStamp DualStamps )
AllowStamp constants.
func ParseAllowStamp ¶
func ParseAllowStamp(s string) (AllowStamp, error)
ParseAllowStamp returns an AllowStamp from a string.
func (AllowStamp) Restrict ¶
func (a AllowStamp) Restrict(at StampAt) StampAt
Restrict returns the StampAt allowed for a given StampAt requested.
func (AllowStamp) String ¶
func (a AllowStamp) String() string
type Averager ¶
type Averager interface { // Push adds a value to be averaged. Push(val float64) // Average returns the average. Average() float64 String() string }
Averager is implemented to return an average of a series of given values.
func NewAverager ¶
NewAverager returns an Averager from a string.
type AveragerFactory ¶
AveragerFactory is the definition for an Averager.
type Bitrate ¶
type Bitrate uint64
Bitrate is a bit rate in bits per second.
func (Bitrate) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type BusyTimer ¶
type BusyTimer struct { }
BusyTimer uses a busy wait loop to wait for the next send. It wastes CPU and should only be used for extremely tight timing requirements.
type Client ¶
type Client struct { *ClientConfig // contains filtered or unexported fields }
Client is the Client. It must be created with NewClient. It may not be used concurrently.
func (*Client) Run ¶
Run runs the test and returns the Result. An error is returned if the test could not be started. If an error occurs during the test, the error is nil, partial results are returned and either or both of the SendErr or ReceiveErr fields of Result will be non-nil. Run may only be called once.
type ClientConfig ¶
type ClientConfig struct { LocalAddress string RemoteAddress string LocalAddr net.Addr RemoteAddr net.Addr OpenTimeouts Durations NoTest bool Params Loose bool IPVersion IPVersion DF DF TTL int Timer Timer Waiter Waiter Filler Filler FillOne bool HMACKey []byte Handler ClientHandler ThreadLock bool Supplied *ClientConfig }
ClientConfig defines the Client configuration.
func NewClientConfig ¶
func NewClientConfig() *ClientConfig
NewClientConfig returns a new ClientConfig with the default settings.
func (*ClientConfig) MarshalJSON ¶
func (c *ClientConfig) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
type ClientHandler ¶
type ClientHandler interface { Handler RecorderHandler }
ClientHandler is called with client events, as well as separately when packets are sent and received. See the documentation for Recorder for information on locking for concurrent access.
type Clock ¶
type Clock int
Clock selects the clock/s to use for timestamps.
Clock constants.
func ClockFromInt ¶
ClockFromInt returns a Clock value from its int constant.
func ParseClock ¶
ParseClock returns a Clock from a string.
func (Clock) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Code ¶
type Code int
Code uniquely identifies events and errors to improve context.
const ( ShortWrite Code = -1 * (iota + 1) InvalidDFString FieldsLengthTooLarge FieldsCapacityTooLarge InvalidStampAtString InvalidStampAtInt InvalidAllowStampString InvalidClockString InvalidClockInt BadMagic NoHMAC BadHMAC UnexpectedHMAC NonexclusiveMidpointTStamp InconsistentClocks DFNotSupported InvalidFlagBitsSet ShortParamBuffer ParamOverflow InvalidParamValue ProtocolVersionMismatch )
Common error codes.
const ( NoMatchingInterfaces Code = -1 * (iota + 1*1024) NoMatchingInterfacesUp UnspecifiedWithSpecifiedAddresses InvalidGCModeString UnexpectedReplyFlag NoSuitableAddressFound InvalidConnToken ShortInterval LargeRequest AddressMismatch )
Server error codes.
const ( InvalidWinAvgWindow Code = -1 * (iota + 2*1024) InvalidExpAvgAlpha AllocateResultsPanic UnexpectedOpenFlag DFError TTLError ExpectedReplyFlag ShortReply StampAtMismatch ClockMismatch UnexpectedSequenceNumber InvalidSleepFactor InvalidWaitString InvalidWaitFactor InvalidWaitDuration NoSuchAverager NoSuchFiller NoSuchTimer NoSuchWaiter IntervalNonPositive DurationNonPositive ConnTokenZero ServerClosed OpenTimeout InvalidServerRestriction InvalidReceivedStatsInt InvalidReceivedStatsString OpenTimeoutTooShort ServerFillTooLong )
Client error codes.
const ( MultipleAddresses Code = iota + 1*1024 ServerStart ServerStop ListenerStart ListenerStop ListenerError Drop NewConn OpenClose CloseConn NoDSCPSupport ExceededDuration NoReceiveDstAddrSupport RemoveNoConn InvalidServerFill )
Server event codes.
type CompTimer ¶
type CompTimer struct { MinErrorFactor float64 `json:"min_error_factor"` MaxErrorFactor float64 `json:"max_error_factor"` // contains filtered or unexported fields }
CompTimer uses Go's default time functions and performs compensation by continually measuring the timer error and applying a correction factor to try to improve precision. It must be created using NewCompTimer. MinErrorFactor and MaxErrorFactor may be adjusted to reject correction factor outliers, which may be seen before enough data is collected. They default to 0 and 2, respectively.
func NewCompTimer ¶
NewCompTimer returns a new CompTimer with the specified Average. MinErrorFactor and MaxErrorFactor may be changed before use.
func NewDefaultCompTimer ¶
func NewDefaultCompTimer() *CompTimer
NewDefaultCompTimer returns a new CompTimer with the default Average. MinErrorFactor and MaxErrorFactor may be changed before use.
type CumulativeAverager ¶
type CumulativeAverager struct {
// contains filtered or unexported fields
}
CumulativeAverager implements the cumulative moving average (takes into account all values equally).
func (*CumulativeAverager) Average ¶
func (ca *CumulativeAverager) Average() float64
Average gets the cumulative average.
func (*CumulativeAverager) Push ¶
func (ca *CumulativeAverager) Push(val float64)
Push adds a value.
func (*CumulativeAverager) String ¶
func (ca *CumulativeAverager) String() string
type DurationStats ¶
type DurationStats struct { Total time.Duration `json:"total"` N uint `json:"n"` Min time.Duration `json:"min"` Max time.Duration `json:"max"` // contains filtered or unexported fields }
DurationStats keeps basic time.Duration statistics. Welford's method is used to keep a running mean and standard deviation. In testing, this seemed to be worth the extra muls and divs necessary to maintain these stats. Worst case, there was a 2% reduction in the send rate on a Raspberry Pi 2 when sending the smallest packets possible at the smallest interval possible. This is not a typical test, however, and the argument is, it's worth paying this price to add standard deviation and variance for timer error and send call time, and running standard deviation for all packet times.
func (*DurationStats) IsZero ¶
func (s *DurationStats) IsZero() bool
IsZero returns true if DurationStats has no recorded values.
func (*DurationStats) MarshalJSON ¶
func (s *DurationStats) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*DurationStats) Mean ¶
func (s *DurationStats) Mean() time.Duration
Mean returns the arithmetical mean.
func (*DurationStats) Median ¶
func (s *DurationStats) Median() (dur time.Duration, ok bool)
Median returns the median (externally calculated).
func (*DurationStats) Stddev ¶
func (s *DurationStats) Stddev() time.Duration
Stddev returns the standard deviation.
func (*DurationStats) Variance ¶
func (s *DurationStats) Variance() float64
Variance returns the variance.
type Durations ¶
Durations contains a slice of time.Duration.
func ParseDurations ¶
ParseDurations returns a Durations value from a comma separated list of time.Duration string representations.
type Error ¶
type Error struct {
*Event
}
Error is an IRTT error.
type Event ¶
type Event struct { Code Code LocalAddr *net.UDPAddr RemoteAddr *net.UDPAddr Detail []interface{} // contains filtered or unexported fields }
Event is an event sent to a Handler.
type ExponentialAverager ¶
type ExponentialAverager struct { Alpha float64 // contains filtered or unexported fields }
ExponentialAverager implements the exponential moving average. More recent values are given higher consideration. Alpha must be between 0 and 1, where a higher Alpha discounts older values faster. An Alpha of 0.1 - 0.2 may give good results for timer compensation, but experimentation is required as results are dependent on hardware and test config.
func NewDefaultExponentialAverager ¶
func NewDefaultExponentialAverager() *ExponentialAverager
NewDefaultExponentialAverager returns a new ExponentialAverage with the default Alpha. This may be changed before used.
func NewExponentialAverager ¶
func NewExponentialAverager(alpha float64) *ExponentialAverager
NewExponentialAverager returns a new ExponentialAverage with the specified Alpha.
func (*ExponentialAverager) Average ¶
func (ea *ExponentialAverager) Average() float64
Average gets the exponential average.
func (*ExponentialAverager) Push ¶
func (ea *ExponentialAverager) Push(val float64)
Push adds a value.
func (*ExponentialAverager) String ¶
func (ea *ExponentialAverager) String() string
type FillerFactory ¶
FillerFactory can create a Filler from a string.
type GCMode ¶
type GCMode int
GCMode selects when the garbage collector is run.
func ParseGCMode ¶
ParseGCMode returns a GCMode value from its string.
type Handler ¶
type Handler interface { // OnEvent is called when an event occurs. OnEvent(e *Event) }
Handler is called with events.
type HybridTimer ¶
type HybridTimer struct {
// contains filtered or unexported fields
}
HybridTimer uses Go's default time functions and performs compensation to try to improve precision. To further improve precision, it sleeps to within some factor of the target value, then uses a busy wait loop for the remainder. The CPU will be in a busy wait for 1 - sleep factor for each sleep performed, so ideally the sleep factor should be increased to some threshold before precision starts to be lost, or some balance between the desired precision and CPU load is struck. The sleep factor typically can be increased for longer intervals and must be decreased for shorter intervals to keep high precision. In one example, a sleep factor of 0.95 could be used for 15ns precision at an interval of 200ms, but a sleep factor of 0.80 was required for 100ns precision at an interval of 1ms. These requirements will likely vary for different hardware and OS combinations.
func NewDefaultHybridTimer ¶
func NewDefaultHybridTimer() *HybridTimer
NewDefaultHybridTimer returns a new HybridTimer using the default Average and sleep factor.
func NewHybridTimer ¶
func NewHybridTimer(a Averager, sleepFactor float64) *HybridTimer
NewHybridTimer returns a new HybridTimer using the given Average algorithm and sleep factor (0 - 1.0) before the busy wait.
func (*HybridTimer) SleepFactor ¶
func (ht *HybridTimer) SleepFactor() float64
SleepFactor returns the sleep factor.
func (*HybridTimer) String ¶
func (ht *HybridTimer) String() string
type IPVersion ¶
type IPVersion int
IPVersion is an IP version, or dual stack for IPv4 and IPv6.
func IPVersionFromBooleans ¶
IPVersionFromBooleans returns an IPVersion from booleans. If both ipv4 and ipv6 are true, DualStack is returned. If neither are true, the value of dfl is returned.
func IPVersionFromIP ¶
IPVersionFromIP returns an IPVersion from a net.IP.
func IPVersionFromUDPAddr ¶
IPVersionFromUDPAddr returns an IPVersion from a net.UDPAddr.
func (IPVersion) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Lost ¶
type Lost int
Lost indicates the lost status of a packet.
func (Lost) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Params ¶
type Params struct { ProtocolVersion int `json:"proto_version"` Duration time.Duration `json:"duration"` Interval time.Duration `json:"interval"` Length int `json:"length"` ReceivedStats ReceivedStats `json:"received_stats"` StampAt StampAt `json:"stamp_at"` Clock Clock `json:"clock"` DSCP int `json:"dscp"` ServerFill string `json:"server_fill"` }
Params are the test parameters sent to and received from the server.
type PatternFiller ¶
type PatternFiller struct { Bytes []byte // contains filtered or unexported fields }
PatternFiller can be used to fill with a repeating byte pattern.
func NewDefaultPatternFiller ¶
func NewDefaultPatternFiller() *PatternFiller
NewDefaultPatternFiller returns a new PatternFiller with the default pattern.
func NewPatternFiller ¶
func NewPatternFiller(bytes []byte) *PatternFiller
NewPatternFiller returns a new PatternFiller.
func (*PatternFiller) String ¶
func (f *PatternFiller) String() string
type RandFiller ¶
RandFiller is a Filler that fills with data from math.rand.
func (*RandFiller) String ¶
func (rf *RandFiller) String() string
type ReceivedStats ¶
type ReceivedStats int
ReceivedStats selects what information to gather about received packets.
const ( ReceivedStatsNone ReceivedStats = 0x00 ReceivedStatsCount ReceivedStats = 0x01 ReceivedStatsWindow ReceivedStats = 0x02 ReceivedStatsBoth ReceivedStats = ReceivedStatsCount | ReceivedStatsWindow )
ReceivedStats constants.
func ParseReceivedStats ¶
func ParseReceivedStats(s string) (ReceivedStats, error)
ParseReceivedStats returns a ReceivedStats value from its string.
func ReceivedStatsFromInt ¶
func ReceivedStatsFromInt(v int) (ReceivedStats, error)
ReceivedStatsFromInt returns a ReceivedStats value from its int constant.
func (ReceivedStats) MarshalJSON ¶
func (rs ReceivedStats) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (ReceivedStats) String ¶
func (rs ReceivedStats) String() string
type Recorder ¶
type Recorder struct { Start time.Time `json:"start_time"` FirstSend time.Time `json:"-"` LastSent time.Time `json:"-"` FirstReceived time.Time `json:"-"` LastReceived time.Time `json:"-"` SendCallStats DurationStats `json:"send_call"` TimerErrorStats DurationStats `json:"timer_error"` RTTStats DurationStats `json:"rtt"` SendDelayStats DurationStats `json:"send_delay"` ReceiveDelayStats DurationStats `json:"receive_delay"` ServerPacketsReceived ReceivedCount `json:"server_packets_received"` BytesSent uint64 `json:"bytes_sent"` BytesReceived uint64 `json:"bytes_received"` Duplicates uint `json:"duplicates"` LatePackets uint `json:"late_packets"` Wait time.Duration `json:"wait"` RoundTripData []RoundTripData `json:"-"` RecorderHandler RecorderHandler `json:"-"` // contains filtered or unexported fields }
Recorder is used to record data during the test. It is available to the Handler during the test for display of basic statistics, and may be used later to create a Result for further statistical analysis and storage. Recorder is accessed concurrently while the test is running, so its RLock and RUnlock methods must be used during read access to prevent race conditions. When RecorderHandler is called, it is already locked and must not be locked again. It is not possible to lock Recorder externally for write, since all recording should be done internally.
type RecorderHandler ¶
type RecorderHandler interface { // OnSent is called when a packet is sent. OnSent(seqno Seqno, rtd *RoundTripData) // OnReceived is called when a packet is received. OnReceived(seqno Seqno, rtd *RoundTripData, pred *RoundTripData, late bool, dup bool) }
RecorderHandler is called when the Recorder records a sent or received packet.
type Result ¶
type Result struct { VersionInfo *VersionInfo `json:"version"` SystemInfo *SystemInfo `json:"system_info"` Config *ClientConfig `json:"config"` SendErr error `json:"send_err,omitempty"` ReceiveErr error `json:"receive_err,omitempty"` *Stats `json:"stats"` RoundTrips []RoundTrip `json:"round_trips"` }
Result is returned from Run.
type RoundTrip ¶
type RoundTrip struct { Seqno Seqno `json:"seqno"` Lost Lost `json:"lost"` *RoundTripData `json:"timestamps"` IPDV time.Duration `json:"-"` SendIPDV time.Duration `json:"-"` ReceiveIPDV time.Duration `json:"-"` }
RoundTrip stores the Timestamps and statistics for a single round trip.
func (*RoundTrip) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type RoundTripData ¶
type RoundTripData struct { Client Timestamp `json:"client"` Server Timestamp `json:"server"` // contains filtered or unexported fields }
RoundTripData contains the information recorded for each round trip during the test.
func (*RoundTripData) IPDVSince ¶
func (ts *RoundTripData) IPDVSince(pts *RoundTripData) time.Duration
IPDVSince returns the instantaneous packet delay variation since the specified RoundTripData.
func (*RoundTripData) IsBothTimestamped ¶
func (ts *RoundTripData) IsBothTimestamped() bool
IsBothTimestamped returns true if the server returned both a send and receive timestamp.
func (*RoundTripData) IsMonoTimestamped ¶
func (ts *RoundTripData) IsMonoTimestamped() bool
IsMonoTimestamped returns true if the server returned any timestamp with a valid monotonic clock value.
func (*RoundTripData) IsReceiveTimestamped ¶
func (ts *RoundTripData) IsReceiveTimestamped() bool
IsReceiveTimestamped returns true if the server returned a receive timestamp.
func (*RoundTripData) IsSendTimestamped ¶
func (ts *RoundTripData) IsSendTimestamped() bool
IsSendTimestamped returns true if the server returned a send timestamp.
func (*RoundTripData) IsTimestamped ¶
func (ts *RoundTripData) IsTimestamped() bool
IsTimestamped returns true if the server returned any timestamp.
func (*RoundTripData) IsWallTimestamped ¶
func (ts *RoundTripData) IsWallTimestamped() bool
IsWallTimestamped returns true if the server returned any timestamp with a valid wall clock value.
func (*RoundTripData) RTT ¶
func (ts *RoundTripData) RTT() (rtt time.Duration)
RTT returns the round-trip time. The monotonic clock values are used for accuracy, and the server processing time is subtracted out if both send and receive timestamps are enabled.
func (*RoundTripData) ReceiveDelay ¶
func (ts *RoundTripData) ReceiveDelay() time.Duration
ReceiveDelay returns the estimated one-way receive delay, valid only if wall clock timestamps are available and the server's system time has been externally synchronized.
func (*RoundTripData) ReceiveIPDVSince ¶
func (ts *RoundTripData) ReceiveIPDVSince(pts *RoundTripData) (d time.Duration)
ReceiveIPDVSince returns the receive instantaneous packet delay variation since the specified RoundTripData.
func (*RoundTripData) ReceiveMonoDiff ¶
func (ts *RoundTripData) ReceiveMonoDiff() time.Duration
ReceiveMonoDiff returns the difference in receive values from the monotonic clock. This is useful for measuring receive IPDV (jitter), but not for absolute receive delay.
func (*RoundTripData) ReceiveWallDiff ¶
func (ts *RoundTripData) ReceiveWallDiff() time.Duration
ReceiveWallDiff returns the difference in receive values from the wall clock. This is useful for measuring receive IPDV (jitter), but not for absolute receive delay. Because the wall clock is used, it is subject to wall clock variability.
func (*RoundTripData) ReplyReceived ¶
func (ts *RoundTripData) ReplyReceived() bool
ReplyReceived returns true if a reply was received from the server.
func (*RoundTripData) SendDelay ¶
func (ts *RoundTripData) SendDelay() time.Duration
SendDelay returns the estimated one-way send delay, valid only if wall clock timestamps are available and the server's system time has been externally synchronized.
func (*RoundTripData) SendIPDVSince ¶
func (ts *RoundTripData) SendIPDVSince(pts *RoundTripData) (d time.Duration)
SendIPDVSince returns the send instantaneous packet delay variation since the specified RoundTripData.
func (*RoundTripData) SendMonoDiff ¶
func (ts *RoundTripData) SendMonoDiff() time.Duration
SendMonoDiff returns the difference in send values from the monotonic clock. This is useful for measuring send IPDV (jitter), but not for absolute send delay.
func (*RoundTripData) SendWallDiff ¶
func (ts *RoundTripData) SendWallDiff() time.Duration
SendWallDiff returns the difference in send values from the wall clock. This is useful for measuring receive IPDV (jitter), but not for absolute send delay. Because the wall clock is used, it is subject to wall clock variability.
func (*RoundTripData) ServerProcessingTime ¶
func (ts *RoundTripData) ServerProcessingTime() (d time.Duration)
ServerProcessingTime returns the amount of time between when the server received a request and when it sent its reply.
type Server ¶
type Server struct { *ServerConfig // contains filtered or unexported fields }
Server is the irtt server.
func (*Server) ListenAndServe ¶
ListenAndServe creates listeners for all requested addresses and serves requests indefinitely. It exits after the listeners have exited. Errors for individual listeners may be handled with a ServerHandler, and will not be returned from this method.
type ServerConfig ¶
type ServerConfig struct { Addrs []string HMACKey []byte MaxDuration time.Duration MinInterval time.Duration MaxLength int Timeout time.Duration PacketBurst int Filler Filler AllowFills []string AllowStamp AllowStamp AllowDSCP bool TTL int IPVersion IPVersion Handler Handler SetSrcIP bool GCMode GCMode ThreadLock bool }
ServerConfig defines the Server configuration.
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
NewServerConfig returns a new ServerConfig with the default settings.
type SimpleTimer ¶
type SimpleTimer struct {
// contains filtered or unexported fields
}
SimpleTimer uses Go's default time functions. It must be created using NewSimpleTimer.
func (*SimpleTimer) String ¶
func (st *SimpleTimer) String() string
type StampAt ¶
type StampAt int
StampAt selects the time/s when timestamps are made on the server.
const ( AtNone StampAt = 0x00 AtSend StampAt = 0x01 AtReceive StampAt = 0x02 AtBoth StampAt = AtSend | AtReceive AtMidpoint StampAt = 0x04 )
StampAt constants.
func ParseStampAt ¶
ParseStampAt returns a StampAt value from its string.
func StampAtFromInt ¶
StampAtFromInt returns a StampAt value from its int constant.
func (StampAt) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
type Stats ¶
type Stats struct { *Recorder Duration time.Duration `json:"duration"` ExpectedPacketsSent uint `json:"-"` PacketsSent uint `json:"packets_sent"` PacketsReceived uint `json:"packets_received"` PacketLossPercent float64 `json:"packet_loss_percent"` UpstreamLossPercent float64 `json:"upstream_loss_percent"` DownstreamLossPercent float64 `json:"downstream_loss_percent"` DuplicatePercent float64 `json:"duplicate_percent"` LatePacketsPercent float64 `json:"late_packets_percent"` SendIPDVStats DurationStats `json:"ipdv_send"` ReceiveIPDVStats DurationStats `json:"ipdv_receive"` RoundTripIPDVStats DurationStats `json:"ipdv_round_trip"` ServerProcessingTimeStats DurationStats `json:"server_processing_time"` TimerErrPercent float64 `json:"timer_err_percent"` TimerMisses uint `json:"timer_misses"` TimerMissPercent float64 `json:"timer_miss_percent"` SendRate Bitrate `json:"send_rate"` ReceiveRate Bitrate `json:"receive_rate"` }
Stats are the statistics in the Result.
type SystemInfo ¶
type SystemInfo struct { OS string `json:"os"` NumCPU int `json:"cpus"` GoVersion string `json:"go_version"` Hostname string `json:"hostname"` }
SystemInfo stores based system information.
type Time ¶
type Time struct { Wall int64 `json:"wall,omitempty"` Mono time.Duration `json:"monotonic,omitempty"` }
Time contains both wall clock (subject to system time adjustments) and monotonic clock (relative to a fixed start time, and not subject to system time adjustments) times in nanoseconds. The monotonic value should be used for calculating time differences, and the wall value must be used for comparing wall clock time. Comparisons between wall clock values are only as accurate as the synchronization between the clocks that produced the values.
type Timer ¶
type Timer interface { // Sleep waits for at least duration d and returns the current time. The // current time is passed as t as a convenience for timers performing error // compensation. Timers should obey the Context and use a select that // includes ctx.Done() so that the sleep can be terminated early. In that // case, ctx.Err() should be returned. Sleep(ctx context.Context, t time.Time, d time.Duration) (time.Time, error) String() string }
Timer is implemented to wait for the next send.
type TimerFactory ¶
TimerFactory can create a Timer from a string.
type Timestamp ¶
Timestamp stores receive and send times. If the Timestamp was set to the midpoint on the server, Receive and Send will be the same.
func (Timestamp) BestReceive ¶
BestReceive returns the best receive time. It prefers the actual receive time, but returns the receive time if it's not available.
func (Timestamp) BestSend ¶
BestSend returns the best send time. It prefers the actual send time, but returns the receive time if it's not available.
func (Timestamp) IsBothMono ¶
IsBothMono returns true if there are both send and receive times from the monotonic clock.
func (Timestamp) IsBothWall ¶
IsBothWall returns true if there are both send and receive times from the wall clock.
func (Timestamp) IsMidpoint ¶
IsMidpoint returns true if this Timestamp was made with the midpoint time (halfway between send and receive). If so, Send and Receive are both non-zero and the same.
type VersionInfo ¶
type VersionInfo struct { IRTT string `json:"irtt"` Protocol int `json:"protocol"` JSONFormat int `json:"json_format"` }
VersionInfo stores the version information.
type WaitDuration ¶
WaitDuration waits for a specific period of time.
func (*WaitDuration) String ¶
func (w *WaitDuration) String() string
type WaitMaxRTT ¶
WaitMaxRTT waits for a factor of the maximum RTT
func (*WaitMaxRTT) String ¶
func (w *WaitMaxRTT) String() string
type WaitMeanRTT ¶
WaitMeanRTT waits for a factor of the mean RTT.
func (*WaitMeanRTT) String ¶
func (w *WaitMeanRTT) String() string
type Waiter ¶
type Waiter interface { // Wait returns the wait duration. Wait(r *Recorder) time.Duration String() string }
Waiter is implemented to return a wait time for final replies. See the documentation for Recorder for information on locking for concurrent access.
type WaiterFactory ¶
WaiterFactory can create a Waiter from a string.
type WindowAverager ¶
type WindowAverager struct { Window int // contains filtered or unexported fields }
WindowAverager implements the moving average with a specified window.
func NewDefaultWindowAverager ¶
func NewDefaultWindowAverager() *WindowAverager
NewDefaultWindowAverager returns a new WindowAverage with the default window.
func NewWindowAverage ¶
func NewWindowAverage(window int) *WindowAverager
NewWindowAverage returns a new WindowAverage with the specified window.
func (*WindowAverager) Average ¶
func (wa *WindowAverager) Average() float64
Average gets the moving average.
func (*WindowAverager) String ¶
func (wa *WindowAverager) String() string
Source Files ¶
- averager.go
- bitrate.go
- bytes.go
- cconfig.go
- client.go
- code_string.go
- conn.go
- context.go
- defaults.go
- df.go
- error.go
- event.go
- fbuf.go
- filler.go
- gc.go
- glob.go
- irtt.go
- irtt_bench.go
- irtt_client.go
- irtt_clock.go
- irtt_print.go
- irtt_server.go
- irtt_sleep.go
- irtt_version.go
- mtu.go
- net.go
- packet.go
- params.go
- prof_off.go
- rand.go
- recorder.go
- result.go
- rstats.go
- sconfig.go
- sconn.go
- server.go
- sys_linux.go
- sys_posix.go
- sysinfo.go
- time.go
- timer.go
- user_dev.go
- version.go
- waiter.go