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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 // server_writer_->set_fake_reorder_percentage(reorder); | 518 // server_writer_->set_fake_reorder_percentage(reorder); |
519 } | 519 } |
520 | 520 |
521 // Verifies that the client and server connections were both free of packets | 521 // Verifies that the client and server connections were both free of packets |
522 // being discarded, based on connection stats. | 522 // being discarded, based on connection stats. |
523 // Calls server_thread_ Pause() and Resume(), which may only be called once | 523 // Calls server_thread_ Pause() and Resume(), which may only be called once |
524 // per test. | 524 // per test. |
525 void VerifyCleanConnection(bool had_packet_loss) { | 525 void VerifyCleanConnection(bool had_packet_loss) { |
526 QuicConnectionStats client_stats = | 526 QuicConnectionStats client_stats = |
527 client_->client()->session()->connection()->GetStats(); | 527 client_->client()->session()->connection()->GetStats(); |
528 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { | 528 if (!had_packet_loss) { |
529 EXPECT_EQ(0u, client_stats.packets_lost); | 529 EXPECT_EQ(0u, client_stats.packets_lost); |
530 } | 530 } |
531 EXPECT_EQ(0u, client_stats.packets_discarded); | 531 EXPECT_EQ(0u, client_stats.packets_discarded); |
532 // When doing 0-RTT with stateless rejects, the encrypted requests cause | 532 // When doing 0-RTT with stateless rejects, the encrypted requests cause |
533 // a retranmission of the SREJ packets which are dropped by the client. | 533 // a retranmission of the SREJ packets which are dropped by the client. |
534 if (!BothSidesSupportStatelessRejects()) { | 534 if (!BothSidesSupportStatelessRejects()) { |
535 EXPECT_EQ(0u, client_stats.packets_dropped); | 535 EXPECT_EQ(0u, client_stats.packets_dropped); |
536 } | 536 } |
537 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); | 537 EXPECT_EQ(client_stats.packets_received, client_stats.packets_processed); |
538 | 538 |
539 const int num_expected_stateless_rejects = | 539 const int num_expected_stateless_rejects = |
540 (BothSidesSupportStatelessRejects() && | 540 (BothSidesSupportStatelessRejects() && |
541 client_->client()->session()->GetNumSentClientHellos() > 0) | 541 client_->client()->session()->GetNumSentClientHellos() > 0) |
542 ? 1 | 542 ? 1 |
543 : 0; | 543 : 0; |
544 EXPECT_EQ(num_expected_stateless_rejects, | 544 EXPECT_EQ(num_expected_stateless_rejects, |
545 client_->client()->num_stateless_rejects_received()); | 545 client_->client()->num_stateless_rejects_received()); |
546 | 546 |
547 server_thread_->Pause(); | 547 server_thread_->Pause(); |
548 QuicDispatcher* dispatcher = | 548 QuicDispatcher* dispatcher = |
549 QuicServerPeer::GetDispatcher(server_thread_->server()); | 549 QuicServerPeer::GetDispatcher(server_thread_->server()); |
550 ASSERT_EQ(1u, dispatcher->session_map().size()); | 550 ASSERT_EQ(1u, dispatcher->session_map().size()); |
551 QuicSession* session = dispatcher->session_map().begin()->second; | 551 QuicSession* session = dispatcher->session_map().begin()->second; |
552 QuicConnectionStats server_stats = session->connection()->GetStats(); | 552 QuicConnectionStats server_stats = session->connection()->GetStats(); |
553 if (FLAGS_quic_reply_to_rej && !had_packet_loss) { | 553 if (!had_packet_loss) { |
554 EXPECT_EQ(0u, server_stats.packets_lost); | 554 EXPECT_EQ(0u, server_stats.packets_lost); |
555 } | 555 } |
556 EXPECT_EQ(0u, server_stats.packets_discarded); | 556 EXPECT_EQ(0u, server_stats.packets_discarded); |
557 // TODO(ianswett): Restore the check for packets_dropped equals 0. | 557 // TODO(ianswett): Restore the check for packets_dropped equals 0. |
558 // The expect for packets received is equal to packets processed fails | 558 // The expect for packets received is equal to packets processed fails |
559 // due to version negotiation packets. | 559 // due to version negotiation packets. |
560 server_thread_->Resume(); | 560 server_thread_->Resume(); |
561 } | 561 } |
562 | 562 |
563 bool BothSidesSupportStatelessRejects() { | 563 bool BothSidesSupportStatelessRejects() { |
(...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2834 client_->WaitForResponse(); | 2834 client_->WaitForResponse(); |
2835 // TODO(fayang): Fix this test to work with stateless rejects. | 2835 // TODO(fayang): Fix this test to work with stateless rejects. |
2836 if (!BothSidesSupportStatelessRejects()) { | 2836 if (!BothSidesSupportStatelessRejects()) { |
2837 VerifyCleanConnection(true); | 2837 VerifyCleanConnection(true); |
2838 } | 2838 } |
2839 } | 2839 } |
2840 | 2840 |
2841 } // namespace | 2841 } // namespace |
2842 } // namespace test | 2842 } // namespace test |
2843 } // namespace net | 2843 } // namespace net |
OLD | NEW |