Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: net/quic/core/quic_protocol.h

Issue 2506903002: Move QUIC typedefs and constants into files other than quic_protocol.h. No behavior change. (Closed)
Patch Set: Move QUIC typedefs and constants into files other than quic_protocol.h. No behavior change. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/core/quic_constants.h ('k') | net/quic/core/quic_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_ 5 #ifndef NET_QUIC_QUIC_PROTOCOL_H_
6 #define NET_QUIC_QUIC_PROTOCOL_H_ 6 #define NET_QUIC_QUIC_PROTOCOL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 11 matching lines...) Expand all
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/macros.h" 23 #include "base/macros.h"
24 #include "base/memory/ref_counted.h" 24 #include "base/memory/ref_counted.h"
25 #include "base/strings/string_piece.h" 25 #include "base/strings/string_piece.h"
26 #include "net/base/int128.h" 26 #include "net/base/int128.h"
27 #include "net/base/iovec.h" 27 #include "net/base/iovec.h"
28 #include "net/base/ip_endpoint.h" 28 #include "net/base/ip_endpoint.h"
29 #include "net/base/net_export.h" 29 #include "net/base/net_export.h"
30 #include "net/quic/core/interval_set.h" 30 #include "net/quic/core/interval_set.h"
31 #include "net/quic/core/quic_bandwidth.h" 31 #include "net/quic/core/quic_bandwidth.h"
32 #include "net/quic/core/quic_constants.h"
32 #include "net/quic/core/quic_time.h" 33 #include "net/quic/core/quic_time.h"
33 #include "net/quic/core/quic_types.h" 34 #include "net/quic/core/quic_types.h"
34 35
35 namespace net { 36 namespace net {
36 37
37 class QuicPacket; 38 class QuicPacket;
38 struct QuicPacketHeader; 39 struct QuicPacketHeader;
39 class QuicAckListenerInterface; 40 class QuicAckListenerInterface;
40 41
41 typedef uint64_t QuicConnectionId;
42 typedef uint32_t QuicStreamId;
43 typedef uint64_t QuicStreamOffset;
44 typedef uint64_t QuicPacketNumber;
45 typedef uint8_t QuicPathId;
46 typedef uint64_t QuicPublicResetNonceProof;
47 typedef uint8_t QuicPacketEntropyHash;
48 typedef uint32_t QuicHeaderId;
49 // QuicTag is the type of a tag in the wire protocol.
50 typedef uint32_t QuicTag;
51 typedef std::vector<QuicTag> QuicTagVector;
52 typedef std::map<QuicTag, std::string> QuicTagValueMap;
53 typedef uint16_t QuicPacketLength;
54
55 // Default initial maximum size in bytes of a QUIC packet.
56 const QuicByteCount kDefaultMaxPacketSize = 1350;
57 // Default initial maximum size in bytes of a QUIC packet for servers.
58 const QuicByteCount kDefaultServerMaxPacketSize = 1000;
59 // The maximum packet size of any QUIC packet, based on ethernet's max size,
60 // minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an
61 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's
62 // max packet size is 1500 bytes, 1500 - 48 = 1452.
63 const QuicByteCount kMaxPacketSize = 1452;
64 // Default maximum packet size used in the Linux TCP implementation.
65 // Used in QUIC for congestion window computations in bytes.
66 const QuicByteCount kDefaultTCPMSS = 1460;
67
68 // We match SPDY's use of 32 (since we'd compete with SPDY).
69 const QuicPacketCount kInitialCongestionWindow = 32;
70
71 // Minimum size of initial flow control window, for both stream and session.
72 const uint32_t kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB
73
74 // Maximum flow control receive window limits for connection and stream.
75 const QuicByteCount kStreamReceiveWindowLimit = 16 * 1024 * 1024; // 16 MB
76 const QuicByteCount kSessionReceiveWindowLimit = 24 * 1024 * 1024; // 24 MB
77
78 // Default limit on the size of uncompressed headers.
79 const QuicByteCount kDefaultMaxUncompressedHeaderSize = 16 * 1024; // 16 KB
80
81 // Minimum size of the CWND, in packets, when doing bandwidth resumption.
82 const QuicPacketCount kMinCongestionWindowForBandwidthResumption = 10;
83
84 // Maximum number of tracked packets.
85 const QuicPacketCount kMaxTrackedPackets = 10000;
86
87 // Default size of the socket receive buffer in bytes.
88 const QuicByteCount kDefaultSocketReceiveBuffer = 1024 * 1024;
89
90 // Don't allow a client to suggest an RTT shorter than 10ms.
91 const uint32_t kMinInitialRoundTripTimeUs = 10 * kNumMicrosPerMilli;
92
93 // Don't allow a client to suggest an RTT longer than 15 seconds.
94 const uint32_t kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond;
95
96 // Maximum number of open streams per connection.
97 const size_t kDefaultMaxStreamsPerConnection = 100;
98
99 // Number of bytes reserved for public flags in the packet header.
100 const size_t kPublicFlagsSize = 1;
101 // Number of bytes reserved for version number in the packet header.
102 const size_t kQuicVersionSize = 4;
103 // Number of bytes reserved for path id in the packet header.
104 const size_t kQuicPathIdSize = 1;
105 // Number of bytes reserved for private flags in the packet header.
106 const size_t kPrivateFlagsSize = 1;
107
108 // Signifies that the QuicPacket will contain version of the protocol.
109 const bool kIncludeVersion = true;
110 // Signifies that the QuicPacket will contain path id.
111 const bool kIncludePathId = true;
112 // Signifies that the QuicPacket will include a diversification nonce.
113 const bool kIncludeDiversificationNonce = true;
114
115 // Stream ID is reserved to denote an invalid ID.
116 const QuicStreamId kInvalidStreamId = 0;
117
118 // Reserved ID for the crypto stream.
119 const QuicStreamId kCryptoStreamId = 1;
120
121 // Reserved ID for the headers stream.
122 const QuicStreamId kHeadersStreamId = 3;
123
124 // Header key used to identify final offset on data stream when sending HTTP/2
125 // trailing headers over QUIC.
126 NET_EXPORT_PRIVATE extern const char* const kFinalOffsetHeaderKey;
127
128 // Maximum delayed ack time, in ms.
129 const int64_t kMaxDelayedAckTimeMs = 25;
130
131 // Minimum tail loss probe time in ms.
132 static const int64_t kMinTailLossProbeTimeoutMs = 10;
133
134 // The timeout before the handshake succeeds.
135 const int64_t kInitialIdleTimeoutSecs = 5;
136 // The default idle timeout.
137 const int64_t kDefaultIdleTimeoutSecs = 30;
138 // The maximum idle timeout that can be negotiated.
139 const int64_t kMaximumIdleTimeoutSecs = 60 * 10; // 10 minutes.
140 // The default timeout for a connection until the crypto handshake succeeds.
141 const int64_t kMaxTimeForCryptoHandshakeSecs = 10; // 10 secs.
142
143 // Default limit on the number of undecryptable packets the connection buffers
144 // before the CHLO/SHLO arrive.
145 const size_t kDefaultMaxUndecryptablePackets = 10;
146
147 // Default ping timeout.
148 const int64_t kPingTimeoutSecs = 15; // 15 secs.
149
150 // Minimum number of RTTs between Server Config Updates (SCUP) sent to client.
151 const int kMinIntervalBetweenServerConfigUpdatesRTTs = 10;
152
153 // Minimum time between Server Config Updates (SCUP) sent to client.
154 const int kMinIntervalBetweenServerConfigUpdatesMs = 1000;
155
156 // Minimum number of packets between Server Config Updates (SCUP).
157 const int kMinPacketsBetweenServerConfigUpdates = 100;
158
159 // The number of open streams that a server will accept is set to be slightly
160 // larger than the negotiated limit. Immediately closing the connection if the
161 // client opens slightly too many streams is not ideal: the client may have sent
162 // a FIN that was lost, and simultaneously opened a new stream. The number of
163 // streams a server accepts is a fixed increment over the negotiated limit, or a
164 // percentage increase, whichever is larger.
165 const float kMaxStreamsMultiplier = 1.1f;
166 const int kMaxStreamsMinimumIncrement = 10;
167
168 // Available streams are ones with IDs less than the highest stream that has
169 // been opened which have neither been opened or reset. The limit on the number
170 // of available streams is 10 times the limit on the number of open streams.
171 const int kMaxAvailableStreamsMultiplier = 10;
172
173 // Track the number of promises that are not yet claimed by a
174 // corresponding get. This must be smaller than
175 // kMaxAvailableStreamsMultiplier, because RST on a promised stream my
176 // create available streams entries.
177 const int kMaxPromisedStreamsMultiplier = kMaxAvailableStreamsMultiplier - 1;
178
179 // TCP RFC calls for 1 second RTO however Linux differs from this default and
180 // define the minimum RTO to 200ms, we will use the same until we have data to
181 // support a higher or lower value.
182 static const int64_t kMinRetransmissionTimeMs = 200;
183
184 // We define an unsigned 16-bit floating point value, inspired by IEEE floats
185 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format),
186 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden
187 // bit) and denormals, but without signs, transfinites or fractions. Wire format
188 // 16 bits (little-endian byte order) are split into exponent (high 5) and
189 // mantissa (low 11) and decoded as:
190 // uint64_t value;
191 // if (exponent == 0) value = mantissa;
192 // else value = (mantissa | 1 << 11) << (exponent - 1)
193 const int kUFloat16ExponentBits = 5;
194 const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30
195 const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11
196 const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12
197 const uint64_t kUFloat16MaxValue = // 0x3FFC0000000
198 ((UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1)
199 << kUFloat16MaxExponent;
200
201 // Default path ID.
202 const QuicPathId kDefaultPathId = 0;
203 // Invalid path ID.
204 const QuicPathId kInvalidPathId = 0xff;
205
206 // kDiversificationNonceSize is the size, in bytes, of the nonce that a server
207 // may set in the packet header to ensure that its INITIAL keys are not
208 // duplicated.
209 const size_t kDiversificationNonceSize = 32;
210
211 // The largest gap in packets we'll accept without closing the connection.
212 // This will likely have to be tuned.
213 const QuicPacketNumber kMaxPacketGap = 5000;
214
215 enum TransmissionType : int8_t { 42 enum TransmissionType : int8_t {
216 NOT_RETRANSMISSION, 43 NOT_RETRANSMISSION,
217 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION, 44 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION,
218 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts. 45 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts.
219 ALL_UNACKED_RETRANSMISSION, // Retransmits all unacked packets. 46 ALL_UNACKED_RETRANSMISSION, // Retransmits all unacked packets.
220 ALL_INITIAL_RETRANSMISSION, // Retransmits all initially encrypted packets. 47 ALL_INITIAL_RETRANSMISSION, // Retransmits all initially encrypted packets.
221 LOSS_RETRANSMISSION, // Retransmits due to loss detection. 48 LOSS_RETRANSMISSION, // Retransmits due to loss detection.
222 RTO_RETRANSMISSION, // Retransmits due to retransmit time out. 49 RTO_RETRANSMISSION, // Retransmits due to retransmit time out.
223 TLP_RETRANSMISSION, // Tail loss probes. 50 TLP_RETRANSMISSION, // Tail loss probes.
224 LAST_TRANSMISSION_TYPE = TLP_RETRANSMISSION, 51 LAST_TRANSMISSION_TYPE = TLP_RETRANSMISSION,
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1519 : iov(iov), iov_count(iov_count), total_length(total_length) {} 1346 : iov(iov), iov_count(iov_count), total_length(total_length) {}
1520 1347
1521 const struct iovec* iov; 1348 const struct iovec* iov;
1522 const int iov_count; 1349 const int iov_count;
1523 const size_t total_length; 1350 const size_t total_length;
1524 }; 1351 };
1525 1352
1526 } // namespace net 1353 } // namespace net
1527 1354
1528 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 1355 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/quic/core/quic_constants.h ('k') | net/quic/core/quic_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698