protocol

package
v0.41.0-28 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AckDelayExponent = 3

AckDelayExponent is the ack delay exponent used when sending ACKs.

View Source
const ConnectionFlowControlMultiplier = 1.5

ConnectionFlowControlMultiplier determines how much larger the connection flow control windows needs to be relative to any stream's flow control window This is the value that Chromium is using

View Source
const DefaultAckDelayExponent = 3

DefaultAckDelayExponent is the default ack delay exponent

View Source
const DefaultActiveConnectionIDLimit = 2 // TODOME: might have to change once more priorities are available

DefaultActiveConnectionIDLimit is the default active connection ID limit

View Source
const DefaultConnectionIDLength = 4

DefaultConnectionIDLength is the connection ID length that is used for multiplexed connections if no other value is configured.

View Source
const DefaultHandshakeIdleTimeout = 5 * time.Second

DefaultHandshakeIdleTimeout is the default idle timeout used before handshake completion.

View Source
const DefaultIdleTimeout = 30 * time.Second

DefaultIdleTimeout is the default idle timeout

DefaultInitialMaxData is the connection-level flow control window for receiving data

View Source
const DefaultInitialMaxStreamData = (1 << 10) * 512 // 512 kb

DefaultInitialMaxStreamData is the default initial stream-level flow control window for receiving data

View Source
const DefaultMaxAckDelay = 25 * time.Millisecond

DefaultMaxAckDelay is the default max_ack_delay

View Source
const DefaultMaxIncomingStreams = 100

DefaultMaxIncomingStreams is the maximum number of streams that a peer may open

View Source
const DefaultMaxIncomingUniStreams = 100

DefaultMaxIncomingUniStreams is the maximum number of unidirectional streams that a peer may open

View Source
const DefaultMaxReceiveConnectionFlowControlWindow = 15 * (1 << 20) // 15 MB

DefaultMaxReceiveConnectionFlowControlWindow is the default connection-level flow control window for receiving data

View Source
const DefaultMaxReceiveStreamFlowControlWindow = 6 * (1 << 20) // 6 MB

DefaultMaxReceiveStreamFlowControlWindow is the default maximum stream-level flow control window for receiving data

View Source
const DesiredReceiveBufferSize = (1 << 20) * 2 // 2 MB

DesiredReceiveBufferSize is the kernel UDP receive buffer size that we'd like to use.

View Source
const DesiredSendBufferSize = (1 << 20) * 2 // 2 MB

DesiredSendBufferSize is the kernel UDP send buffer size that we'd like to use.

View Source
const InitialPacketSizeIPv4 = 1252

InitialPacketSizeIPv4 is the maximum packet size that we use for sending IPv4 packets.

View Source
const InitialPacketSizeIPv6 = 1232

InitialPacketSizeIPv6 is the maximum packet size that we use for sending IPv6 packets.

View Source
const InvalidPacketLimitAES = 1 << 52

InvalidPacketLimitAES is the maximum number of packets that we can fail to decrypt when using AEAD_AES_128_GCM or AEAD_AES_265_GCM.

View Source
const InvalidPacketLimitChaCha = 1 << 36

InvalidPacketLimitChaCha is the maximum number of packets that we can fail to decrypt when using AEAD_CHACHA20_POLY1305.

View Source
const KeyUpdateInterval = 100 * 1000

KeyUpdateInterval is the maximum number of packets we send or receive before initiating a key update.

View Source
const Max0RTTQueueLen = 31

Max0RTTQueueLen is the maximum number of 0-RTT packets that we buffer for each connection. When a new connection is created, all buffered packets are passed to the connection immediately. To avoid blocking, this value has to be smaller than MaxConnUnprocessedPackets. To avoid packets being dropped as undecryptable by the connection, this value has to be smaller than MaxUndecryptablePackets.

View Source
const Max0RTTQueueingDuration = 100 * time.Millisecond

Max0RTTQueueingDuration is the maximum time that we store 0-RTT packets in order to wait for the corresponding Initial to be received.

View Source
const Max0RTTQueues = 32

Max0RTTQueues is the maximum number of connections that we buffer 0-RTT packets for.

View Source
const MaxAcceptQueueSize = 32

MaxAcceptQueueSize is the maximum number of connections that the server queues for accepting. If the queue is full, new connection attempts will be rejected.

