congestion

package
v0.0.0-...-582326c Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 protocol.ByteCount, delta time.Duration) Bandwidth

BandwidthFromDelta calculates the bandwidth from a number of bytes and a time delta

type Clock

type Clock interface {
	Now() time.Time
}

A Clock returns the current time

type Cubic

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

Cubic implements the cubic algorithm from TCP

func NewCubic

func NewCubic(clock Clock) *Cubic

NewCubic returns a new Cubic instance

func (*Cubic) CongestionWindowAfterAck

func (c *Cubic) CongestionWindowAfterAck(currentCongestionWindow protocol.PacketNumber, delayMin time.Duration) protocol.PacketNumber

CongestionWindowAfterAck computes a new congestion window to use after a received ACK. Returns the new congestion window in packets. The new congestion window follows a cubic function that depends on the time passed since last packet loss.

func (*Cubic) CongestionWindowAfterPacketLoss

func (c *Cubic) CongestionWindowAfterPacketLoss(currentCongestionWindow protocol.PacketNumber) protocol.PacketNumber

CongestionWindowAfterPacketLoss computes a new congestion window to use after a loss event. Returns the new congestion window in packets. The new congestion window is a multiplicative decrease of our current window.

func (*Cubic) OnApplicationLimited

func (c *Cubic) OnApplicationLimited()

OnApplicationLimited is called on ack arrival when sender is unable to use the available congestion window. Resets Cubic state during quiescence.

func (*Cubic) Reset

func (c *Cubic) Reset()

Reset is called after a timeout to reset the cubic state

func (*Cubic) SetNumConnections

func (c *Cubic) SetNumConnections(n int)

SetNumConnections sets the number of emulated connections

type DefaultClock

type DefaultClock struct{}

DefaultClock implements the Clock interface using the Go stdlib clock.

func (DefaultClock) Now

func (DefaultClock) Now() time.Time

Now gets the current time

type HybridSlowStart

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

HybridSlowStart implements the TCP hybrid slow start algorithm

func (*HybridSlowStart) IsEndOfRound

func (s *HybridSlowStart) IsEndOfRound(ack protocol.PacketNumber) bool

IsEndOfRound returns true if this ack is the last packet number of our current slow start round.

func (*HybridSlowStart) OnPacketAcked

func (s *HybridSlowStart) OnPacketAcked(ackedPacketNumber protocol.PacketNumber)

OnPacketAcked gets invoked after ShouldExitSlowStart, so it's best to end the round when the final packet of the burst is received and start it on the next incoming ack.

func (*HybridSlowStart) OnPacketSent

func (s *HybridSlowStart) OnPacketSent(packetNumber protocol.PacketNumber)

OnPacketSent is called when a packet was sent

func (*HybridSlowStart) Restart

func (s *HybridSlowStart) Restart()

Restart the slow start phase

func (*HybridSlowStart) ShouldExitSlowStart

func (s *HybridSlowStart) ShouldExitSlowStart(latestRTT time.Duration, minRTT time.Duration, congestionWindow protocol.ByteCount) bool

ShouldExitSlowStart should be called on every new ack frame, since a new RTT measurement can be made then. rtt: the RTT for this ack packet. minRTT: is the lowest delay (RTT) we have seen during the session. congestionWindow: the congestion window in packets.

func (*HybridSlowStart) StartReceiveRound

func (s *HybridSlowStart) StartReceiveRound(lastSent protocol.PacketNumber)

StartReceiveRound is called for the start of each receive round (burst) in the slow start phase.

func (*HybridSlowStart) Started

func (s *HybridSlowStart) Started() bool

Started returns true if started

type Olia

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

Olia implements the olia algorithm from MPTCP

func NewOlia

func NewOlia(ackedBytes protocol.ByteCount) *Olia

func (*Olia) CongestionWindowAfterAck

func (o *Olia) CongestionWindowAfterAck(currentCongestionWindow protocol.PacketNumber, rate protocol.ByteCount, cwndScaled uint64) protocol.PacketNumber

func (*Olia) OnPacketLost

