| 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 "base/time/time.h" | 15 #include "base/time/time.h" |
| 16 #include "net/base/ip_endpoint.h" | 16 #include "net/base/ip_endpoint.h" |
| 17 #include "net/quic/congestion_control/tcp_cubic_sender.h" | 17 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
| 18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 18 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| 19 #include "net/quic/crypto/null_encrypter.h" | 19 #include "net/quic/crypto/null_encrypter.h" |
| 20 #include "net/quic/quic_flags.h" | 20 #include "net/quic/quic_flags.h" |
| 21 #include "net/quic/quic_framer.h" | 21 #include "net/quic/quic_framer.h" |
| 22 #include "net/quic/quic_packet_creator.h" | 22 #include "net/quic/quic_packet_creator.h" |
| 23 #include "net/quic/quic_protocol.h" | 23 #include "net/quic/quic_protocol.h" |
| 24 #include "net/quic/quic_sent_packet_manager.h" | 24 #include "net/quic/quic_sent_packet_manager.h" |
| 25 #include "net/quic/quic_server_id.h" | 25 #include "net/quic/quic_server_id.h" |
| 26 #include "net/quic/test_tools/quic_connection_peer.h" | 26 #include "net/quic/test_tools/quic_connection_peer.h" |
| 27 #include "net/quic/test_tools/quic_packet_generator_peer.h" | |
| 28 #include "net/quic/test_tools/quic_session_peer.h" | 27 #include "net/quic/test_tools/quic_session_peer.h" |
| 29 #include "net/quic/test_tools/quic_test_utils.h" | 28 #include "net/quic/test_tools/quic_test_utils.h" |
| 30 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 29 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 31 #include "net/test/gtest_util.h" | 30 #include "net/test/gtest_util.h" |
| 32 #include "net/tools/epoll_server/epoll_server.h" | 31 #include "net/tools/epoll_server/epoll_server.h" |
| 33 #include "net/tools/quic/quic_epoll_connection_helper.h" | 32 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 34 #include "net/tools/quic/quic_in_memory_cache.h" | 33 #include "net/tools/quic/quic_in_memory_cache.h" |
| 35 #include "net/tools/quic/quic_packet_writer_wrapper.h" | 34 #include "net/tools/quic/quic_packet_writer_wrapper.h" |
| 36 #include "net/tools/quic/quic_server.h" | 35 #include "net/tools/quic/quic_server.h" |
| 37 #include "net/tools/quic/quic_socket_utils.h" | 36 #include "net/tools/quic/quic_socket_utils.h" |
| 38 #include "net/tools/quic/quic_spdy_client_stream.h" | 37 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 39 #include "net/tools/quic/test_tools/http_message.h" | 38 #include "net/tools/quic/test_tools/http_message.h" |
| 40 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" | 39 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" |
| 41 #include "net/tools/quic/test_tools/quic_client_peer.h" | 40 #include "net/tools/quic/test_tools/quic_client_peer.h" |
| 42 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" | 41 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" |
| 43 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" | 42 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h" |
| 44 #include "net/tools/quic/test_tools/quic_server_peer.h" | 43 #include "net/tools/quic/test_tools/quic_server_peer.h" |
| 45 #include "net/tools/quic/test_tools/quic_test_client.h" | 44 #include "net/tools/quic/test_tools/quic_test_client.h" |
| 46 #include "net/tools/quic/test_tools/server_thread.h" | 45 #include "net/tools/quic/test_tools/server_thread.h" |
| 47 #include "testing/gtest/include/gtest/gtest.h" | 46 #include "testing/gtest/include/gtest/gtest.h" |
| 48 | 47 |
| 49 using base::StringPiece; | 48 using base::StringPiece; |
| 50 using base::WaitableEvent; | 49 using base::WaitableEvent; |
| 51 using net::EpollServer; | 50 using net::EpollServer; |
| 52 using net::test::GenerateBody; | 51 using net::test::GenerateBody; |
| 53 using net::test::QuicConnectionPeer; | 52 using net::test::QuicConnectionPeer; |
| 54 using net::test::QuicPacketGeneratorPeer; | |
| 55 using net::test::QuicSessionPeer; | 53 using net::test::QuicSessionPeer; |
| 56 using net::test::ReliableQuicStreamPeer; | 54 using net::test::ReliableQuicStreamPeer; |
| 57 using net::test::kClientDataStreamId1; | 55 using net::test::kClientDataStreamId1; |
| 58 using net::tools::test::PacketDroppingTestWriter; | 56 using net::tools::test::PacketDroppingTestWriter; |
| 59 using net::tools::test::QuicDispatcherPeer; | 57 using net::tools::test::QuicDispatcherPeer; |
| 60 using net::tools::test::QuicServerPeer; | 58 using net::tools::test::QuicServerPeer; |
| 61 using std::ostream; | 59 using std::ostream; |
| 62 using std::string; | 60 using std::string; |
| 63 using std::vector; | 61 using std::vector; |
| 64 | 62 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // DFATAL when they are serialized after the downgrade. | 630 // DFATAL when they are serialized after the downgrade. |
| 633 client_->client()->WaitForCryptoHandshakeConfirmed(); | 631 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 634 } | 632 } |
| 635 ASSERT_TRUE(client_->client()->connected()); | 633 ASSERT_TRUE(client_->client()->connected()); |
| 636 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 634 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| 637 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); | 635 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); |
| 638 VerifyCleanConnection(false); | 636 VerifyCleanConnection(false); |
| 639 } | 637 } |
| 640 | 638 |
| 641 TEST_P(EndToEndTest, LargePostFEC) { | 639 TEST_P(EndToEndTest, LargePostFEC) { |
| 640 // TODO(jri): Set FecPolicy to always protect on client_->stream_. |
| 641 // This test currently does not do any FEC protection. |
| 642 |
| 642 // Connect without packet loss to avoid issues with losing handshake packets, | 643 // Connect without packet loss to avoid issues with losing handshake packets, |
| 643 // and then up the packet loss rate (b/10126687). | 644 // and then up the packet loss rate (b/10126687). |
| 644 ASSERT_TRUE(Initialize()); | 645 ASSERT_TRUE(Initialize()); |
| 645 | 646 |
| 646 // Wait for the server SHLO before upping the packet loss. | 647 // Wait for the server SHLO before upping the packet loss. |
| 647 client_->client()->WaitForCryptoHandshakeConfirmed(); | 648 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 648 SetPacketLossPercentage(30); | 649 SetPacketLossPercentage(30); |
| 649 | 650 |
| 650 // Turn on FEC protection. | 651 // Enable FEC protection. |
| 651 QuicPacketGeneratorPeer::SwitchFecProtectionOn( | 652 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( |
| 652 QuicConnectionPeer::GetPacketGenerator( | 653 client_->client()->session()->connection()); |
| 653 client_->client()->session()->connection()), 6); | 654 creator->set_max_packets_per_fec_group(6); |
| 654 | 655 |
| 655 string body; | 656 string body; |
| 656 GenerateBody(&body, 10240); | 657 GenerateBody(&body, 10240); |
| 657 | 658 |
| 658 HTTPMessage request(HttpConstants::HTTP_1_1, | 659 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 659 HttpConstants::POST, "/foo"); | 660 HttpConstants::POST, "/foo"); |
| 660 request.AddBody(body, true); | 661 request.AddBody(body, true); |
| 661 | |
| 662 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 662 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| 663 VerifyCleanConnection(true); | 663 VerifyCleanConnection(true); |
| 664 } | 664 } |
| 665 | 665 |
| 666 // TODO(shess): This is flaky on ChromiumOS bots. | 666 // TODO(shess): This is flaky on ChromiumOS bots. |
| 667 // http://crbug.com/374871 | 667 // http://crbug.com/374871 |
| 668 TEST_P(EndToEndTest, DISABLED_LargePostSmallBandwidthLargeBuffer) { | 668 TEST_P(EndToEndTest, DISABLED_LargePostSmallBandwidthLargeBuffer) { |
| 669 ASSERT_TRUE(Initialize()); | 669 ASSERT_TRUE(Initialize()); |
| 670 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); | 670 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); |
| 671 // 256KB per second with a 256KB buffer from server to client. Wireless | 671 // 256KB per second with a 256KB buffer from server to client. Wireless |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1067 QuicSession* session = dispatcher->session_map().begin()->second; | 1067 QuicSession* session = dispatcher->session_map().begin()->second; |
| 1068 EXPECT_EQ(kClientIFCW, | 1068 EXPECT_EQ(kClientIFCW, |
| 1069 session->config()->ReceivedInitialFlowControlWindowBytes()); | 1069 session->config()->ReceivedInitialFlowControlWindowBytes()); |
| 1070 server_thread_->Resume(); | 1070 server_thread_->Resume(); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 } // namespace | 1073 } // namespace |
| 1074 } // namespace test | 1074 } // namespace test |
| 1075 } // namespace tools | 1075 } // namespace tools |
| 1076 } // namespace net | 1076 } // namespace net |
| OLD | NEW |