Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: net/quic/congestion_control/tcp_cubic_sender_test.cc

Issue 1343093003: Landing Recent QUIC changes until 9/2/2015 17:00 UTC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with TOT Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/crypto/crypto_framer_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "net/quic/congestion_control/rtt_stats.h" 11 #include "net/quic/congestion_control/rtt_stats.h"
12 #include "net/quic/crypto/crypto_protocol.h" 12 #include "net/quic/crypto/crypto_protocol.h"
13 #include "net/quic/proto/cached_network_parameters.pb.h" 13 #include "net/quic/proto/cached_network_parameters.pb.h"
14 #include "net/quic/quic_flags.h"
14 #include "net/quic/quic_protocol.h" 15 #include "net/quic/quic_protocol.h"
15 #include "net/quic/quic_utils.h" 16 #include "net/quic/quic_utils.h"
16 #include "net/quic/test_tools/mock_clock.h" 17 #include "net/quic/test_tools/mock_clock.h"
17 #include "net/quic/test_tools/quic_config_peer.h" 18 #include "net/quic/test_tools/quic_config_peer.h"
19 #include "net/quic/test_tools/quic_test_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 using std::min; 22 using std::min;
21 23
22 namespace net { 24 namespace net {
23 namespace test { 25 namespace test {
24 26
25 // TODO(ianswett): A number of theses tests were written with the assumption of 27 // TODO(ianswett): A number of theses tests were written with the assumption of
26 // an initial CWND of 10. They have carefully calculated values which should be 28 // an initial CWND of 10. They have carefully calculated values which should be
27 // updated to be based on kInitialCongestionWindowInsecure. 29 // updated to be based on kInitialCongestionWindowInsecure.
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 for (int i = 0; i < kNumberOfAcks; ++i) { 480 for (int i = 0; i < kNumberOfAcks; ++i) {
479 // Send our full send window. 481 // Send our full send window.
480 SendAvailableSendWindow(); 482 SendAvailableSendWindow();
481 AckNPackets(2); 483 AckNPackets(2);
482 } 484 }
483 485
484 QuicByteCount expected_send_window = kMaxCongestionWindowTCP * kDefaultTCPMSS; 486 QuicByteCount expected_send_window = kMaxCongestionWindowTCP * kDefaultTCPMSS;
485 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow()); 487 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
486 } 488 }
487 489
490 TEST_F(TcpCubicSenderTest, TcpCubicResetEpochOnQuiescence) {
491 ValueRestore<bool> old_flag(&FLAGS_reset_cubic_epoch_when_app_limited, true);
492 const int kMaxCongestionWindow = 50;
493 const QuicByteCount kMaxCongestionWindowBytes =
494 kMaxCongestionWindow * kDefaultTCPMSS;
495 sender_.reset(new TcpCubicSenderPeer(&clock_, false, kMaxCongestionWindow));
496
497 int num_sent = SendAvailableSendWindow();
498
499 // Make sure we fall out of slow start.
500 QuicByteCount saved_cwnd = sender_->GetCongestionWindow();
501 LoseNPackets(1);
502 EXPECT_GT(saved_cwnd, sender_->GetCongestionWindow());
503
504 // Ack the rest of the outstanding packets to get out of recovery.
505 for (int i = 1; i < num_sent; ++i) {
506 AckNPackets(1);
507 }
508 EXPECT_EQ(0u, bytes_in_flight_);
509
510 // Send a new window of data and ack all; cubic growth should occur.
511 saved_cwnd = sender_->GetCongestionWindow();
512 num_sent = SendAvailableSendWindow();
513 for (int i = 0; i < num_sent; ++i) {
514 AckNPackets(1);
515 }
516 EXPECT_LT(saved_cwnd, sender_->GetCongestionWindow());
517 EXPECT_GT(kMaxCongestionWindowBytes, sender_->GetCongestionWindow());
518 EXPECT_EQ(0u, bytes_in_flight_);
519
520 // Quiescent time of 100 seconds
521 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(100000));
522
523 // Send new window of data and ack one packet. Cubic epoch should have
524 // been reset; ensure cwnd increase is not dramatic.
525 saved_cwnd = sender_->GetCongestionWindow();
526 SendAvailableSendWindow();
527 AckNPackets(1);
528 EXPECT_NEAR(saved_cwnd, sender_->GetCongestionWindow(), kDefaultTCPMSS);
529 EXPECT_GT(kMaxCongestionWindowBytes, sender_->GetCongestionWindow());
530 }
531
488 TEST_F(TcpCubicSenderTest, MultipleLossesInOneWindow) { 532 TEST_F(TcpCubicSenderTest, MultipleLossesInOneWindow) {
489 SendAvailableSendWindow(); 533 SendAvailableSendWindow();
490 const QuicByteCount initial_window = sender_->GetCongestionWindow(); 534 const QuicByteCount initial_window = sender_->GetCongestionWindow();
491 LosePacket(acked_packet_number_ + 1); 535 LosePacket(acked_packet_number_ + 1);
492 const QuicByteCount post_loss_window = sender_->GetCongestionWindow(); 536 const QuicByteCount post_loss_window = sender_->GetCongestionWindow();
493 EXPECT_GT(initial_window, post_loss_window); 537 EXPECT_GT(initial_window, post_loss_window);
494 LosePacket(acked_packet_number_ + 3); 538 LosePacket(acked_packet_number_ + 3);
495 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow()); 539 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow());
496 LosePacket(packet_number_ - 1); 540 LosePacket(packet_number_ - 1);
497 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow()); 541 EXPECT_EQ(post_loss_window, sender_->GetCongestionWindow());
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS, 755 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 2 * kDefaultTCPMSS,
712 HAS_RETRANSMITTABLE_DATA).IsZero()); 756 HAS_RETRANSMITTABLE_DATA).IsZero());
713 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS, 757 EXPECT_TRUE(sender_->TimeUntilSend(QuicTime::Zero(), 3 * kDefaultTCPMSS,
714 HAS_RETRANSMITTABLE_DATA).IsZero()); 758 HAS_RETRANSMITTABLE_DATA).IsZero());
715 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS, 759 EXPECT_FALSE(sender_->TimeUntilSend(QuicTime::Zero(), 4 * kDefaultTCPMSS,
716 HAS_RETRANSMITTABLE_DATA).IsZero()); 760 HAS_RETRANSMITTABLE_DATA).IsZero());
717 } 761 }
718 762
719 } // namespace test 763 } // namespace test
720 } // namespace net 764 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/crypto/crypto_framer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698