View Source
const MaxAckDelay = 25 * time.Millisecond

MaxAckDelay is the maximum time by which we delay sending ACKs.

View Source
const MaxAckDelayExponent = 20

MaxAckDelayExponent is the maximum ack delay exponent

View Source
const MaxAckDelayInclGranularity = MaxAckDelay + TimerGranularity

MaxAckDelayInclGranularity is the max_ack_delay including the timer granularity. This is the value that should be advertised to the peer.

View Source
const MaxActiveConnectionIDs = 4

MaxActiveConnectionIDs is the number of connection IDs that we're storing.

View Source
const MaxByteCount = ByteCount(1<<62 - 1)

MaxByteCount is the maximum value of a ByteCount

View Source
const MaxCongestionWindowPackets = 10000

MaxCongestionWindowPackets is the maximum congestion window in packet.

View Source
const MaxConnIDLen = 20

MaxConnIDLen is the maximum length of the connection ID

View Source
const MaxConnUnprocessedPackets = 256

MaxConnUnprocessedPackets is the max number of packets stored in each connection that are not yet processed.

View Source
const MaxCryptoStreamOffset = 16 * (1 << 10)

MaxCryptoStreamOffset is the maximum offset allowed on any of the crypto streams. This limits the size of the ClientHello and Certificates that can be received.

View Source
const MaxIssuedConnectionIDs = 6

MaxIssuedConnectionIDs is the maximum number of connection IDs that we're issuing at the same time.

View Source
const MaxKeepAliveInterval = 20 * time.Second

MaxKeepAliveInterval is the maximum time until we send a packet to keep a connection alive. It should be shorter than the time that NATs clear their mapping.

View Source
const MaxLargePacketBufferSize = 20 * 1024

MaxLargePacketBufferSize is used when using GSO

View Source
const MaxMaxAckDelay = (1<<14 - 1) * time.Millisecond

MaxMaxAckDelay is the maximum max_ack_delay

View Source
const MaxNonAckElicitingAcks = 19

MaxNonAckElicitingAcks is the maximum number of packets containing an ACK, but no ack-eliciting frames, that we send in a row

View Source
const MaxNumAckRanges = 32

MaxNumAckRanges is the maximum number of ACK ranges that we send in an ACK frame. It also serves as a limit for the packet history. If at any point we keep track of more ranges, old ranges are discarded.

View Source
const MaxOutstandingSentPackets = 2 * MaxCongestionWindowPackets

MaxOutstandingSentPackets is maximum number of packets saved for retransmission. When reached, it imposes a soft limit on sending new packets: Sending ACKs and retransmission is still allowed, but now new regular packets can be sent.

View Source
const MaxPacketBufferSize = 1452

MaxPacketBufferSize maximum packet size of any QUIC packet, based on ethernet's max size, minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's max packet size is 1500 bytes, 1500 - 48 = 1452.

View Source
const MaxPostHandshakeCryptoFrameSize = 1000

MaxPostHandshakeCryptoFrameSize is the maximum size of CRYPTO frames we send after the handshake completes.

View Source
const MaxServerUnprocessedPackets = 1024

MaxServerUnprocessedPackets is the max number of packets stored in the server that are not yet processed.

View Source
const MaxStreamFrameSorterGaps = 1000

MaxStreamFrameSorterGaps is the maximum number of gaps between received StreamFrames prevents DoS attacks against the streamFrameSorter

View Source
const MaxTrackedSentPackets = MaxOutstandingSentPackets * 5 / 4

MaxTrackedSentPackets is maximum number of sent packets saved for retransmission. When reached, no more packets will be sent. This value *must* be larger than MaxOutstandingSentPackets.

View Source
const MaxUndecryptablePackets = 32

MaxUndecryptablePackets limits the number of undecryptable packets that are queued in the connection.

View Source
const MinCoalescedPacketSize = 128

MinCoalescedPacketSize is the minimum size of a coalesced packet that we pack. If a packet has less than this number of bytes, we won't coalesce any more packets onto it.

View Source
const MinConnectionIDLenInitial = 8

MinConnectionIDLenInitial is the minimum length of the destination connection ID on an Initial packet.

View Source
const MinInitialPacketSize = 1200

MinInitialPacketSize is the minimum size an Initial packet is required to have.

View Source
const MinPacingDelay = time.Millisecond

