OLD | NEW |
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 #include "net/quic/core/quic_config.h" | 5 #include "net/quic/core/quic_config.h" |
6 | 6 |
7 #include "net/quic/core/crypto/crypto_handshake_message.h" | 7 #include "net/quic/core/crypto/crypto_handshake_message.h" |
8 #include "net/quic/core/crypto/crypto_protocol.h" | 8 #include "net/quic/core/crypto/crypto_protocol.h" |
9 #include "net/quic/core/quic_packets.h" | 9 #include "net/quic/core/quic_packets.h" |
10 #include "net/quic/core/quic_time.h" | 10 #include "net/quic/core/quic_time.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 }; | 26 }; |
27 | 27 |
28 TEST_F(QuicConfigTest, ToHandshakeMessage) { | 28 TEST_F(QuicConfigTest, ToHandshakeMessage) { |
29 config_.SetInitialStreamFlowControlWindowToSend( | 29 config_.SetInitialStreamFlowControlWindowToSend( |
30 kInitialStreamFlowControlWindowForTest); | 30 kInitialStreamFlowControlWindowForTest); |
31 config_.SetInitialSessionFlowControlWindowToSend( | 31 config_.SetInitialSessionFlowControlWindowToSend( |
32 kInitialSessionFlowControlWindowForTest); | 32 kInitialSessionFlowControlWindowForTest); |
33 config_.SetIdleNetworkTimeout(QuicTime::Delta::FromSeconds(5), | 33 config_.SetIdleNetworkTimeout(QuicTime::Delta::FromSeconds(5), |
34 QuicTime::Delta::FromSeconds(2)); | 34 QuicTime::Delta::FromSeconds(2)); |
35 config_.SetMaxStreamsPerConnection(4, 2); | 35 config_.SetMaxStreamsPerConnection(4, 2); |
36 config_.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); | 36 if (!FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
| 37 config_.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); |
| 38 } |
37 CryptoHandshakeMessage msg; | 39 CryptoHandshakeMessage msg; |
38 config_.ToHandshakeMessage(&msg); | 40 config_.ToHandshakeMessage(&msg); |
39 | 41 |
40 uint32_t value; | 42 uint32_t value; |
41 QuicErrorCode error = msg.GetUint32(kICSL, &value); | 43 QuicErrorCode error = msg.GetUint32(kICSL, &value); |
42 EXPECT_EQ(QUIC_NO_ERROR, error); | 44 EXPECT_EQ(QUIC_NO_ERROR, error); |
43 EXPECT_EQ(5u, value); | 45 EXPECT_EQ(5u, value); |
44 | 46 |
45 error = msg.GetUint32(kMSPC, &value); | 47 error = msg.GetUint32(kMSPC, &value); |
46 EXPECT_EQ(QUIC_NO_ERROR, error); | 48 EXPECT_EQ(QUIC_NO_ERROR, error); |
47 EXPECT_EQ(4u, value); | 49 EXPECT_EQ(4u, value); |
48 | 50 |
49 error = msg.GetUint32(kSFCW, &value); | 51 error = msg.GetUint32(kSFCW, &value); |
50 EXPECT_EQ(QUIC_NO_ERROR, error); | 52 EXPECT_EQ(QUIC_NO_ERROR, error); |
51 EXPECT_EQ(kInitialStreamFlowControlWindowForTest, value); | 53 EXPECT_EQ(kInitialStreamFlowControlWindowForTest, value); |
52 | 54 |
53 error = msg.GetUint32(kCFCW, &value); | 55 error = msg.GetUint32(kCFCW, &value); |
54 EXPECT_EQ(QUIC_NO_ERROR, error); | 56 EXPECT_EQ(QUIC_NO_ERROR, error); |
55 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, value); | 57 EXPECT_EQ(kInitialSessionFlowControlWindowForTest, value); |
56 | 58 |
57 error = msg.GetUint32(kSRBF, &value); | 59 if (!FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
58 EXPECT_EQ(QUIC_NO_ERROR, error); | 60 error = msg.GetUint32(kSRBF, &value); |
59 EXPECT_EQ(kDefaultSocketReceiveBuffer, value); | 61 EXPECT_EQ(QUIC_NO_ERROR, error); |
| 62 EXPECT_EQ(kDefaultSocketReceiveBuffer, value); |
| 63 } |
60 } | 64 } |
61 | 65 |
62 TEST_F(QuicConfigTest, ProcessClientHello) { | 66 TEST_F(QuicConfigTest, ProcessClientHello) { |
63 QuicConfig client_config; | 67 QuicConfig client_config; |
64 QuicTagVector cgst; | 68 QuicTagVector cgst; |
65 cgst.push_back(kQBIC); | 69 cgst.push_back(kQBIC); |
66 client_config.SetIdleNetworkTimeout( | 70 client_config.SetIdleNetworkTimeout( |
67 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs), | 71 QuicTime::Delta::FromSeconds(2 * kMaximumIdleTimeoutSecs), |
68 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs)); | 72 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs)); |
69 client_config.SetMaxStreamsPerConnection(2 * kDefaultMaxStreamsPerConnection, | 73 client_config.SetMaxStreamsPerConnection(2 * kDefaultMaxStreamsPerConnection, |
70 kDefaultMaxStreamsPerConnection); | 74 kDefaultMaxStreamsPerConnection); |
71 client_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli); | 75 client_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli); |
72 client_config.SetInitialStreamFlowControlWindowToSend( | 76 client_config.SetInitialStreamFlowControlWindowToSend( |
73 2 * kInitialStreamFlowControlWindowForTest); | 77 2 * kInitialStreamFlowControlWindowForTest); |
74 client_config.SetInitialSessionFlowControlWindowToSend( | 78 client_config.SetInitialSessionFlowControlWindowToSend( |
75 2 * kInitialSessionFlowControlWindowForTest); | 79 2 * kInitialSessionFlowControlWindowForTest); |
76 client_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); | 80 if (!FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
| 81 client_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); |
| 82 } |
77 client_config.SetForceHolBlocking(); | 83 client_config.SetForceHolBlocking(); |
78 QuicTagVector copt; | 84 QuicTagVector copt; |
79 copt.push_back(kTBBR); | 85 copt.push_back(kTBBR); |
80 client_config.SetConnectionOptionsToSend(copt); | 86 client_config.SetConnectionOptionsToSend(copt); |
81 CryptoHandshakeMessage msg; | 87 CryptoHandshakeMessage msg; |
82 client_config.ToHandshakeMessage(&msg); | 88 client_config.ToHandshakeMessage(&msg); |
83 | 89 |
84 string error_details; | 90 string error_details; |
85 QuicTagVector initial_received_options; | 91 QuicTagVector initial_received_options; |
86 initial_received_options.push_back(kIW50); | 92 initial_received_options.push_back(kIW50); |
(...skipping 15 matching lines...) Expand all Loading... |
102 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); | 108 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); |
103 EXPECT_TRUE(config_.ForceHolBlocking(Perspective::IS_SERVER)); | 109 EXPECT_TRUE(config_.ForceHolBlocking(Perspective::IS_SERVER)); |
104 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); | 110 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); |
105 EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size()); | 111 EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size()); |
106 EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kIW50); | 112 EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kIW50); |
107 EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kTBBR); | 113 EXPECT_EQ(config_.ReceivedConnectionOptions()[1], kTBBR); |
108 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), | 114 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), |
109 2 * kInitialStreamFlowControlWindowForTest); | 115 2 * kInitialStreamFlowControlWindowForTest); |
110 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), | 116 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), |
111 2 * kInitialSessionFlowControlWindowForTest); | 117 2 * kInitialSessionFlowControlWindowForTest); |
112 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), kDefaultSocketReceiveBuffer); | 118 if (!FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
| 119 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), |
| 120 kDefaultSocketReceiveBuffer); |
| 121 } |
113 } | 122 } |
114 | 123 |
115 TEST_F(QuicConfigTest, ProcessServerHello) { | 124 TEST_F(QuicConfigTest, ProcessServerHello) { |
116 QuicIpAddress host; | 125 QuicIpAddress host; |
117 host.FromString("127.0.3.1"); | 126 host.FromString("127.0.3.1"); |
118 const QuicSocketAddress kTestServerAddress = QuicSocketAddress(host, 1234); | 127 const QuicSocketAddress kTestServerAddress = QuicSocketAddress(host, 1234); |
119 QuicConfig server_config; | 128 QuicConfig server_config; |
120 QuicTagVector cgst; | 129 QuicTagVector cgst; |
121 cgst.push_back(kQBIC); | 130 cgst.push_back(kQBIC); |
122 server_config.SetIdleNetworkTimeout( | 131 server_config.SetIdleNetworkTimeout( |
123 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), | 132 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), |
124 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2)); | 133 QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2)); |
125 server_config.SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection / 2, | 134 server_config.SetMaxStreamsPerConnection(kDefaultMaxStreamsPerConnection / 2, |
126 kDefaultMaxStreamsPerConnection / 2); | 135 kDefaultMaxStreamsPerConnection / 2); |
127 server_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli); | 136 server_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli); |
128 server_config.SetInitialStreamFlowControlWindowToSend( | 137 server_config.SetInitialStreamFlowControlWindowToSend( |
129 2 * kInitialStreamFlowControlWindowForTest); | 138 2 * kInitialStreamFlowControlWindowForTest); |
130 server_config.SetInitialSessionFlowControlWindowToSend( | 139 server_config.SetInitialSessionFlowControlWindowToSend( |
131 2 * kInitialSessionFlowControlWindowForTest); | 140 2 * kInitialSessionFlowControlWindowForTest); |
132 server_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); | 141 if (!FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
| 142 server_config.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); |
| 143 } |
133 server_config.SetAlternateServerAddressToSend(kTestServerAddress); | 144 server_config.SetAlternateServerAddressToSend(kTestServerAddress); |
134 CryptoHandshakeMessage msg; | 145 CryptoHandshakeMessage msg; |
135 server_config.ToHandshakeMessage(&msg); | 146 server_config.ToHandshakeMessage(&msg); |
136 string error_details; | 147 string error_details; |
137 const QuicErrorCode error = | 148 const QuicErrorCode error = |
138 config_.ProcessPeerHello(msg, SERVER, &error_details); | 149 config_.ProcessPeerHello(msg, SERVER, &error_details); |
139 EXPECT_EQ(QUIC_NO_ERROR, error); | 150 EXPECT_EQ(QUIC_NO_ERROR, error); |
140 EXPECT_TRUE(config_.negotiated()); | 151 EXPECT_TRUE(config_.negotiated()); |
141 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), | 152 EXPECT_EQ(QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs / 2), |
142 config_.IdleNetworkTimeout()); | 153 config_.IdleNetworkTimeout()); |
143 EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2, | 154 EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2, |
144 config_.MaxStreamsPerConnection()); | 155 config_.MaxStreamsPerConnection()); |
145 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); | 156 EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs()); |
146 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), | 157 EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(), |
147 2 * kInitialStreamFlowControlWindowForTest); | 158 2 * kInitialStreamFlowControlWindowForTest); |
148 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), | 159 EXPECT_EQ(config_.ReceivedInitialSessionFlowControlWindowBytes(), |
149 2 * kInitialSessionFlowControlWindowForTest); | 160 2 * kInitialSessionFlowControlWindowForTest); |
150 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), kDefaultSocketReceiveBuffer); | 161 if (!FLAGS_quic_reloadable_flag_quic_no_socket_receive_buffer) { |
| 162 EXPECT_EQ(config_.ReceivedSocketReceiveBuffer(), |
| 163 kDefaultSocketReceiveBuffer); |
| 164 } |
151 EXPECT_TRUE(config_.HasReceivedAlternateServerAddress()); | 165 EXPECT_TRUE(config_.HasReceivedAlternateServerAddress()); |
152 EXPECT_EQ(kTestServerAddress, config_.ReceivedAlternateServerAddress()); | 166 EXPECT_EQ(kTestServerAddress, config_.ReceivedAlternateServerAddress()); |
153 } | 167 } |
154 | 168 |
155 TEST_F(QuicConfigTest, MissingOptionalValuesInCHLO) { | 169 TEST_F(QuicConfigTest, MissingOptionalValuesInCHLO) { |
156 CryptoHandshakeMessage msg; | 170 CryptoHandshakeMessage msg; |
157 msg.SetValue(kICSL, 1); | 171 msg.SetValue(kICSL, 1); |
158 | 172 |
159 // Set all REQUIRED tags. | 173 // Set all REQUIRED tags. |
160 msg.SetValue(kICSL, 1); | 174 msg.SetValue(kICSL, 1); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 EXPECT_EQ(1u, config_.ReceivedConnectionOptions().size()); | 311 EXPECT_EQ(1u, config_.ReceivedConnectionOptions().size()); |
298 EXPECT_FALSE(config_.HasClientRequestedIndependentOption( | 312 EXPECT_FALSE(config_.HasClientRequestedIndependentOption( |
299 kRENO, Perspective::IS_SERVER)); | 313 kRENO, Perspective::IS_SERVER)); |
300 EXPECT_TRUE(config_.HasClientRequestedIndependentOption( | 314 EXPECT_TRUE(config_.HasClientRequestedIndependentOption( |
301 kTBBR, Perspective::IS_SERVER)); | 315 kTBBR, Perspective::IS_SERVER)); |
302 } | 316 } |
303 | 317 |
304 } // namespace | 318 } // namespace |
305 } // namespace test | 319 } // namespace test |
306 } // namespace net | 320 } // namespace net |
OLD | NEW |