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 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <string> | 6 #include <string> |
7 #include <sys/epoll.h> | 7 #include <sys/epoll.h> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
15 #include "net/base/ip_endpoint.h" | 15 #include "net/base/ip_endpoint.h" |
16 #include "net/quic/congestion_control/tcp_cubic_sender.h" | 16 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
17 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 17 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
18 #include "net/quic/crypto/null_encrypter.h" | 18 #include "net/quic/crypto/null_encrypter.h" |
19 #include "net/quic/quic_flags.h" | 19 #include "net/quic/quic_flags.h" |
20 #include "net/quic/quic_framer.h" | 20 #include "net/quic/quic_framer.h" |
21 #include "net/quic/quic_packet_creator.h" | 21 #include "net/quic/quic_packet_creator.h" |
22 #include "net/quic/quic_protocol.h" | 22 #include "net/quic/quic_protocol.h" |
23 #include "net/quic/quic_sent_packet_manager.h" | 23 #include "net/quic/quic_sent_packet_manager.h" |
24 #include "net/quic/quic_session_key.h" | 24 #include "net/quic/quic_server_id.h" |
25 #include "net/quic/test_tools/quic_connection_peer.h" | 25 #include "net/quic/test_tools/quic_connection_peer.h" |
26 #include "net/quic/test_tools/quic_session_peer.h" | 26 #include "net/quic/test_tools/quic_session_peer.h" |
27 #include "net/quic/test_tools/quic_test_utils.h" | 27 #include "net/quic/test_tools/quic_test_utils.h" |
28 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 28 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
29 #include "net/test/gtest_util.h" | 29 #include "net/test/gtest_util.h" |
30 #include "net/tools/quic/quic_epoll_connection_helper.h" | 30 #include "net/tools/quic/quic_epoll_connection_helper.h" |
31 #include "net/tools/quic/quic_in_memory_cache.h" | 31 #include "net/tools/quic/quic_in_memory_cache.h" |
32 #include "net/tools/quic/quic_packet_writer_wrapper.h" | 32 #include "net/tools/quic/quic_packet_writer_wrapper.h" |
33 #include "net/tools/quic/quic_server.h" | 33 #include "net/tools/quic/quic_server.h" |
34 #include "net/tools/quic/quic_socket_utils.h" | 34 #include "net/tools/quic/quic_socket_utils.h" |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 EpollEvent event(EPOLLOUT, false); | 137 EpollEvent event(EPOLLOUT, false); |
138 client_->OnEvent(client_->fd(), &event); | 138 client_->OnEvent(client_->fd(), &event); |
139 } | 139 } |
140 private: | 140 private: |
141 QuicClient* client_; | 141 QuicClient* client_; |
142 }; | 142 }; |
143 | 143 |
144 class EndToEndTest : public ::testing::TestWithParam<TestParams> { | 144 class EndToEndTest : public ::testing::TestWithParam<TestParams> { |
145 protected: | 145 protected: |
146 EndToEndTest() | 146 EndToEndTest() |
147 : server_started_(false), | 147 : server_hostname_("example.com"), |
| 148 server_started_(false), |
148 strike_register_no_startup_period_(false) { | 149 strike_register_no_startup_period_(false) { |
149 net::IPAddressNumber ip; | 150 net::IPAddressNumber ip; |
150 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); | 151 CHECK(net::ParseIPLiteralToNumber("127.0.0.1", &ip)); |
151 uint port = 0; | 152 server_address_ = IPEndPoint(ip, 0); |
152 server_address_ = IPEndPoint(ip, port); | |
153 server_key_ = QuicSessionKey("example.com", port, false, | |
154 kPrivacyModeDisabled); | |
155 | 153 |
156 client_supported_versions_ = GetParam().client_supported_versions; | 154 client_supported_versions_ = GetParam().client_supported_versions; |
157 server_supported_versions_ = GetParam().server_supported_versions; | 155 server_supported_versions_ = GetParam().server_supported_versions; |
158 negotiated_version_ = GetParam().negotiated_version; | 156 negotiated_version_ = GetParam().negotiated_version; |
159 FLAGS_enable_quic_pacing = GetParam().use_pacing; | 157 FLAGS_enable_quic_pacing = GetParam().use_pacing; |
160 | 158 |
161 if (negotiated_version_ >= QUIC_VERSION_17) { | 159 if (negotiated_version_ >= QUIC_VERSION_17) { |
162 FLAGS_enable_quic_stream_flow_control = true; | 160 FLAGS_enable_quic_stream_flow_control = true; |
163 } | 161 } |
164 VLOG(1) << "Using Configuration: " << GetParam(); | 162 VLOG(1) << "Using Configuration: " << GetParam(); |
(...skipping 18 matching lines...) Expand all Loading... |
183 | 181 |
184 virtual ~EndToEndTest() { | 182 virtual ~EndToEndTest() { |
185 // TODO(rtenneti): port RecycleUnusedPort if needed. | 183 // TODO(rtenneti): port RecycleUnusedPort if needed. |
186 // RecycleUnusedPort(server_address_.port()); | 184 // RecycleUnusedPort(server_address_.port()); |
187 QuicInMemoryCachePeer::ResetForTests(); | 185 QuicInMemoryCachePeer::ResetForTests(); |
188 } | 186 } |
189 | 187 |
190 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { | 188 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { |
191 QuicTestClient* client = new QuicTestClient( | 189 QuicTestClient* client = new QuicTestClient( |
192 server_address_, | 190 server_address_, |
193 server_key_, | 191 server_hostname_, |
194 false, // not secure | 192 false, // not secure |
195 client_config_, | 193 client_config_, |
196 client_supported_versions_, | 194 client_supported_versions_, |
197 client_initial_flow_control_receive_window_); | 195 client_initial_flow_control_receive_window_); |
198 client->UseWriter(writer); | 196 client->UseWriter(writer); |
199 client->Connect(); | 197 client->Connect(); |
200 return client; | 198 return client; |
201 } | 199 } |
202 | 200 |
203 void set_client_initial_flow_control_receive_window(uint32 window) { | 201 void set_client_initial_flow_control_receive_window(uint32 window) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 void StartServer() { | 238 void StartServer() { |
241 server_thread_.reset( | 239 server_thread_.reset( |
242 new ServerThread(server_address_, | 240 new ServerThread(server_address_, |
243 server_config_, | 241 server_config_, |
244 server_supported_versions_, | 242 server_supported_versions_, |
245 strike_register_no_startup_period_, | 243 strike_register_no_startup_period_, |
246 server_initial_flow_control_receive_window_)); | 244 server_initial_flow_control_receive_window_)); |
247 server_thread_->Initialize(); | 245 server_thread_->Initialize(); |
248 server_address_ = IPEndPoint(server_address_.address(), | 246 server_address_ = IPEndPoint(server_address_.address(), |
249 server_thread_->GetPort()); | 247 server_thread_->GetPort()); |
250 server_key_ = QuicSessionKey(server_key_.host(), server_thread_->GetPort(), | |
251 false, kPrivacyModeDisabled); | |
252 | |
253 QuicDispatcher* dispatcher = | 248 QuicDispatcher* dispatcher = |
254 QuicServerPeer::GetDispatcher(server_thread_->server()); | 249 QuicServerPeer::GetDispatcher(server_thread_->server()); |
255 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); | 250 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); |
256 server_writer_->Initialize( | 251 server_writer_->Initialize( |
257 QuicDispatcherPeer::GetHelper(dispatcher), | 252 QuicDispatcherPeer::GetHelper(dispatcher), |
258 new ServerDelegate(dispatcher)); | 253 new ServerDelegate(dispatcher)); |
259 server_thread_->Start(); | 254 server_thread_->Start(); |
260 server_started_ = true; | 255 server_started_ = true; |
261 } | 256 } |
262 | 257 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } | 291 } |
297 | 292 |
298 void SetReorderPercentage(int32 reorder) { | 293 void SetReorderPercentage(int32 reorder) { |
299 // TODO(rtenneti): enable when we can do random packet reorder tests in | 294 // TODO(rtenneti): enable when we can do random packet reorder tests in |
300 // chrome's tree. | 295 // chrome's tree. |
301 // client_writer_->set_fake_reorder_percentage(reorder); | 296 // client_writer_->set_fake_reorder_percentage(reorder); |
302 // server_writer_->set_fake_reorder_percentage(reorder); | 297 // server_writer_->set_fake_reorder_percentage(reorder); |
303 } | 298 } |
304 | 299 |
305 IPEndPoint server_address_; | 300 IPEndPoint server_address_; |
306 QuicSessionKey server_key_; | 301 string server_hostname_; |
307 scoped_ptr<ServerThread> server_thread_; | 302 scoped_ptr<ServerThread> server_thread_; |
308 scoped_ptr<QuicTestClient> client_; | 303 scoped_ptr<QuicTestClient> client_; |
309 PacketDroppingTestWriter* client_writer_; | 304 PacketDroppingTestWriter* client_writer_; |
310 PacketDroppingTestWriter* server_writer_; | 305 PacketDroppingTestWriter* server_writer_; |
311 bool server_started_; | 306 bool server_started_; |
312 QuicConfig client_config_; | 307 QuicConfig client_config_; |
313 QuicConfig server_config_; | 308 QuicConfig server_config_; |
314 QuicVersionVector client_supported_versions_; | 309 QuicVersionVector client_supported_versions_; |
315 QuicVersionVector server_supported_versions_; | 310 QuicVersionVector server_supported_versions_; |
316 QuicVersion negotiated_version_; | 311 QuicVersion negotiated_version_; |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 QuicSession* session = dispatcher->session_map().begin()->second; | 935 QuicSession* session = dispatcher->session_map().begin()->second; |
941 EXPECT_EQ(kClientIFCW, | 936 EXPECT_EQ(kClientIFCW, |
942 session->config()->peer_initial_flow_control_window_bytes()); | 937 session->config()->peer_initial_flow_control_window_bytes()); |
943 server_thread_->Resume(); | 938 server_thread_->Resume(); |
944 } | 939 } |
945 | 940 |
946 } // namespace | 941 } // namespace |
947 } // namespace test | 942 } // namespace test |
948 } // namespace tools | 943 } // namespace tools |
949 } // namespace net | 944 } // namespace net |
OLD | NEW |