MinPacingDelay is the minimum duration that is used for packet pacing If the packet packing frequency is higher, multiple packets might be sent at once. Example: For a packet pacing delay of 200μs, we would send 5 packets at once, wait for 1ms, and so forth.

View Source
const MinRemoteIdleTimeout = 5 * time.Second

MinRemoteIdleTimeout is the minimum value that we accept for the remote idle timeout

View Source
const MinStatelessResetSize = 1 + 20 + 4 + 1 + 16 /* token */

MinStatelessResetSize is the minimum size of a stateless reset packet that we send

View Source
const MinStreamFrameBufferSize = 128

MinStreamFrameBufferSize is the minimum data length of a received STREAM frame that we use the buffer for. This protects against a DoS where an attacker would send us very small STREAM frames to consume a lot of memory.

View Source
const MinUnknownVersionPacketSize = MinInitialPacketSize

MinUnknownVersionPacketSize is the minimum size a packet with an unknown version needs to have in order to trigger a Version Negotiation packet.

View Source
const PacketsPerConnectionID = 10000

PacketsPerConnectionID is the number of packets we send using one connection ID. If the peer provices us with enough new connection IDs, we switch to a new connection ID.

View Source
const PriorityConnIDLen uint8 = 16

PRIO_PACKS_TAG

View Source
const RetiredConnectionIDDeleteTimeout = 5 * time.Second

RetiredConnectionIDDeleteTimeout is the time we keep closed connections around in order to retransmit the CONNECTION_CLOSE. after this time all information about the old connection will be deleted

View Source
const TimerGranularity = time.Millisecond

Estimated timer granularity. The loss detection timer will not be set to a value smaller than granularity.

View Source
const TokenValidity = 24 * time.Hour

TokenValidity is the duration that a (non-retry) token is considered valid

View Source
const WindowUpdateThreshold = 0.25

WindowUpdateThreshold is the fraction of the receive window that has to be consumed before an higher offset is advertised to the client

Variables

View Source
var ErrInvalidConnectionIDLen = errors.New("invalid Connection ID length")
View Source
var SupportedVersions = []Version{Version1, Version2}

SupportedVersions lists the versions that the server supports must be in sorted descending order

Functions

func IsSupportedVersion

func IsSupportedVersion(supported []Version, v Version) bool

IsSupportedVersion returns true if the server supports this version

func IsValidVersion

func IsValidVersion(v Version) bool

IsValidVersion says if the version is known to quic-go

Types

type ArbitraryLenConnectionID

type ArbitraryLenConnectionID []byte

An ArbitraryLenConnectionID is a QUIC Connection ID able to represent Connection IDs according to RFC 8999. Future QUIC versions might allow connection ID lengths up to 255 bytes, while QUIC v1 restricts the length to 20 bytes.

func (ArbitraryLenConnectionID) Bytes

func (c ArbitraryLenConnectionID) Bytes() []byte

func (ArbitraryLenConnectionID) Len

func (c ArbitraryLenConnectionID) Len() int

func (ArbitraryLenConnectionID) String

func (c ArbitraryLenConnectionID) String() string

type ByteCount

type ByteCount int64

A ByteCount in QUIC

const InvalidByteCount ByteCount = -1

InvalidByteCount is an invalid byte count

const MaxAckFrameSize ByteCount = 1000

MaxAckFrameSize is the maximum size for an ACK frame that we write Due to the varint encoding, ACK frames can grow (almost) indefinitely large. The MaxAckFrameSize should be large enough to encode many ACK range, but must ensure that a maximum size ACK frame fits into one packet.

const MinStreamFrameSize ByteCount = 128

MinStreamFrameSize is the minimum size that has to be left in a packet, so that we add another STREAM frame. This avoids splitting up STREAM frames into small pieces, which has 2 advantages: 1. it reduces the framing overhead 2. it reduces the head-of-line blocking, when a packet is lost

type ConnectionID

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

A ConnectionID in QUIC

func GenerateConnectionID

func GenerateConnectionID(l int) (ConnectionID, error)

GenerateConnectionID generates a connection ID using cryptographic random

func GenerateConnectionIDForInitial

func GenerateConnectionIDForInitial() (ConnectionID, error)

GenerateConnectionIDForInitial generates a connection ID for the Initial packet. It uses a length randomly chosen between 8 and 20 bytes.

