github.com/danielpfeifer02/quic-go-prio-packs@v0.41.0-28/internal/protocol/params.go (about) 1 package protocol 2 3 import "time" 4 5 // DesiredReceiveBufferSize is the kernel UDP receive buffer size that we'd like to use. 6 const DesiredReceiveBufferSize = (1 << 20) * 2 // 2 MB 7 8 // DesiredSendBufferSize is the kernel UDP send buffer size that we'd like to use. 9 const DesiredSendBufferSize = (1 << 20) * 2 // 2 MB 10 11 // InitialPacketSizeIPv4 is the maximum packet size that we use for sending IPv4 packets. 12 const InitialPacketSizeIPv4 = 1252 13 14 // InitialPacketSizeIPv6 is the maximum packet size that we use for sending IPv6 packets. 15 const InitialPacketSizeIPv6 = 1232 16 17 // MaxCongestionWindowPackets is the maximum congestion window in packet. 18 const MaxCongestionWindowPackets = 10000 19 20 // MaxUndecryptablePackets limits the number of undecryptable packets that are queued in the connection. 21 const MaxUndecryptablePackets = 32 22 23 // ConnectionFlowControlMultiplier determines how much larger the connection flow control windows needs to be relative to any stream's flow control window 24 // This is the value that Chromium is using 25 const ConnectionFlowControlMultiplier = 1.5 26 27 // DefaultInitialMaxStreamData is the default initial stream-level flow control window for receiving data 28 const DefaultInitialMaxStreamData = (1 << 10) * 512 // 512 kb 29 30 // DefaultInitialMaxData is the connection-level flow control window for receiving data 31 const DefaultInitialMaxData = ConnectionFlowControlMultiplier * DefaultInitialMaxStreamData 32 33 // DefaultMaxReceiveStreamFlowControlWindow is the default maximum stream-level flow control window for receiving data 34 const DefaultMaxReceiveStreamFlowControlWindow = 6 * (1 << 20) // 6 MB 35 36 // DefaultMaxReceiveConnectionFlowControlWindow is the default connection-level flow control window for receiving data 37 const DefaultMaxReceiveConnectionFlowControlWindow = 15 * (1 << 20) // 15 MB 38 39 // WindowUpdateThreshold is the fraction of the receive window that has to be consumed before an higher offset is advertised to the client 40 const WindowUpdateThreshold = 0.25 41 42 // DefaultMaxIncomingStreams is the maximum number of streams that a peer may open 43 const DefaultMaxIncomingStreams = 100 44 45 // DefaultMaxIncomingUniStreams is the maximum number of unidirectional streams that a peer may open 46 const DefaultMaxIncomingUniStreams = 100 47 48 // MaxServerUnprocessedPackets is the max number of packets stored in the server that are not yet processed. 49 const MaxServerUnprocessedPackets = 1024 50 51 // MaxConnUnprocessedPackets is the max number of packets stored in each connection that are not yet processed. 52 const MaxConnUnprocessedPackets = 256 53 54 // SkipPacketInitialPeriod is the initial period length used for packet number skipping to prevent an Optimistic ACK attack. 55 // Every time a packet number is skipped, the period is doubled, up to SkipPacketMaxPeriod. 56 const SkipPacketInitialPeriod PacketNumber = 256 57 58 // SkipPacketMaxPeriod is the maximum period length used for packet number skipping. 59 const SkipPacketMaxPeriod PacketNumber = 128 * 1024 60 61 // MaxAcceptQueueSize is the maximum number of connections that the server queues for accepting. 62 // If the queue is full, new connection attempts will be rejected. 63 const MaxAcceptQueueSize = 32 64 65 // TokenValidity is the duration that a (non-retry) token is considered valid 66 const TokenValidity = 24 * time.Hour 67 68 // MaxOutstandingSentPackets is maximum number of packets saved for retransmission. 69 // When reached, it imposes a soft limit on sending new packets: 70 // Sending ACKs and retransmission is still allowed, but now new regular packets can be sent. 71 const MaxOutstandingSentPackets = 2 * MaxCongestionWindowPackets 72 73 // MaxTrackedSentPackets is maximum number of sent packets saved for retransmission. 74 // When reached, no more packets will be sent. 75 // This value *must* be larger than MaxOutstandingSentPackets. 76 const MaxTrackedSentPackets = MaxOutstandingSentPackets * 5 / 4 77 78 // MaxNonAckElicitingAcks is the maximum number of packets containing an ACK, 79 // but no ack-eliciting frames, that we send in a row 80 const MaxNonAckElicitingAcks = 19 81 82 // MaxStreamFrameSorterGaps is the maximum number of gaps between received StreamFrames 83 // prevents DoS attacks against the streamFrameSorter 84 const MaxStreamFrameSorterGaps = 1000 85 86 // MinStreamFrameBufferSize is the minimum data length of a received STREAM frame 87 // that we use the buffer for. This protects against a DoS where an attacker would send us 88 // very small STREAM frames to consume a lot of memory. 89 const MinStreamFrameBufferSize = 128 90 91 // MinCoalescedPacketSize is the minimum size of a coalesced packet that we pack. 92 // If a packet has less than this number of bytes, we won't coalesce any more packets onto it. 93 const MinCoalescedPacketSize = 128 94 95 // MaxCryptoStreamOffset is the maximum offset allowed on any of the crypto streams. 96 // This limits the size of the ClientHello and Certificates that can be received. 97 const MaxCryptoStreamOffset = 16 * (1 << 10) 98 99 // MinRemoteIdleTimeout is the minimum value that we accept for the remote idle timeout 100 const MinRemoteIdleTimeout = 5 * time.Second 101 102 // DefaultIdleTimeout is the default idle timeout 103 const DefaultIdleTimeout = 30 * time.Second 104 105 // DefaultHandshakeIdleTimeout is the default idle timeout used before handshake completion. 106 const DefaultHandshakeIdleTimeout = 5 * time.Second 107 108 // MaxKeepAliveInterval is the maximum time until we send a packet to keep a connection alive. 109 // It should be shorter than the time that NATs clear their mapping. 110 const MaxKeepAliveInterval = 20 * time.Second 111 112 // RetiredConnectionIDDeleteTimeout is the time we keep closed connections around in order to retransmit the CONNECTION_CLOSE. 113 // after this time all information about the old connection will be deleted 114 const RetiredConnectionIDDeleteTimeout = 5 * time.Second 115 116 // MinStreamFrameSize is the minimum size that has to be left in a packet, so that we add another STREAM frame. 117 // This avoids splitting up STREAM frames into small pieces, which has 2 advantages: 118 // 1. it reduces the framing overhead 119 // 2. it reduces the head-of-line blocking, when a packet is lost 120 const MinStreamFrameSize ByteCount = 128 121 122 // MaxPostHandshakeCryptoFrameSize is the maximum size of CRYPTO frames 123 // we send after the handshake completes. 124 const MaxPostHandshakeCryptoFrameSize = 1000 125 126 // MaxAckFrameSize is the maximum size for an ACK frame that we write 127 // Due to the varint encoding, ACK frames can grow (almost) indefinitely large. 128 // The MaxAckFrameSize should be large enough to encode many ACK range, 129 // but must ensure that a maximum size ACK frame fits into one packet. 130 const MaxAckFrameSize ByteCount = 1000 131 132 // MaxNumAckRanges is the maximum number of ACK ranges that we send in an ACK frame. 133 // It also serves as a limit for the packet history. 134 // If at any point we keep track of more ranges, old ranges are discarded. 135 const MaxNumAckRanges = 32 136 137 // MinPacingDelay is the minimum duration that is used for packet pacing 138 // If the packet packing frequency is higher, multiple packets might be sent at once. 139 // Example: For a packet pacing delay of 200μs, we would send 5 packets at once, wait for 1ms, and so forth. 140 const MinPacingDelay = time.Millisecond 141 142 // DefaultConnectionIDLength is the connection ID length that is used for multiplexed connections 143 // if no other value is configured. 144 const DefaultConnectionIDLength = 4 145 146 // MaxActiveConnectionIDs is the number of connection IDs that we're storing. 147 const MaxActiveConnectionIDs = 4 148 149 // MaxIssuedConnectionIDs is the maximum number of connection IDs that we're issuing at the same time. 150 const MaxIssuedConnectionIDs = 6 151 152 // PacketsPerConnectionID is the number of packets we send using one connection ID. 153 // If the peer provices us with enough new connection IDs, we switch to a new connection ID. 154 const PacketsPerConnectionID = 10000 155 156 // AckDelayExponent is the ack delay exponent used when sending ACKs. 157 const AckDelayExponent = 3 158 159 // Estimated timer granularity. 160 // The loss detection timer will not be set to a value smaller than granularity. 161 const TimerGranularity = time.Millisecond 162 163 // MaxAckDelay is the maximum time by which we delay sending ACKs. 164 const MaxAckDelay = 25 * time.Millisecond 165 166 // MaxAckDelayInclGranularity is the max_ack_delay including the timer granularity. 167 // This is the value that should be advertised to the peer. 168 const MaxAckDelayInclGranularity = MaxAckDelay + TimerGranularity 169 170 // KeyUpdateInterval is the maximum number of packets we send or receive before initiating a key update. 171 const KeyUpdateInterval = 100 * 1000 172 173 // Max0RTTQueueingDuration is the maximum time that we store 0-RTT packets in order to wait for the corresponding Initial to be received. 174 const Max0RTTQueueingDuration = 100 * time.Millisecond 175 176 // Max0RTTQueues is the maximum number of connections that we buffer 0-RTT packets for. 177 const Max0RTTQueues = 32 178 179 // Max0RTTQueueLen is the maximum number of 0-RTT packets that we buffer for each connection. 180 // When a new connection is created, all buffered packets are passed to the connection immediately. 181 // To avoid blocking, this value has to be smaller than MaxConnUnprocessedPackets. 182 // To avoid packets being dropped as undecryptable by the connection, this value has to be smaller than MaxUndecryptablePackets. 183 const Max0RTTQueueLen = 31