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

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

Issue 1535363003: Switch to standard integer types in net/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stddef Created 5 years 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/quic_packet_writer.h ('k') | net/quic/quic_protocol.cc » ('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 #include <limits> 11 #include <limits>
11 #include <list> 12 #include <list>
12 #include <map> 13 #include <map>
13 #include <ostream> 14 #include <ostream>
14 #include <set> 15 #include <set>
15 #include <string> 16 #include <string>
16 #include <utility> 17 #include <utility>
17 #include <vector> 18 #include <vector>
18 19
19 #include "base/basictypes.h"
20 #include "base/containers/hash_tables.h" 20 #include "base/containers/hash_tables.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/macros.h"
22 #include "base/memory/ref_counted.h" 23 #include "base/memory/ref_counted.h"
23 #include "base/memory/scoped_ptr.h" 24 #include "base/memory/scoped_ptr.h"
24 #include "base/strings/string_piece.h" 25 #include "base/strings/string_piece.h"
25 #include "net/base/int128.h" 26 #include "net/base/int128.h"
26 #include "net/base/iovec.h" 27 #include "net/base/iovec.h"
27 #include "net/base/ip_endpoint.h" 28 #include "net/base/ip_endpoint.h"
28 #include "net/base/net_export.h" 29 #include "net/base/net_export.h"
29 #include "net/quic/interval_set.h" 30 #include "net/quic/interval_set.h"
30 #include "net/quic/quic_ack_listener_interface.h" 31 #include "net/quic/quic_ack_listener_interface.h"
31 #include "net/quic/quic_bandwidth.h" 32 #include "net/quic/quic_bandwidth.h"
32 #include "net/quic/quic_time.h" 33 #include "net/quic/quic_time.h"
33 #include "net/quic/quic_types.h" 34 #include "net/quic/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 40
40 typedef uint64 QuicConnectionId; 41 typedef uint64_t QuicConnectionId;
41 typedef uint32 QuicStreamId; 42 typedef uint32_t QuicStreamId;
42 typedef uint64 QuicStreamOffset; 43 typedef uint64_t QuicStreamOffset;
43 typedef uint64 QuicPacketNumber; 44 typedef uint64_t QuicPacketNumber;
44 typedef uint8 QuicPathId; 45 typedef uint8_t QuicPathId;
45 typedef QuicPacketNumber QuicFecGroupNumber; 46 typedef QuicPacketNumber QuicFecGroupNumber;
46 typedef uint64 QuicPublicResetNonceProof; 47 typedef uint64_t QuicPublicResetNonceProof;
47 typedef uint8 QuicPacketEntropyHash; 48 typedef uint8_t QuicPacketEntropyHash;
48 typedef uint32 QuicHeaderId; 49 typedef uint32_t QuicHeaderId;
49 // QuicTag is the type of a tag in the wire protocol. 50 // QuicTag is the type of a tag in the wire protocol.
50 typedef uint32 QuicTag; 51 typedef uint32_t QuicTag;
51 typedef std::vector<QuicTag> QuicTagVector; 52 typedef std::vector<QuicTag> QuicTagVector;
52 typedef std::map<QuicTag, std::string> QuicTagValueMap; 53 typedef std::map<QuicTag, std::string> QuicTagValueMap;
53 typedef uint16 QuicPacketLength; 54 typedef uint16_t QuicPacketLength;
54 55
55 // Default initial maximum size in bytes of a QUIC packet. 56 // Default initial maximum size in bytes of a QUIC packet.
56 const QuicByteCount kDefaultMaxPacketSize = 1350; 57 const QuicByteCount kDefaultMaxPacketSize = 1350;
57 // Default initial maximum size in bytes of a QUIC packet for servers. 58 // Default initial maximum size in bytes of a QUIC packet for servers.
58 const QuicByteCount kDefaultServerMaxPacketSize = 1000; 59 const QuicByteCount kDefaultServerMaxPacketSize = 1000;
59 // The maximum packet size of any QUIC packet, based on ethernet's max size, 60 // 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, UPD adds an 61 // minus the IP and UDP headers. IPv6 has a 40 byte header, UPD adds an
61 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's 62 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's
62 // max packet size is 1500 bytes, 1500 - 48 = 1452. 63 // max packet size is 1500 bytes, 1500 - 48 = 1452.
63 const QuicByteCount kMaxPacketSize = 1452; 64 const QuicByteCount kMaxPacketSize = 1452;
64 // Default maximum packet size used in the Linux TCP implementation. 65 // Default maximum packet size used in the Linux TCP implementation.
65 // Used in QUIC for congestion window computations in bytes. 66 // Used in QUIC for congestion window computations in bytes.
66 const QuicByteCount kDefaultTCPMSS = 1460; 67 const QuicByteCount kDefaultTCPMSS = 1460;
67 68
68 // We match SPDY's use of 32 (since we'd compete with SPDY). 69 // We match SPDY's use of 32 (since we'd compete with SPDY).
69 const QuicPacketCount kInitialCongestionWindow = 32; 70 const QuicPacketCount kInitialCongestionWindow = 32;
70 71
71 // Minimum size of initial flow control window, for both stream and session. 72 // Minimum size of initial flow control window, for both stream and session.
72 const uint32 kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB 73 const uint32_t kMinimumFlowControlSendWindow = 16 * 1024; // 16 KB
73 74
74 // Maximum flow control receive window limits for connection and stream. 75 // Maximum flow control receive window limits for connection and stream.
75 const QuicByteCount kStreamReceiveWindowLimit = 16 * 1024 * 1024; // 16 MB 76 const QuicByteCount kStreamReceiveWindowLimit = 16 * 1024 * 1024; // 16 MB
76 const QuicByteCount kSessionReceiveWindowLimit = 24 * 1024 * 1024; // 24 MB 77 const QuicByteCount kSessionReceiveWindowLimit = 24 * 1024 * 1024; // 24 MB
77 78
78 // Minimum size of the CWND, in packets, when doing bandwidth resumption. 79 // Minimum size of the CWND, in packets, when doing bandwidth resumption.
79 const QuicPacketCount kMinCongestionWindowForBandwidthResumption = 10; 80 const QuicPacketCount kMinCongestionWindowForBandwidthResumption = 10;
80 81
81 // Maximum size of the CWND, in packets. 82 // Maximum size of the CWND, in packets.
82 const QuicPacketCount kMaxCongestionWindow = 200; 83 const QuicPacketCount kMaxCongestionWindow = 200;
83 84
84 // Maximum number of tracked packets. 85 // Maximum number of tracked packets.
85 const QuicPacketCount kMaxTrackedPackets = 5000; 86 const QuicPacketCount kMaxTrackedPackets = 5000;
86 87
87 // Default size of the socket receive buffer in bytes. 88 // Default size of the socket receive buffer in bytes.
88 const QuicByteCount kDefaultSocketReceiveBuffer = 256 * 1024; 89 const QuicByteCount kDefaultSocketReceiveBuffer = 256 * 1024;
89 // Minimum size of the socket receive buffer in bytes. 90 // Minimum size of the socket receive buffer in bytes.
90 // Smaller values are ignored. 91 // Smaller values are ignored.
91 const QuicByteCount kMinSocketReceiveBuffer = 16 * 1024; 92 const QuicByteCount kMinSocketReceiveBuffer = 16 * 1024;
92 93
93 // Fraction of the receive buffer that can be used for encrypted bytes. 94 // Fraction of the receive buffer that can be used for encrypted bytes.
94 // Allows a 5% overhead for IP and UDP framing, as well as ack only packets. 95 // Allows a 5% overhead for IP and UDP framing, as well as ack only packets.
95 static const float kUsableRecieveBufferFraction = 0.95f; 96 static const float kUsableRecieveBufferFraction = 0.95f;
96 // Fraction of the receive buffer that can be used, based on conservative 97 // Fraction of the receive buffer that can be used, based on conservative
97 // estimates and testing on Linux. 98 // estimates and testing on Linux.
98 // An alternative to kUsableRecieveBufferFraction. 99 // An alternative to kUsableRecieveBufferFraction.
99 static const float kConservativeReceiveBufferFraction = 0.6f; 100 static const float kConservativeReceiveBufferFraction = 0.6f;
100 101
101 // Don't allow a client to suggest an RTT shorter than 10ms. 102 // Don't allow a client to suggest an RTT shorter than 10ms.
102 const uint32 kMinInitialRoundTripTimeUs = 10 * kNumMicrosPerMilli; 103 const uint32_t kMinInitialRoundTripTimeUs = 10 * kNumMicrosPerMilli;
103 104
104 // Don't allow a client to suggest an RTT longer than 15 seconds. 105 // Don't allow a client to suggest an RTT longer than 15 seconds.
105 const uint32 kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond; 106 const uint32_t kMaxInitialRoundTripTimeUs = 15 * kNumMicrosPerSecond;
106 107
107 // Maximum number of open streams per connection. 108 // Maximum number of open streams per connection.
108 const size_t kDefaultMaxStreamsPerConnection = 100; 109 const size_t kDefaultMaxStreamsPerConnection = 100;
109 110
110 // Number of bytes reserved for public flags in the packet header. 111 // Number of bytes reserved for public flags in the packet header.
111 const size_t kPublicFlagsSize = 1; 112 const size_t kPublicFlagsSize = 1;
112 // Number of bytes reserved for version number in the packet header. 113 // Number of bytes reserved for version number in the packet header.
113 const size_t kQuicVersionSize = 4; 114 const size_t kQuicVersionSize = 4;
114 // Number of bytes reserved for path id in the packet header. 115 // Number of bytes reserved for path id in the packet header.
115 const size_t kQuicPathIdSize = 1; 116 const size_t kQuicPathIdSize = 1;
(...skipping 11 matching lines...) Expand all
127 const QuicStreamId kCryptoStreamId = 1; 128 const QuicStreamId kCryptoStreamId = 1;
128 129
129 // Reserved ID for the headers stream. 130 // Reserved ID for the headers stream.
130 const QuicStreamId kHeadersStreamId = 3; 131 const QuicStreamId kHeadersStreamId = 3;
131 132
132 // Header key used to identify final offset on data stream when sending HTTP/2 133 // Header key used to identify final offset on data stream when sending HTTP/2
133 // trailing headers over QUIC. 134 // trailing headers over QUIC.
134 NET_EXPORT_PRIVATE extern const char* const kFinalOffsetHeaderKey; 135 NET_EXPORT_PRIVATE extern const char* const kFinalOffsetHeaderKey;
135 136
136 // Maximum delayed ack time, in ms. 137 // Maximum delayed ack time, in ms.
137 const int64 kMaxDelayedAckTimeMs = 25; 138 const int64_t kMaxDelayedAckTimeMs = 25;
138 139
139 // The timeout before the handshake succeeds. 140 // The timeout before the handshake succeeds.
140 const int64 kInitialIdleTimeoutSecs = 5; 141 const int64_t kInitialIdleTimeoutSecs = 5;
141 // The default idle timeout. 142 // The default idle timeout.
142 const int64 kDefaultIdleTimeoutSecs = 30; 143 const int64_t kDefaultIdleTimeoutSecs = 30;
143 // The maximum idle timeout that can be negotiated. 144 // The maximum idle timeout that can be negotiated.
144 const int64 kMaximumIdleTimeoutSecs = 60 * 10; // 10 minutes. 145 const int64_t kMaximumIdleTimeoutSecs = 60 * 10; // 10 minutes.
145 // The default timeout for a connection until the crypto handshake succeeds. 146 // The default timeout for a connection until the crypto handshake succeeds.
146 const int64 kMaxTimeForCryptoHandshakeSecs = 10; // 10 secs. 147 const int64_t kMaxTimeForCryptoHandshakeSecs = 10; // 10 secs.
147 148
148 // Default limit on the number of undecryptable packets the connection buffers 149 // Default limit on the number of undecryptable packets the connection buffers
149 // before the CHLO/SHLO arrive. 150 // before the CHLO/SHLO arrive.
150 const size_t kDefaultMaxUndecryptablePackets = 10; 151 const size_t kDefaultMaxUndecryptablePackets = 10;
151 152
152 // Default ping timeout. 153 // Default ping timeout.
153 const int64 kPingTimeoutSecs = 15; // 15 secs. 154 const int64_t kPingTimeoutSecs = 15; // 15 secs.
154 155
155 // Minimum number of RTTs between Server Config Updates (SCUP) sent to client. 156 // Minimum number of RTTs between Server Config Updates (SCUP) sent to client.
156 const int kMinIntervalBetweenServerConfigUpdatesRTTs = 10; 157 const int kMinIntervalBetweenServerConfigUpdatesRTTs = 10;
157 158
158 // Minimum time between Server Config Updates (SCUP) sent to client. 159 // Minimum time between Server Config Updates (SCUP) sent to client.
159 const int kMinIntervalBetweenServerConfigUpdatesMs = 1000; 160 const int kMinIntervalBetweenServerConfigUpdatesMs = 1000;
160 161
161 // Minimum number of packets between Server Config Updates (SCUP). 162 // Minimum number of packets between Server Config Updates (SCUP).
162 const int kMinPacketsBetweenServerConfigUpdates = 100; 163 const int kMinPacketsBetweenServerConfigUpdates = 100;
163 164
(...skipping 10 matching lines...) Expand all
174 // been opened which have neither been opened or reset. The limit on the number 175 // been opened which have neither been opened or reset. The limit on the number
175 // of available streams is 10 times the limit on the number of open streams. 176 // of available streams is 10 times the limit on the number of open streams.
176 const int kMaxAvailableStreamsMultiplier = 10; 177 const int kMaxAvailableStreamsMultiplier = 10;
177 178
178 // We define an unsigned 16-bit floating point value, inspired by IEEE floats 179 // We define an unsigned 16-bit floating point value, inspired by IEEE floats
179 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), 180 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format),
180 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden 181 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden
181 // bit) and denormals, but without signs, transfinites or fractions. Wire format 182 // bit) and denormals, but without signs, transfinites or fractions. Wire format
182 // 16 bits (little-endian byte order) are split into exponent (high 5) and 183 // 16 bits (little-endian byte order) are split into exponent (high 5) and
183 // mantissa (low 11) and decoded as: 184 // mantissa (low 11) and decoded as:
184 // uint64 value; 185 // uint64_t value;
185 // if (exponent == 0) value = mantissa; 186 // if (exponent == 0) value = mantissa;
186 // else value = (mantissa | 1 << 11) << (exponent - 1) 187 // else value = (mantissa | 1 << 11) << (exponent - 1)
187 const int kUFloat16ExponentBits = 5; 188 const int kUFloat16ExponentBits = 5;
188 const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30 189 const int kUFloat16MaxExponent = (1 << kUFloat16ExponentBits) - 2; // 30
189 const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11 190 const int kUFloat16MantissaBits = 16 - kUFloat16ExponentBits; // 11
190 const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12 191 const int kUFloat16MantissaEffectiveBits = kUFloat16MantissaBits + 1; // 12
191 const uint64 kUFloat16MaxValue = // 0x3FFC0000000 192 const uint64_t kUFloat16MaxValue = // 0x3FFC0000000
192 ((UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1) 193 ((UINT64_C(1) << kUFloat16MantissaEffectiveBits) - 1)
193 << kUFloat16MaxExponent; 194 << kUFloat16MaxExponent;
194 195
195 // Default path ID. 196 // Default path ID.
196 const QuicPathId kDefaultPathId = 0; 197 const QuicPathId kDefaultPathId = 0;
197 198
198 enum TransmissionType { 199 enum TransmissionType {
199 NOT_RETRANSMISSION, 200 NOT_RETRANSMISSION,
200 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION, 201 FIRST_TRANSMISSION_TYPE = NOT_RETRANSMISSION,
201 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts. 202 HANDSHAKE_RETRANSMISSION, // Retransmits due to handshake timeouts.
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 393
393 // Returns comma separated list of string representations of QuicVersion enum 394 // Returns comma separated list of string representations of QuicVersion enum
394 // values in the supplied |versions| vector. 395 // values in the supplied |versions| vector.
395 NET_EXPORT_PRIVATE std::string QuicVersionVectorToString( 396 NET_EXPORT_PRIVATE std::string QuicVersionVectorToString(
396 const QuicVersionVector& versions); 397 const QuicVersionVector& versions);
397 398
398 // Version and Crypto tags are written to the wire with a big-endian 399 // Version and Crypto tags are written to the wire with a big-endian
399 // representation of the name of the tag. For example 400 // representation of the name of the tag. For example
400 // the client hello tag (CHLO) will be written as the 401 // the client hello tag (CHLO) will be written as the
401 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is 402 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is
402 // stored in memory as a little endian uint32, we need 403 // stored in memory as a little endian uint32_t, we need
403 // to reverse the order of the bytes. 404 // to reverse the order of the bytes.
404 405
405 // MakeQuicTag returns a value given the four bytes. For example: 406 // MakeQuicTag returns a value given the four bytes. For example:
406 // MakeQuicTag('C', 'H', 'L', 'O'); 407 // MakeQuicTag('C', 'H', 'L', 'O');
407 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); 408 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d);
408 409
409 // Returns true if the tag vector contains the specified tag. 410 // Returns true if the tag vector contains the specified tag.
410 NET_EXPORT_PRIVATE bool ContainsQuicTag(const QuicTagVector& tag_vector, 411 NET_EXPORT_PRIVATE bool ContainsQuicTag(const QuicTagVector& tag_vector,
411 QuicTag tag); 412 QuicTag tag);
412 413
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 QuicTime sent_time, 1243 QuicTime sent_time,
1243 QuicPacketLength bytes_sent, 1244 QuicPacketLength bytes_sent,
1244 bool is_fec_packet); 1245 bool is_fec_packet);
1245 1246
1246 ~TransmissionInfo(); 1247 ~TransmissionInfo();
1247 1248
1248 RetransmittableFrames* retransmittable_frames; 1249 RetransmittableFrames* retransmittable_frames;
1249 EncryptionLevel encryption_level; 1250 EncryptionLevel encryption_level;
1250 QuicPacketNumberLength packet_number_length; 1251 QuicPacketNumberLength packet_number_length;
1251 QuicPacketLength bytes_sent; 1252 QuicPacketLength bytes_sent;
1252 uint16 nack_count; 1253 uint16_t nack_count;
1253 QuicTime sent_time; 1254 QuicTime sent_time;
1254 // Reason why this packet was transmitted. 1255 // Reason why this packet was transmitted.
1255 TransmissionType transmission_type; 1256 TransmissionType transmission_type;
1256 // In flight packets have not been abandoned or lost. 1257 // In flight packets have not been abandoned or lost.
1257 bool in_flight; 1258 bool in_flight;
1258 // True if the packet can never be acked, so it can be removed. 1259 // True if the packet can never be acked, so it can be removed.
1259 bool is_unackable; 1260 bool is_unackable;
1260 // True if the packet is an FEC packet. 1261 // True if the packet is an FEC packet.
1261 bool is_fec_packet; 1262 bool is_fec_packet;
1262 // Stores the packet numbers of all transmissions of this packet. 1263 // Stores the packet numbers of all transmissions of this packet.
(...skipping 16 matching lines...) Expand all
1279 : iov(iov), iov_count(iov_count), total_length(total_length) {} 1280 : iov(iov), iov_count(iov_count), total_length(total_length) {}
1280 1281
1281 const struct iovec* iov; 1282 const struct iovec* iov;
1282 const int iov_count; 1283 const int iov_count;
1283 const size_t total_length; 1284 const size_t total_length;
1284 }; 1285 };
1285 1286
1286 } // namespace net 1287 } // namespace net
1287 1288
1288 #endif // NET_QUIC_QUIC_PROTOCOL_H_ 1289 #endif // NET_QUIC_QUIC_PROTOCOL_H_
OLDNEW
« no previous file with comments | « net/quic/quic_packet_writer.h ('k') | net/quic/quic_protocol.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698