OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NET_QUIC_QUIC_CONSTANTS_H_ |
| 6 #define NET_QUIC_QUIC_CONSTANTS_H_ |
| 7 |
| 8 #include <stddef.h> |
| 9 #include <cstdint> |
| 10 #include <limits> |
| 11 |
| 12 #include "base/macros.h" |
| 13 #include "net/quic/core/quic_types.h" |
| 14 |
| 15 // Definitions of constant values used throughout the QUIC code. |
| 16 |
| 17 namespace net { |
| 18 |
| 19 // Default initial maximum size in bytes of a QUIC packet. |
| 20 const QuicByteCount kDefaultMaxPacketSize = 1350; |
| 21 const QuicByteCount kDefaultServerMaxPacketSize = 1000; |
| 22 // The maximum packet size of any QUIC packet, based on ethernet's max size, |
| 23 // minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an |
| 24 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's |
| 25 // max packet size is 1500 bytes, 1500 - 48 = 1452. |
| 26 const QuicByteCount kMaxPacketSize = 1452; |
| 27 // Default maximum packet size used in the Linux TCP implementation. |
| 28 // Used in QUIC for congestion window computations in bytes. |
| 29 const QuicByteCount kDefaultTCPMSS = 1460; |
| 30 |
| 31 // We match SPDY's use of 32 (since we'd compete with SPDY). |
| 32 const QuicPacketCount kInitialCongestionWindow = 32; |
| 33 |
| 34 // Minimum size of initial flow control window, for both stream and session. |
| 35 const uint32_t kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB |
| 36 |
| 37 // Maximum flow control receive window limits for connection and stream. |
| 38 const QuicByteCount kStreamReceiveWindowLimit = 16 * 1024 * 1024; // 16 MB |
| 39 const QuicByteCount kSessionReceiveWindowLimit = 24 * 1024 * 1024; // 24 MB |
| 40 |
| 41 // Default limit on the size of uncompressed headers. |
| 42 const QuicByteCount kDefaultMaxUncompressedHeaderSize = 16 * 1024; // 16 KB |
| 43 |
| 44 // Minimum size of the CWND, in packets, when doing bandwidth resumption. |
| 45 const QuicPacketCount kMinCongestionWindowForBandwidthResumption = 10; |
| 46 |
| 47 // Maximum number of tracked packets. |
| 48 const QuicPacketCount kMaxTrackedPackets = 10000; |
| 49 |
| 50 // Default size of the socket receive buffer in bytes. |
| 51 const QuicByteCount kDefaultSocketReceiveBuffer = 1024 * 1024; |
| 52 |
| 53 // Don't allow a client to suggest an RTT shorter than 10ms. |
| 54 const uint32_t kMinInitialRoundTripTimeUs = 10 * kNumMicrosPerMilli; |
| 55 |
| 56 // Don't allow a client to suggest an RTT longer than 15 seconds. |
| 57 const uint32_t kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond; |
| 58 |
| 59 // Maximum number of open streams per connection. |
| 60 const size_t kDefaultMaxStreamsPerConnection = 100; |
| 61 |
| 62 // Number of bytes reserved for public flags in the packet header. |
| 63 const size_t kPublicFlagsSize = 1; |
| 64 // Number of bytes reserved for version number in the packet header. |
| 65 const size_t kQuicVersionSize = 4; |
| 66 // Number of bytes reserved for path id in the packet header. |
| 67 const size_t kQuicPathIdSize = 1; |
| 68 // Number of bytes reserved for private flags in the packet header. |
| 69 const size_t kPrivateFlagsSize = 1; |
| 70 |
| 71 // Signifies that the QuicPacket will contain version of the protocol. |
| 72 const bool kIncludeVersion = true; |
| 73 // Signifies that the QuicPacket will contain path id. |
| 74 const bool kIncludePathId = true; |
| 75 // Signifies that the QuicPacket will include a diversification nonce. |
| 76 const bool kIncludeDiversificationNonce = true; |
| 77 |
| 78 // Stream ID is reserved to denote an invalid ID. |
| 79 const QuicStreamId kInvalidStreamId = 0; |
| 80 |
| 81 // Reserved ID for the crypto stream. |
| 82 const QuicStreamId kCryptoStreamId = 1; |
| 83 |
| 84 // Reserved ID for the headers stream. |
| 85 const QuicStreamId kHeadersStreamId = 3; |
| 86 |
| 87 // Header key used to identify final offset on data stream when sending HTTP/2 |
| 88 // trailing headers over QUIC. |
| 89 NET_EXPORT_PRIVATE extern const char* const kFinalOffsetHeaderKey; |
| 90 |
| 91 // Maximum delayed ack time, in ms. |
| 92 const int64_t kMaxDelayedAckTimeMs = 25; |
| 93 |
| 94 // Minimum tail loss probe time in ms. |
| 95 static const int64_t kMinTailLossProbeTimeoutMs = 10; |
| 96 |
| 97 // The timeout before the handshake succeeds. |
| 98 const int64_t kInitialIdleTimeoutSecs = 5; |
| 99 // The default idle timeout. |
| 100 const int64_t kDefaultIdleTimeoutSecs = 30; |
| 101 // The maximum idle timeout that can be negotiated. |
| 102 const int64_t kMaximumIdleTimeoutSecs = 60 * 10; // 10 minutes. |
| 103 // The default timeout for a connection until the crypto handshake succeeds. |
| 104 const int64_t kMaxTimeForCryptoHandshakeSecs = 10; // 10 secs. |
| 105 |
| 106 // Default limit on the number of undecryptable packets the connection buffers |
| 107 // before the CHLO/SHLO arrive. |
| 108 const size_t kDefaultMaxUndecryptablePackets = 10; |
| 109 |
| 110 // Default ping timeout. |
| 111 const int64_t kPingTimeoutSecs = 15; // 15 secs. |
| 112 |
| 113 // Minimum number of RTTs between Server Config Updates (SCUP) sent to client. |
| 114 const int kMinIntervalBetweenServerConfigUpdatesRTTs = 10; |
| 115 |
| 116 // Minimum time between Server Config Updates (SCUP) sent to client. |
| 117 const int kMinIntervalBetweenServerConfigUpdatesMs = 1000; |
| 118 |
| 119 // Minimum number of packets between Server Config Updates (SCUP). |
| 120 const int kMinPacketsBetweenServerConfigUpdates = 100; |
| 121 |
| 122 // The number of open streams that a server will accept is set to be slightly |
| 123 // larger than the negotiated limit. Immediately closing the connection if the |
| 124 // client opens slightly too many streams is not ideal: the client may have sent |
| 125 // a FIN that was lost, and simultaneously opened a new stream. The number of |
| 126 // streams a server accepts is a fixed increment over the negotiated limit, or a |
| 127 // percentage increase, whichever is larger. |
| 128 const float kMaxStreamsMultiplier = 1.1f; |
| 129 const int kMaxStreamsMinimumIncrement = 10; |
| 130 |
| 131 // Available streams are ones with IDs less than the highest stream that has |
| 132 // been opened which have neither been opened or reset. The limit on the number |
| 133 // of available streams is 10 times the limit on the number of open streams. |
| 134 const int kMaxAvailableStreamsMultiplier = 10; |
| 135 |
| 136 // Track the number of promises that are not yet claimed by a |
| 137 // corresponding get. This must be smaller than |
| 138 // kMaxAvailableStreamsMultiplier, because RST on a promised stream my |
| 139 // create available streams entries. |
| 140 const int kMaxPromisedStreamsMultiplier = kMaxAvailableStreamsMultiplier - 1; |
| 141 |
| 142 // TCP RFC calls for 1 second RTO however Linux differs from this default and |
| 143 // define the minimum RTO to 200ms, we will use the same until we have data to |
| 144 // support a higher or lower value. |
| 145 static const int64_t kMinRetransmissionTimeMs = 200; |
| 146 |
| 147 // We define an unsigned 16-bit floating point value, inspired by IEEE floats |
| 148 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), |
| 149 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden |
| 150 // bit) and denormals, but without signs, transfinites or fractions. Wire format |
| 151 // 16 bits (little-endian byte order) are split into exponent (high 5) and |
| 152 // mantissa (low 11) and decoded as: |
| 153 // uint64_t value; |
| 154 // if (exponent == 0) value = mantissa; |
| 155 // else value = (mantissa | 1 << 11) << (exponent - 1) |
| 156 const int kUFloat16ExponentBits = 5; |
| 157 const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30 |
| 158 const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11 |
| 159 const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12 |
| 160 const uint64_t kUFloat16MaxValue = // 0x3FFC0000000 |
| 161 ((UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1) |
| 162 << kUFloat16MaxExponent; |
| 163 |
| 164 // Default path ID. |
| 165 const QuicPathId kDefaultPathId = 0; |
| 166 // Invalid path ID. |
| 167 const QuicPathId kInvalidPathId = 0xff; |
| 168 |
| 169 // kDiversificationNonceSize is the size, in bytes, of the nonce that a server |
| 170 // may set in the packet header to ensure that its INITIAL keys are not |
| 171 // duplicated. |
| 172 const size_t kDiversificationNonceSize = 32; |
| 173 |
| 174 // The largest gap in packets we'll accept without closing the connection. |
| 175 // This will likely have to be tuned. |
| 176 const QuicPacketNumber kMaxPacketGap = 5000; |
| 177 |
| 178 } // namespace net |
| 179 |
| 180 #endif // NET_QUIC_QUIC_CONSTANTS_H_ |
OLD | NEW |