ackhandler

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasAckElicitingFrames

func HasAckElicitingFrames(fs []Frame) bool

HasAckElicitingFrames returns true if at least one frame is ack-eliciting.

func IsFrameAckEliciting

func IsFrameAckEliciting(f wire.Frame) bool

IsFrameAckEliciting returns true if the frame is ack-eliciting.

func IsFrameTypeAckEliciting

func IsFrameTypeAckEliciting(t wire.FrameType) bool

IsFrameTypeAckEliciting returns true if the frame is ack-eliciting.

Types

type Frame

type Frame struct {
	Frame   wire.Frame // nil if the frame has already been acknowledged in another packet
	Handler FrameHandler
}

type FrameHandler

type FrameHandler interface {
	OnAcked(wire.Frame)
	OnLost(wire.Frame)
}

FrameHandler handles the acknowledgement and the loss of a frame.

type PacketEvent

type PacketEvent struct {
	PacketNumber         protocol.PacketNumber
	Length               protocol.ByteCount
	EncryptionLevel      protocol.EncryptionLevel
	PathID               protocol.PathID
	IsAckEliciting       bool
	IsPathProbePacket    bool
	IsPathMTUProbePacket bool
	SendTime             monotime.Time
	EventTime            monotime.Time
	Frames               []Frame
	StreamFrames         []StreamFrame
}

PacketEvent describes a sent packet with its path association.

type PacketObserver

type PacketObserver interface {
	OnPacketSent(PacketEvent)
	OnPacketAcked(PacketEvent)
	OnPacketLost(PacketEvent)
}

PacketObserver receives packet lifecycle events.

type PathPacketNumberManager

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

PathPacketNumberManager manages packet numbers independently for each path. This is essential for multipath QUIC where each path needs its own packet number sequence to avoid ambiguity in ACKs.

func NewPathPacketNumberManager

func NewPathPacketNumberManager() *PathPacketNumberManager

NewPathPacketNumberManager creates a new per-path packet number manager.

func (*PathPacketNumberManager) GetHighestSent

func (m *PathPacketNumberManager) GetHighestSent(
	pathID protocol.PathID,
	encLevel protocol.EncryptionLevel,
) protocol.PacketNumber

GetHighestSent returns the highest sent packet number for a path.

func (*PathPacketNumberManager) PeekPacketNumber

PeekPacketNumber returns the next packet number for a path without incrementing.

func (*PathPacketNumberManager) PopPacketNumber

func (m *PathPacketNumberManager) PopPacketNumber(
	pathID protocol.PathID,
	encLevel protocol.EncryptionLevel,
) protocol.PacketNumber

PopPacketNumber consumes and returns the next packet number for a path.

func (*PathPacketNumberManager) PopPacketNumberWithSkip

func (m *PathPacketNumberManager) PopPacketNumberWithSkip(
	pathID protocol.PathID,
	encLevel protocol.EncryptionLevel,
) (bool, protocol.PacketNumber)

PopPacketNumberWithSkip consumes and returns the next packet number for a path. It also reports whether an internal skip occurred.

func (*PathPacketNumberManager) RemovePath

func (m *PathPacketNumberManager) RemovePath(pathID protocol.PathID)

RemovePath removes all packet number generators for a path. Called when a path is closed or removed.

func (*PathPacketNumberManager) SetHighestAcked

func (m *PathPacketNumberManager) SetHighestAcked(
	pathID protocol.PathID,
	encLevel protocol.EncryptionLevel,
	pn protocol.PacketNumber,
)

SetHighestAcked updates the highest acked packet number for a path.

type ReceivedPacketHandler

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

func NewReceivedPacketHandler

func NewReceivedPacketHandler(logger utils.Logger) *ReceivedPacketHandler

func (*ReceivedPacketHandler) DropPackets

func (h *ReceivedPacketHandler) DropPackets(encLevel protocol.EncryptionLevel)

func (*ReceivedPacketHandler) GetAckFrame

func (h *ReceivedPacketHandler) GetAckFrame(encLevel protocol.EncryptionLevel, now monotime.Time, onlyIfQueued bool, pathID protocol.PathID) *wire.AckFrame

func (*ReceivedPacketHandler) GetAlarmTimeout

func (h *ReceivedPacketHandler) GetAlarmTimeout() monotime.Time

func (*ReceivedPacketHandler) IgnorePacketsBelow

