github.com/daeuniverse/quic-go@v0.0.0-20240413031024-943f218e0810/internal/congestion/interface.go (about)

     1  package congestion
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/daeuniverse/quic-go/congestion"
     7  	"github.com/daeuniverse/quic-go/internal/protocol"
     8  )
     9  
    10  // A SendAlgorithm performs congestion control
    11  type SendAlgorithm interface {
    12  	TimeUntilSend(bytesInFlight protocol.ByteCount) time.Time
    13  	HasPacingBudget(now time.Time) bool
    14  	OnPacketSent(sentTime time.Time, bytesInFlight protocol.ByteCount, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool)
    15  	CanSend(bytesInFlight protocol.ByteCount) bool
    16  	MaybeExitSlowStart()
    17  	OnPacketAcked(number protocol.PacketNumber, ackedBytes protocol.ByteCount, priorInFlight protocol.ByteCount, eventTime time.Time)
    18  	OnCongestionEvent(number protocol.PacketNumber, lostBytes protocol.ByteCount, priorInFlight protocol.ByteCount)
    19  	OnRetransmissionTimeout(packetsRetransmitted bool)
    20  	SetMaxDatagramSize(protocol.ByteCount)
    21  }
    22  
    23  type SendAlgorithmEx interface {
    24  	SendAlgorithm
    25  	OnCongestionEventEx(priorInFlight protocol.ByteCount, eventTime time.Time, ackedPackets []congestion.AckedPacketInfo, lostPackets []congestion.LostPacketInfo)
    26  }
    27  
    28  // A SendAlgorithmWithDebugInfos is a SendAlgorithm that exposes some debug infos
    29  type SendAlgorithmWithDebugInfos interface {
    30  	SendAlgorithm
    31  	InSlowStart() bool
    32  	InRecovery() bool
    33  	GetCongestionWindow() protocol.ByteCount
    34  }