func ParseConnectionID

func ParseConnectionID(b []byte) ConnectionID

ParseConnectionID interprets b as a Connection ID. It panics if b is longer than 20 bytes.

func ReadConnectionID

func ReadConnectionID(r io.Reader, l int) (ConnectionID, error)

ReadConnectionID reads a connection ID of length len from the given io.Reader. It returns io.EOF if there are not enough bytes to read.

func (ConnectionID) Bytes

func (c ConnectionID) Bytes() []byte

Bytes returns the byte representation

func (ConnectionID) Len

func (c ConnectionID) Len() int

Len returns the length of the connection ID in bytes

func (ConnectionID) String

func (c ConnectionID) String() string

type DefaultConnectionIDGenerator

type DefaultConnectionIDGenerator struct {
	ConnLen int
}

func (*DefaultConnectionIDGenerator) ConnectionIDLen

func (d *DefaultConnectionIDGenerator) ConnectionIDLen() int

func (*DefaultConnectionIDGenerator) GenerateConnectionID

func (d *DefaultConnectionIDGenerator) GenerateConnectionID() (ConnectionID, error)

type ECN

type ECN uint8
const (
	ECNUnsupported ECN = iota
	ECNNon             // 00
	ECT1               // 01
	ECT0               // 10
	ECNCE              // 11
)

func ParseECNHeaderBits

func ParseECNHeaderBits(bits byte) ECN

func (ECN) String

func (e ECN) String() string

func (ECN) ToHeaderBits

func (e ECN) ToHeaderBits() byte

type EncryptionLevel

type EncryptionLevel uint8

EncryptionLevel is the encryption level Default value is Unencrypted

const (
	// EncryptionInitial is the Initial encryption level
	EncryptionInitial EncryptionLevel = 1 + iota
	// EncryptionHandshake is the Handshake encryption level
	EncryptionHandshake
	// Encryption0RTT is the 0-RTT encryption level
	Encryption0RTT
	// Encryption1RTT is the 1-RTT encryption level
	Encryption1RTT
)

func (EncryptionLevel) String

func (e EncryptionLevel) String() string

type KeyPhase

type KeyPhase uint64

KeyPhase is the key phase

func (KeyPhase) Bit

func (p KeyPhase) Bit() KeyPhaseBit

Bit determines the key phase bit

type KeyPhaseBit

type KeyPhaseBit uint8

KeyPhaseBit is the key phase bit

const (
	// KeyPhaseUndefined is an undefined key phase
	KeyPhaseUndefined KeyPhaseBit = iota
	// KeyPhaseZero is key phase 0
	KeyPhaseZero
	// KeyPhaseOne is key phase 1
	KeyPhaseOne
)

func (KeyPhaseBit) String

func (p KeyPhaseBit) String() string

type PacketNumber

type PacketNumber int64

A PacketNumber in QUIC

const InvalidPacketNumber PacketNumber = -1

InvalidPacketNumber is a packet number that is never sent. In QUIC, 0 is a valid packet number.

const SkipPacketInitialPeriod PacketNumber = 256

SkipPacketInitialPeriod is the initial period length used for packet number skipping to prevent an Optimistic ACK attack. Every time a packet number is skipped, the period is doubled, up to SkipPacketMaxPeriod.

const SkipPacketMaxPeriod PacketNumber = 128 * 1024

SkipPacketMaxPeriod is the maximum period length used for packet number skipping.

func DecodePacketNumber

func DecodePacketNumber(
	packetNumberLength PacketNumberLen,
	lastPacketNumber PacketNumber,
	wirePacketNumber PacketNumber,
) PacketNumber

DecodePacketNumber calculates the packet number based on the received packet number, its length and the last seen packet number

type PacketNumberLen

type PacketNumberLen uint8

PacketNumberLen is the length of the packet number in bytes

const (
	// PacketNumberLen1 is a packet number length of 1 byte
	PacketNumberLen1 PacketNumberLen = 1
	// PacketNumberLen2 is a packet number length of 2 bytes
	PacketNumberLen2 PacketNumberLen = 2
	// PacketNumberLen3 is a packet number length of 3 bytes
	PacketNumberLen3 PacketNumberLen = 3
	// PacketNumberLen4 is a packet number length of 4 bytes
	PacketNumberLen4 PacketNumberLen = 4
)

