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

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

Issue 47283002: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compilation error Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/quic_client_session_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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "net/quic/congestion_control/tcp_cubic_sender.h" 7 #include "net/quic/congestion_control/tcp_cubic_sender.h"
8 #include "net/quic/congestion_control/tcp_receiver.h" 8 #include "net/quic/congestion_control/tcp_receiver.h"
9 #include "net/quic/test_tools/mock_clock.h" 9 #include "net/quic/test_tools/mock_clock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 SendAlgorithmInterface::SentPacketsMap not_used_; 68 SendAlgorithmInterface::SentPacketsMap not_used_;
69 scoped_ptr<TcpCubicSenderPeer> sender_; 69 scoped_ptr<TcpCubicSenderPeer> sender_;
70 scoped_ptr<TcpReceiver> receiver_; 70 scoped_ptr<TcpReceiver> receiver_;
71 QuicPacketSequenceNumber sequence_number_; 71 QuicPacketSequenceNumber sequence_number_;
72 QuicPacketSequenceNumber acked_sequence_number_; 72 QuicPacketSequenceNumber acked_sequence_number_;
73 }; 73 };
74 74
75 TEST_F(TcpCubicSenderTest, SimpleSender) { 75 TEST_F(TcpCubicSenderTest, SimpleSender) {
76 QuicCongestionFeedbackFrame feedback; 76 QuicCongestionFeedbackFrame feedback;
77 // At startup make sure we are at the default. 77 // At startup make sure we are at the default.
78 EXPECT_EQ(kDefaultWindowTCP, 78 EXPECT_EQ(kDefaultWindowTCP, sender_->AvailableSendWindow());
79 sender_->AvailableSendWindow()); 79 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
80 // At startup make sure we can send. 80 // At startup make sure we can send.
81 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 81 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(),
82 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero()); 82 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero());
83 // Get default QuicCongestionFeedbackFrame from receiver. 83 // Get default QuicCongestionFeedbackFrame from receiver.
84 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback)); 84 ASSERT_TRUE(receiver_->GenerateCongestionFeedback(&feedback));
85 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now(), 85 sender_->OnIncomingQuicCongestionFeedbackFrame(feedback, clock_.Now(),
86 not_used_); 86 not_used_);
87 // Make sure we can send. 87 // Make sure we can send.
88 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 88 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(),
89 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero()); 89 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero());
90 // And that window is un-affected. 90 // And that window is un-affected.
91 EXPECT_EQ(kDefaultWindowTCP, sender_->AvailableSendWindow()); 91 EXPECT_EQ(kDefaultWindowTCP, sender_->AvailableSendWindow());
92 EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
92 93
93 // A retransmit should always return 0. 94 // A retransmit should always return 0.
94 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), 95 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(),
95 NACK_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero()); 96 NACK_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero());
96 } 97 }
97 98
98 TEST_F(TcpCubicSenderTest, ExponentialSlowStart) { 99 TEST_F(TcpCubicSenderTest, ExponentialSlowStart) {
99 const int kNumberOfAck = 20; 100 const int kNumberOfAck = 20;
100 QuicCongestionFeedbackFrame feedback; 101 QuicCongestionFeedbackFrame feedback;
101 // At startup make sure we can send. 102 // At startup make sure we can send.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero()); 140 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero());
140 141
141 for (int n = 0; n < kNumberOfAck; ++n) { 142 for (int n = 0; n < kNumberOfAck; ++n) {
142 // Send our full send window. 143 // Send our full send window.
143 SendAvailableSendWindow(); 144 SendAvailableSendWindow();
144 AckNPackets(2); 145 AckNPackets(2);
145 } 146 }
146 QuicByteCount expected_send_window = 147 QuicByteCount expected_send_window =
147 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAck); 148 kDefaultWindowTCP + (kDefaultTCPMSS * 2 * kNumberOfAck);
148 EXPECT_EQ(expected_send_window, sender_->SendWindow()); 149 EXPECT_EQ(expected_send_window, sender_->SendWindow());
150 EXPECT_EQ(expected_send_window, sender_->GetCongestionWindow());
149 // We should now have fallen out of slow start. 151 // We should now have fallen out of slow start.
150 SendAvailableSendWindow(); 152 SendAvailableSendWindow();
151 AckNPackets(2); 153 AckNPackets(2);
152 expected_send_window += kDefaultTCPMSS; 154 expected_send_window += kDefaultTCPMSS;
153 EXPECT_EQ(expected_send_window, sender_->SendWindow()); 155 EXPECT_EQ(expected_send_window, sender_->SendWindow());
154 156
155 // Testing Reno phase. 157 // Testing Reno phase.
156 // We should need 141(65*2+1+10) ACK:ed packets before increasing window by 158 // We should need 141(65*2+1+10) ACK:ed packets before increasing window by
157 // one. 159 // one.
158 for (int m = 0; m < 70; ++m) { 160 for (int m = 0; m < 70; ++m) {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 366
365 // Send a data packet with retransmittable data, and ensure that the 367 // Send a data packet with retransmittable data, and ensure that the
366 // congestion window has shrunk. 368 // congestion window has shrunk.
367 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet, 369 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet,
368 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); 370 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
369 EXPECT_GT(send_window, sender_->AvailableSendWindow()); 371 EXPECT_GT(send_window, sender_->AvailableSendWindow());
370 } 372 }
371 373
372 } // namespace test 374 } // namespace test
373 } // namespace net 375 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/quic_client_session_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698