utils

package
v0.0.0-...-fe4bbfe Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultInitialRTT = 100 * time.Millisecond

The default RTT used before an RTT sample is taken

Variables

This section is empty.

Functions

func NewBufferedWriteCloser

func NewBufferedWriteCloser(writer *bufio.Writer, closer io.Closer) io.WriteCloser

NewBufferedWriteCloser creates an io.WriteCloser from a bufio.Writer and an io.Closer

Types

type ConnectionStats

type ConnectionStats struct {
	BytesSent       atomic.Uint64
	PacketsSent     atomic.Uint64
	BytesReceived   atomic.Uint64
	PacketsReceived atomic.Uint64
	BytesLost       atomic.Uint64
	PacketsLost     atomic.Uint64
}

ConnectionStats stores stats for the connection. See the public ConnectionStats struct in connection.go for more information

type LogLevel

type LogLevel uint8

LogLevel of quic-go

const (
	// LogLevelNothing disables
	LogLevelNothing LogLevel = iota
	// LogLevelError enables err logs
	LogLevelError
	// LogLevelInfo enables info logs (e.g. packets)
	LogLevelInfo
	// LogLevelDebug enables debug logs (e.g. packet contents)
	LogLevelDebug
)

type Logger

type Logger interface {
	SetLogLevel(LogLevel)
	SetLogTimeFormat(format string)
	WithPrefix(prefix string) Logger
	Debug() bool

	Errorf(format string, args ...any)
	Infof(format string, args ...any)
	Debugf(format string, args ...any)
}

A Logger logs.

var DefaultLogger Logger

DefaultLogger is used by quic-go for logging.

type RTTStats

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

RTTStats provides round-trip statistics

func NewRTTStats

func NewRTTStats() *RTTStats

func (*RTTStats) Clone

func (r *RTTStats) Clone() *RTTStats

func (*RTTStats) HasMeasurement

func (r *RTTStats) HasMeasurement() bool

func (*RTTStats) LatestRTT

func (r *RTTStats) LatestRTT() time.Duration

LatestRTT returns the most recent rtt measurement. May return Zero if no valid updates have occurred.

func (*RTTStats) MaxAckDelay

func (r *RTTStats) MaxAckDelay() time.Duration

MaxAckDelay gets the max_ack_delay advertised by the peer

func (*RTTStats) MeanDeviation

func (r *RTTStats) MeanDeviation() time.Duration

MeanDeviation gets the mean deviation

func (*RTTStats) MinRTT

func (r *RTTStats) MinRTT() time.Duration

MinRTT Returns the minRTT for the entire connection. May return Zero if no valid updates have occurred.

func (*RTTStats) PTO

func (r *RTTStats) PTO(includeMaxAckDelay bool) time.Duration

PTO gets the probe timeout duration.

func (*RTTStats) ResetForPathMigration

func (r *RTTStats) ResetForPathMigration()

func (*RTTStats) SetInitialRTT

func (r *RTTStats) SetInitialRTT(t time.Duration)

SetInitialRTT sets the initial RTT. It is used during handshake when restoring the RTT stats from the token.

func (*RTTStats) SetMaxAckDelay

func (r *RTTStats) SetMaxAckDelay(mad time.Duration)

SetMaxAckDelay sets the max_ack_delay

func (*RTTStats) SmoothedRTT

func (r *RTTStats) SmoothedRTT() time.Duration

SmoothedRTT returns the smoothed RTT for the connection. May return Zero if no valid updates have occurred.

func (*RTTStats) UpdateRTT

func (r *RTTStats) UpdateRTT(sendDelta, ackDelay time.Duration)

UpdateRTT updates the RTT based on a new sample.

type Rand

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

Rand is a wrapper around crypto/rand that adds some convenience functions known from math/rand.

func (*Rand) Int31

func (r *Rand) Int31() int32

func (*Rand) Int31n

func (r *Rand) Int31n(n int32) int32

copied from the standard library math/rand implementation of Int63n

Directories

Path Synopsis
Package list implements a doubly linked list.
Package list implements a doubly linked list.

Jump to

Keyboard shortcuts

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