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 <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // QuicTag is the type of a tag in the wire protocol. | 49 // QuicTag is the type of a tag in the wire protocol. |
50 typedef uint32_t QuicTag; | 50 typedef uint32_t QuicTag; |
51 typedef std::vector<QuicTag> QuicTagVector; | 51 typedef std::vector<QuicTag> QuicTagVector; |
52 typedef std::map<QuicTag, std::string> QuicTagValueMap; | 52 typedef std::map<QuicTag, std::string> QuicTagValueMap; |
53 typedef uint16_t QuicPacketLength; | 53 typedef uint16_t QuicPacketLength; |
54 | 54 |
55 // Default initial maximum size in bytes of a QUIC packet. | 55 // Default initial maximum size in bytes of a QUIC packet. |
56 const QuicByteCount kDefaultMaxPacketSize = 1350; | 56 const QuicByteCount kDefaultMaxPacketSize = 1350; |
57 // Default initial maximum size in bytes of a QUIC packet for servers. | 57 // Default initial maximum size in bytes of a QUIC packet for servers. |
58 const QuicByteCount kDefaultServerMaxPacketSize = 1000; | 58 const QuicByteCount kDefaultServerMaxPacketSize = 1000; |
59 // Minimum size of a QUIC packet, used if a server receives packets from a | |
60 // client with unusual network headers. 1280 - sizeof(eth) - sizeof(ipv6). | |
61 const QuicByteCount kMinimumSupportedPacketSize = 1214; | |
62 // The maximum packet size of any QUIC packet, based on ethernet's max size, | 59 // The maximum packet size of any QUIC packet, based on ethernet's max size, |
63 // minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an | 60 // minus the IP and UDP headers. IPv6 has a 40 byte header, UDP adds an |
64 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's | 61 // additional 8 bytes. This is a total overhead of 48 bytes. Ethernet's |
65 // max packet size is 1500 bytes, 1500 - 48 = 1452. | 62 // max packet size is 1500 bytes, 1500 - 48 = 1452. |
66 const QuicByteCount kMaxPacketSize = 1452; | 63 const QuicByteCount kMaxPacketSize = 1452; |
67 // Default maximum packet size used in the Linux TCP implementation. | 64 // Default maximum packet size used in the Linux TCP implementation. |
68 // Used in QUIC for congestion window computations in bytes. | 65 // Used in QUIC for congestion window computations in bytes. |
69 const QuicByteCount kDefaultTCPMSS = 1460; | 66 const QuicByteCount kDefaultTCPMSS = 1460; |
70 | 67 |
71 // We match SPDY's use of 32 (since we'd compete with SPDY). | 68 // We match SPDY's use of 32 (since we'd compete with SPDY). |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 PACKET_PUBLIC_FLAGS_MAX = (1 << 7) - 1, | 335 PACKET_PUBLIC_FLAGS_MAX = (1 << 7) - 1, |
339 }; | 336 }; |
340 | 337 |
341 // The private flags are specified in one byte. | 338 // The private flags are specified in one byte. |
342 enum QuicPacketPrivateFlags { | 339 enum QuicPacketPrivateFlags { |
343 PACKET_PRIVATE_FLAGS_NONE = 0, | 340 PACKET_PRIVATE_FLAGS_NONE = 0, |
344 | 341 |
345 // Bit 0: Does this packet contain an entropy bit? | 342 // Bit 0: Does this packet contain an entropy bit? |
346 PACKET_PRIVATE_FLAGS_ENTROPY = 1 << 0, | 343 PACKET_PRIVATE_FLAGS_ENTROPY = 1 << 0, |
347 | 344 |
348 // Bit 1: Payload is part of an FEC group? | 345 // (bits 1-7 are not used): 00000001 |
349 PACKET_PRIVATE_FLAGS_FEC_GROUP = 1 << 1, | 346 PACKET_PRIVATE_FLAGS_MAX = (1 << 1) - 1 |
350 | |
351 // Bit 2: Payload is FEC as opposed to frames? | |
352 PACKET_PRIVATE_FLAGS_FEC = 1 << 2, | |
353 | |
354 // All bits set (bits 3-7 are not currently used): 00000111 | |
355 PACKET_PRIVATE_FLAGS_MAX = (1 << 3) - 1, | |
356 | |
357 // For version 32 (bits 1-7 are not used): 00000001 | |
358 PACKET_PRIVATE_FLAGS_MAX_VERSION_32 = (1 << 1) - 1 | |
359 }; | 347 }; |
360 | 348 |
361 // The available versions of QUIC. Guaranteed that the integer value of the enum | 349 // The available versions of QUIC. Guaranteed that the integer value of the enum |
362 // will match the version number. | 350 // will match the version number. |
363 // When adding a new version to this enum you should add it to | 351 // When adding a new version to this enum you should add it to |
364 // kSupportedQuicVersions (if appropriate), and also add a new case to the | 352 // kSupportedQuicVersions (if appropriate), and also add a new case to the |
365 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and | 353 // helper methods QuicVersionToQuicTag, QuicTagToQuicVersion, and |
366 // QuicVersionToString. | 354 // QuicVersionToString. |
367 enum QuicVersion { | 355 enum QuicVersion { |
368 // Special case to indicate unknown/unsupported QUIC version. | 356 // Special case to indicate unknown/unsupported QUIC version. |
369 QUIC_VERSION_UNSUPPORTED = 0, | 357 QUIC_VERSION_UNSUPPORTED = 0, |
370 | 358 |
371 QUIC_VERSION_30 = 30, // Add server side support of cert transparency. | |
372 QUIC_VERSION_31 = 31, // Adds a hash of the client hello to crypto proof. | |
373 QUIC_VERSION_32 = 32, // FEC related fields are removed from wire format. | 359 QUIC_VERSION_32 = 32, // FEC related fields are removed from wire format. |
374 QUIC_VERSION_33 = 33, // Adds diversification nonces. | 360 QUIC_VERSION_33 = 33, // Adds diversification nonces. |
375 QUIC_VERSION_34 = 34, // Deprecates entropy, removes private flag from packet | 361 QUIC_VERSION_34 = 34, // Deprecates entropy, removes private flag from packet |
376 // header, uses new ack and stop waiting wire format. | 362 // header, uses new ack and stop waiting wire format. |
377 QUIC_VERSION_35 = 35, // Allows endpoints to independently set stream limit. | 363 QUIC_VERSION_35 = 35, // Allows endpoints to independently set stream limit. |
378 QUIC_VERSION_36 = 36, // Add support to force HOL blocking. | 364 QUIC_VERSION_36 = 36, // Add support to force HOL blocking. |
379 | 365 |
380 // IMPORTANT: if you are adding to this std::list, follow the instructions at | 366 // IMPORTANT: if you are adding to this std::list, follow the instructions at |
381 // http://sites/quic/adding-and-removing-versions | 367 // http://sites/quic/adding-and-removing-versions |
382 }; | 368 }; |
383 | 369 |
384 // This vector contains QUIC versions which we currently support. | 370 // This vector contains QUIC versions which we currently support. |
385 // This should be ordered such that the highest supported version is the first | 371 // This should be ordered such that the highest supported version is the first |
386 // element, with subsequent elements in descending order (versions can be | 372 // element, with subsequent elements in descending order (versions can be |
387 // skipped as necessary). | 373 // skipped as necessary). |
388 // | 374 // |
389 // IMPORTANT: if you are adding to this list, follow the instructions at | 375 // IMPORTANT: if you are adding to this list, follow the instructions at |
390 // http://sites/quic/adding-and-removing-versions | 376 // http://sites/quic/adding-and-removing-versions |
391 static const QuicVersion kSupportedQuicVersions[] = { | 377 static const QuicVersion kSupportedQuicVersions[] = { |
392 QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34, QUIC_VERSION_33, | 378 QUIC_VERSION_36, QUIC_VERSION_35, QUIC_VERSION_34, QUIC_VERSION_33, |
393 QUIC_VERSION_32, QUIC_VERSION_31, QUIC_VERSION_30}; | 379 QUIC_VERSION_32}; |
394 | 380 |
395 typedef std::vector<QuicVersion> QuicVersionVector; | 381 typedef std::vector<QuicVersion> QuicVersionVector; |
396 | 382 |
397 // Returns a vector of QUIC versions in kSupportedQuicVersions. | 383 // Returns a vector of QUIC versions in kSupportedQuicVersions. |
398 NET_EXPORT_PRIVATE QuicVersionVector AllSupportedVersions(); | 384 NET_EXPORT_PRIVATE QuicVersionVector AllSupportedVersions(); |
399 | 385 |
400 // Returns a vector of QUIC versions from kSupportedQuicVersions which exclude | 386 // Returns a vector of QUIC versions from kSupportedQuicVersions which exclude |
401 // any versions which are disabled by flags. | 387 // any versions which are disabled by flags. |
402 NET_EXPORT_PRIVATE QuicVersionVector CurrentSupportedVersions(); | 388 NET_EXPORT_PRIVATE QuicVersionVector CurrentSupportedVersions(); |
403 | 389 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 QuicPacketHeader(const QuicPacketHeader& other); | 753 QuicPacketHeader(const QuicPacketHeader& other); |
768 | 754 |
769 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, | 755 NET_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream& os, |
770 const QuicPacketHeader& s); | 756 const QuicPacketHeader& s); |
771 | 757 |
772 QuicPacketPublicHeader public_header; | 758 QuicPacketPublicHeader public_header; |
773 QuicPacketNumber packet_number; | 759 QuicPacketNumber packet_number; |
774 QuicPathId path_id; | 760 QuicPathId path_id; |
775 bool entropy_flag; | 761 bool entropy_flag; |
776 QuicPacketEntropyHash entropy_hash; | 762 QuicPacketEntropyHash entropy_hash; |
777 bool fec_flag; | |
778 }; | 763 }; |
779 | 764 |
780 struct NET_EXPORT_PRIVATE QuicPublicResetPacket { | 765 struct NET_EXPORT_PRIVATE QuicPublicResetPacket { |
781 QuicPublicResetPacket(); | 766 QuicPublicResetPacket(); |
782 explicit QuicPublicResetPacket(const QuicPacketPublicHeader& header); | 767 explicit QuicPublicResetPacket(const QuicPacketPublicHeader& header); |
783 | 768 |
784 QuicPacketPublicHeader public_header; | 769 QuicPacketPublicHeader public_header; |
785 QuicPublicResetNonceProof nonce_proof; | 770 QuicPublicResetNonceProof nonce_proof; |
| 771 // TODO(fayang): remove rejected_packet_number when deprecating |
| 772 // FLAGS_quic_remove_packet_number_from_public_reset. |
786 QuicPacketNumber rejected_packet_number; | 773 QuicPacketNumber rejected_packet_number; |
787 IPEndPoint client_address; | 774 IPEndPoint client_address; |
788 }; | 775 }; |
789 | 776 |
790 enum QuicVersionNegotiationState { | 777 enum QuicVersionNegotiationState { |
791 START_NEGOTIATION = 0, | 778 START_NEGOTIATION = 0, |
792 // Server-side this implies we've sent a version negotiation packet and are | 779 // Server-side this implies we've sent a version negotiation packet and are |
793 // waiting on the client to select a compatible version. Client-side this | 780 // waiting on the client to select a compatible version. Client-side this |
794 // implies we've gotten a version negotiation packet, are retransmitting the | 781 // implies we've gotten a version negotiation packet, are retransmitting the |
795 // initial packets with a supported version and are waiting for our first | 782 // initial packets with a supported version and are waiting for our first |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 kCubicBytes, | 1052 kCubicBytes, |
1066 kReno, | 1053 kReno, |
1067 kRenoBytes, | 1054 kRenoBytes, |
1068 kBBR, | 1055 kBBR, |
1069 }; | 1056 }; |
1070 | 1057 |
1071 enum LossDetectionType { | 1058 enum LossDetectionType { |
1072 kNack, // Used to mimic TCP's loss detection. | 1059 kNack, // Used to mimic TCP's loss detection. |
1073 kTime, // Time based loss detection. | 1060 kTime, // Time based loss detection. |
1074 kAdaptiveTime, // Adaptive time based loss detection. | 1061 kAdaptiveTime, // Adaptive time based loss detection. |
| 1062 kLazyFack, // Nack based but with FACK disabled for the first ack. |
1075 }; | 1063 }; |
1076 | 1064 |
1077 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { | 1065 struct NET_EXPORT_PRIVATE QuicRstStreamFrame { |
1078 QuicRstStreamFrame(); | 1066 QuicRstStreamFrame(); |
1079 QuicRstStreamFrame(QuicStreamId stream_id, | 1067 QuicRstStreamFrame(QuicStreamId stream_id, |
1080 QuicRstStreamErrorCode error_code, | 1068 QuicRstStreamErrorCode error_code, |
1081 QuicStreamOffset bytes_written); | 1069 QuicStreamOffset bytes_written); |
1082 | 1070 |
1083 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1071 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
1084 std::ostream& os, | 1072 std::ostream& os, |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 public: | 1312 public: |
1325 QuicReceivedPacket(const char* buffer, size_t length, QuicTime receipt_time); | 1313 QuicReceivedPacket(const char* buffer, size_t length, QuicTime receipt_time); |
1326 QuicReceivedPacket(const char* buffer, | 1314 QuicReceivedPacket(const char* buffer, |
1327 size_t length, | 1315 size_t length, |
1328 QuicTime receipt_time, | 1316 QuicTime receipt_time, |
1329 bool owns_buffer); | 1317 bool owns_buffer); |
1330 QuicReceivedPacket(const char* buffer, | 1318 QuicReceivedPacket(const char* buffer, |
1331 size_t length, | 1319 size_t length, |
1332 QuicTime receipt_time, | 1320 QuicTime receipt_time, |
1333 bool owns_buffer, | 1321 bool owns_buffer, |
1334 bool potentially_small_mtu, | |
1335 int ttl, | 1322 int ttl, |
1336 bool ttl_valid); | 1323 bool ttl_valid); |
1337 | 1324 |
1338 // Clones the packet into a new packet which owns the buffer. | 1325 // Clones the packet into a new packet which owns the buffer. |
1339 QuicReceivedPacket* Clone() const; | 1326 QuicReceivedPacket* Clone() const; |
1340 | 1327 |
1341 // Returns the time at which the packet was received. | 1328 // Returns the time at which the packet was received. |
1342 QuicTime receipt_time() const { return receipt_time_; } | 1329 QuicTime receipt_time() const { return receipt_time_; } |
1343 | 1330 |
1344 // This is the TTL of the packet, assuming ttl_vaild_ is true. | 1331 // This is the TTL of the packet, assuming ttl_vaild_ is true. |
1345 int ttl() const { return ttl_; } | 1332 int ttl() const { return ttl_; } |
1346 | 1333 |
1347 bool potentially_small_mtu() const { return potentially_small_mtu_; } | |
1348 | |
1349 // By default, gtest prints the raw bytes of an object. The bool data | 1334 // By default, gtest prints the raw bytes of an object. The bool data |
1350 // member (in the base class QuicData) causes this object to have padding | 1335 // member (in the base class QuicData) causes this object to have padding |
1351 // bytes, which causes the default gtest object printer to read | 1336 // bytes, which causes the default gtest object printer to read |
1352 // uninitialize memory. So we need to teach gtest how to print this object. | 1337 // uninitialize memory. So we need to teach gtest how to print this object. |
1353 NET_EXPORT_PRIVATE friend std::ostream& operator<<( | 1338 NET_EXPORT_PRIVATE friend std::ostream& operator<<( |
1354 std::ostream& os, | 1339 std::ostream& os, |
1355 const QuicReceivedPacket& s); | 1340 const QuicReceivedPacket& s); |
1356 | 1341 |
1357 private: | 1342 private: |
1358 const QuicTime receipt_time_; | 1343 const QuicTime receipt_time_; |
1359 int ttl_; | 1344 int ttl_; |
1360 bool potentially_small_mtu_; | |
1361 | 1345 |
1362 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); | 1346 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacket); |
1363 }; | 1347 }; |
1364 | 1348 |
1365 // Pure virtual class to listen for packet acknowledgements. | 1349 // Pure virtual class to listen for packet acknowledgements. |
1366 class NET_EXPORT_PRIVATE QuicAckListenerInterface | 1350 class NET_EXPORT_PRIVATE QuicAckListenerInterface |
1367 : public base::RefCounted<QuicAckListenerInterface> { | 1351 : public base::RefCounted<QuicAckListenerInterface> { |
1368 public: | 1352 public: |
1369 QuicAckListenerInterface() {} | 1353 QuicAckListenerInterface() {} |
1370 | 1354 |
(...skipping 27 matching lines...) Expand all Loading... |
1398 // Used to generate filtered supported versions based on flags. | 1382 // Used to generate filtered supported versions based on flags. |
1399 class NET_EXPORT_PRIVATE QuicVersionManager { | 1383 class NET_EXPORT_PRIVATE QuicVersionManager { |
1400 public: | 1384 public: |
1401 explicit QuicVersionManager(QuicVersionVector supported_versions); | 1385 explicit QuicVersionManager(QuicVersionVector supported_versions); |
1402 ~QuicVersionManager(); | 1386 ~QuicVersionManager(); |
1403 | 1387 |
1404 // Returns supported versions based on flags. | 1388 // Returns supported versions based on flags. |
1405 const QuicVersionVector& GetSupportedVersions(); | 1389 const QuicVersionVector& GetSupportedVersions(); |
1406 | 1390 |
1407 private: | 1391 private: |
1408 // FLAGS_quic_disable_pre_32 | |
1409 bool disable_pre_32_; | |
1410 // FLAGS_quic_disable_pre_34 | 1392 // FLAGS_quic_disable_pre_34 |
1411 bool disable_pre_34_; | 1393 bool disable_pre_34_; |
1412 // FLAGS_quic_enable_version_35 | 1394 // FLAGS_quic_enable_version_35 |
1413 bool enable_version_35_; | 1395 bool enable_version_35_; |
1414 // FLAGS_quic_enable_version_36_v2 | 1396 // FLAGS_quic_enable_version_36_v2 |
1415 bool enable_version_36_; | 1397 bool enable_version_36_; |
1416 // The list of versions that may be supported. | 1398 // The list of versions that may be supported. |
1417 QuicVersionVector allowed_supported_versions_; | 1399 QuicVersionVector allowed_supported_versions_; |
1418 // This vector contains QUIC versions which are currently supported based | 1400 // This vector contains QUIC versions which are currently supported based |
1419 // on flags. | 1401 // on flags. |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1544 : iov(iov), iov_count(iov_count), total_length(total_length) {} | 1526 : iov(iov), iov_count(iov_count), total_length(total_length) {} |
1545 | 1527 |
1546 const struct iovec* iov; | 1528 const struct iovec* iov; |
1547 const int iov_count; | 1529 const int iov_count; |
1548 const size_t total_length; | 1530 const size_t total_length; |
1549 }; | 1531 }; |
1550 | 1532 |
1551 } // namespace net | 1533 } // namespace net |
1552 | 1534 |
1553 #endif // NET_QUIC_QUIC_PROTOCOL_H_ | 1535 #endif // NET_QUIC_QUIC_PROTOCOL_H_ |
OLD | NEW |