const AckDelayExponent = 3
AckDelayExponent is the ack delay exponent used when sending ACKs.
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
const DefaultAckDelayExponent = 3
DefaultAckDelayExponent is the default ack delay exponent
const DefaultConnectionIDLength = 4
DefaultConnectionIDLength is the connection ID length that is used for multiplexed connections if no other value is configured.
DefaultHandshakeTimeout is the default timeout for a connection until the crypto handshake succeeds.
DefaultIdleTimeout is the default idle timeout
DefaultMaxAckDelay is the default max_ack_delay
const DefaultMaxIncomingStreams = 100
DefaultMaxIncomingStreams is the maximum number of streams that a peer may open
const DefaultMaxIncomingUniStreams = 100
DefaultMaxIncomingUniStreams is the maximum number of unidirectional streams that a peer may open
const DefaultMaxReceiveConnectionFlowControlWindow = 15 * (1 << 20) // 12 MB
DefaultMaxReceiveConnectionFlowControlWindow is the default connection-level flow control window for receiving data, for the server
const DefaultMaxReceiveStreamFlowControlWindow = 6 * (1 << 20) // 6 MB
DefaultMaxReceiveStreamFlowControlWindow is the default maximum stream-level flow control window for receiving data, for the server
InitialMaxData is the connection-level flow control window for receiving data
const InitialMaxStreamData = (1 << 10) * 512 // 512 kb
InitialMaxStreamData is the stream-level flow control window for receiving data
const KeyUpdateInterval = 100 * 1000
KeyUpdateInterval is the maximum number of packets we send or receive before initiating a key udpate.
const Max0RTTQueueLen = 32
Max0RTTQueueLen is the maximum number of 0-RTT packets that we buffer for each connection. When a new session is created, all buffered packets are passed to the session immediately. To avoid blocking, this value has to be smaller than MaxSessionUnprocessedPackets. To avoid packets being dropped as undecryptable by the session, this value has to be smaller than MaxUndecryptablePackets.
Max0RTTQueueingDuration is the maximum time that we store 0-RTT packets in order to wait for the corresponding Initial to be received.
const Max0RTTQueues = 32
Max0RTTQueues is the maximum number of connections that we buffer 0-RTT packets for.
const MaxAcceptQueueSize = 32
MaxAcceptQueueSize is the maximum number of sessions that the server queues for accepting. If the queue is full, new connection attempts will be rejected.
MaxAckDelay is the maximum time by which we delay sending ACKs.
const MaxAckDelayExponent = 20
MaxAckDelayExponent is the maximum ack delay exponent
MaxAckDelayInclGranularity is the max_ack_delay including the timer granularity. This is the value that should be advertised to the peer.
const MaxActiveConnectionIDs = 4
MaxActiveConnectionIDs is the number of connection IDs that we're storing.
MaxByteCount is the maximum value of a ByteCount
const MaxCongestionWindowPackets = 10000
MaxCongestionWindowPackets is the maximum congestion window in packet.
const MaxConnIDLen = 20
MaxConnIDLen is the maximum length of the connection ID
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.
const MaxIssuedConnectionIDs = 6
MaxIssuedConnectionIDs is the maximum number of connection IDs that we're issuing at the same time.
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.
MaxMaxAckDelay is the maximum max_ack_delay
const MaxNonAckElicitingAcks = 19
MaxNonAckElicitingAcks is the maximum number of packets containing an ACK, but no ack-eliciting frames, that we send in a row
const MaxNumAckRanges = 500
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.
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.
const MaxPacketSizeIPv4 = 1252
MaxPacketSizeIPv4 is the maximum packet size that we use for sending IPv4 packets.
const MaxPacketSizeIPv6 = 1232
MaxPacketSizeIPv6 is the maximum packet size that we use for sending IPv6 packets.
const MaxPostHandshakeCryptoFrameSize = 1000
MaxPostHandshakeCryptoFrameSize is the maximum size of CRYPTO frames we send after the handshake completes.
const MaxServerUnprocessedPackets = 1024
MaxServerUnprocessedPackets is the max number of packets stored in the server that are not yet processed.
MaxSessionUnprocessedPackets is the max number of packets stored in each session that are not yet processed.
const MaxStreamFrameSorterGaps = 1000
MaxStreamFrameSorterGaps is the maximum number of gaps between received StreamFrames prevents DoS attacks against the streamFrameSorter
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.
const MaxTrackedSkippedPackets = 10
MaxTrackedSkippedPackets is the maximum number of skipped packet numbers the SentPacketHandler keep track of for Optimistic ACK attack mitigation
const MaxUndecryptablePackets = 33
MaxUndecryptablePackets limits the number of undecryptable packets that are queued in the session.
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.
const MinConnectionIDLenInitial = 8
MinConnectionIDLenInitial is the minimum length of the destination connection ID on an Initial packet.
const MinInitialPacketSize = 1200
MinInitialPacketSize is the minimum size an Initial packet is required to have.
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 20 microseconds, we would send 5 packets at once, wait for 100 microseconds, and so forth.
MinRemoteIdleTimeout is the minimum value that we accept for the remote idle timeout
const MinStatelessResetSize = 1 + 20 + 4 + 1 + 16 /* token */
MinStatelessResetSize is the minimum size of a stateless reset packet that we send
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.
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.
RetiredConnectionIDDeleteTimeout is the time we keep closed sessions around in order to retransmit the CONNECTION_CLOSE. after this time all information about the old connection will be deleted
RetryTokenValidity is the duration that a retry token is considered valid
Estimated timer granularity. The loss detection timer will not be set to a value smaller than granularity.
TokenValidity is the duration that a (non-retry) token is considered valid
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
SupportedVersions lists the versions that the server supports must be in sorted descending order
IsSupportedVersion returns true if the server supports this version
IsValidVersion says if the version is known to quic-go
An ApplicationErrorCode is an application-defined error code.
A ByteCount in QUIC
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.
MaxReceivePacketSize 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.
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
A ConnectionID in QUIC
GenerateConnectionID generates a connection ID using cryptographic random
GenerateConnectionIDForInitial generates a connection ID for the Initial packet. It uses a length randomly chosen between 8 and 18 bytes.
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.
Bytes returns the byte representation
Equal says if two connection IDs are equal
Len returns the length of the connection ID in bytes
EncryptionLevel is the encryption level Default value is Unencrypted
const ( // EncryptionUnspecified is a not specified encryption level EncryptionUnspecified EncryptionLevel = iota // EncryptionInitial is the Initial encryption level EncryptionInitial // EncryptionHandshake is the Handshake encryption level EncryptionHandshake // Encryption0RTT is the 0-RTT encryption level Encryption0RTT // Encryption1RTT is the 1-RTT encryption level Encryption1RTT )
KeyPhase is the key phase
KeyPhaseBit is the key phase bit
const ( // KeyPhaseZero is key phase 0 KeyPhaseZero KeyPhaseBit = false // KeyPhaseOne is key phase 1 KeyPhaseOne KeyPhaseBit = true )
A PacketNumber in QUIC
InvalidPacketNumber is a packet number that is never sent. In QUIC, 0 is a valid packet number.
SkipPacketAveragePeriodLength is the average period length in which one packet number is skipped to prevent an Optimistic ACK attack
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
PacketNumberLen is the length of the packet number in bytes
const ( // PacketNumberLenInvalid is the default value and not a valid length for a packet number PacketNumberLenInvalid PacketNumberLen = 0 // 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 )
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
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 )
Perspective determines if we're acting as a server or a client
Opposite returns the perspective of the peer
A StreamID in QUIC
InvalidPacketNumber is a stream ID that is invalid. The first valid stream ID in QUIC is 0.
InitiatedBy says if the stream was initiated by the client or by the server
StreamNum returns how many streams in total are below this Example: for stream 9 it returns 3 (i.e. streams 1, 5 and 9)
Type says if this is a unidirectional or bidirectional stream
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 )
StreamID calculates the stream ID.
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 )
VersionNumber is a version number as int
const ( VersionTLS VersionNumber = 0x51474fff VersionWhatever VersionNumber = 1 // for when the version doesn't matter VersionUnknown VersionNumber = math.MaxUint32 )
The version numbers, making grepping easier
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.
GetGreasedVersions adds one reserved version number to a slice of version numbers, at a random position
StripGreasedVersions strips all greased versions from a slice of versions