func GetPacketNumberLengthForHeader

func GetPacketNumberLengthForHeader(packetNumber, leastUnacked PacketNumber) PacketNumberLen

GetPacketNumberLengthForHeader gets the length of the packet number for the public header it never chooses a PacketNumberLen of 1 byte, since this is too short under certain circumstances

type PacketType

type PacketType uint8

The PacketType is the Long Header Type

const (
	// PacketTypeInitial is the packet type of an Initial packet
	PacketTypeInitial PacketType = 1 + iota
	// PacketTypeRetry is the packet type of a Retry packet
	PacketTypeRetry
	// PacketTypeHandshake is the packet type of a Handshake packet
	PacketTypeHandshake
	// PacketType0RTT is the packet type of a 0-RTT packet
	PacketType0RTT
)

func (PacketType) String

func (t PacketType) String() string

type Perspective

type Perspective int

Perspective determines if we're acting as a server or a client

const (
	PerspectiveServer Perspective = 1
	PerspectiveClient Perspective = 2
)

the perspectives

func (Perspective) Opposite

func (p Perspective) Opposite() Perspective

Opposite returns the perspective of the peer

func (Perspective) String

func (p Perspective) String() string

type Priority

type Priority int8

PRIO_PACKS_TAG Priority encodes the priority of the stream

type PriorityConnectionIDGenerator

type PriorityConnectionIDGenerator struct {
	ConnLen            int
	NumberOfPriorities int
	PriorityCounter    int8
	NextPriority       int8
	NextPriorityValid  bool
}

PRIO_PACKS_TAG

func (*PriorityConnectionIDGenerator) ConnectionIDLen

func (t *PriorityConnectionIDGenerator) ConnectionIDLen() int

func (*PriorityConnectionIDGenerator) GenerateConnectionID

func (t *PriorityConnectionIDGenerator) GenerateConnectionID() (ConnectionID, error)

type StatelessResetToken

type StatelessResetToken [16]byte

A StatelessResetToken is a stateless reset token.

type StreamID

type StreamID int64

A StreamID in QUIC

const InvalidStreamID StreamID = -1

InvalidPacketNumber is a stream ID that is invalid. The first valid stream ID in QUIC is 0.

func (StreamID) InitiatedBy

func (s StreamID) InitiatedBy() Perspective

InitiatedBy says if the stream was initiated by the client or by the server

func (StreamID) StreamNum

func (s StreamID) StreamNum() StreamNum

StreamNum returns how many streams in total are below this Example: for stream 9 it returns 3 (i.e. streams 1, 5 and 9)

func (StreamID) Type

func (s StreamID) Type() StreamType

Type says if this is a unidirectional or bidirectional stream

type StreamNum

type StreamNum int64

StreamNum is the stream number

const (
	// InvalidStreamNum is an invalid stream number.
	InvalidStreamNum = -1
	// MaxStreamCount is the maximum stream count value that can be sent in MAX_STREAMS frames
	// and as the stream count in the transport parameters
	MaxStreamCount StreamNum = 1 << 60
)

func (StreamNum) StreamID

func (s StreamNum) StreamID(stype StreamType, pers Perspective) StreamID

StreamID calculates the stream ID.

type StreamType

type StreamType uint8

StreamType encodes if this is a unidirectional or bidirectional stream

const (
	// StreamTypeUni is a unidirectional stream
	StreamTypeUni StreamType = iota
	// StreamTypeBidi is a bidirectional stream
	StreamTypeBidi
)

type Version

type Version uint32

Version is a version number as int

const (
	VersionUnknown Version = math.MaxUint32

	Version1 Version = 0x1
	Version2 Version = 0x6b3343cf
)

The version numbers, making grepping easier

func ChooseSupportedVersion

func ChooseSupportedVersion(ours, theirs []Version) (Version, bool)

ChooseSupportedVersion finds the best version in the overlap of ours and theirs ours is a slice of versions that we support, sorted by our preference (descending) theirs is a slice of versions offered by the peer. The order does not matter. The bool returned indicates if a matching version was found.

func GetGreasedVersions

func GetGreasedVersions(supported []Version) []Version

GetGreasedVersions adds one reserved version number to a slice of version numbers, at a random position. It doesn't modify the supported slice.

func (Version) String

func (vn Version) String() string

Jump to

Keyboard shortcuts

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