| 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 <sys/epoll.h> | 6 #include <sys/epoll.h> |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // server_writer_->set_fake_reorder_percentage(reorder); | 502 // server_writer_->set_fake_reorder_percentage(reorder); |
| 503 } | 503 } |
| 504 | 504 |
| 505 // Verifies that the client and server connections were both free of packets | 505 // Verifies that the client and server connections were both free of packets |
| 506 // being discarded, based on connection stats. | 506 // being discarded, based on connection stats. |
| 507 // Calls server_thread_ Pause() and Resume(), which may only be called once | 507 // Calls server_thread_ Pause() and Resume(), which may only be called once |
| 508 // per test. | 508 // per test. |
| 509 void VerifyCleanConnection(bool had_packet_loss) { | 509 void VerifyCleanConnection(bool had_packet_loss) { |
| 510 QuicConnectionStats client_stats = | 510 QuicConnectionStats client_stats = |
| 511 client_->client()->session()->connection()->GetStats(); | 511 client_->client()->session()->connection()->GetStats(); |
| 512 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { | 512 if (!had_packet_loss) { |
| 513 EXPECT_EQ(0u, client_stats.packets_lost); | 513 EXPECT_EQ(0u, client_stats.packets_lost); |
| 514 } | 514 } |
| 515 EXPECT_EQ(0u, client_stats.packets_discarded); | 515 EXPECT_EQ(0u, client_stats.packets_discarded); |
| 516 // When doing 0-RTT with stateless rejects, the encrypted requests cause | 516 // When doing 0-RTT with stateless rejects, the encrypted requests cause |
| 517 // a retranmission of the SREJ packets which are dropped by the client. | 517 // a retranmission of the SREJ packets which are dropped by the client. |
| 518 if (!BothSidesSupportStatelessRejects()) { | 518 if (!BothSidesSupportStatelessRejects()) { |
| 519 EXPECT_EQ(0u, client_stats.packets_dropped); | 519 EXPECT_EQ(0u, client_stats.packets_dropped); |
| 520 } | 520 } |
| 521 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); | 521 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); |
| 522 | 522 |
| 523 const int num_expected_stateless_rejects = | 523 const int num_expected_stateless_rejects = |
| 524 (BothSidesSupportStatelessRejects() && | 524 (BothSidesSupportStatelessRejects() && |
| 525 client_->client()->session()->GetNumSentClientHellos() > 0) | 525 client_->client()->session()->GetNumSentClientHellos() > 0) |
| 526 ? 1 | 526 ? 1 |
| 527 : 0; | 527 : 0; |
| 528 EXPECT_EQ(num_expected_stateless_rejects, | 528 EXPECT_EQ(num_expected_stateless_rejects, |
| 529 client_->client()->num_stateless_rejects_received()); | 529 client_->client()->num_stateless_rejects_received()); |
| 530 | 530 |
| 531 server_thread_->Pause(); | 531 server_thread_->Pause(); |
| 532 QuicDispatcher* dispatcher = | 532 QuicDispatcher* dispatcher = |
| 533 QuicServerPeer::GetDispatcher(server_thread_->server()); | 533 QuicServerPeer::GetDispatcher(server_thread_->server()); |
| 534 ASSERT_EQ(1u, dispatcher->session_map().size()); | 534 ASSERT_EQ(1u, dispatcher->session_map().size()); |
| 535 QuicSession* session = dispatcher->session_map().begin()->second; | 535 QuicSession* session = dispatcher->session_map().begin()->second; |
| 536 QuicConnectionStats server_stats = session->connection()->GetStats(); | 536 QuicConnectionStats server_stats = session->connection()->GetStats(); |
| 537 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { | 537 if (!had_packet_loss) { |
| 538 EXPECT_EQ(0u, server_stats.packets_lost); | 538 EXPECT_EQ(0u, server_stats.packets_lost); |
| 539 } | 539 } |
| 540 EXPECT_EQ(0u, server_stats.packets_discarded); | 540 EXPECT_EQ(0u, server_stats.packets_discarded); |
| 541 // TODO(ianswett): Restore the check for packets_dropped equals 0. | 541 // TODO(ianswett): Restore the check for packets_dropped equals 0. |
| 542 // The expect for packets received is equal to packets processed fails | 542 // The expect for packets received is equal to packets processed fails |
| 543 // due to version negotiation packets. | 543 // due to version negotiation packets. |
| 544 server_thread_->Resume(); | 544 server_thread_->Resume(); |
| 545 } | 545 } |
| 546 | 546 |
| 547 bool BothSidesSupportStatelessRejects() { | 547 bool BothSidesSupportStatelessRejects() { |
| (...skipping 2269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 client_->WaitForResponse(); | 2817 client_->WaitForResponse(); |
| 2818 // TODO(fayang): Fix this test to work with stateless rejects. | 2818 // TODO(fayang): Fix this test to work with stateless rejects. |
| 2819 if (!BothSidesSupportStatelessRejects()) { | 2819 if (!BothSidesSupportStatelessRejects()) { |
| 2820 VerifyCleanConnection(true); | 2820 VerifyCleanConnection(true); |
| 2821 } | 2821 } |
| 2822 } | 2822 } |
| 2823 | 2823 |
| 2824 } // namespace | 2824 } // namespace |
| 2825 } // namespace test | 2825 } // namespace test |
| 2826 } // namespace net | 2826 } // namespace net |
| OLD | NEW |