Documentation ¶
Index ¶
- func Max[T cmp.Ordered](a, b T) T
- func MaxFilter[O constraints.Ordered](a, b O) int
- func Min[T cmp.Ordered](a, b T) T
- func MinFilter[O constraints.Ordered](a, b O) int
- func NewBbrSender(clock Clock, initialMaxDatagramSize congestion.ByteCount, ...) *bbrSender
- type Bandwidth
- type Clock
- type DefaultClock
- type Pacer
- type RingBuffer
- func (r *RingBuffer[T]) Back() *T
- func (r *RingBuffer[T]) Clear()
- func (r *RingBuffer[T]) Empty() bool
- func (r *RingBuffer[T]) Front() *T
- func (r *RingBuffer[T]) Init(size int)
- func (r *RingBuffer[T]) Len() int
- func (r *RingBuffer[T]) Offset(index int) *T
- func (r *RingBuffer[T]) PopFront() T
- func (r *RingBuffer[T]) PushBack(t T)
- type WindowedFilter
- func (f *WindowedFilter[V, T]) Clear()
- func (f *WindowedFilter[V, T]) GetBest() V
- func (f *WindowedFilter[V, T]) GetSecondBest() V
- func (f *WindowedFilter[V, T]) GetThirdBest() V
- func (f *WindowedFilter[V, T]) Reset(newSample V, newTime T)
- func (f *WindowedFilter[V, T]) SetWindowLength(windowLength T)
- func (f *WindowedFilter[V, T]) Update(newSample V, newTime T)
- type WindowedFilterTime
- type WindowedFilterValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaxFilter ¶
func MaxFilter[O constraints.Ordered](a, b O) int
Compares two values and returns true if the first is greater than or equal to the second.
func MinFilter ¶
func MinFilter[O constraints.Ordered](a, b O) int
Compares two values and returns true if the first is less than or equal to the second.
func NewBbrSender ¶
func NewBbrSender( clock Clock, initialMaxDatagramSize congestion.ByteCount, initialCongestionWindowPackets congestion.ByteCount, ) *bbrSender
Types ¶
type Bandwidth ¶
type Bandwidth uint64
Bandwidth of a connection
const ( // BitsPerSecond is 1 bit per second BitsPerSecond Bandwidth = 1 // BytesPerSecond is 1 byte per second BytesPerSecond = 8 * BitsPerSecond )
func BandwidthFromDelta ¶
func BandwidthFromDelta(bytes congestion.ByteCount, delta time.Duration) Bandwidth
BandwidthFromDelta calculates the bandwidth from a number of bytes and a time delta
type DefaultClock ¶
DefaultClock implements the Clock interface using the Go stdlib clock.
type Pacer ¶
type Pacer struct {
// contains filtered or unexported fields
}
Pacer implements a token bucket pacing algorithm.
func NewPacer ¶
func NewPacer(getBandwidth func() congestion.ByteCount) *Pacer
func (*Pacer) SentPacket ¶
func (p *Pacer) SentPacket(sendTime time.Time, size congestion.ByteCount)
func (*Pacer) SetMaxDatagramSize ¶
func (p *Pacer) SetMaxDatagramSize(s congestion.ByteCount)
func (*Pacer) TimeUntilSend ¶
TimeUntilSend returns when the next packet should be sent. It returns the zero value of time.Time if a packet can be sent immediately.
type RingBuffer ¶
type RingBuffer[T any] struct { // contains filtered or unexported fields }
A RingBuffer is a ring buffer. It acts as a heap that doesn't cause any allocations.
func (*RingBuffer[T]) Back ¶
func (r *RingBuffer[T]) Back() *T
Back returns the back element. It must not be called when the buffer is empty, that means that callers might need to check if there are elements in the buffer first.
func (*RingBuffer[T]) Empty ¶
func (r *RingBuffer[T]) Empty() bool
Empty says if the ring buffer is empty.
func (*RingBuffer[T]) Front ¶
func (r *RingBuffer[T]) Front() *T
Front returns the front element. It must not be called when the buffer is empty, that means that callers might need to check if there are elements in the buffer first.
func (*RingBuffer[T]) Init ¶
func (r *RingBuffer[T]) Init(size int)
Init preallocs a buffer with a certain size.
func (*RingBuffer[T]) Len ¶
func (r *RingBuffer[T]) Len() int
Len returns the number of elements in the ring buffer.
func (*RingBuffer[T]) Offset ¶
func (r *RingBuffer[T]) Offset(index int) *T
Offset returns the offset element. It must not be called when the buffer is empty, that means that callers might need to check if there are elements in the buffer first and check if the index larger than buffer length.
func (*RingBuffer[T]) PopFront ¶
func (r *RingBuffer[T]) PopFront() T
PopFront returns the next element. It must not be called when the buffer is empty, that means that callers might need to check if there are elements in the buffer first.
func (*RingBuffer[T]) PushBack ¶
func (r *RingBuffer[T]) PushBack(t T)
PushBack adds a new element. If the ring buffer is full, its capacity is increased first.
type WindowedFilter ¶
type WindowedFilter[V WindowedFilterValue, T WindowedFilterTime] struct { // contains filtered or unexported fields }
func NewWindowedFilter ¶
func NewWindowedFilter[V WindowedFilterValue, T WindowedFilterTime](windowLength T, comparator func(V, V) int) *WindowedFilter[V, T]
func (*WindowedFilter[V, T]) Clear ¶
func (f *WindowedFilter[V, T]) Clear()
func (*WindowedFilter[V, T]) GetBest ¶
func (f *WindowedFilter[V, T]) GetBest() V
func (*WindowedFilter[V, T]) GetSecondBest ¶
func (f *WindowedFilter[V, T]) GetSecondBest() V
func (*WindowedFilter[V, T]) GetThirdBest ¶
func (f *WindowedFilter[V, T]) GetThirdBest() V
func (*WindowedFilter[V, T]) Reset ¶
func (f *WindowedFilter[V, T]) Reset(newSample V, newTime T)
Resets all estimates to new sample.
func (*WindowedFilter[V, T]) SetWindowLength ¶
func (f *WindowedFilter[V, T]) SetWindowLength(windowLength T)
Changes the window length. Does not update any current samples.
func (*WindowedFilter[V, T]) Update ¶
func (f *WindowedFilter[V, T]) Update(newSample V, newTime T)
Updates best estimates with |sample|, and expires and updates best estimates as necessary.
type WindowedFilterTime ¶
type WindowedFilterTime interface { constraints.Integer | constraints.Float }
type WindowedFilterValue ¶
type WindowedFilterValue interface { any }