ackhandler

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 PathAck added in v0.3.0

type PathAck struct {
	PathID       protocol.PathID
	LargestAcked protocol.PacketNumber
}

A PathAck describes a PATH_ACK frame (IETF Multipath QUIC) contained in a sent packet.

type ReceivedPacketHandler

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

func NewReceivedPacketHandler

func NewReceivedPacketHandler(logger utils.Logger) *ReceivedPacketHandler

func (*ReceivedPacketHandler) AbandonPath added in v0.3.0

func (h *ReceivedPacketHandler) AbandonPath(pathID protocol.PathID)

AbandonPath is called when a path is abandoned (IETF Multipath QUIC). The packets received on the path, and on the path until it is removed, are acknowledged immediately.

func (*ReceivedPacketHandler) AckDuePaths added in v0.3.0

func (h *ReceivedPacketHandler) AckDuePaths(now monotime.Time) []protocol.PathID

AckDuePaths returns the paths for which an ACK frame should be sent now, in ascending order of their path IDs. The returned slice is only valid until the next call.

func (*ReceivedPacketHandler) DropPackets

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

func (*ReceivedPacketHandler) EnableMultipath added in v0.3.0

func (h *ReceivedPacketHandler) EnableMultipath()

EnableMultipath enables IETF Multipath QUIC (draft-ietf-quic-multipath). Every path has its own packet number space, and 1-RTT packets are acknowledged using PATH_ACK frames. The tracker used so far becomes the tracker of path 0.

func (*ReceivedPacketHandler) GetAckFrame

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

GetAckFrame returns the ACK frame for the packets received on a path. With IETF Multipath QUIC, 1-RTT packets are acknowledged using PATH_ACK frames.

func (*ReceivedPacketHandler) GetAlarmTimeout

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

func (*ReceivedPacketHandler) IgnorePacketsBelow

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

IgnorePacketsBelow is called when an ACK frame that acknowledged packets up to pn-1 was acknowledged by the peer. ACK frames acknowledge packets received on path 0.

func (*ReceivedPacketHandler) IgnorePacketsBelowForPath added in v0.3.0

func (h *ReceivedPacketHandler) IgnorePacketsBelowForPath(pathID protocol.PathID, pn protocol.PacketNumber)

IgnorePacketsBelowForPath is called when a PATH_ACK frame (or an ACK frame, for path 0) that acknowledged packets of a path up to pn-1 was acknowledged by the peer (IETF Multipath QUIC).

func (*ReceivedPacketHandler) IsPotentiallyDuplicate

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

IsPotentiallyDuplicate says if a packet might be a duplicate. With IETF Multipath QUIC, packets received on a removed path are reported as duplicates.

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

func (*ReceivedPacketHandler) RemovePath

func (h *ReceivedPacketHandler) RemovePath(pathID protocol.PathID)

RemovePath removes the tracker for a path (IETF Multipath QUIC). Packets received on the path afterwards are ignored, and no ACK is sent for the path.

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
	// pathAcks are the PATH_ACK frames contained in the packet (IETF Multipath QUIC),
	// largestAcked refers to the ACK frame.
	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, pathAcks ...PathAck)
	// ReceivedAck processes an ACK frame.
	// It does not store a copy of the frame.
	ReceivedAck(f *wire.AckFrame, encLevel protocol.EncryptionLevel, rcvTime monotime.Time) (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)
	// SetECNEnabled is called when the connection switched to a sendConn that can or can't set the ECN bits
	// (RFC 9000 connection migration by the client).
	SetECNEnabled(enabled bool)

	// BytesInFlight returns the bytes in flight of all paths.
	BytesInFlight() protocol.ByteCount
	SetPacketObserver(PacketObserver)
	SetCongestionControlFactory(func(protocol.PathID, *utils.RTTStats, protocol.ByteCount) congestion.SendAlgorithmWithDebugInfos)
	AddPath(_ protocol.PathID, addressValidated bool)
	// AbandonPath declares all packets sent on a path lost.
	AbandonPath(protocol.PathID, monotime.Time)
	RemovePath(protocol.PathID, monotime.Time)
	PathCongestionState(protocol.PathID) (cwnd, bytesInFlight protocol.ByteCount, ok bool)
	GetPathRTTStats(protocol.PathID) *utils.RTTStats
	ECNModeForPath(protocol.PathID) protocol.ECN

	// EnableMultipath enables IETF Multipath QUIC.
	EnableMultipath(ignorePacketsBelow func(protocol.PathID, protocol.PacketNumber))
	SetPathAddressValidated(protocol.PathID, monotime.Time)
	// AmplificationBudgetForPath returns the number of bytes that can be sent on a path
	// before the anti-amplification limit of the path is reached.
	// For path 0, this is the anti-amplification limit of the handshake.
	AmplificationBudgetForPath(protocol.PathID) protocol.ByteCount
	ReceivedBytesForPath(_ protocol.PathID, _ protocol.ByteCount, rcvTime monotime.Time)
	SendModeForPath(_ protocol.PathID, now monotime.Time) SendMode
	TimeUntilSendForPath(protocol.PathID) monotime.Time
	QueueProbePacketForPath(protocol.PathID) bool /* was a packet queued */
	NextProbePath() (protocol.PathID, bool)
	SetMaxDatagramSizeForPath(protocol.PathID, protocol.ByteCount)
	MigratedPathForPath(_ protocol.PathID, now monotime.Time, initialMaxPacketSize protocol.ByteCount)
	// MaxPTO returns the largest PTO of all paths that were not removed.
	MaxPTO(includeMaxAckDelay bool) time.Duration
	// OutstandingPackets iterates over the outstanding packets sent on a path (IETF Multipath QUIC).
	OutstandingPackets(protocol.PathID) iter.Seq[PacketEvent]
	// DeclareOutstandingLost declares the outstanding packets sent on a path lost (IETF Multipath QUIC).
	DeclareOutstandingLost(protocol.PathID, monotime.Time)
}

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