github.com/apernet/quic-go@v0.43.1-0.20240515053213-5e9e635fd9f0/internal/ackhandler/interfaces.go (about)

     1  package ackhandler
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/apernet/quic-go/congestion"
     7  	"github.com/apernet/quic-go/internal/protocol"
     8  	"github.com/apernet/quic-go/internal/wire"
     9  )
    10  
    11  // SentPacketHandler handles ACKs received for outgoing packets
    12  type SentPacketHandler interface {
    13  	// SentPacket may modify the packet
    14  	SentPacket(t time.Time, pn, largestAcked protocol.PacketNumber, streamFrames []StreamFrame, frames []Frame, encLevel protocol.EncryptionLevel, ecn protocol.ECN, size protocol.ByteCount, isPathMTUProbePacket bool)
    15  	// ReceivedAck processes an ACK frame.
    16  	// It does not store a copy of the frame.
    17  	ReceivedAck(f *wire.AckFrame, encLevel protocol.EncryptionLevel, rcvTime time.Time) (bool /* 1-RTT packet acked */, error)
    18  	ReceivedBytes(protocol.ByteCount)
    19  	DropPackets(protocol.EncryptionLevel)
    20  	ResetForRetry(rcvTime time.Time) error
    21  	SetHandshakeConfirmed()
    22  
    23  	// The SendMode determines if and what kind of packets can be sent.
    24  	SendMode(now time.Time) SendMode
    25  	// TimeUntilSend is the time when the next packet should be sent.
    26  	// It is used for pacing packets.
    27  	TimeUntilSend() time.Time
    28  	SetMaxDatagramSize(count protocol.ByteCount)
    29  
    30  	// only to be called once the handshake is complete
    31  	QueueProbePacket(protocol.EncryptionLevel) bool /* was a packet queued */
    32  
    33  	ECNMode(isShortHeaderPacket bool) protocol.ECN // isShortHeaderPacket should only be true for non-coalesced 1-RTT packets
    34  	PeekPacketNumber(protocol.EncryptionLevel) (protocol.PacketNumber, protocol.PacketNumberLen)
    35  	PopPacketNumber(protocol.EncryptionLevel) protocol.PacketNumber
    36  
    37  	GetLossDetectionTimeout() time.Time
    38  	OnLossDetectionTimeout() error
    39  
    40  	SetCongestionControl(congestion.CongestionControl)
    41  }
    42  
    43  type sentPacketTracker interface {
    44  	GetLowestPacketNotConfirmedAcked() protocol.PacketNumber
    45  	ReceivedPacket(protocol.EncryptionLevel)
    46  }
    47  
    48  // ReceivedPacketHandler handles ACKs needed to send for incoming packets
    49  type ReceivedPacketHandler interface {
    50  	IsPotentiallyDuplicate(protocol.PacketNumber, protocol.EncryptionLevel) bool
    51  	ReceivedPacket(pn protocol.PacketNumber, ecn protocol.ECN, encLevel protocol.EncryptionLevel, rcvTime time.Time, ackEliciting bool) error
    52  	DropPackets(protocol.EncryptionLevel)
    53  
    54  	GetAlarmTimeout() time.Time
    55  	GetAckFrame(encLevel protocol.EncryptionLevel, onlyIfQueued bool) *wire.AckFrame
    56  }