| 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 "net/quic/congestion_control/tcp_cubic_sender.h" | 5 #include "net/quic/congestion_control/tcp_cubic_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 for (int i = 0; i < kNumberOfAcks; ++i) { | 478 for (int i = 0; i < kNumberOfAcks; ++i) { |
| 479 // Send our full send window. | 479 // Send our full send window. |
| 480 SendAvailableSendWindow(); | 480 SendAvailableSendWindow(); |
| 481 AckNPackets(2); | 481 AckNPackets(2); |
| 482 } | 482 } |
| 483 | 483 |
| 484 QuicByteCount expected_send_window = kMaxCongestionWindowTCP * kDefaultTCPMSS; | 484 QuicByteCount expected_send_window = kMaxCongestionWindowTCP * kDefaultTCPMSS; |
| 485 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); | 485 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); |
| 486 } | 486 } |
| 487 | 487 |
| 488 TEST_F(TcpCubicSenderTest, TcpCubicResetEpochOnQuiescence) { |
| 489 const int kMaxCongestionWindow = 50; |
| 490 const QuicByteCount kMaxCongestionWindowBytes = |
| 491 kMaxCongestionWindow * kDefaultTCPMSS; |
| 492 sender_.reset(new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindow)); |
| 493 |
| 494 int num_sent = SendAvailableSendWindow(); |
| 495 |
| 496 // Make sure we fall out of slow start. |
| 497 QuicByteCount saved_cwnd = sender_->GetCongestionWindow(); |
| 498 LoseNPackets(1); |
| 499 EXPECT_GT(saved_cwnd, sender_->GetCongestionWindow()); |
| 500 |
| 501 // Ack the rest of the outstanding packets to get out of recovery. |
| 502 for (int i = 1; i < num_sent; ++i) { |
| 503 AckNPackets(1); |
| 504 } |
| 505 EXPECT_EQ(0u, bytes_in_flight_); |
| 506 |
| 507 // Send a new window of data and ack all; cubic growth should occur. |
| 508 saved_cwnd = sender_->GetCongestionWindow(); |
| 509 num_sent = SendAvailableSendWindow(); |
| 510 for (int i = 0; i < num_sent; ++i) { |
| 511 AckNPackets(1); |
| 512 } |
| 513 EXPECT_LT(saved_cwnd, sender_->GetCongestionWindow()); |
| 514 EXPECT_GT(kMaxCongestionWindowBytes, sender_->GetCongestionWindow()); |
| 515 EXPECT_EQ(0u, bytes_in_flight_); |
| 516 |
| 517 // Quiescent time of 100 seconds |
| 518 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(100000)); |
| 519 |
| 520 // Send new window of data and ack one packet. Cubic epoch should have |
| 521 // been reset; ensure cwnd increase is not dramatic. |
| 522 saved_cwnd = sender_->GetCongestionWindow(); |
| 523 SendAvailableSendWindow(); |
| 524 AckNPackets(1); |
| 525 EXPECT_NEAR(saved_cwnd, sender_->GetCongestionWindow(), kDefaultTCPMSS); |
| 526 EXPECT_GT(kMaxCongestionWindowBytes, sender_->GetCongestionWindow()); |
| 527 } |
| 528 |
| 488 TEST_F(TcpCubicSenderTest, MultipleLossesInOneWindow) { | 529 TEST_F(TcpCubicSenderTest, MultipleLossesInOneWindow) { |
| 489 SendAvailableSendWindow(); | 530 SendAvailableSendWindow(); |
| 490 const QuicByteCount initial_window = sender_->GetCongestionWindow(); | 531 const QuicByteCount initial_window = sender_->GetCongestionWindow(); |
| 491 LosePacket(acked_packet_number_ + 1); | 532 LosePacket(acked_packet_number_ + 1); |
| 492 const QuicByteCount post_loss_window = sender_->GetCongestionWindow(); | 533 const QuicByteCount post_loss_window = sender_->GetCongestionWindow(); |
| 493 EXPECT_GT(initial_window, post_loss_window); | 534 EXPECT_GT(initial_window, post_loss_window); |
| 494 LosePacket(acked_packet_number_ + 3); | 535 LosePacket(acked_packet_number_ + 3); |
| 495 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow()); | 536 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow()); |
| 496 LosePacket(packet_number_ - 1); | 537 LosePacket(packet_number_ - 1); |
| 497 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow()); | 538 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow()); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, | 752 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, |
| 712 HAS_RETRANSMITTABLE_DATA).IsZero()); | 753 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 713 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, | 754 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, |
| 714 HAS_RETRANSMITTABLE_DATA).IsZero()); | 755 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 715 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, | 756 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, |
| 716 HAS_RETRANSMITTABLE_DATA).IsZero()); | 757 HAS_RETRANSMITTABLE_DATA).IsZero()); |
| 717 } | 758 } |
| 718 | 759 |
| 719 } // namespace test | 760 } // namespace test |
| 720 } // namespace net | 761 } // namespace net |
| OLD | NEW |