| 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" |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 // Otherwise it may have queued QUIC_VERSION_17 frames which will trigger a | 661 // Otherwise it may have queued QUIC_VERSION_17 frames which will trigger a |
| 662 // DFATAL when they are serialized after the downgrade. | 662 // DFATAL when they are serialized after the downgrade. |
| 663 client_->client()->WaitForCryptoHandshakeConfirmed(); | 663 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 664 } | 664 } |
| 665 ASSERT_TRUE(client_->client()->connected()); | 665 ASSERT_TRUE(client_->client()->connected()); |
| 666 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 666 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| 667 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); | 667 EXPECT_EQ(2, client_->client()->session()->GetNumSentClientHellos()); |
| 668 VerifyCleanConnection(false); | 668 VerifyCleanConnection(false); |
| 669 } | 669 } |
| 670 | 670 |
| 671 TEST_P(EndToEndTest, LargePostFEC) { | 671 TEST_P(EndToEndTest, LargePostFec) { |
| 672 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); |
| 673 |
| 672 // Connect without packet loss to avoid issues with losing handshake packets, | 674 // Connect without packet loss to avoid issues with losing handshake packets, |
| 673 // and then up the packet loss rate (b/10126687). | 675 // and then up the packet loss rate (b/10126687). |
| 674 ASSERT_TRUE(Initialize()); | 676 ASSERT_TRUE(Initialize()); |
| 675 | 677 |
| 676 // Wait for the server SHLO before upping the packet loss. | 678 // Wait for the server SHLO before upping the packet loss. |
| 677 client_->client()->WaitForCryptoHandshakeConfirmed(); | 679 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 678 SetPacketLossPercentage(30); | 680 SetPacketLossPercentage(30); |
| 679 | 681 |
| 680 // Enable FEC protection. | 682 // Verify that FEC is enabled. |
| 681 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( | 683 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( |
| 682 client_->client()->session()->connection()); | 684 client_->client()->session()->connection()); |
| 683 creator->set_max_packets_per_fec_group(3); | 685 EXPECT_TRUE(creator->IsFecEnabled()); |
| 686 EXPECT_EQ(kMaxPacketsPerFecGroup, creator->max_packets_per_fec_group()); |
| 687 |
| 684 // Set FecPolicy to always protect data on all streams. | 688 // Set FecPolicy to always protect data on all streams. |
| 685 client_->SetFecPolicy(FEC_PROTECT_ALWAYS); | 689 client_->SetFecPolicy(FEC_PROTECT_ALWAYS); |
| 686 | 690 |
| 687 string body; | 691 string body; |
| 688 GenerateBody(&body, 10240); | 692 GenerateBody(&body, 10240); |
| 689 | 693 |
| 690 HTTPMessage request(HttpConstants::HTTP_1_1, | 694 HTTPMessage request(HttpConstants::HTTP_1_1, |
| 691 HttpConstants::POST, "/foo"); | 695 HttpConstants::POST, "/foo"); |
| 692 request.AddBody(body, true); | 696 request.AddBody(body, true); |
| 693 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); | 697 EXPECT_EQ(kFooResponseBody, client_->SendCustomSynchronousRequest(request)); |
| 694 VerifyCleanConnection(true); | 698 VerifyCleanConnection(true); |
| 695 } | 699 } |
| 696 | 700 |
| 701 TEST_P(EndToEndTest, ClientSpecifiedFecProtectionForHeaders) { |
| 702 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); |
| 703 |
| 704 // Set FEC config in client's connection options and in client session. |
| 705 QuicTagVector copt; |
| 706 copt.push_back(kFHDR); |
| 707 client_config_.SetConnectionOptionsToSend(copt); |
| 708 |
| 709 // Connect without packet loss to avoid issues with losing handshake packets, |
| 710 // and then up the packet loss rate (b/10126687). |
| 711 ASSERT_TRUE(Initialize()); |
| 712 client_->client()->WaitForCryptoHandshakeConfirmed(); |
| 713 server_thread_->WaitForCryptoHandshakeConfirmed(); |
| 714 |
| 715 // Verify that FEC is enabled. |
| 716 QuicPacketCreator* creator = QuicConnectionPeer::GetPacketCreator( |
| 717 client_->client()->session()->connection()); |
| 718 EXPECT_TRUE(creator->IsFecEnabled()); |
| 719 EXPECT_EQ(kMaxPacketsPerFecGroup, creator->max_packets_per_fec_group()); |
| 720 |
| 721 // Verify that server headers stream is FEC protected. |
| 722 server_thread_->Pause(); |
| 723 QuicDispatcher* dispatcher = |
| 724 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 725 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 726 QuicSession* session = dispatcher->session_map().begin()->second; |
| 727 EXPECT_EQ(FEC_PROTECT_ALWAYS, |
| 728 QuicSessionPeer::GetHeadersStream(session)->fec_policy()); |
| 729 server_thread_->Resume(); |
| 730 |
| 731 // Verify that at the client, headers stream is protected and other data |
| 732 // streams are optionally protected. |
| 733 EXPECT_EQ(FEC_PROTECT_ALWAYS, QuicSessionPeer::GetHeadersStream( |
| 734 client_->client()->session())->fec_policy()); |
| 735 EXPECT_EQ(FEC_PROTECT_OPTIONAL, client_->GetOrCreateStream()->fec_policy()); |
| 736 } |
| 737 |
| 697 // TODO(shess): This is flaky on ChromiumOS bots. | 738 // TODO(shess): This is flaky on ChromiumOS bots. |
| 698 // http://crbug.com/374871 | 739 // http://crbug.com/374871 |
| 699 TEST_P(EndToEndTest, DISABLED_LargePostSmallBandwidthLargeBuffer) { | 740 TEST_P(EndToEndTest, DISABLED_LargePostSmallBandwidthLargeBuffer) { |
| 700 ASSERT_TRUE(Initialize()); | 741 ASSERT_TRUE(Initialize()); |
| 701 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); | 742 SetPacketSendDelay(QuicTime::Delta::FromMicroseconds(1)); |
| 702 // 256KB per second with a 256KB buffer from server to client. Wireless | 743 // 256KB per second with a 256KB buffer from server to client. Wireless |
| 703 // clients commonly have larger buffers, but our max CWND is 200. | 744 // clients commonly have larger buffers, but our max CWND is 200. |
| 704 server_writer_->set_max_bandwidth_and_buffer_size( | 745 server_writer_->set_max_bandwidth_and_buffer_size( |
| 705 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024); | 746 QuicBandwidth::FromBytesPerSecond(256 * 1024), 256 * 1024); |
| 706 | 747 |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 session->config()->ReceivedInitialSessionFlowControlWindowBytes()); | 1272 session->config()->ReceivedInitialSessionFlowControlWindowBytes()); |
| 1232 EXPECT_EQ(kClientSessionIFCW, QuicFlowControllerPeer::SendWindowOffset( | 1273 EXPECT_EQ(kClientSessionIFCW, QuicFlowControllerPeer::SendWindowOffset( |
| 1233 session->flow_controller())); | 1274 session->flow_controller())); |
| 1234 server_thread_->Resume(); | 1275 server_thread_->Resume(); |
| 1235 } | 1276 } |
| 1236 | 1277 |
| 1237 } // namespace | 1278 } // namespace |
| 1238 } // namespace test | 1279 } // namespace test |
| 1239 } // namespace tools | 1280 } // namespace tools |
| 1240 } // namespace net | 1281 } // namespace net |
| OLD | NEW |