quic-go: github.com/lucas-clemente/quic-go/internal/congestion Index | Files

package congestion

import "github.com/lucas-clemente/quic-go/internal/congestion"

Index

Package Files

bandwidth.go clock.go cubic.go cubic_sender.go hybrid_slow_start.go interface.go prr_sender.go rtt_stats.go stats.go

func NewCubicSender Uses

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

NewCubicSender makes a new cubic sender

type Bandwidth Uses

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 Uses

func BandwidthFromDelta(bytes protocol.ByteCount, delta time.Duration) Bandwidth

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

type Clock Uses

type Clock interface {
    Now() time.Time
}

A Clock returns the current time

type Cubic Uses

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

Cubic implements the cubic algorithm from TCP

func NewCubic Uses

func NewCubic(clock Clock) *Cubic

NewCubic returns a new Cubic instance

func (*Cubic) CongestionWindowAfterAck Uses

func (c *Cubic) CongestionWindowAfterAck(
    ackedBytes protocol.ByteCount,
    currentCongestionWindow protocol.ByteCount,
    delayMin time.Duration,
    eventTime time.Time,
) protocol.ByteCount

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 Uses

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

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 Uses

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 Uses

func (c *Cubic) Reset()

Reset is called after a timeout to reset the cubic state

func (*Cubic) SetNumConnections Uses

func (c *Cubic) SetNumConnections(n int)

SetNumConnections sets the number of emulated connections

type DefaultClock Uses

type DefaultClock struct{}

DefaultClock implements the Clock interface using the Go stdlib clock.

func (DefaultClock) Now Uses

func (DefaultClock) Now() time.Time

Now gets the current time

type HybridSlowStart Uses

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

HybridSlowStart implements the TCP hybrid slow start algorithm

func (*HybridSlowStart) IsEndOfRound Uses

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 Uses

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 Uses

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

OnPacketSent is called when a packet was sent

func (*HybridSlowStart) Restart Uses

func (s *HybridSlowStart) Restart()

Restart the slow start phase

func (*HybridSlowStart) ShouldExitSlowStart Uses

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 Uses

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 Uses

func (s *HybridSlowStart) Started() bool

Started returns true if started

type PrrSender Uses

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

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

func (*PrrSender) CanSend Uses

func (p *PrrSender) CanSend(congestionWindow, bytesInFlight, slowstartThreshold protocol.ByteCount) bool

CanSend returns if packets can be sent

func (*PrrSender) OnPacketAcked Uses

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

OnPacketAcked should be called after a packet was acked

func (*PrrSender) OnPacketLost Uses

func (p *PrrSender) OnPacketLost(priorInFlight 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 Uses

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

OnPacketSent should be called after a packet was sent

type RTTStats Uses

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

RTTStats provides round-trip statistics

func NewRTTStats Uses

func NewRTTStats() *RTTStats

NewRTTStats makes a properly initialized RTTStats object

func (*RTTStats) ExpireSmoothedMetrics Uses

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) LatestRTT Uses

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 Uses

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

func (*RTTStats) MeanDeviation Uses

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

MeanDeviation gets the mean deviation

func (*RTTStats) MinRTT Uses

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 Uses

func (r *RTTStats) OnConnectionMigration()

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

func (*RTTStats) PTO Uses

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

func (*RTTStats) SetMaxAckDelay Uses

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

func (*RTTStats) SmoothedRTT Uses

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 Uses

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

UpdateRTT updates the RTT based on a new sample.

type SendAlgorithm Uses

type SendAlgorithm interface {
    TimeUntilSend(bytesInFlight protocol.ByteCount) time.Duration
    OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool)
    CanSend(bytesInFlight protocol.ByteCount) bool
    MaybeExitSlowStart()
    OnPacketAcked(number protocol.PacketNumber, ackedBytes protocol.ByteCount, priorInFlight protocol.ByteCount, eventTime time.Time)
    OnPacketLost(number protocol.PacketNumber, lostBytes protocol.ByteCount, priorInFlight protocol.ByteCount)
    OnRetransmissionTimeout(packetsRetransmitted bool)
}

A SendAlgorithm performs congestion control

type SendAlgorithmWithDebugInfos Uses

type SendAlgorithmWithDebugInfos interface {
    SendAlgorithm
    InSlowStart() bool
    InRecovery() bool
    GetCongestionWindow() protocol.ByteCount
}

A SendAlgorithmWithDebugInfos is a SendAlgorithm that exposes some debug infos

Package congestion imports 4 packages (graph) and is imported by 12 packages. Updated 2019-09-18. Refresh now. Tools for package owners.