func (h *ReceivedPacketHandler) IgnorePacketsBelow(pn protocol.PacketNumber)

func (*ReceivedPacketHandler) IsPotentiallyDuplicate

func (h *ReceivedPacketHandler) IsPotentiallyDuplicate(pn protocol.PacketNumber, encLevel protocol.EncryptionLevel, pathID protocol.PathID) bool

func (*ReceivedPacketHandler) ReceivedPacket

func (h *ReceivedPacketHandler) ReceivedPacket(
	pn protocol.PacketNumber,
	ecn protocol.ECN,
	encLevel protocol.EncryptionLevel,
	rcvTime monotime.Time,
	ackEliciting bool,
	pathID protocol.PathID,
) error

type SendMode

type SendMode uint8

The SendMode says what kind of packets can be sent.

const (
	// SendNone means that no packets should be sent
	SendNone SendMode = iota
	// SendAck means an ACK-only packet should be sent
	SendAck
	// SendPTOInitial means that an Initial probe packet should be sent
	SendPTOInitial
	// SendPTOHandshake means that a Handshake probe packet should be sent
	SendPTOHandshake
	// SendPTOAppData means that an Application data probe packet should be sent
	SendPTOAppData
	// SendPacingLimited means that the pacer doesn't allow sending of a packet right now,
	// but will do in a little while.
	// The timestamp when sending is allowed again can be obtained via the SentPacketHandler.TimeUntilSend.
	SendPacingLimited
	// SendAny means that any packet should be sent
	SendAny
)

func (SendMode) String

func (s SendMode) String() string

type SentPacketHandler

type SentPacketHandler interface {
	// SentPacket may modify the packet
	SentPacket(t monotime.Time, pn, largestAcked protocol.PacketNumber, streamFrames []StreamFrame, frames []Frame, encLevel protocol.EncryptionLevel, ecn protocol.ECN, size protocol.ByteCount, isPathMTUProbePacket, isPathProbePacket bool, pathID protocol.PathID)
	// ReceivedAck processes an ACK frame.
	// It does not store a copy of the frame.
	ReceivedAck(f *wire.AckFrame, encLevel protocol.EncryptionLevel, rcvTime monotime.Time, pathID protocol.PathID) (bool, error)
	ReceivedPacket(protocol.EncryptionLevel, monotime.Time)
	ReceivedBytes(_ protocol.ByteCount, rcvTime monotime.Time)
	DropPackets(_ protocol.EncryptionLevel, rcvTime monotime.Time)
	ResetForRetry(rcvTime monotime.Time)

	// The SendMode determines if and what kind of packets can be sent.
	SendMode(now monotime.Time) SendMode
	// TimeUntilSend is the time when the next packet should be sent.
	// It is used for pacing packets.
	TimeUntilSend() monotime.Time
	SetMaxDatagramSize(count protocol.ByteCount)

	// only to be called once the handshake is complete
	QueueProbePacket(protocol.EncryptionLevel) bool /* was a packet queued */

	ECNMode(isShortHeaderPacket bool) protocol.ECN // isShortHeaderPacket should only be true for non-coalesced 1-RTT packets
	PeekPacketNumber(protocol.PathID, protocol.EncryptionLevel) (protocol.PacketNumber, protocol.PacketNumberLen)
	PopPacketNumber(protocol.PathID, protocol.EncryptionLevel) protocol.PacketNumber

	GetLossDetectionTimeout() monotime.Time
	OnLossDetectionTimeout(now monotime.Time) error

	MigratedPath(now monotime.Time, initialMaxPacketSize protocol.ByteCount)
}

SentPacketHandler handles ACKs received for outgoing packets

func NewSentPacketHandler

func NewSentPacketHandler(
	initialPN protocol.PacketNumber,
	initialMaxDatagramSize protocol.ByteCount,
	rttStats *utils.RTTStats,
	connStats *utils.ConnectionStats,
	clientAddressValidated bool,
	enableECN bool,
	ignorePacketsBelow func(protocol.PacketNumber),
	pers protocol.Perspective,
	qlogger qlogwriter.Recorder,
	logger utils.Logger,
) SentPacketHandler

clientAddressValidated indicates whether the address was validated beforehand by an address validation token. If the address was validated, the amplification limit doesn't apply. It has no effect for a client.

type StreamFrame

type StreamFrame struct {
	Frame   *wire.StreamFrame
	Handler FrameHandler
}

Jump to

Keyboard shortcuts

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