Documentation
¶
Index ¶
- Constants
- Variables
- func NewOLIACongestionControlFactory(sharedState *oliaSharedState) ...
- func NewOLIASharedState() *oliaSharedState
- type ApplicationError
- type ApplicationErrorCode
- type ByteCount
- type ClientInfo
- type ClientToken
- type Config
- type Conn
- func Dial(ctx context.Context, c net.PacketConn, addr net.Addr, tlsConf *tls.Config, ...) (*Conn, error)
- func DialAddr(ctx context.Context, addr string, tlsConf *tls.Config, conf *Config) (*Conn, error)
- func DialAddrEarly(ctx context.Context, addr string, tlsConf *tls.Config, conf *Config) (*Conn, error)
- func DialEarly(ctx context.Context, c net.PacketConn, addr net.Addr, tlsConf *tls.Config, ...) (*Conn, error)
- func (c *Conn) AcceptStream(ctx context.Context) (*Stream, error)
- func (c *Conn) AcceptUniStream(ctx context.Context) (*ReceiveStream, error)
- func (c *Conn) AddPath(t *Transport) (*Path, error)
- func (c *Conn) CloseWithError(code ApplicationErrorCode, desc string) error
- func (c *Conn) ConnectionState() ConnectionState
- func (c *Conn) ConnectionStats() ConnectionStats
- func (c *Conn) Context() context.Context
- func (c *Conn) HandshakeComplete() <-chan struct{}
- func (c *Conn) LocalAddr() net.Addr
- func (c *Conn) NextConnection(ctx context.Context) (*Conn, error)
- func (c *Conn) OpenStream() (*Stream, error)
- func (c *Conn) OpenStreamSync(ctx context.Context) (*Stream, error)
- func (c *Conn) OpenUniStream() (*SendStream, error)
- func (c *Conn) OpenUniStreamSync(ctx context.Context) (*SendStream, error)
- func (c *Conn) QlogTrace() qlogwriter.Trace
- func (c *Conn) QueueRawFrame(frame RawFrame)
- func (c *Conn) ReceiveDatagram(ctx context.Context) ([]byte, error)
- func (c *Conn) RemoteAddr() net.Addr
- func (c *Conn) SendDatagram(p []byte) error
- type ConnectionID
- type ConnectionIDGenerator
- type ConnectionState
- type ConnectionStats
- type DatagramTooLargeError
- type DefaultMultipathController
- func (c *DefaultMultipathController) AddPath(info PathInfo) (PathID, bool)
- func (c *DefaultMultipathController) EnablePacketDuplication(enable bool)
- func (c *DefaultMultipathController) GetAvailablePaths() []PathInfo
- func (c *DefaultMultipathController) GetScheduler() PathScheduler
- func (c *DefaultMultipathController) GetStatistics() map[PathID]PathStatistics
- func (c *DefaultMultipathController) HandleAddAddressFrame(frame *wire.AddAddressFrame)
- func (c *DefaultMultipathController) OnPacketAcked(pathID PathID)
- func (c *DefaultMultipathController) OnPacketLost(pathID PathID)
- func (c *DefaultMultipathController) OnPacketSent(pathID PathID, packetSize ByteCount)
- func (c *DefaultMultipathController) PathIDForPacket(remoteAddr, localAddr net.Addr) (PathID, bool)
- func (c *DefaultMultipathController) PathInfoForID(pathID PathID) (PathInfo, bool)
- func (c *DefaultMultipathController) RegisterPath(info PathInfo)
- func (c *DefaultMultipathController) RemovePath(pathID PathID)
- func (c *DefaultMultipathController) SelectPath(ctx PathSelectionContext) (PathInfo, bool)
- func (c *DefaultMultipathController) SetDuplicationParameters(unprobedOnly bool, maxQuotaDiff uint64)
- func (c *DefaultMultipathController) ShouldDuplicatePacket(sentOnPath PathID) (PathID, bool)
- func (c *DefaultMultipathController) UpdatePathState(pathID PathID, update PathStateUpdate)
- func (c *DefaultMultipathController) ValidatePath(pathID PathID)
- type EarlyListener
- type EncryptionLevel
- type ExtensionFrameContext
- type ExtensionFrameHandler
- type HandshakeTimeoutError
- type IdleTimeoutError
- type Listener
- type LowLatencyScheduler
- type MinRTTScheduler
- type MultiSocketManager
- func (m *MultiSocketManager) AddLocalAddr(ip net.IP) (*net.UDPAddr, error)
- func (m *MultiSocketManager) Close() error
- func (m *MultiSocketManager) LocalAddr() net.Addr
- func (m *MultiSocketManager) LocalAddrs() []net.IP
- func (m *MultiSocketManager) ReadFrom(b []byte) (n int, addr net.Addr, err error)
- func (m *MultiSocketManager) ReadPacket() (receivedPacket, error)
- func (m *MultiSocketManager) RefreshInterfaces() error
- func (m *MultiSocketManager) RemoveLocalAddr(ip net.IP) bool
- func (m *MultiSocketManager) SetDeadline(t time.Time) error
- func (m *MultiSocketManager) SetLocalAddrs(addrs []net.IP) error
- func (m *MultiSocketManager) SetReadDeadline(t time.Time) error
- func (m *MultiSocketManager) SetWriteDeadline(t time.Time) error
- func (m *MultiSocketManager) WritePacket(b []byte, addr net.Addr, packetInfoOOB []byte, gsoSize uint16, ...) (int, error)
- func (m *MultiSocketManager) WritePacketWithInfo(b []byte, addr net.Addr, info packetInfo, gsoSize uint16, ecn protocol.ECN) (int, error)
- func (m *MultiSocketManager) WriteTo(b []byte, addr net.Addr) (int, error)
- type MultiSocketManagerConfig
- type MultipathController
- type MultipathDuplicationPolicy
- func (p *MultipathDuplicationPolicy) AddStreamForDuplication(streamID protocol.StreamID)
- func (p *MultipathDuplicationPolicy) Disable()
- func (p *MultipathDuplicationPolicy) Enable()
- func (p *MultipathDuplicationPolicy) GetDuplicatePathCount() int
- func (p *MultipathDuplicationPolicy) IsEnabled() bool
- func (p *MultipathDuplicationPolicy) RemoveStreamForDuplication(streamID protocol.StreamID)
- func (p *MultipathDuplicationPolicy) SetDuplicateCryptoFrames(enable bool)
- func (p *MultipathDuplicationPolicy) SetDuplicatePathCount(count int)
- func (p *MultipathDuplicationPolicy) SetDuplicateResets(enable bool)
- func (p *MultipathDuplicationPolicy) ShouldDuplicateCrypto() bool
- func (p *MultipathDuplicationPolicy) ShouldDuplicateReset() bool
- func (p *MultipathDuplicationPolicy) ShouldDuplicateStream(streamID protocol.StreamID) bool
- type MultipathObserver
- type MultipathPath
- type MultipathPathManager
- func (pm *MultipathPathManager) ActivatePath(pathID protocol.PathID) bool
- func (pm *MultipathPathManager) AddPath(localAddr, remoteAddr net.Addr) protocol.PathID
- func (pm *MultipathPathManager) ClosePath(pathID protocol.PathID)
- func (pm *MultipathPathManager) EnableMultipath()
- func (pm *MultipathPathManager) GetActivePathCount() int
- func (pm *MultipathPathManager) GetActivePaths() []*MultipathPath
- func (pm *MultipathPathManager) GetAllPaths() []*MultipathPath
- func (pm *MultipathPathManager) GetPath(pathID protocol.PathID) *MultipathPath
- func (pm *MultipathPathManager) GetPathCount() int
- func (pm *MultipathPathManager) GetPrimaryPathID() protocol.PathID
- func (pm *MultipathPathManager) HandleAddAddressFrame(frame *wire.AddAddressFrame)
- func (pm *MultipathPathManager) HandleClosePathFrame(frame *wire.ClosePathFrame)
- func (pm *MultipathPathManager) IsMultipathEnabled() bool
- func (pm *MultipathPathManager) RecordPathUsage(pathID protocol.PathID, bytesSent uint64)
- func (pm *MultipathPathManager) SetPrimaryPath(localAddr, remoteAddr net.Addr)
- func (pm *MultipathPathManager) UpdatePathRTT(pathID protocol.PathID, rtt time.Duration)
- func (pm *MultipathPathManager) ValidatePath(pathID protocol.PathID)
- type MultipathPathState
- type MultipathReinjectionManager
- func (m *MultipathReinjectionManager) GetPendingReinjections(now time.Time) []*PacketReinjectionInfo
- func (m *MultipathReinjectionManager) GetStatistics() (pending, reinjected int)
- func (m *MultipathReinjectionManager) MarkReinjected(pn protocol.PacketNumber, targetPath protocol.PathID)
- func (m *MultipathReinjectionManager) OnPacketAcked(pn protocol.PacketNumber)
- func (m *MultipathReinjectionManager) OnPacketLost(pathID protocol.PathID, pn protocol.PacketNumber, ...)
- func (m *MultipathReinjectionManager) Reset()
- type MultipathReinjectionPolicy
- func (p *MultipathReinjectionPolicy) AddPreferredPathForReinjection(pathID protocol.PathID)
- func (p *MultipathReinjectionPolicy) Disable()
- func (p *MultipathReinjectionPolicy) Enable()
- func (p *MultipathReinjectionPolicy) GetMaxReinjectionQueuePerPath() int
- func (p *MultipathReinjectionPolicy) GetMaxReinjections() int
- func (p *MultipathReinjectionPolicy) GetMinReinjectionInterval() time.Duration
- func (p *MultipathReinjectionPolicy) GetReinjectionDelay() time.Duration
- func (p *MultipathReinjectionPolicy) IsEnabled() bool
- func (p *MultipathReinjectionPolicy) IsPreferredPathForReinjection(pathID protocol.PathID) bool
- func (p *MultipathReinjectionPolicy) RemovePreferredPathForReinjection(pathID protocol.PathID)
- func (p *MultipathReinjectionPolicy) SetMaxReinjectionQueuePerPath(max int)
- func (p *MultipathReinjectionPolicy) SetMaxReinjections(max int)
- func (p *MultipathReinjectionPolicy) SetMinReinjectionInterval(interval time.Duration)
- func (p *MultipathReinjectionPolicy) SetReinjectionDelay(delay time.Duration)
- func (p *MultipathReinjectionPolicy) ShouldReinjectFrame(frame wire.Frame) bool
- type MultipathReinjectionTargetSelector
- type MultipathScheduler
- type OLIACongestionControl
- func (o *OLIACongestionControl) CanSend(bytesInFlight protocol.ByteCount) bool
- func (o *OLIACongestionControl) GetCongestionWindow() protocol.ByteCount
- func (o *OLIACongestionControl) GetStatistics() OLIAStatistics
- func (o *OLIACongestionControl) InRecovery() bool
- func (o *OLIACongestionControl) InSlowStart() bool
- func (o *OLIACongestionControl) OnCongestionEvent(packetNumber protocol.PacketNumber, lostBytes protocol.ByteCount, ...)
- func (o *OLIACongestionControl) OnPacketAcked(packetNumber protocol.PacketNumber, ackedBytes protocol.ByteCount, ...)
- func (o *OLIACongestionControl) OnPacketLost(packetNumber protocol.PacketNumber, lostBytes protocol.ByteCount, ...)
- func (o *OLIACongestionControl) OnPacketSent(sentTime time.Time, packetNumber protocol.PacketNumber, ...)
- func (o *OLIACongestionControl) OnRetransmissionTimeout(packetsRetransmitted bool)
- func (o *OLIACongestionControl) Reset()
- func (o *OLIACongestionControl) SetMaxDatagramSize(size protocol.ByteCount)
- func (o *OLIACongestionControl) SmoothedBytesBetweenLosses() protocol.ByteCount
- func (o *OLIACongestionControl) Unregister()
- func (o *OLIACongestionControl) UpdateRTT(rtt, minRTT time.Duration)
- type OLIAStatistics
- type OOBCapablePacketConn
- type PacketNumber
- type PacketReinjectionInfo
- type Path
- type PathEvent
- type PathID
- type PathInfo
- type PathScheduler
- type PathSchedulerWrapper
- func (s *PathSchedulerWrapper) AddPath(info PathInfo) (PathID, bool)
- func (s *PathSchedulerWrapper) DisableMultipath()
- func (s *PathSchedulerWrapper) EnableMultipath()
- func (s *PathSchedulerWrapper) GetAvailablePaths() []PathInfo
- func (s *PathSchedulerWrapper) HandleAddAddressFrame(frame *wire.AddAddressFrame)
- func (s *PathSchedulerWrapper) HandleClosePathFrame(frame *wire.ClosePathFrame)
- func (s *PathSchedulerWrapper) HandlePathsFrame(frame *wire.PathsFrame)
- func (s *PathSchedulerWrapper) IsMultipathEnabled() bool
- func (s *PathSchedulerWrapper) OnPacketAcked(ev PathEvent)
- func (s *PathSchedulerWrapper) OnPacketLost(ev PathEvent)
- func (s *PathSchedulerWrapper) OnPacketSent(ev PathEvent)
- func (s *PathSchedulerWrapper) PathIDForPacket(remoteAddr, localAddr net.Addr) (PathID, bool)
- func (s *PathSchedulerWrapper) PathInfoForID(pathID PathID) (PathInfo, bool)
- func (s *PathSchedulerWrapper) RecordSent(pathID protocol.PathID, packetSize uint64)
- func (s *PathSchedulerWrapper) RegisterPath(info PathInfo)
- func (s *PathSchedulerWrapper) SelectPath(ctx PathSelectionContext) (PathInfo, bool)
- func (s *PathSchedulerWrapper) ValidatePath(pathID PathID)
- type PathSelectionContext
- type PathStateUpdate
- type PathStatistics
- type RawFrame
- type ReceiveStream
- type ReinjectionTargetContext
- type RoundRobinScheduler
- type SchedulerPathInfo
- type SchedulerStats
- type SchedulingPolicy
- type SendStream
- func (s *SendStream) CancelWrite(errorCode StreamErrorCode)
- func (s *SendStream) Close() error
- func (s *SendStream) Context() context.Context
- func (s *SendStream) SetReliableBoundary()
- func (s *SendStream) SetWriteDeadline(t time.Time) error
- func (s *SendStream) StreamID() StreamID
- func (s *SendStream) Write(p []byte) (int, error)
- type StatelessResetError
- type StatelessResetKey
- type Stream
- func (s *Stream) CancelRead(errorCode StreamErrorCode)
- func (s *Stream) CancelWrite(errorCode StreamErrorCode)
- func (s *Stream) Close() error
- func (s *Stream) Context() context.Context
- func (s *Stream) Peek(b []byte) (int, error)
- func (s *Stream) Read(p []byte) (int, error)
- func (s *Stream) SetDeadline(t time.Time) error
- func (s *Stream) SetReadDeadline(t time.Time) error
- func (s *Stream) SetReliableBoundary()
- func (s *Stream) SetWriteDeadline(t time.Time) error
- func (s *Stream) StreamID() protocol.StreamID
- func (s *Stream) Write(p []byte) (int, error)
- type StreamError
- type StreamErrorCode
- type StreamID
- type StreamLimitReachedError
- type TokenGeneratorKey
- type TokenStore
- type Transport
- func (t *Transport) Close() error
- func (t *Transport) Dial(ctx context.Context, addr net.Addr, tlsConf *tls.Config, conf *Config) (*Conn, error)
- func (t *Transport) DialEarly(ctx context.Context, addr net.Addr, tlsConf *tls.Config, conf *Config) (*Conn, error)
- func (t *Transport) Listen(tlsConf *tls.Config, conf *Config) (*Listener, error)
- func (t *Transport) ListenEarly(tlsConf *tls.Config, conf *Config) (*EarlyListener, error)
- func (t *Transport) ReadNonQUICPacket(ctx context.Context, b []byte) (int, net.Addr, error)
- func (t *Transport) WriteTo(b []byte, addr net.Addr) (int, error)
- type TransportError
- type TransportErrorCode
- type Version
- type VersionNegotiationError
Constants ¶
const ( // NoError is the NO_ERROR transport error code. NoError = qerr.NoError // InternalError is the INTERNAL_ERROR transport error code. InternalError = qerr.InternalError // ConnectionRefused is the CONNECTION_REFUSED transport error code. ConnectionRefused = qerr.ConnectionRefused // FlowControlError is the FLOW_CONTROL_ERROR transport error code. FlowControlError = qerr.FlowControlError // StreamLimitError is the STREAM_LIMIT_ERROR transport error code. StreamLimitError = qerr.StreamLimitError // StreamStateError is the STREAM_STATE_ERROR transport error code. StreamStateError = qerr.StreamStateError // FinalSizeError is the FINAL_SIZE_ERROR transport error code. FinalSizeError = qerr.FinalSizeError // FrameEncodingError is the FRAME_ENCODING_ERROR transport error code. FrameEncodingError = qerr.FrameEncodingError // TransportParameterError is the TRANSPORT_PARAMETER_ERROR transport error code. TransportParameterError = qerr.TransportParameterError // ConnectionIDLimitError is the CONNECTION_ID_LIMIT_ERROR transport error code. ConnectionIDLimitError = qerr.ConnectionIDLimitError // ProtocolViolation is the PROTOCOL_VIOLATION transport error code. ProtocolViolation = qerr.ProtocolViolation // InvalidToken is the INVALID_TOKEN transport error code. InvalidToken = qerr.InvalidToken // ApplicationErrorErrorCode is the APPLICATION_ERROR transport error code. ApplicationErrorErrorCode = qerr.ApplicationErrorErrorCode // CryptoBufferExceeded is the CRYPTO_BUFFER_EXCEEDED transport error code. CryptoBufferExceeded = qerr.CryptoBufferExceeded // KeyUpdateError is the KEY_UPDATE_ERROR transport error code. KeyUpdateError = qerr.KeyUpdateError // AEADLimitReached is the AEAD_LIMIT_REACHED transport error code. AEADLimitReached = qerr.AEADLimitReached // NoViablePathError is the NO_VIABLE_PATH_ERROR transport error code. NoViablePathError = qerr.NoViablePathError )
Variables ¶
var ( // ErrPathClosed is returned when trying to switch to a path that has been closed. ErrPathClosed = errors.New("path closed") // ErrPathNotValidated is returned when trying to use a path before path probing has completed. ErrPathNotValidated = errors.New("path not yet validated") )
var Err0RTTRejected = errors.New("0-RTT rejected")
Err0RTTRejected is the returned from:
- Open{Uni}Stream{Sync}
- Accept{Uni}Stream
- Stream.Read and Stream.Write
when the server rejects a 0-RTT connection attempt.
var ErrServerClosed = errServerClosed{}
ErrServerClosed is returned by the Listener or EarlyListener's Accept method after a call to Close.
var ErrTransportClosed = &errTransportClosed{}
ErrTransportClosed is returned by the Transport's Listen or Dial method after it was closed.
var QUICVersionContextKey = handshake.QUICVersionContextKey
QUICVersionContextKey can be used to find out the QUIC version of a TLS handshake from the context returned by tls.Config.ClientInfo.Context.
Functions ¶
func NewOLIACongestionControlFactory ¶
func NewOLIACongestionControlFactory(sharedState *oliaSharedState) func(pathID protocol.PathID, rttStats *utils.RTTStats, initialMaxDatagramSize protocol.ByteCount) congestion.SendAlgorithmWithDebugInfos
NewOLIACongestionControlFactory creates a factory function for OLIA congestion controllers. This factory is used by sent_packet_handler to create per-path OLIA instances.
func NewOLIASharedState ¶
func NewOLIASharedState() *oliaSharedState
NewOLIASharedState creates shared state for OLIA congestion control.
Types ¶
type ApplicationError ¶
type ApplicationError = qerr.ApplicationError
ApplicationError is an application-defined error.
type ApplicationErrorCode ¶
type ApplicationErrorCode = qerr.ApplicationErrorCode
ApplicationErrorCode is an QUIC application error code.
type ClientInfo ¶
type ClientInfo struct {
// RemoteAddr is the remote address on the Initial packet.
// Unless AddrVerified is set, the address is not yet verified, and could be a spoofed IP address.
RemoteAddr net.Addr
// AddrVerified says if the remote address was verified using QUIC's Retry mechanism.
// Note that the Retry mechanism costs one network roundtrip,
// and is not performed unless Transport.MaxUnvalidatedHandshakes is surpassed.
AddrVerified bool
}
ClientInfo contains information about an incoming connection attempt.
type ClientToken ¶
type ClientToken struct {
// contains filtered or unexported fields
}
A ClientToken is a token received by the client. It can be used to skip address validation on future connection attempts.
type Config ¶
type Config struct {
// GetConfigForClient is called for incoming connections.
// If the error is not nil, the connection attempt is refused.
GetConfigForClient func(info *ClientInfo) (*Config, error)
// The QUIC versions that can be negotiated.
// If not set, it uses all versions available.
Versions []Version
// HandshakeIdleTimeout is the idle timeout before completion of the handshake.
// If we don't receive any packet from the peer within this time, the connection attempt is aborted.
// Additionally, if the handshake doesn't complete in twice this time, the connection attempt is also aborted.
// If this value is zero, the timeout is set to 5 seconds.
HandshakeIdleTimeout time.Duration
// MaxIdleTimeout is the maximum duration that may pass without any incoming network activity.
// The actual value for the idle timeout is the minimum of this value and the peer's.
// This value only applies after the handshake has completed.
// If the timeout is exceeded, the connection is closed.
// If this value is zero, the timeout is set to 30 seconds.
MaxIdleTimeout time.Duration
// The TokenStore stores tokens received from the server.
// Tokens are used to skip address validation on future connection attempts.
// The key used to store tokens is the ServerName from the tls.Config, if set
// otherwise the token is associated with the server's IP address.
TokenStore TokenStore
// InitialStreamReceiveWindow is the initial size of the stream-level flow control window for receiving data.
// If the application is consuming data quickly enough, the flow control auto-tuning algorithm
// will increase the window up to MaxStreamReceiveWindow.
// If this value is zero, it will default to 512 KB.
// Values larger than the maximum varint (quicvarint.Max) will be clipped to that value.
InitialStreamReceiveWindow uint64
// MaxStreamReceiveWindow is the maximum stream-level flow control window for receiving data.
// If this value is zero, it will default to 6 MB.
// Values larger than the maximum varint (quicvarint.Max) will be clipped to that value.
MaxStreamReceiveWindow uint64
// InitialConnectionReceiveWindow is the initial size of the stream-level flow control window for receiving data.
// If the application is consuming data quickly enough, the flow control auto-tuning algorithm
// will increase the window up to MaxConnectionReceiveWindow.
// If this value is zero, it will default to 512 KB.
// Values larger than the maximum varint (quicvarint.Max) will be clipped to that value.
InitialConnectionReceiveWindow uint64
// MaxConnectionReceiveWindow is the connection-level flow control window for receiving data.
// If this value is zero, it will default to 15 MB.
// Values larger than the maximum varint (quicvarint.Max) will be clipped to that value.
MaxConnectionReceiveWindow uint64
// AllowConnectionWindowIncrease is called every time the connection flow controller attempts
// to increase the connection flow control window.
// If set, the caller can prevent an increase of the window. Typically, it would do so to
// limit the memory usage.
// To avoid deadlocks, it is not valid to call other functions on the connection or on streams
// in this callback.
AllowConnectionWindowIncrease func(conn *Conn, delta uint64) bool
// MaxIncomingStreams is the maximum number of concurrent bidirectional streams that a peer is allowed to open.
// If not set, it will default to 100.
// If set to a negative value, it doesn't allow any bidirectional streams.
// Values larger than 2^60 will be clipped to that value.
MaxIncomingStreams int64
// MaxIncomingUniStreams is the maximum number of concurrent unidirectional streams that a peer is allowed to open.
// If not set, it will default to 100.
// If set to a negative value, it doesn't allow any unidirectional streams.
// Values larger than 2^60 will be clipped to that value.
MaxIncomingUniStreams int64
// KeepAlivePeriod defines whether this peer will periodically send a packet to keep the connection alive.
// If set to 0, then no keep alive is sent. Otherwise, the keep alive is sent on that period (or at most
// every half of MaxIdleTimeout, whichever is smaller).
KeepAlivePeriod time.Duration
// InitialPacketSize is the initial size (and the lower limit) for packets sent.
// Under most circumstances, it is not necessary to manually set this value,
// since path MTU discovery quickly finds the path's MTU.
// If set too high, the path might not support packets of that size, leading to a timeout of the QUIC handshake.
// Values below 1200 are invalid.
InitialPacketSize uint16
// DisablePathMTUDiscovery disables Path MTU Discovery (RFC 8899).
// This allows the sending of QUIC packets that fully utilize the available MTU of the path.
// Path MTU discovery is only available on systems that allow setting of the Don't Fragment (DF) bit.
DisablePathMTUDiscovery bool
// Allow0RTT allows the application to decide if a 0-RTT connection attempt should be accepted.
// Only valid for the server.
Allow0RTT bool
// Enable QUIC datagram support (RFC 9221).
EnableDatagrams bool
// Enable QUIC Stream Resets with Partial Delivery.
// See https://datatracker.ietf.org/doc/html/draft-ietf-quic-reliable-stream-reset-07.
EnableStreamResetPartialDelivery bool
// MaxPaths is the maximum number of paths to keep track of simultaneously.
// If set to 0, it defaults to 3.
// When a peer probes another path after this limit is reached (before pathTimeout of an existing path expires),
// the probing attempt is ignored.
MaxPaths int
// MultipathController enables path-aware scheduling and packet mapping.
MultipathController MultipathController
// MultipathDuplicationPolicy enables packet duplication across paths.
MultipathDuplicationPolicy *MultipathDuplicationPolicy
// MultipathReinjectionPolicy enables packet reinjection on alternate paths.
MultipathReinjectionPolicy *MultipathReinjectionPolicy
// MultipathAutoPaths automatically creates additional paths after the handshake.
MultipathAutoPaths bool
// MultipathAutoAdvertise automatically advertises local addresses using ADD_ADDRESS frames.
MultipathAutoAdvertise bool
// MultipathAutoAddrs optionally overrides auto-discovered local addresses.
MultipathAutoAddrs []net.IP
// ExtensionFrameHandler enables parsing of custom frame types.
ExtensionFrameHandler ExtensionFrameHandler
Tracer func(ctx context.Context, isClient bool, connID ConnectionID) qlogwriter.Trace
}
Config contains all configuration data needed for a QUIC server or client.
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
A Conn is a QUIC connection between two peers. Calls to the connection (and to streams) can return the following types of errors:
- ApplicationError: for errors triggered by the application running on top of QUIC
- TransportError: for errors triggered by the QUIC transport (in many cases a misbehaving peer)
- IdleTimeoutError: when the peer goes away unexpectedly (this is a net.Error timeout error)
- HandshakeTimeoutError: when the cryptographic handshake takes too long (this is a net.Error timeout error)
- StatelessResetError: when we receive a stateless reset
- VersionNegotiationError: returned by the client, when there's no version overlap between the peers
func Dial ¶
func Dial(ctx context.Context, c net.PacketConn, addr net.Addr, tlsConf *tls.Config, conf *Config) (*Conn, error)
Dial establishes a new QUIC connection to a server using a net.PacketConn. If the PacketConn satisfies the OOBCapablePacketConn interface (as a net.UDPConn does), ECN and packet info support will be enabled. In this case, ReadMsgUDP and WriteMsgUDP will be used instead of ReadFrom and WriteTo to read/write packets. The tls.Config must define an application protocol (using tls.Config.NextProtos).
This is a convenience function. More advanced use cases should instantiate a Transport, which offers configuration options for a more fine-grained control of the connection establishment, including reusing the underlying UDP socket for multiple QUIC connections.
func DialAddr ¶
DialAddr establishes a new QUIC connection to a server. It resolves the address, and then creates a new UDP connection to dial the QUIC server. When the QUIC connection is closed, this UDP connection is closed. See Dial for more details.
func DialAddrEarly ¶
func DialAddrEarly(ctx context.Context, addr string, tlsConf *tls.Config, conf *Config) (*Conn, error)
DialAddrEarly establishes a new 0-RTT QUIC connection to a server. See DialAddr for more details.
func DialEarly ¶
func DialEarly(ctx context.Context, c net.PacketConn, addr net.Addr, tlsConf *tls.Config, conf *Config) (*Conn, error)
DialEarly establishes a new 0-RTT QUIC connection to a server using a net.PacketConn. See Dial for more details.
func (*Conn) AcceptStream ¶
AcceptStream returns the next stream opened by the peer, blocking until one is available.
func (*Conn) AcceptUniStream ¶
func (c *Conn) AcceptUniStream(ctx context.Context) (*ReceiveStream, error)
AcceptUniStream returns the next unidirectional stream opened by the peer, blocking until one is available.
func (*Conn) CloseWithError ¶
func (c *Conn) CloseWithError(code ApplicationErrorCode, desc string) error
CloseWithError closes the connection with an error. The error string will be sent to the peer.
func (*Conn) ConnectionState ¶
func (c *Conn) ConnectionState() ConnectionState
ConnectionState returns basic details about the QUIC connection.
func (*Conn) ConnectionStats ¶
func (c *Conn) ConnectionStats() ConnectionStats
func (*Conn) Context ¶
Context returns a context that is cancelled when the connection is closed. The cancellation cause is set to the error that caused the connection to close.
func (*Conn) HandshakeComplete ¶
func (c *Conn) HandshakeComplete() <-chan struct{}
HandshakeComplete blocks until the handshake completes (or fails). For the client, data sent before completion of the handshake is encrypted with 0-RTT keys. For the server, data sent before completion of the handshake is encrypted with 1-RTT keys, however the client's identity is only verified once the handshake completes.
func (*Conn) NextConnection ¶
NextConnection transitions a connection to be usable after a 0-RTT rejection. It waits for the handshake to complete and then enables the connection for normal use. This should be called when the server rejects 0-RTT and the application receives Err0RTTRejected errors.
Note that 0-RTT rejection invalidates all data sent in 0-RTT packets. It is the application's responsibility to handle this (for example by resending the data).
func (*Conn) OpenStream ¶
OpenStream opens a new bidirectional QUIC stream. There is no signaling to the peer about new streams: The peer can only accept the stream after data has been sent on the stream, or the stream has been reset or closed. When reaching the peer's stream limit, it is not possible to open a new stream until the peer raises the stream limit. In that case, a StreamLimitReachedError is returned.
func (*Conn) OpenStreamSync ¶
OpenStreamSync opens a new bidirectional QUIC stream. It blocks until a new stream can be opened. There is no signaling to the peer about new streams: The peer can only accept the stream after data has been sent on the stream, or the stream has been reset or closed.
func (*Conn) OpenUniStream ¶
func (c *Conn) OpenUniStream() (*SendStream, error)
OpenUniStream opens a new outgoing unidirectional QUIC stream. There is no signaling to the peer about new streams: The peer can only accept the stream after data has been sent on the stream, or the stream has been reset or closed. When reaching the peer's stream limit, it is not possible to open a new stream until the peer raises the stream limit. In that case, a StreamLimitReachedError is returned.
func (*Conn) OpenUniStreamSync ¶
func (c *Conn) OpenUniStreamSync(ctx context.Context) (*SendStream, error)
OpenUniStreamSync opens a new outgoing unidirectional QUIC stream. It blocks until a new stream can be opened. There is no signaling to the peer about new streams: The peer can only accept the stream after data has been sent on the stream, or the stream has been reset or closed.
func (*Conn) QlogTrace ¶
func (c *Conn) QlogTrace() qlogwriter.Trace
QlogTrace returns the qlog trace of the QUIC connection. It is nil if qlog is not enabled.
func (*Conn) QueueRawFrame ¶
QueueRawFrame queues a custom frame for sending.
func (*Conn) ReceiveDatagram ¶
ReceiveDatagram gets a message received in a QUIC datagram, as specified in RFC 9221.
func (*Conn) RemoteAddr ¶
RemoteAddr returns the remote address of the QUIC connection.
func (*Conn) SendDatagram ¶
SendDatagram sends a message using a QUIC datagram, as specified in RFC 9221, if the peer enabled datagram support. There is no delivery guarantee for DATAGRAM frames, they are not retransmitted if lost. The payload of the datagram needs to fit into a single QUIC packet. In addition, a datagram may be dropped before being sent out if the available packet size suddenly decreases. If the payload is too large to be sent at the current time, a DatagramTooLargeError is returned.
type ConnectionID ¶
type ConnectionID = protocol.ConnectionID
A ConnectionID is a QUIC Connection ID, as defined in RFC 9000. It is not able to handle QUIC Connection IDs longer than 20 bytes, as they are allowed by RFC 8999.
func ConnectionIDFromBytes ¶
func ConnectionIDFromBytes(b []byte) ConnectionID
ConnectionIDFromBytes interprets b as a ConnectionID. It panics if b is longer than 20 bytes.
type ConnectionIDGenerator ¶
type ConnectionIDGenerator interface {
// GenerateConnectionID generates a new Connection ID.
// Generated Connection IDs must be unique and observers should not be able to correlate two Connection IDs.
GenerateConnectionID() (ConnectionID, error)
// ConnectionIDLen returns the length of Connection IDs generated by this implementation.
// Implementations must return constant-length Connection IDs with lengths between 0 and 20 bytes.
// A length of 0 can only be used when an endpoint doesn't need to multiplex connections during migration.
ConnectionIDLen() int
}
A ConnectionIDGenerator allows the application to take control over the generation of Connection IDs. Connection IDs generated by an implementation must be of constant length.
type ConnectionState ¶
type ConnectionState struct {
// TLS contains information about the TLS connection state, incl. the tls.ConnectionState.
TLS tls.ConnectionState
// SupportsDatagrams indicates whether the peer advertised support for QUIC datagrams (RFC 9221).
// When true, datagrams can be sent using the Conn's SendDatagram method.
// This is a unilateral declaration by the peer - receiving datagrams is only possible if
// datagram support was enabled locally via Config.EnableDatagrams.
SupportsDatagrams bool
// SupportsMultipath indicates whether the peer advertised support for multipath QUIC.
// When true, multipath features can be enabled if configured locally.
SupportsMultipath bool
// SupportsStreamResetPartialDelivery indicates whether the peer advertised support for QUIC Stream Resets with Partial Delivery.
SupportsStreamResetPartialDelivery bool
// Used0RTT says if 0-RTT resumption was used.
Used0RTT bool
// Version is the QUIC version of the QUIC connection.
Version Version
// GSO says if generic segmentation offload is used.
GSO bool
}
ConnectionState records basic details about a QUIC connection.
type ConnectionStats ¶
type ConnectionStats struct {
// MinRTT is the estimate of the minimum RTT observed on the active network
// path.
MinRTT time.Duration
// LatestRTT is the last RTT sample observed on the active network path.
LatestRTT time.Duration
// SmoothedRTT is an exponentially weighted moving average of an endpoint's
// RTT samples. See https://www.rfc-editor.org/rfc/rfc9002#section-5.3
SmoothedRTT time.Duration
// MeanDeviation estimates the variation in the RTT samples using a mean
// variation. See https://www.rfc-editor.org/rfc/rfc9002#section-5.3
MeanDeviation time.Duration
// BytesSent is the number of bytes sent on the underlying connection,
// including retransmissions. Does not include UDP or any other outer
// framing.
BytesSent uint64
// PacketsSent is the number of packets sent on the underlying connection,
// including those that are determined to have been lost.
PacketsSent uint64
// BytesReceived is the number of total bytes received on the underlying
// connection, including duplicate data for streams. Does not include UDP or
// any other outer framing.
BytesReceived uint64
// PacketsReceived is the number of total packets received on the underlying
// connection, including packets that were not processable.
PacketsReceived uint64
// BytesLost is the number of bytes lost on the underlying connection (does
// not monotonically increase, because packets that are declared lost can
// subsequently be received). Does not include UDP or any other outer
// framing.
BytesLost uint64
// PacketsLost is the number of packets lost on the underlying connection
// (does not monotonically increase, because packets that are declared lost
// can subsequently be received).
PacketsLost uint64
}
ConnectionStats contains statistics about the QUIC connection
type DatagramTooLargeError ¶
type DatagramTooLargeError struct {
MaxDatagramPayloadSize int64
}
DatagramTooLargeError is returned from Conn.SendDatagram if the payload is too large to be sent.
func (*DatagramTooLargeError) Error ¶
func (e *DatagramTooLargeError) Error() string
func (*DatagramTooLargeError) Is ¶
func (e *DatagramTooLargeError) Is(target error) bool
type DefaultMultipathController ¶
type DefaultMultipathController struct {
// contains filtered or unexported fields
}
DefaultMultipathController is a complete implementation of MultipathController with integrated scheduling and path management.
func NewDefaultMultipathController ¶
func NewDefaultMultipathController(scheduler PathScheduler) *DefaultMultipathController
NewDefaultMultipathController creates a new multipath controller with the specified scheduler. If scheduler is nil, it defaults to LowLatencyScheduler.
func (*DefaultMultipathController) AddPath ¶
func (c *DefaultMultipathController) AddPath(info PathInfo) (PathID, bool)
AddPath adds a new path and returns the assigned path ID.
func (*DefaultMultipathController) EnablePacketDuplication ¶
func (c *DefaultMultipathController) EnablePacketDuplication(enable bool)
EnablePacketDuplication enables packet duplication on unprobed paths.
func (*DefaultMultipathController) GetAvailablePaths ¶
func (c *DefaultMultipathController) GetAvailablePaths() []PathInfo
GetAvailablePaths returns paths that are eligible for sending.
func (*DefaultMultipathController) GetScheduler ¶
func (c *DefaultMultipathController) GetScheduler() PathScheduler
GetScheduler returns the underlying PathScheduler.
func (*DefaultMultipathController) GetStatistics ¶
func (c *DefaultMultipathController) GetStatistics() map[PathID]PathStatistics
GetStatistics returns statistics for all paths.
func (*DefaultMultipathController) HandleAddAddressFrame ¶
func (c *DefaultMultipathController) HandleAddAddressFrame(frame *wire.AddAddressFrame)
HandleAddAddressFrame registers a new remote address as a path.
func (*DefaultMultipathController) OnPacketAcked ¶
func (c *DefaultMultipathController) OnPacketAcked(pathID PathID)
OnPacketAcked is called when a packet is acknowledged.
func (*DefaultMultipathController) OnPacketLost ¶
func (c *DefaultMultipathController) OnPacketLost(pathID PathID)
OnPacketLost is called when a packet is lost.
func (*DefaultMultipathController) OnPacketSent ¶
func (c *DefaultMultipathController) OnPacketSent(pathID PathID, packetSize ByteCount)
OnPacketSent is called when a packet is sent on a path.
func (*DefaultMultipathController) PathIDForPacket ¶
func (c *DefaultMultipathController) PathIDForPacket(remoteAddr, localAddr net.Addr) (PathID, bool)
PathIDForPacket maps a received packet to a path ID.
func (*DefaultMultipathController) PathInfoForID ¶
func (c *DefaultMultipathController) PathInfoForID(pathID PathID) (PathInfo, bool)
PathInfoForID returns path info by ID.
func (*DefaultMultipathController) RegisterPath ¶
func (c *DefaultMultipathController) RegisterPath(info PathInfo)
RegisterPath registers a new path with the controller.
func (*DefaultMultipathController) RemovePath ¶
func (c *DefaultMultipathController) RemovePath(pathID PathID)
RemovePath removes a path from the controller.
func (*DefaultMultipathController) SelectPath ¶
func (c *DefaultMultipathController) SelectPath(ctx PathSelectionContext) (PathInfo, bool)
SelectPath selects the best path for sending a packet.
func (*DefaultMultipathController) SetDuplicationParameters ¶
func (c *DefaultMultipathController) SetDuplicationParameters(unprobedOnly bool, maxQuotaDiff uint64)
SetDuplicationParameters configures packet duplication behavior.
func (*DefaultMultipathController) ShouldDuplicatePacket ¶
func (c *DefaultMultipathController) ShouldDuplicatePacket(sentOnPath PathID) (PathID, bool)
ShouldDuplicatePacket returns whether a packet should be duplicated and on which path.
func (*DefaultMultipathController) UpdatePathState ¶
func (c *DefaultMultipathController) UpdatePathState(pathID PathID, update PathStateUpdate)
UpdatePathState updates the state of a path.
func (*DefaultMultipathController) ValidatePath ¶
func (c *DefaultMultipathController) ValidatePath(pathID PathID)
ValidatePath marks a path as validated.
type EarlyListener ¶
type EarlyListener struct {
// contains filtered or unexported fields
}
An EarlyListener listens for incoming QUIC connections, and returns them before the handshake completes. For connections that don't use 0-RTT, this allows the server to send 0.5-RTT data. This data is encrypted with forward-secure keys, however, the client's identity has not yet been verified. For connection using 0-RTT, this allows the server to accept and respond to streams that the client opened in the 0-RTT data it sent. Note that at this point during the handshake, the live-ness of the client has not yet been confirmed, and the 0-RTT data could have been replayed by an attacker.
func ListenAddrEarly ¶
ListenAddrEarly works like ListenAddr, but it returns connections before the handshake completes.
func ListenEarly ¶
func ListenEarly(conn net.PacketConn, tlsConf *tls.Config, config *Config) (*EarlyListener, error)
ListenEarly works like Listen, but it returns connections before the handshake completes.
func (*EarlyListener) Accept ¶
func (l *EarlyListener) Accept(ctx context.Context) (*Conn, error)
Accept returns a new connections. It should be called in a loop.
func (*EarlyListener) Addr ¶
func (l *EarlyListener) Addr() net.Addr
Addr returns the local network addr that the server is listening on.
func (*EarlyListener) Close ¶
func (l *EarlyListener) Close() error
Close closes the listener. Accept will return ErrServerClosed as soon as all connections in the accept queue have been accepted. Early connections that are still in flight will be rejected with a CONNECTION_REFUSED error. Already established (accepted) connections will be unaffected.
type EncryptionLevel ¶
type EncryptionLevel = protocol.EncryptionLevel
EncryptionLevel is the QUIC encryption level.
type ExtensionFrameContext ¶
type ExtensionFrameContext struct {
FrameType uint64
EncryptionLevel EncryptionLevel
Version Version
Data []byte // frame payload without the type varint
}
ExtensionFrameContext provides context for a custom frame.
type ExtensionFrameHandler ¶
type ExtensionFrameHandler interface {
HandleFrame(ctx ExtensionFrameContext) (int, error)
}
ExtensionFrameHandler allows parsing of custom frame types.
type HandshakeTimeoutError ¶
type HandshakeTimeoutError = qerr.HandshakeTimeoutError
HandshakeTimeoutError indicates that the connection timed out before completing the handshake.
type IdleTimeoutError ¶
type IdleTimeoutError = qerr.IdleTimeoutError
IdleTimeoutError indicates that the connection timed out because it was inactive for too long.
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
A Listener listens for incoming QUIC connections. It returns connections once the handshake has completed.
func Listen ¶
Listen listens for QUIC connections on a given net.PacketConn. If the PacketConn satisfies the OOBCapablePacketConn interface (as a net.UDPConn does), ECN and packet info support will be enabled. In this case, ReadMsgUDP and WriteMsgUDP will be used instead of ReadFrom and WriteTo to read/write packets. A single net.PacketConn can only be used for a single call to Listen.
The tls.Config must not be nil and must contain a certificate configuration. Furthermore, it must define an application control (using [NextProtos]). The quic.Config may be nil, in that case the default values will be used.
This is a convenience function. More advanced use cases should instantiate a Transport, which offers configuration options for a more fine-grained control of the connection establishment, including reusing the underlying UDP socket for outgoing QUIC connections. When closing a listener created with Listen, all established QUIC connections will be closed immediately.
func ListenAddr ¶
ListenAddr creates a QUIC server listening on a given address. See Listen for more details.
func (*Listener) Close ¶
Close closes the listener. Accept will return ErrServerClosed as soon as all connections in the accept queue have been accepted. QUIC handshakes that are still in flight will be rejected with a CONNECTION_REFUSED error. Already established (accepted) connections will be unaffected.
type LowLatencyScheduler ¶
type LowLatencyScheduler struct {
// contains filtered or unexported fields
}
LowLatencyScheduler implements a low-latency scheduling algorithm. It prefers paths with lower RTT for better latency.
func NewLowLatencyScheduler ¶
func NewLowLatencyScheduler() *LowLatencyScheduler
NewLowLatencyScheduler creates a new low-latency scheduler.
func (*LowLatencyScheduler) Reset ¶
func (s *LowLatencyScheduler) Reset()
Reset clears all quota counters.
func (*LowLatencyScheduler) SelectPath ¶
func (s *LowLatencyScheduler) SelectPath(paths []SchedulerPathInfo, hasRetransmission bool) *SchedulerPathInfo
SelectPath selects the path with the lowest RTT. For unprobed paths (RTT == 0), it uses quotas to distribute initial probing.
func (*LowLatencyScheduler) UpdateQuota ¶
func (s *LowLatencyScheduler) UpdateQuota(pathID PathID, packetSize ByteCount)
UpdateQuota increments the quota for a path after sending a packet.
type MinRTTScheduler ¶
type MinRTTScheduler struct {
// contains filtered or unexported fields
}
MinRTTScheduler implements a minimum RTT scheduling algorithm with smoothing. It uses a weighted approach to balance between RTT and path utilization.
func NewMinRTTScheduler ¶
func NewMinRTTScheduler(rttBias float64) *MinRTTScheduler
NewMinRTTScheduler creates a new minimum RTT scheduler. rttBias controls the trade-off between RTT optimization and load balancing: - 1.0: Pure minimum RTT (no load balancing) - 0.5: Balanced between RTT and load distribution - 0.0: Pure load balancing (ignores RTT)
func (*MinRTTScheduler) GetStatistics ¶
func (s *MinRTTScheduler) GetStatistics() map[PathID]SchedulerStats
GetStatistics returns scheduling statistics for monitoring and debugging.
func (*MinRTTScheduler) SelectPath ¶
func (s *MinRTTScheduler) SelectPath(paths []SchedulerPathInfo, hasRetransmission bool) *SchedulerPathInfo
SelectPath selects the path with the best score based on RTT and quota.
func (*MinRTTScheduler) UpdateQuota ¶
func (s *MinRTTScheduler) UpdateQuota(pathID PathID, packetSize ByteCount)
UpdateQuota updates statistics after sending a packet.
type MultiSocketManager ¶
type MultiSocketManager struct {
// contains filtered or unexported fields
}
MultiSocketManager manages multiple UDP sockets for multipath and hot-plug scenarios. It implements both net.PacketConn and rawConn, and can be used as Transport.Conn.
func NewMultiSocketManager ¶
func NewMultiSocketManager(cfg MultiSocketManagerConfig) (*MultiSocketManager, error)
NewMultiSocketManager creates a MultiSocketManager.
func (*MultiSocketManager) AddLocalAddr ¶
AddLocalAddr adds a new UDP socket bound to the given local IP.
func (*MultiSocketManager) Close ¶
func (m *MultiSocketManager) Close() error
func (*MultiSocketManager) LocalAddr ¶
func (m *MultiSocketManager) LocalAddr() net.Addr
func (*MultiSocketManager) LocalAddrs ¶
func (m *MultiSocketManager) LocalAddrs() []net.IP
LocalAddrs returns the list of managed local IPs.
func (*MultiSocketManager) ReadPacket ¶
func (m *MultiSocketManager) ReadPacket() (receivedPacket, error)
func (*MultiSocketManager) RefreshInterfaces ¶
func (m *MultiSocketManager) RefreshInterfaces() error
RefreshInterfaces scans system interfaces and syncs sockets.
func (*MultiSocketManager) RemoveLocalAddr ¶
func (m *MultiSocketManager) RemoveLocalAddr(ip net.IP) bool
RemoveLocalAddr removes and closes a socket bound to the given local IP.
func (*MultiSocketManager) SetDeadline ¶
func (m *MultiSocketManager) SetDeadline(t time.Time) error
func (*MultiSocketManager) SetLocalAddrs ¶
func (m *MultiSocketManager) SetLocalAddrs(addrs []net.IP) error
SetLocalAddrs synchronizes the managed sockets with the provided IP list.
func (*MultiSocketManager) SetReadDeadline ¶
func (m *MultiSocketManager) SetReadDeadline(t time.Time) error
func (*MultiSocketManager) SetWriteDeadline ¶
func (m *MultiSocketManager) SetWriteDeadline(t time.Time) error
func (*MultiSocketManager) WritePacket ¶
func (*MultiSocketManager) WritePacketWithInfo ¶
type MultiSocketManagerConfig ¶
type MultiSocketManagerConfig struct {
// BaseConn is the primary socket. If nil, a UDP socket is opened on 0.0.0.0:0.
BaseConn net.PacketConn
// ListenPort is the port to bind new sockets to. 0 uses an ephemeral port.
ListenPort int
// LocalAddrs are the local IPs to bind new sockets to.
LocalAddrs []net.IP
// RefreshInterval enables periodic interface refresh. 0 disables it.
RefreshInterval time.Duration
// IncludeLoopback enables loopback interface addresses in refresh.
IncludeLoopback bool
// AllowIPv6 enables IPv6 addresses in refresh.
AllowIPv6 bool
// Logger defaults to utils.DefaultLogger if nil.
Logger utils.Logger
}
MultiSocketManagerConfig controls MultiSocketManager behavior.
type MultipathController ¶
type MultipathController interface {
SelectPath(PathSelectionContext) (PathInfo, bool)
PathIDForPacket(remoteAddr, localAddr net.Addr) (PathID, bool)
}
MultipathController selects paths and maps received packets to paths.
type MultipathDuplicationPolicy ¶
type MultipathDuplicationPolicy struct {
// contains filtered or unexported fields
}
MultipathDuplicationPolicy defines when and how to duplicate packets across paths
func NewMultipathDuplicationPolicy ¶
func NewMultipathDuplicationPolicy() *MultipathDuplicationPolicy
NewMultipathDuplicationPolicy creates a new duplication policy with defaults
func (*MultipathDuplicationPolicy) AddStreamForDuplication ¶
func (p *MultipathDuplicationPolicy) AddStreamForDuplication(streamID protocol.StreamID)
AddStreamForDuplication marks a stream for packet duplication
func (*MultipathDuplicationPolicy) Disable ¶
func (p *MultipathDuplicationPolicy) Disable()
Disable disables packet duplication
func (*MultipathDuplicationPolicy) Enable ¶
func (p *MultipathDuplicationPolicy) Enable()
Enable enables packet duplication
func (*MultipathDuplicationPolicy) GetDuplicatePathCount ¶
func (p *MultipathDuplicationPolicy) GetDuplicatePathCount() int
GetDuplicatePathCount returns how many paths to use for duplication
func (*MultipathDuplicationPolicy) IsEnabled ¶
func (p *MultipathDuplicationPolicy) IsEnabled() bool
IsEnabled returns whether duplication is enabled
func (*MultipathDuplicationPolicy) RemoveStreamForDuplication ¶
func (p *MultipathDuplicationPolicy) RemoveStreamForDuplication(streamID protocol.StreamID)
RemoveStreamForDuplication removes a stream from duplication
func (*MultipathDuplicationPolicy) SetDuplicateCryptoFrames ¶
func (p *MultipathDuplicationPolicy) SetDuplicateCryptoFrames(enable bool)
SetDuplicateCryptoFrames sets whether to duplicate crypto frames
func (*MultipathDuplicationPolicy) SetDuplicatePathCount ¶
func (p *MultipathDuplicationPolicy) SetDuplicatePathCount(count int)
SetDuplicatePathCount sets how many paths to use for duplication
func (*MultipathDuplicationPolicy) SetDuplicateResets ¶
func (p *MultipathDuplicationPolicy) SetDuplicateResets(enable bool)
SetDuplicateResets sets whether to duplicate reset frames
func (*MultipathDuplicationPolicy) ShouldDuplicateCrypto ¶
func (p *MultipathDuplicationPolicy) ShouldDuplicateCrypto() bool
ShouldDuplicateCrypto returns whether crypto frames should be duplicated
func (*MultipathDuplicationPolicy) ShouldDuplicateReset ¶
func (p *MultipathDuplicationPolicy) ShouldDuplicateReset() bool
ShouldDuplicateReset returns whether RST_STREAM frames should be duplicated
func (*MultipathDuplicationPolicy) ShouldDuplicateStream ¶
func (p *MultipathDuplicationPolicy) ShouldDuplicateStream(streamID protocol.StreamID) bool
ShouldDuplicateStream returns whether frames for this stream should be duplicated
type MultipathObserver ¶
type MultipathObserver interface {
OnPacketSent(PathEvent)
OnPacketAcked(PathEvent)
OnPacketLost(PathEvent)
}
MultipathObserver receives per-packet events with path information.
type MultipathPath ¶
type MultipathPath struct {
// PathID uniquely identifies this path
PathID protocol.PathID
// LocalAddr is the local address for this path
LocalAddr net.Addr
// RemoteAddr is the remote address for this path
RemoteAddr net.Addr
// State is the current path state
State MultipathPathState
// CreatedAt is when the path was created
CreatedAt time.Time
// LastUsed is when the path was last used to send data
LastUsed time.Time
// BytesSent tracks total bytes sent on this path
BytesSent uint64
// BytesReceived tracks total bytes received on this path
BytesReceived uint64
// RTT is the current round-trip time (populated from RTT stats)
RTT time.Duration
// Validated indicates if the path has been validated
Validated bool
}
MultipathPath represents a single path in a multipath connection
type MultipathPathManager ¶
type MultipathPathManager struct {
// contains filtered or unexported fields
}
MultipathPathManager manages multiple paths in a multipath connection
func NewMultipathPathManager ¶
func NewMultipathPathManager(perspective protocol.Perspective) *MultipathPathManager
NewMultipathPathManager creates a new multipath path manager
func (*MultipathPathManager) ActivatePath ¶
func (pm *MultipathPathManager) ActivatePath(pathID protocol.PathID) bool
ActivatePath marks a path as active
func (*MultipathPathManager) AddPath ¶
func (pm *MultipathPathManager) AddPath(localAddr, remoteAddr net.Addr) protocol.PathID
AddPath adds a new path to the manager
func (*MultipathPathManager) ClosePath ¶
func (pm *MultipathPathManager) ClosePath(pathID protocol.PathID)
ClosePath closes a path
func (*MultipathPathManager) EnableMultipath ¶
func (pm *MultipathPathManager) EnableMultipath()
EnableMultipath enables multipath support
func (*MultipathPathManager) GetActivePathCount ¶
func (pm *MultipathPathManager) GetActivePathCount() int
GetActivePathCount returns the number of active paths
func (*MultipathPathManager) GetActivePaths ¶
func (pm *MultipathPathManager) GetActivePaths() []*MultipathPath
GetActivePaths returns a slice of all active paths
func (*MultipathPathManager) GetAllPaths ¶
func (pm *MultipathPathManager) GetAllPaths() []*MultipathPath
GetAllPaths returns all paths
func (*MultipathPathManager) GetPath ¶
func (pm *MultipathPathManager) GetPath(pathID protocol.PathID) *MultipathPath
GetPath returns a path by ID
func (*MultipathPathManager) GetPathCount ¶
func (pm *MultipathPathManager) GetPathCount() int
GetPathCount returns the total number of paths
func (*MultipathPathManager) GetPrimaryPathID ¶
func (pm *MultipathPathManager) GetPrimaryPathID() protocol.PathID
GetPrimaryPathID returns the primary path ID
func (*MultipathPathManager) HandleAddAddressFrame ¶
func (pm *MultipathPathManager) HandleAddAddressFrame(frame *wire.AddAddressFrame)
HandleAddAddressFrame processes an ADD_ADDRESS frame
func (*MultipathPathManager) HandleClosePathFrame ¶
func (pm *MultipathPathManager) HandleClosePathFrame(frame *wire.ClosePathFrame)
HandleClosePathFrame processes a CLOSE_PATH frame
func (*MultipathPathManager) IsMultipathEnabled ¶
func (pm *MultipathPathManager) IsMultipathEnabled() bool
IsMultipathEnabled returns whether multipath is enabled
func (*MultipathPathManager) RecordPathUsage ¶
func (pm *MultipathPathManager) RecordPathUsage(pathID protocol.PathID, bytesSent uint64)
RecordPathUsage updates usage statistics for a path
func (*MultipathPathManager) SetPrimaryPath ¶
func (pm *MultipathPathManager) SetPrimaryPath(localAddr, remoteAddr net.Addr)
SetPrimaryPath sets the primary path (usually path 0)
func (*MultipathPathManager) UpdatePathRTT ¶
func (pm *MultipathPathManager) UpdatePathRTT(pathID protocol.PathID, rtt time.Duration)
UpdatePathRTT updates the RTT for a path
func (*MultipathPathManager) ValidatePath ¶
func (pm *MultipathPathManager) ValidatePath(pathID protocol.PathID)
ValidatePath marks a path as validated
type MultipathPathState ¶
type MultipathPathState int
MultipathPathState represents the current state of a path in multipath mode
const ( // MultipathPathStateUnknown indicates path state is not yet determined MultipathPathStateUnknown MultipathPathState = iota // MultipathPathStateValidating indicates path is being validated MultipathPathStateValidating // MultipathPathStateActive indicates path is active and can send data MultipathPathStateActive // MultipathPathStateStandby indicates path is available but not actively used MultipathPathStateStandby // MultipathPathStateClosing indicates path is being closed MultipathPathStateClosing // MultipathPathStateClosed indicates path is closed MultipathPathStateClosed )
type MultipathReinjectionManager ¶
type MultipathReinjectionManager struct {
// contains filtered or unexported fields
}
MultipathReinjectionManager manages packet reinjection across paths
func NewMultipathReinjectionManager ¶
func NewMultipathReinjectionManager(policy *MultipathReinjectionPolicy) *MultipathReinjectionManager
NewMultipathReinjectionManager creates a new reinjection manager
func (*MultipathReinjectionManager) GetPendingReinjections ¶
func (m *MultipathReinjectionManager) GetPendingReinjections(now time.Time) []*PacketReinjectionInfo
GetPendingReinjections returns packets ready for reinjection
func (*MultipathReinjectionManager) GetStatistics ¶
func (m *MultipathReinjectionManager) GetStatistics() (pending, reinjected int)
GetStatistics returns reinjection statistics
func (*MultipathReinjectionManager) MarkReinjected ¶
func (m *MultipathReinjectionManager) MarkReinjected(pn protocol.PacketNumber, targetPath protocol.PathID)
MarkReinjected marks a packet as having been reinjected
func (*MultipathReinjectionManager) OnPacketAcked ¶
func (m *MultipathReinjectionManager) OnPacketAcked(pn protocol.PacketNumber)
OnPacketAcked is called when a packet is acknowledged, removing it from tracking
func (*MultipathReinjectionManager) OnPacketLost ¶
func (m *MultipathReinjectionManager) OnPacketLost( pathID protocol.PathID, pn protocol.PacketNumber, encLevel protocol.EncryptionLevel, frames []ackhandler.Frame, )
OnPacketLost is called when a packet is lost and should be considered for reinjection
func (*MultipathReinjectionManager) Reset ¶
func (m *MultipathReinjectionManager) Reset()
Reset clears all reinjection state
type MultipathReinjectionPolicy ¶
type MultipathReinjectionPolicy struct {
// contains filtered or unexported fields
}
MultipathReinjectionPolicy defines when and how to reinject lost packets on alternate paths
func NewMultipathReinjectionPolicy ¶
func NewMultipathReinjectionPolicy() *MultipathReinjectionPolicy
NewMultipathReinjectionPolicy creates a new reinjection policy with defaults
func (*MultipathReinjectionPolicy) AddPreferredPathForReinjection ¶
func (p *MultipathReinjectionPolicy) AddPreferredPathForReinjection(pathID protocol.PathID)
AddPreferredPathForReinjection adds a path to the preferred list
func (*MultipathReinjectionPolicy) Disable ¶
func (p *MultipathReinjectionPolicy) Disable()
Disable disables packet reinjection
func (*MultipathReinjectionPolicy) Enable ¶
func (p *MultipathReinjectionPolicy) Enable()
Enable enables packet reinjection
func (*MultipathReinjectionPolicy) GetMaxReinjectionQueuePerPath ¶
func (p *MultipathReinjectionPolicy) GetMaxReinjectionQueuePerPath() int
GetMaxReinjectionQueuePerPath returns the maximum queue size per target path
func (*MultipathReinjectionPolicy) GetMaxReinjections ¶
func (p *MultipathReinjectionPolicy) GetMaxReinjections() int
GetMaxReinjections returns the maximum number of reinjections
func (*MultipathReinjectionPolicy) GetMinReinjectionInterval ¶
func (p *MultipathReinjectionPolicy) GetMinReinjectionInterval() time.Duration
GetMinReinjectionInterval returns the minimum reinjection interval
func (*MultipathReinjectionPolicy) GetReinjectionDelay ¶
func (p *MultipathReinjectionPolicy) GetReinjectionDelay() time.Duration
GetReinjectionDelay returns the current reinjection delay
func (*MultipathReinjectionPolicy) IsEnabled ¶
func (p *MultipathReinjectionPolicy) IsEnabled() bool
IsEnabled returns whether reinjection is enabled
func (*MultipathReinjectionPolicy) IsPreferredPathForReinjection ¶
func (p *MultipathReinjectionPolicy) IsPreferredPathForReinjection(pathID protocol.PathID) bool
IsPreferredPathForReinjection checks if a path is preferred for reinjection
func (*MultipathReinjectionPolicy) RemovePreferredPathForReinjection ¶
func (p *MultipathReinjectionPolicy) RemovePreferredPathForReinjection(pathID protocol.PathID)
RemovePreferredPathForReinjection removes a path from the preferred list
func (*MultipathReinjectionPolicy) SetMaxReinjectionQueuePerPath ¶
func (p *MultipathReinjectionPolicy) SetMaxReinjectionQueuePerPath(max int)
SetMaxReinjectionQueuePerPath sets the maximum queue size per target path (0 = unlimited)
func (*MultipathReinjectionPolicy) SetMaxReinjections ¶
func (p *MultipathReinjectionPolicy) SetMaxReinjections(max int)
SetMaxReinjections sets the maximum number of reinjections per packet
func (*MultipathReinjectionPolicy) SetMinReinjectionInterval ¶
func (p *MultipathReinjectionPolicy) SetMinReinjectionInterval(interval time.Duration)
SetMinReinjectionInterval sets a minimum interval between reinjections on the same path
func (*MultipathReinjectionPolicy) SetReinjectionDelay ¶
func (p *MultipathReinjectionPolicy) SetReinjectionDelay(delay time.Duration)
SetReinjectionDelay sets the delay before reinjecting a lost packet
func (*MultipathReinjectionPolicy) ShouldReinjectFrame ¶
func (p *MultipathReinjectionPolicy) ShouldReinjectFrame(frame wire.Frame) bool
ShouldReinjectFrame determines if a frame should be reinjected
type MultipathReinjectionTargetSelector ¶
type MultipathReinjectionTargetSelector interface {
SelectReinjectionTarget(ReinjectionTargetContext) (PathID, bool)
}
MultipathReinjectionTargetSelector allows overriding reinjection target selection. Implement this on your MultipathController to customize reinjection path choice.
type MultipathScheduler ¶
type MultipathScheduler interface {
MultipathController
// GetScheduler returns the underlying PathScheduler if available.
GetScheduler() PathScheduler
}
MultipathScheduler provides advanced path scheduling capabilities. This is an optional extension to MultipathController.
type OLIACongestionControl ¶
type OLIACongestionControl struct {
// contains filtered or unexported fields
}
OLIACongestionControl implements the OLIA (Opportunistic Linked-Increase Algorithm) congestion control for multipath connections. OLIA provides coupled congestion control across multiple paths to ensure fairness and performance.
Reference: "MPTCP is not Pareto-optimal: performance issues and a possible solution" by R. Khalili et al., CoNEXT 2012
func NewOLIACongestionControl ¶
func NewOLIACongestionControl( pathID protocol.PathID, sharedState *oliaSharedState, maxDatagramSize protocol.ByteCount, ) *OLIACongestionControl
NewOLIACongestionControl creates a new OLIA congestion controller for a path.
func (*OLIACongestionControl) CanSend ¶
func (o *OLIACongestionControl) CanSend(bytesInFlight protocol.ByteCount) bool
CanSend returns whether a packet can be sent.
func (*OLIACongestionControl) GetCongestionWindow ¶
func (o *OLIACongestionControl) GetCongestionWindow() protocol.ByteCount
GetCongestionWindow returns the current congestion window.
func (*OLIACongestionControl) GetStatistics ¶
func (o *OLIACongestionControl) GetStatistics() OLIAStatistics
GetStatistics returns congestion control statistics.
func (*OLIACongestionControl) InRecovery ¶
func (o *OLIACongestionControl) InRecovery() bool
InRecovery returns whether the connection is in recovery mode.
func (*OLIACongestionControl) InSlowStart ¶
func (o *OLIACongestionControl) InSlowStart() bool
InSlowStart returns whether the connection is in slow start.
func (*OLIACongestionControl) OnCongestionEvent ¶
func (o *OLIACongestionControl) OnCongestionEvent( packetNumber protocol.PacketNumber, lostBytes protocol.ByteCount, priorInFlight protocol.ByteCount, )
OnCongestionEvent is called when congestion is detected (packet loss).
func (*OLIACongestionControl) OnPacketAcked ¶
func (o *OLIACongestionControl) OnPacketAcked( packetNumber protocol.PacketNumber, ackedBytes protocol.ByteCount, bytesInFlight protocol.ByteCount, eventTime time.Time, )
OnPacketAcked is called when a packet is acknowledged.
func (*OLIACongestionControl) OnPacketLost ¶
func (o *OLIACongestionControl) OnPacketLost( packetNumber protocol.PacketNumber, lostBytes protocol.ByteCount, priorInFlight protocol.ByteCount, )
OnPacketLost is called when a packet is declared lost.
func (*OLIACongestionControl) OnPacketSent ¶
func (o *OLIACongestionControl) OnPacketSent( sentTime time.Time, packetNumber protocol.PacketNumber, bytes protocol.ByteCount, isRetransmittable bool, )
OnPacketSent is called when a packet is sent.
func (*OLIACongestionControl) OnRetransmissionTimeout ¶
func (o *OLIACongestionControl) OnRetransmissionTimeout(packetsRetransmitted bool)
OnRetransmissionTimeout is called on an retransmission timeout.
func (*OLIACongestionControl) Reset ¶
func (o *OLIACongestionControl) Reset()
Reset resets the congestion control state.
func (*OLIACongestionControl) SetMaxDatagramSize ¶
func (o *OLIACongestionControl) SetMaxDatagramSize(size protocol.ByteCount)
SetMaxDatagramSize updates the maximum datagram size.
func (*OLIACongestionControl) SmoothedBytesBetweenLosses ¶
func (o *OLIACongestionControl) SmoothedBytesBetweenLosses() protocol.ByteCount
SmoothedBytesBetweenLosses returns smoothed bytes between losses.
func (*OLIACongestionControl) Unregister ¶
func (o *OLIACongestionControl) Unregister()
Unregister removes this path from shared state.
func (*OLIACongestionControl) UpdateRTT ¶
func (o *OLIACongestionControl) UpdateRTT(rtt, minRTT time.Duration)
UpdateRTT updates the RTT estimate for this path.
type OLIAStatistics ¶
type OLIAStatistics struct {
PathID protocol.PathID
CongestionWindow protocol.ByteCount
SlowStartThreshold protocol.ByteCount
BytesInFlight protocol.ByteCount
InSlowStart bool
EpsilonNum int
EpsilonDen uint32
RTT time.Duration
}
OLIAStatistics contains statistics for OLIA congestion control.
type OOBCapablePacketConn ¶
type OOBCapablePacketConn interface {
net.PacketConn
SyscallConn() (syscall.RawConn, error)
SetReadBuffer(int) error
ReadMsgUDP(b, oob []byte) (n, oobn, flags int, addr *net.UDPAddr, err error)
WriteMsgUDP(b, oob []byte, addr *net.UDPAddr) (n, oobn int, err error)
}
OOBCapablePacketConn is a connection that allows the reading of ECN bits from the IP header. If the PacketConn passed to the Transport satisfies this interface, quic-go will use it. In this case, ReadMsgUDP() will be used instead of ReadFrom() to read packets.
type PacketReinjectionInfo ¶
type PacketReinjectionInfo struct {
OriginalPathID protocol.PathID
PacketNumber protocol.PacketNumber
EncryptionLevel protocol.EncryptionLevel
Frames []ackhandler.Frame
LostTime time.Time
NextAttemptAt time.Time
ReinjectionCount int
LastReinjectedAt time.Time
TargetPathID protocol.PathID
}
PacketReinjectionInfo tracks information about a packet pending reinjection
type Path ¶
type Path struct {
// contains filtered or unexported fields
}
Path is a network path.
type PathEvent ¶
type PathEvent struct {
PathID PathID
PacketNumber PacketNumber
PacketSize ByteCount
EncryptionLevel EncryptionLevel
AckEliciting bool
IsPathProbe bool
IsPathMTUProbe bool
IsDuplicate bool // True if this is a duplicate packet
SentAt time.Time
EventAt time.Time
SmoothedRTT time.Duration
RTTVar time.Duration
}
PathEvent reports a packet lifecycle event for a specific path.
type PathID ¶
PathID identifies a network path.
const InvalidPathID PathID = protocol.InvalidPathID
InvalidPathID represents an unspecified path.
type PathScheduler ¶
type PathScheduler interface {
// SelectPath selects the best path for sending a packet.
// It returns nil if no path is available for sending.
SelectPath(paths []SchedulerPathInfo, hasRetransmission bool) *SchedulerPathInfo
// UpdateQuota is called after a packet is sent on a path.
UpdateQuota(pathID PathID, packetSize ByteCount)
// Reset resets the scheduler state.
Reset()
}
PathScheduler defines the interface for multipath scheduling algorithms. A PathScheduler decides which path to use for sending the next packet.
type PathSchedulerWrapper ¶
type PathSchedulerWrapper struct {
// contains filtered or unexported fields
}
PathSchedulerWrapper integrates the path manager with scheduling algorithms
func NewMultipathScheduler ¶
func NewMultipathScheduler(pm *MultipathPathManager, policy SchedulingPolicy) *PathSchedulerWrapper
NewMultipathScheduler creates a new multipath scheduler
func (*PathSchedulerWrapper) AddPath ¶
func (s *PathSchedulerWrapper) AddPath(info PathInfo) (PathID, bool)
AddPath adds a new path and returns the assigned path ID.
func (*PathSchedulerWrapper) DisableMultipath ¶
func (s *PathSchedulerWrapper) DisableMultipath()
DisableMultipath disables multipath support
func (*PathSchedulerWrapper) EnableMultipath ¶
func (s *PathSchedulerWrapper) EnableMultipath()
EnableMultipath enables multipath support
func (*PathSchedulerWrapper) GetAvailablePaths ¶
func (s *PathSchedulerWrapper) GetAvailablePaths() []PathInfo
GetAvailablePaths returns active paths suitable for scheduling.
func (*PathSchedulerWrapper) HandleAddAddressFrame ¶
func (s *PathSchedulerWrapper) HandleAddAddressFrame(frame *wire.AddAddressFrame)
HandleAddAddressFrame forwards ADD_ADDRESS frames to the path manager.
func (*PathSchedulerWrapper) HandleClosePathFrame ¶
func (s *PathSchedulerWrapper) HandleClosePathFrame(frame *wire.ClosePathFrame)
HandleClosePathFrame forwards CLOSE_PATH frames to the path manager.
func (*PathSchedulerWrapper) HandlePathsFrame ¶
func (s *PathSchedulerWrapper) HandlePathsFrame(frame *wire.PathsFrame)
HandlePathsFrame forwards PATHS frames to the path manager.
func (*PathSchedulerWrapper) IsMultipathEnabled ¶
func (s *PathSchedulerWrapper) IsMultipathEnabled() bool
IsMultipathEnabled returns whether multipath is enabled
func (*PathSchedulerWrapper) OnPacketAcked ¶
func (s *PathSchedulerWrapper) OnPacketAcked(ev PathEvent)
OnPacketAcked updates RTT statistics for a path.
func (*PathSchedulerWrapper) OnPacketLost ¶
func (s *PathSchedulerWrapper) OnPacketLost(ev PathEvent)
OnPacketLost is a no-op for scheduler wrapper.
func (*PathSchedulerWrapper) OnPacketSent ¶
func (s *PathSchedulerWrapper) OnPacketSent(ev PathEvent)
OnPacketSent updates scheduler and path statistics.
func (*PathSchedulerWrapper) PathIDForPacket ¶
func (s *PathSchedulerWrapper) PathIDForPacket(remoteAddr, localAddr net.Addr) (PathID, bool)
PathIDForPacket implements MultipathController interface
func (*PathSchedulerWrapper) PathInfoForID ¶
func (s *PathSchedulerWrapper) PathInfoForID(pathID PathID) (PathInfo, bool)
PathInfoForID returns path information for a given ID.
func (*PathSchedulerWrapper) RecordSent ¶
func (s *PathSchedulerWrapper) RecordSent(pathID protocol.PathID, packetSize uint64)
RecordSent updates scheduler state after sending a packet
func (*PathSchedulerWrapper) RegisterPath ¶
func (s *PathSchedulerWrapper) RegisterPath(info PathInfo)
RegisterPath registers the primary path for scheduling.
func (*PathSchedulerWrapper) SelectPath ¶
func (s *PathSchedulerWrapper) SelectPath(ctx PathSelectionContext) (PathInfo, bool)
SelectPath implements MultipathController interface
func (*PathSchedulerWrapper) ValidatePath ¶
func (s *PathSchedulerWrapper) ValidatePath(pathID PathID)
ValidatePath marks a path as validated and active.
type PathSelectionContext ¶
type PathSelectionContext struct {
Now time.Time
AckOnly bool
HasRetransmission bool
BytesInFlight ByteCount
}
PathSelectionContext provides context for path selection.
type PathStateUpdate ¶
type PathStateUpdate struct {
SendingAllowed *bool
CongestionLimited *bool
BytesInFlight *ByteCount
CongestionWindow *ByteCount
SmoothedRTT *time.Duration
RTTVar *time.Duration
PotentiallyFailed *bool
Validated *bool
}
PathStateUpdate contains optional updates for path state.
type PathStatistics ¶
type PathStatistics struct {
PathID PathID
PacketsSent uint64
BytesSent ByteCount
PacketsLost uint64
PacketsRetransmitted uint64
SmoothedRTT time.Duration
RTTVar time.Duration
CongestionWindow ByteCount
BytesInFlight ByteCount
LastPacketTime time.Time
}
PathStatistics contains statistics for a path.
type RawFrame ¶
type RawFrame struct {
FrameType uint64
Data []byte // payload without the frame type varint
NonAckEliciting bool
RetransmitOnLoss bool
OnAcked func()
OnLost func()
}
RawFrame represents a custom frame payload with optional callbacks.
type ReceiveStream ¶
type ReceiveStream struct {
// contains filtered or unexported fields
}
A ReceiveStream is a unidirectional Receive Stream.
func (*ReceiveStream) CancelRead ¶
func (s *ReceiveStream) CancelRead(errorCode StreamErrorCode)
CancelRead aborts receiving on this stream. It instructs the peer to stop transmitting stream data. Read will unblock immediately, and future Read calls will fail. When called multiple times or after reading the io.EOF it is a no-op.
func (*ReceiveStream) Peek ¶
func (s *ReceiveStream) Peek(b []byte) (int, error)
Peek fills b with stream data, without consuming the stream data. It blocks until len(b) bytes are available, or an error occurs. It respects the stream deadline set by SetReadDeadline. If the stream ends before len(b) bytes are available, it returns the number of bytes peeked along with io.EOF.
func (*ReceiveStream) Read ¶
func (s *ReceiveStream) Read(p []byte) (int, error)
Read reads data from the stream. Read can be made to time out using ReceiveStream.SetReadDeadline. If the stream was canceled, the error is a StreamError.
func (*ReceiveStream) SetReadDeadline ¶
func (s *ReceiveStream) SetReadDeadline(t time.Time) error
SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out.
func (*ReceiveStream) StreamID ¶
func (s *ReceiveStream) StreamID() protocol.StreamID
StreamID returns the stream ID.
type ReinjectionTargetContext ¶
type ReinjectionTargetContext struct {
Now time.Time
OriginalPathID PathID
Candidates []PathInfo
Packet *PacketReinjectionInfo
}
ReinjectionTargetContext provides context for selecting a reinjection target.
type RoundRobinScheduler ¶
type RoundRobinScheduler struct {
// contains filtered or unexported fields
}
RoundRobinScheduler implements a round-robin scheduling algorithm with quotas. It distributes packets evenly across all available paths.
func NewRoundRobinScheduler ¶
func NewRoundRobinScheduler() *RoundRobinScheduler
NewRoundRobinScheduler creates a new round-robin scheduler.
func (*RoundRobinScheduler) Reset ¶
func (s *RoundRobinScheduler) Reset()
Reset clears all quota counters.
func (*RoundRobinScheduler) SelectPath ¶
func (s *RoundRobinScheduler) SelectPath(paths []SchedulerPathInfo, hasRetransmission bool) *SchedulerPathInfo
SelectPath selects the path with the lowest quota.
func (*RoundRobinScheduler) UpdateQuota ¶
func (s *RoundRobinScheduler) UpdateQuota(pathID PathID, packetSize ByteCount)
UpdateQuota increments the quota for a path after sending a packet.
type SchedulerPathInfo ¶
type SchedulerPathInfo struct {
PathID PathID
RemoteAddr string
SendingAllowed bool
CongestionLimited bool
BytesInFlight ByteCount
CongestionWindow ByteCount
SmoothedRTT time.Duration
RTTVar time.Duration
PotentiallyFailed bool
PacketsSent uint64
BytesSent ByteCount
PacketsLost uint64
PacketsRetransmitted uint64
}
SchedulerPathInfo contains information about a path for scheduling decisions.
type SchedulerStats ¶
SchedulerStats contains statistics for a single path.
type SchedulingPolicy ¶
type SchedulingPolicy int
SchedulingPolicy defines the scheduling algorithm to use
const ( SchedulingPolicyRoundRobin SchedulingPolicy = iota SchedulingPolicyMinRTT SchedulingPolicyLowLatency )
type SendStream ¶
type SendStream struct {
// contains filtered or unexported fields
}
A SendStream is a unidirectional Send Stream.
func (*SendStream) CancelWrite ¶
func (s *SendStream) CancelWrite(errorCode StreamErrorCode)
CancelWrite aborts sending on this stream. Data already written, but not yet delivered to the peer is not guaranteed to be delivered reliably. Write will unblock immediately, and future calls to Write will fail. When called multiple times it is a no-op. When called after Close, it aborts reliable delivery of outstanding stream data. Note that there is no guarantee if the peer will receive the FIN or the cancellation error first.
func (*SendStream) Close ¶
func (s *SendStream) Close() error
Close closes the write-direction of the stream. Future calls to Write are not permitted after calling Close. It must not be called concurrently with Write. It must not be called after calling CancelWrite.
func (*SendStream) Context ¶
func (s *SendStream) Context() context.Context
The Context is canceled as soon as the write-side of the stream is closed. This happens when Close() or CancelWrite() is called, or when the peer cancels the read-side of their stream. The cancellation cause is set to the error that caused the stream to close, or `context.Canceled` in case the stream is closed without error.
func (*SendStream) SetReliableBoundary ¶
func (s *SendStream) SetReliableBoundary()
SetReliableBoundary marks the data written to this stream so far as reliable. It is valid to call this function multiple times, thereby increasing the reliable size. It only has an effect if the peer enabled support for the RESET_STREAM_AT extension, otherwise, it is a no-op.
func (*SendStream) SetWriteDeadline ¶
func (s *SendStream) SetWriteDeadline(t time.Time) error
SetWriteDeadline sets the deadline for future Write calls and any currently-blocked Write call. Even if write times out, it may return n > 0, indicating that some data was successfully written. A zero value for t means Write will not time out.
func (*SendStream) StreamID ¶
func (s *SendStream) StreamID() StreamID
StreamID returns the stream ID.
func (*SendStream) Write ¶
func (s *SendStream) Write(p []byte) (int, error)
Write writes data to the stream. Write can be made to time out using SendStream.SetWriteDeadline. If the stream was canceled, the error is a StreamError.
type StatelessResetError ¶
type StatelessResetError = qerr.StatelessResetError
StatelessResetError indicates a stateless reset was received. This can happen when the peer reboots, or when packets are misrouted. See section 10.3 of RFC 9000 for details.
type StatelessResetKey ¶
type StatelessResetKey [32]byte
StatelessResetKey is a key used to derive stateless reset tokens.
type Stream ¶
type Stream struct {
// contains filtered or unexported fields
}
func (*Stream) CancelRead ¶
func (s *Stream) CancelRead(errorCode StreamErrorCode)
CancelRead aborts receiving on this stream. See ReceiveStream.CancelRead for more details.
func (*Stream) CancelWrite ¶
func (s *Stream) CancelWrite(errorCode StreamErrorCode)
CancelWrite aborts sending on this stream. See SendStream.CancelWrite for more details.
func (*Stream) Close ¶
Close closes the send-direction of the stream. It does not close the receive-direction of the stream.
func (*Stream) Context ¶
The Context is canceled as soon as the write-side of the stream is closed. See SendStream.Context for more details.
func (*Stream) Peek ¶
Peek fills b with stream data, without consuming the stream data. It blocks until len(b) bytes are available, or an error occurs. It respects the stream deadline set by SetReadDeadline. If the stream ends before len(b) bytes are available, it returns the number of bytes peeked along with io.EOF.
func (*Stream) Read ¶
Read reads data from the stream. Read can be made to time out using Stream.SetReadDeadline and Stream.SetDeadline. If the stream was canceled, the error is a StreamError.
func (*Stream) SetDeadline ¶
SetDeadline sets the read and write deadlines associated with the stream. It is equivalent to calling both SetReadDeadline and SetWriteDeadline.
func (*Stream) SetReadDeadline ¶
SetReadDeadline sets the deadline for future Read calls. See ReceiveStream.SetReadDeadline for more details.
func (*Stream) SetReliableBoundary ¶
func (s *Stream) SetReliableBoundary()
SetReliableBoundary marks the data written to this stream so far as reliable. It is valid to call this function multiple times, thereby increasing the reliable size. It only has an effect if the peer enabled support for the RESET_STREAM_AT extension, otherwise, it is a no-op.
func (*Stream) SetWriteDeadline ¶
SetWriteDeadline sets the deadline for future Write calls. See SendStream.SetWriteDeadline for more details.
func (*Stream) Write ¶
Write writes data to the stream. Write can be made to time out using Stream.SetWriteDeadline or Stream.SetDeadline. If the stream was canceled, the error is a StreamError.
type StreamError ¶
type StreamError struct {
StreamID StreamID
ErrorCode StreamErrorCode
Remote bool
}
A StreamError is used to signal stream cancellations. It is returned from the Read and Write methods of the ReceiveStream, SendStream and Stream.
func (*StreamError) Error ¶
func (e *StreamError) Error() string
func (*StreamError) Is ¶
func (e *StreamError) Is(target error) bool
type StreamErrorCode ¶
type StreamErrorCode = qerr.StreamErrorCode
StreamErrorCode is a QUIC stream error code. The meaning of the value is defined by the application.
type StreamLimitReachedError ¶
type StreamLimitReachedError struct{}
StreamLimitReachedError is returned from Conn.OpenStream and Conn.OpenUniStream when it is not possible to open a new stream because the number of opens streams reached the peer's stream limit.
func (StreamLimitReachedError) Error ¶
func (e StreamLimitReachedError) Error() string
type TokenGeneratorKey ¶
type TokenGeneratorKey = handshake.TokenProtectorKey
TokenGeneratorKey is a key used to encrypt session resumption tokens.
type TokenStore ¶
type TokenStore interface {
// Pop searches for a ClientToken associated with the given key.
// Since tokens are not supposed to be reused, it must remove the token from the cache.
// It returns nil when no token is found.
Pop(key string) (token *ClientToken)
// Put adds a token to the cache with the given key. It might get called
// multiple times in a connection.
Put(key string, token *ClientToken)
}
func NewLRUTokenStore ¶
func NewLRUTokenStore(maxOrigins, tokensPerOrigin int) TokenStore
NewLRUTokenStore creates a new LRU cache for tokens received by the client. maxOrigins specifies how many origins this cache is saving tokens for. tokensPerOrigin specifies the maximum number of tokens per origin.
type Transport ¶
type Transport struct {
// A single net.PacketConn can only be handled by one Transport.
// Bad things will happen if passed to multiple Transports.
//
// A number of optimizations will be enabled if the connections implements the OOBCapablePacketConn interface,
// as a *net.UDPConn does.
// 1. It enables the Don't Fragment (DF) bit on the IP header.
// This is required to run DPLPMTUD (Path MTU Discovery, RFC 8899).
// 2. It enables reading of the ECN bits from the IP header.
// This allows the remote node to speed up its loss detection and recovery.
// 3. It uses batched syscalls (recvmmsg) to more efficiently receive packets from the socket.
// 4. It uses Generic Segmentation Offload (GSO) to efficiently send batches of packets (on Linux).
//
// After passing the connection to the Transport, it's invalid to call ReadFrom or WriteTo on the connection.
Conn net.PacketConn
// The length of the connection ID in bytes.
// It can be any value between 1 and 20.
// Due to the increased risk of collisions, it is not recommended to use connection IDs shorter than 4 bytes.
// If unset, a 4 byte connection ID will be used.
ConnectionIDLength int
// Use for generating new connection IDs.
// This allows the application to control of the connection IDs used,
// which allows routing / load balancing based on connection IDs.
// All Connection IDs returned by the ConnectionIDGenerator MUST
// have the same length.
ConnectionIDGenerator ConnectionIDGenerator
// The StatelessResetKey is used to generate stateless reset tokens.
// If no key is configured, sending of stateless resets is disabled.
// It is highly recommended to configure a stateless reset key, as stateless resets
// allow the peer to quickly recover from crashes and reboots of this node.
// See section 10.3 of RFC 9000 for details.
StatelessResetKey *StatelessResetKey
// The TokenGeneratorKey is used to encrypt session resumption tokens.
// If no key is configured, a random key will be generated.
// If multiple servers are authoritative for the same domain, they should use the same key,
// see section 8.1.3 of RFC 9000 for details.
TokenGeneratorKey *TokenGeneratorKey
// MaxTokenAge is the maximum age of the resumption token presented during the handshake.
// These tokens allow skipping address resumption when resuming a QUIC connection,
// and are especially useful when using 0-RTT.
// If not set, it defaults to 24 hours.
// See section 8.1.3 of RFC 9000 for details.
MaxTokenAge time.Duration
// DisableVersionNegotiationPackets disables the sending of Version Negotiation packets.
// This can be useful if version information is exchanged out-of-band.
// It has no effect for clients.
DisableVersionNegotiationPackets bool
// VerifySourceAddress decides if a connection attempt originating from unvalidated source
// addresses first needs to go through source address validation using QUIC's Retry mechanism,
// as described in RFC 9000 section 8.1.2.
// Note that the address passed to this callback is unvalidated, and might be spoofed in case
// of an attack.
// Validating the source address adds one additional network roundtrip to the handshake,
// and should therefore only be used if a suspiciously high number of incoming connection is recorded.
// For most use cases, wrapping the Allow function of a rate.Limiter will be a reasonable
// implementation of this callback (negating its return value).
VerifySourceAddress func(net.Addr) bool
// ConnContext is called when the server accepts a new connection. To reject a connection return
// a non-nil error.
// The context is closed when the connection is closed, or when the handshake fails for any reason.
// The context returned from the callback is used to derive every other context used during the
// lifetime of the connection:
// * the context passed to crypto/tls (and used on the tls.ClientHelloInfo)
// * the context used in Config.QlogTrace
// * the context returned from Conn.Context
// * the context returned from SendStream.Context
// It is not used for dialed connections.
ConnContext func(context.Context, *ClientInfo) (context.Context, error)
// A Tracer traces events that don't belong to a single QUIC connection.
// Recorder.Close is called when the transport is closed.
Tracer qlogwriter.Recorder
// contains filtered or unexported fields
}
The Transport is the central point to manage incoming and outgoing QUIC connections. QUIC demultiplexes connections based on their QUIC Connection IDs, not based on the 4-tuple. This means that a single UDP socket can be used for listening for incoming connections, as well as for dialing an arbitrary number of outgoing connections. A Transport handles a single net.PacketConn, and offers a range of configuration options compared to the simple helper functions like Listen and Dial that this package provides.
func (*Transport) Close ¶
Close stops listening for UDP datagrams on the Transport.Conn. It abruptly terminates all existing connections, without sending a CONNECTION_CLOSE to the peers. It is the application's responsibility to cleanly terminate existing connections prior to calling Close.
If a server was started, it will be closed as well. It is not possible to start any new server or dial new connections after that.
func (*Transport) Dial ¶
func (t *Transport) Dial(ctx context.Context, addr net.Addr, tlsConf *tls.Config, conf *Config) (*Conn, error)
Dial dials a new connection to a remote host (not using 0-RTT).
func (*Transport) DialEarly ¶
func (t *Transport) DialEarly(ctx context.Context, addr net.Addr, tlsConf *tls.Config, conf *Config) (*Conn, error)
DialEarly dials a new connection, attempting to use 0-RTT if possible.
func (*Transport) Listen ¶
Listen starts listening for incoming QUIC connections. There can only be a single listener on any net.PacketConn. Listen may only be called again after the current listener was closed.
func (*Transport) ListenEarly ¶
ListenEarly starts listening for incoming QUIC connections. There can only be a single listener on any net.PacketConn. ListenEarly may only be called again after the current listener was closed.
func (*Transport) ReadNonQUICPacket ¶
ReadNonQUICPacket reads non-QUIC packets received on the underlying connection. The detection logic is very simple: Any packet that has the first and second bit of the packet set to 0. Note that this is stricter than the detection logic defined in RFC 9443.
type TransportError ¶
type TransportError = qerr.TransportError
TransportError indicates an error that occurred on the QUIC transport layer. Every transport error other than CONNECTION_REFUSED and APPLICATION_ERROR is likely a bug in the implementation.
type TransportErrorCode ¶
type TransportErrorCode = qerr.TransportErrorCode
TransportErrorCode is a QUIC transport error code, see section 20 of RFC 9000.
type Version ¶
A Version is a QUIC version number.
func SupportedVersions ¶
func SupportedVersions() []Version
SupportedVersions returns the support versions, sorted in descending order of preference.
type VersionNegotiationError ¶
type VersionNegotiationError = qerr.VersionNegotiationError
VersionNegotiationError indicates a failure to negotiate a QUIC version.
Source Files
¶
- buffer_pool.go
- client.go
- closed_conn.go
- config.go
- conn_id_generator.go
- conn_id_manager.go
- connection.go
- connection_logging.go
- crypto_stream.go
- crypto_stream_manager.go
- datagram_queue.go
- errors.go
- frame_sorter.go
- framer.go
- interface.go
- mtu_discoverer.go
- multi_socket_manager.go
- multipath_auto_paths.go
- multipath_congestion.go
- multipath_controller.go
- multipath_duplication.go
- multipath_failure_detector.go
- multipath_olia.go
- multipath_path_manager.go
- multipath_reinjection.go
- multipath_scheduler.go
- multipath_scheduler_wrapper.go
- packet_packer.go
- packet_unpacker.go
- path_manager.go
- path_manager_outgoing.go
- receive_stream.go
- retransmission_queue.go
- send_conn.go
- send_queue.go
- send_stream.go
- server.go
- sni.go
- stateless_reset.go
- stream.go
- streams_map.go
- streams_map_incoming.go
- streams_map_outgoing.go
- sys_conn.go
- sys_conn_buffers.go
- sys_conn_buffers_write.go
- sys_conn_df_linux.go
- sys_conn_helper_linux.go
- sys_conn_oob.go
- token_store.go
- transport.go
Directories
¶
| Path | Synopsis |
|---|---|
|
client
command
|
|
|
echo
command
|
|
|
fuzzing
|
|
|
frames/cmd
command
|
|
|
handshake/cmd
command
|
|
|
header/cmd
command
|
|
|
transportparameters/cmd
command
|
|
|
integrationtests
|
|
|
internal
|
|
|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
|
mocks/ackhandler
Package mockackhandler is a generated GoMock package.
|
Package mockackhandler is a generated GoMock package. |
|
monotime
Package monotime provides a monotonic time representation that is useful for measuring elapsed time.
|
Package monotime provides a monotonic time representation that is useful for measuring elapsed time. |
|
utils/linkedlist
Package list implements a doubly linked list.
|
Package list implements a doubly linked list. |
|
interop
|
|
|
client
command
|
|
|
server
command
|
|
|
jsontext
Package jsontext provides a fast JSON encoder providing only the necessary features for qlog encoding.
|
Package jsontext provides a fast JSON encoder providing only the necessary features for qlog encoding. |
|
Package testutils contains utilities for simulating packet injection and man-in-the-middle (MITM) attacker tests.
|
Package testutils contains utilities for simulating packet injection and man-in-the-middle (MITM) attacker tests. |