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

Side by Side Diff: net/quic/crypto/source_address_token.h

Issue 404343003: Add bandwidth_estimate and server_namespace fields to the source-address (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months 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 | « no previous file | net/quic/crypto/source_address_token.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ 5 #ifndef NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_
6 #define NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ 6 #define NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/strings/string_piece.h" 11 #include "base/strings/string_piece.h"
12 12
13 namespace net { 13 namespace net {
14 14
15 // TODO(rtenneti): sync with server more rationally. 15 // TODO(rtenneti): sync with server more rationally.
16 // CachedNetworkParameters contains data that can be used to choose appropriate
17 // connection parameters (initial RTT, initial CWND, etc.) in new connections.
18 class CachedNetworkParameters {
19 public:
20 // Describes the state of the connection during which the supplied network
21 // parameters were calculated.
22 enum PreviousConnectionState {
23 SLOW_START = 0,
24 CONGESTION_AVOIDANCE = 1,
25 };
26
27 CachedNetworkParameters();
28 ~CachedNetworkParameters();
29
30 std::string serving_region() const {
31 return serving_region_;
32 }
33 void set_serving_region(base::StringPiece serving_region) {
34 serving_region_ = serving_region.as_string();
35 }
36
37 int32 bandwidth_estimate_bytes_per_second() const {
38 return bandwidth_estimate_bytes_per_second_;
39 }
40 void set_bandwidth_estimate_bytes_per_second(
41 int32 bandwidth_estimate_bytes_per_second) {
42 bandwidth_estimate_bytes_per_second_ = bandwidth_estimate_bytes_per_second;
43 }
44
45 int32 min_rtt_ms() const {
46 return min_rtt_ms_;
47 }
48 void set_min_rtt_ms(int32 min_rtt_ms) {
49 min_rtt_ms_ = min_rtt_ms;
50 }
51
52 int32 previous_connection_state() const {
53 return previous_connection_state_;
54 }
55 void set_previous_connection_state(int32 previous_connection_state) {
56 previous_connection_state_ = previous_connection_state;
57 }
58
59 private:
60 // serving_region is used to decide whether or not the bandwidth estimate and
wtc 2014/07/23 23:17:14 serving_region => serving_region_
ramant (doing other things) 2014/07/23 23:56:00 Done.
61 // min RTT are reasonable and if they should be used.
62 // For example a group of geographically close servers may share the same
63 // serving_region string if they are expected to have similar network
wtc 2014/07/23 23:17:14 serving_region => serving_region_
ramant (doing other things) 2014/07/23 23:56:00 Done.
64 // performance.
65 std::string serving_region_;
66 // The server can supply a bandwidth estimate (in bytes/s) which it may re-use
67 // on receipt of a source-address token with this field set.
68 int32 bandwidth_estimate_bytes_per_second_;
69 // The min RTT seen on a previous connection can be used by the server to
70 // inform initial connection parameters for new connections.
71 int32 min_rtt_ms_;
72 // Encodes the PreviousConnectionState enum.
73 int32 previous_connection_state_;
74 };
75
76 // TODO(rtenneti): sync with server more rationally.
77 // A SourceAddressToken is serialised, encrypted and sent to clients so that
78 // they can prove ownership of an IP address.
16 class SourceAddressToken { 79 class SourceAddressToken {
17 public: 80 public:
18 SourceAddressToken(); 81 SourceAddressToken();
19 ~SourceAddressToken(); 82 ~SourceAddressToken();
20 83
21 std::string SerializeAsString() const; 84 std::string SerializeAsString() const;
22 85
23 bool ParseFromArray(const char* plaintext, size_t plaintext_length); 86 bool ParseFromArray(const char* plaintext, size_t plaintext_length);
24 87
25 std::string ip() const { 88 std::string ip() const {
26 return ip_; 89 return ip_;
27 } 90 }
91 void set_ip(base::StringPiece ip) {
92 ip_ = ip.as_string();
93 }
28 94
29 int64 timestamp() const { 95 int64 timestamp() const {
30 return timestamp_; 96 return timestamp_;
31 } 97 }
32
33 void set_ip(base::StringPiece ip) {
34 ip_ = ip.as_string();
35 }
36
37 void set_timestamp(int64 timestamp) { 98 void set_timestamp(int64 timestamp) {
38 timestamp_ = timestamp; 99 timestamp_ = timestamp;
39 } 100 }
40 101
102 const CachedNetworkParameters& cached_network_parameters() const {
103 return cached_network_parameters_;
104 }
105 void set_cached_network_parameters(
106 const CachedNetworkParameters& cached_network_parameters) {
107 cached_network_parameters_ = cached_network_parameters;
108 }
109
41 private: 110 private:
111 // ip contains either 4 (IPv4) or 16 (IPv6) bytes of IP address in network
wtc 2014/07/23 23:17:14 ip => ip_
ramant (doing other things) 2014/07/23 23:56:00 Done.
112 // byte order.
42 std::string ip_; 113 std::string ip_;
114 // timestamp contains a UNIX timestamp value of the time when the token was
wtc 2014/07/23 23:17:14 timestamp => timestamp_ (just the first occurrence
ramant (doing other things) 2014/07/23 23:56:00 Done.
115 // created.
43 int64 timestamp_; 116 int64 timestamp_;
44 117
118 // The server can provide estimated network parameters to be used for
119 // initial parameter selection in future connections.
120 CachedNetworkParameters cached_network_parameters_;
121
45 DISALLOW_COPY_AND_ASSIGN(SourceAddressToken); 122 DISALLOW_COPY_AND_ASSIGN(SourceAddressToken);
46 }; 123 };
47 124
48 } // namespace net 125 } // namespace net
49 126
50 #endif // NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_ 127 #endif // NET_QUIC_CRYPTO_SOURCE_ADDRESS_TOKEN_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/crypto/source_address_token.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698