func (o *Olia) OnPacketLost()

func (*Olia) Reset

func (o *Olia) Reset()

func (*Olia) SmoothedBytesBetweenLosses

func (o *Olia) SmoothedBytesBetweenLosses() protocol.ByteCount

func (*Olia) UpdateAckedSinceLastLoss

func (o *Olia) UpdateAckedSinceLastLoss(ackedBytes protocol.ByteCount)

type OliaSender

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

func (*OliaSender) BandwidthEstimate

func (o *OliaSender) BandwidthEstimate() Bandwidth

func (*OliaSender) ExitSlowstart

func (o *OliaSender) ExitSlowstart()

func (*OliaSender) GetCongestionWindow

func (o *OliaSender) GetCongestionWindow() protocol.ByteCount

func (*OliaSender) GetSlowStartThreshold

func (o *OliaSender) GetSlowStartThreshold() protocol.ByteCount

func (*OliaSender) HybridSlowStart

func (o *OliaSender) HybridSlowStart() *HybridSlowStart

HybridSlowStart returns the hybrid slow start instance for testing

func (*OliaSender) InRecovery

func (o *OliaSender) InRecovery() bool

func (*OliaSender) InSlowStart

func (o *OliaSender) InSlowStart() bool

func (*OliaSender) MaybeExitSlowStart

func (o *OliaSender) MaybeExitSlowStart()

func (*OliaSender) OnConnectionMigration

func (o *OliaSender) OnConnectionMigration()

func (*OliaSender) OnPacketAcked

func (o *OliaSender) OnPacketAcked(ackedPacketNumber protocol.PacketNumber, ackedBytes protocol.ByteCount, bytesInFlight protocol.ByteCount)

func (*OliaSender) OnPacketLost

func (o *OliaSender) OnPacketLost(packetNumber protocol.PacketNumber, lostBytes protocol.ByteCount, bytesInFlight protocol.ByteCount)

func (*OliaSender) OnPacketSent

func (o *OliaSender) OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool) bool

func (*OliaSender) OnRetransmissionTimeout

func (o *OliaSender) OnRetransmissionTimeout(packetsRetransmitted bool)

OnRetransmissionTimeout is called on an retransmission timeout

func (*OliaSender) RenoBeta

func (o *OliaSender) RenoBeta() float32

func (*OliaSender) RetransmissionDelay

func (o *OliaSender) RetransmissionDelay() time.Duration

RetransmissionDelay gives the RTO retransmission time

func (*OliaSender) SetNumEmulatedConnections

func (o *OliaSender) SetNumEmulatedConnections(n int)

func (*OliaSender) SetSlowStartLargeReduction

func (o *OliaSender) SetSlowStartLargeReduction(enabled bool)

func (*OliaSender) SlowstartThreshold

func (o *OliaSender) SlowstartThreshold() protocol.PacketNumber

func (*OliaSender) SmoothedRTT

func (o *OliaSender) SmoothedRTT() time.Duration

func (*OliaSender) TimeUntilSend

func (o *OliaSender) TimeUntilSend(now time.Time, bytesInFlight protocol.ByteCount) time.Duration

type PrrSender

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

PrrSender implements the Proportional Rate Reduction (PRR) per RFC 6937

func (*PrrSender) OnPacketAcked

func (p *PrrSender) OnPacketAcked(ackedBytes protocol.ByteCount)

OnPacketAcked should be called after a packet was acked

func (*PrrSender) OnPacketLost

func (p *PrrSender) OnPacketLost(bytesInFlight protocol.ByteCount)

OnPacketLost should be called on the first loss that triggers a recovery period and all other methods in this class should only be called when in recovery.

func (*PrrSender) OnPacketSent

func (p *PrrSender) OnPacketSent(sentBytes protocol.ByteCount)

OnPacketSent should be called after a packet was sent

func (*PrrSender) TimeUntilSend

func (p *PrrSender) TimeUntilSend(congestionWindow, bytesInFlight, slowstartThreshold protocol.ByteCount) time.Duration

