| OLD | NEW |
| 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 <limits> | 9 #include <limits> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 // This is the default network timeout a for connection till the crypto | 106 // This is the default network timeout a for connection till the crypto |
| 107 // handshake succeeds and the negotiated timeout from the handshake is received. | 107 // handshake succeeds and the negotiated timeout from the handshake is received. |
| 108 const int64 kDefaultInitialTimeoutSecs = 120; // 2 mins. | 108 const int64 kDefaultInitialTimeoutSecs = 120; // 2 mins. |
| 109 const int64 kDefaultTimeoutSecs = 60 * 10; // 10 minutes. | 109 const int64 kDefaultTimeoutSecs = 60 * 10; // 10 minutes. |
| 110 const int64 kDefaultMaxTimeForCryptoHandshakeSecs = 5; // 5 secs. | 110 const int64 kDefaultMaxTimeForCryptoHandshakeSecs = 5; // 5 secs. |
| 111 | 111 |
| 112 // Default ping timeout. | 112 // Default ping timeout. |
| 113 const int64 kPingTimeoutSecs = 15; // 15 secs. | 113 const int64 kPingTimeoutSecs = 15; // 15 secs. |
| 114 | 114 |
| 115 // Default max packets in an FEC group. |
| 116 const size_t kMaxPacketsPerFecGroup = 10; |
| 117 |
| 115 // We define an unsigned 16-bit floating point value, inspired by IEEE floats | 118 // We define an unsigned 16-bit floating point value, inspired by IEEE floats |
| 116 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), | 119 // (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), |
| 117 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden | 120 // with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden |
| 118 // bit) and denormals, but without signs, transfinites or fractions. Wire format | 121 // bit) and denormals, but without signs, transfinites or fractions. Wire format |
| 119 // 16 bits (little-endian byte order) are split into exponent (high 5) and | 122 // 16 bits (little-endian byte order) are split into exponent (high 5) and |
| 120 // mantissa (low 11) and decoded as: | 123 // mantissa (low 11) and decoded as: |
| 121 // uint64 value; | 124 // uint64 value; |
| 122 // if (exponent == 0) value = mantissa; | 125 // if (exponent == 0) value = mantissa; |
| 123 // else value = (mantissa | 1 << 11) << (exponent - 1) | 126 // else value = (mantissa | 1 << 11) << (exponent - 1) |
| 124 const int kUFloat16ExponentBits = 5; | 127 const int kUFloat16ExponentBits = 5; |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 // When adding a new version to this enum you should add it to | 273 // When adding a new version to this enum you should add it to |
| 271 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 274 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
| 272 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 275 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
| 273 // QuicVersionToString. | 276 // QuicVersionToString. |
| 274 enum QuicVersion { | 277 enum QuicVersion { |
| 275 // Special case to indicate unknown/unsupported QUIC version. | 278 // Special case to indicate unknown/unsupported QUIC version. |
| 276 QUIC_VERSION_UNSUPPORTED = 0, | 279 QUIC_VERSION_UNSUPPORTED = 0, |
| 277 | 280 |
| 278 QUIC_VERSION_15 = 15, | 281 QUIC_VERSION_15 = 15, |
| 279 QUIC_VERSION_16 = 16, | 282 QUIC_VERSION_16 = 16, |
| 280 QUIC_VERSION_17 = 17, | |
| 281 QUIC_VERSION_18 = 18, | 283 QUIC_VERSION_18 = 18, |
| 282 QUIC_VERSION_19 = 19, | 284 QUIC_VERSION_19 = 19, |
| 283 QUIC_VERSION_20 = 20, // Current version. | 285 QUIC_VERSION_20 = 20, // Current version. |
| 284 }; | 286 }; |
| 285 | 287 |
| 286 // This vector contains QUIC versions which we currently support. | 288 // This vector contains QUIC versions which we currently support. |
| 287 // This should be ordered such that the highest supported version is the first | 289 // This should be ordered such that the highest supported version is the first |
| 288 // element, with subsequent elements in descending order (versions can be | 290 // element, with subsequent elements in descending order (versions can be |
| 289 // skipped as necessary). | 291 // skipped as necessary). |
| 290 // | 292 // |
| 291 // IMPORTANT: if you are addding to this list, follow the instructions at | 293 // IMPORTANT: if you are addding to this list, follow the instructions at |
| 292 // http://sites/quic/adding-and-removing-versions | 294 // http://sites/quic/adding-and-removing-versions |
| 293 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_20, | 295 static const QuicVersion kSupportedQuicVersions[] = {QUIC_VERSION_20, |
| 294 QUIC_VERSION_19, | 296 QUIC_VERSION_19, |
| 295 QUIC_VERSION_18, | 297 QUIC_VERSION_18, |
| 296 QUIC_VERSION_17, | |
| 297 QUIC_VERSION_16, | 298 QUIC_VERSION_16, |
| 298 QUIC_VERSION_15}; | 299 QUIC_VERSION_15}; |
| 299 | 300 |
| 300 typedef std::vector<QuicVersion> QuicVersionVector; | 301 typedef std::vector<QuicVersion> QuicVersionVector; |
| 301 | 302 |
| 302 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 303 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
| 303 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); | 304 NET_EXPORT_PRIVATE QuicVersionVector QuicSupportedVersions(); |
| 304 | 305 |
| 305 // QuicTag is written to and read from the wire, but we prefer to use | 306 // QuicTag is written to and read from the wire, but we prefer to use |
| 306 // the more readable QuicVersion at other levels. | 307 // the more readable QuicVersion at other levels. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 326 // the client hello tag (CHLO) will be written as the | 327 // the client hello tag (CHLO) will be written as the |
| 327 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is | 328 // following 4 bytes: 'C' 'H' 'L' 'O'. Since it is |
| 328 // stored in memory as a little endian uint32, we need | 329 // stored in memory as a little endian uint32, we need |
| 329 // to reverse the order of the bytes. | 330 // to reverse the order of the bytes. |
| 330 | 331 |
| 331 // MakeQuicTag returns a value given the four bytes. For example: | 332 // MakeQuicTag returns a value given the four bytes. For example: |
| 332 // MakeQuicTag('C', 'H', 'L', 'O'); | 333 // MakeQuicTag('C', 'H', 'L', 'O'); |
| 333 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); | 334 NET_EXPORT_PRIVATE QuicTag MakeQuicTag(char a, char b, char c, char d); |
| 334 | 335 |
| 335 // Returns true if the tag vector contains the specified tag. | 336 // Returns true if the tag vector contains the specified tag. |
| 336 bool ContainsQuicTag(const QuicTagVector& tag_vector, QuicTag tag); | 337 NET_EXPORT_PRIVATE bool ContainsQuicTag(const QuicTagVector& tag_vector, |
| 338 QuicTag tag); |
| 337 | 339 |
| 338 // Size in bytes of the data or fec packet header. | 340 // Size in bytes of the data or fec packet header. |
| 339 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header); | 341 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize(const QuicPacketHeader& header); |
| 340 | 342 |
| 341 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize( | 343 NET_EXPORT_PRIVATE size_t GetPacketHeaderSize( |
| 342 QuicConnectionIdLength connection_id_length, | 344 QuicConnectionIdLength connection_id_length, |
| 343 bool include_version, | 345 bool include_version, |
| 344 QuicSequenceNumberLength sequence_number_length, | 346 QuicSequenceNumberLength sequence_number_length, |
| 345 InFecGroup is_in_fec_group); | 347 InFecGroup is_in_fec_group); |
| 346 | 348 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 // Stores the sequence numbers of all transmissions of this packet. | 1065 // Stores the sequence numbers of all transmissions of this packet. |
| 1064 // Can never be null. | 1066 // Can never be null. |
| 1065 SequenceNumberSet* all_transmissions; | 1067 SequenceNumberSet* all_transmissions; |
| 1066 // In flight packets have not been abandoned or lost. | 1068 // In flight packets have not been abandoned or lost. |
| 1067 bool in_flight; | 1069 bool in_flight; |
| 1068 }; | 1070 }; |
| 1069 | 1071 |
| 1070 } // namespace net | 1072 } // namespace net |
| 1071 | 1073 |
| 1072 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1074 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
| OLD | NEW |