TimeUntilSend calculates the time until a packet can be sent

type RTTStats

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

RTTStats provides round-trip statistics

func NewRTTStats

func NewRTTStats() *RTTStats

NewRTTStats makes a properly initialized RTTStats object

func (*RTTStats) ExpireSmoothedMetrics

func (r *RTTStats) ExpireSmoothedMetrics()

ExpireSmoothedMetrics causes the smoothed_rtt to be increased to the latest_rtt if the latest_rtt is larger. The mean deviation is increased to the most recent deviation if it's larger.

func (*RTTStats) GetHalfWindowRTT

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

GetHalfWindowRTT gets the half window RTT

func (*RTTStats) GetQuarterWindowRTT

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

GetQuarterWindowRTT gets the quarter window RTT

func (*RTTStats) InitialRTTus

func (r *RTTStats) InitialRTTus() int64

InitialRTTus is the initial RTT in us

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) 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) OnConnectionMigration

func (r *RTTStats) OnConnectionMigration()

OnConnectionMigration is called when connection migrates and rtt measurement needs to be reset.

func (*RTTStats) RecentMinRTT

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

RecentMinRTT the minRTT since SampleNewRecentMinRtt has been called, or the minRTT for the entire connection if SampleNewMinRtt was never called.

func (*RTTStats) SampleNewRecentMinRTT

func (r *RTTStats) SampleNewRecentMinRTT(numSamples uint32)

SampleNewRecentMinRTT forces RttStats to sample a new recent min rtt within the next |numSamples| UpdateRTT calls.

func (*RTTStats) SetRecentMinRTTwindow

func (r *RTTStats) SetRecentMinRTTwindow(recentMinRTTwindow time.Duration)

SetRecentMinRTTwindow sets how old a recent min rtt sample can be.

func (*RTTStats) SmoothedRTT

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

SmoothedRTT returns the EWMA 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, now time.Time)

UpdateRTT updates the RTT based on a new sample.

func (*RTTStats) UpdateSessionRTT

func (r *RTTStats) UpdateSessionRTT(smoothedRTT time.Duration)

XXX (QDC): This is subject to improvement Update the smoothed RTT to the given value

type SendAlgorithm

type SendAlgorithm interface {
	TimeUntilSend(now time.Time, bytesInFlight protocol.ByteCount) time.Duration
	OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool) bool
	GetCongestionWindow() protocol.ByteCount
	MaybeExitSlowStart()
	OnPacketAcked(number protocol.PacketNumber, ackedBytes protocol.ByteCount, bytesInFlight protocol.ByteCount)
	OnPacketLost(number protocol.PacketNumber, lostBytes protocol.ByteCount, bytesInFlight protocol.ByteCount)
	SetNumEmulatedConnections(n int)
	OnRetransmissionTimeout(packetsRetransmitted bool)
	OnConnectionMigration()
	RetransmissionDelay() time.Duration
	SmoothedRTT() time.Duration

	// Experiments
	SetSlowStartLargeReduction(enabled bool)
}

A SendAlgorithm performs congestion control and calculates the congestion window

type SendAlgorithmWithDebugInfo

type SendAlgorithmWithDebugInfo interface {
	SendAlgorithm
	BandwidthEstimate() Bandwidth

	HybridSlowStart() *HybridSlowStart
	SlowstartThreshold() protocol.PacketNumber
	RenoBeta() float32
	InRecovery() bool
}

SendAlgorithmWithDebugInfo adds some debug functions to SendAlgorithm

func NewCubicSender

func NewCubicSender(clock Clock, rttStats *RTTStats, reno bool, initialCongestionWindow, initialMaxCongestionWindow protocol.PacketNumber) SendAlgorithmWithDebugInfo

NewCubicSender makes a new cubic sender

func NewOliaSender

func NewOliaSender(oliaSenders map[protocol.PathID]*OliaSender, rttStats *RTTStats, initialCongestionWindow, initialMaxCongestionWindow protocol.PacketNumber) SendAlgorithmWithDebugInfo

Jump to

Keyboard shortcuts

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