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

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

Issue 125403006: Various QUIC cleanups to sync with internal code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix comments Created 6 years, 11 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 | Annotate | Revision Log
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 <algorithm>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/quic/congestion_control/tcp_cubic_sender.h"
9 #include "net/quic/congestion_control/tcp_receiver.h" 10 #include "net/quic/congestion_control/tcp_receiver.h"
10 #include "net/quic/test_tools/mock_clock.h" 11 #include "net/quic/test_tools/mock_clock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
14 using std::min;
15
13 namespace net { 16 namespace net {
14 namespace test { 17 namespace test {
15 18
16 const uint32 kDefaultWindowTCP = 10 * kDefaultTCPMSS; 19 const uint32 kDefaultWindowTCP = 10 * kDefaultTCPMSS;
17 20
18 // TODO(ianswett): Remove 10000 once b/10075719 is fixed. 21 // TODO(ianswett): Remove 10000 once b/10075719 is fixed.
19 const QuicTcpCongestionWindow kDefaultMaxCongestionWindowTCP = 10000; 22 const QuicTcpCongestionWindow kDefaultMaxCongestionWindowTCP = 10000;
20 23
21 class TcpCubicSenderPeer : public TcpCubicSender { 24 class TcpCubicSenderPeer : public TcpCubicSender {
22 public: 25 public:
(...skipping 20 matching lines...) Expand all
43 sender_(new TcpCubicSenderPeer(&clock_, true, 46 sender_(new TcpCubicSenderPeer(&clock_, true,
44 kDefaultMaxCongestionWindowTCP)), 47 kDefaultMaxCongestionWindowTCP)),
45 receiver_(new TcpReceiver()), 48 receiver_(new TcpReceiver()),
46 sequence_number_(1), 49 sequence_number_(1),
47 acked_sequence_number_(0) { 50 acked_sequence_number_(0) {
48 } 51 }
49 52
50 void SendAvailableSendWindow() { 53 void SendAvailableSendWindow() {
51 QuicByteCount bytes_to_send = sender_->AvailableSendWindow(); 54 QuicByteCount bytes_to_send = sender_->AvailableSendWindow();
52 while (bytes_to_send > 0) { 55 while (bytes_to_send > 0) {
53 QuicByteCount bytes_in_packet = std::min(kDefaultTCPMSS, bytes_to_send); 56 QuicByteCount bytes_in_packet = min(kDefaultTCPMSS, bytes_to_send);
54 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet, 57 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet,
55 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); 58 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
56 bytes_to_send -= bytes_in_packet; 59 bytes_to_send -= bytes_in_packet;
57 if (bytes_to_send > 0) { 60 if (bytes_to_send > 0) {
58 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), NOT_RETRANSMISSION, 61 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), NOT_RETRANSMISSION,
59 HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero()); 62 HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero());
60 } 63 }
61 } 64 }
62 } 65 }
63 // Normal is that TCP acks every other segment. 66 // Normal is that TCP acks every other segment.
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // Lose a later packet and ensure the window decreases. 390 // Lose a later packet and ensure the window decreases.
388 sender_->OnPacketLost(sequence_number_, clock_.Now()); 391 sender_->OnPacketLost(sequence_number_, clock_.Now());
389 EXPECT_GT(post_loss_window, sender_->GetCongestionWindow()); 392 EXPECT_GT(post_loss_window, sender_->GetCongestionWindow());
390 } 393 }
391 394
392 TEST_F(TcpCubicSenderTest, SendWindowNotAffectedByAcks) { 395 TEST_F(TcpCubicSenderTest, SendWindowNotAffectedByAcks) {
393 QuicByteCount send_window = sender_->AvailableSendWindow(); 396 QuicByteCount send_window = sender_->AvailableSendWindow();
394 397
395 // Send a packet with no retransmittable data, and ensure that the congestion 398 // Send a packet with no retransmittable data, and ensure that the congestion
396 // window doesn't change. 399 // window doesn't change.
397 QuicByteCount bytes_in_packet = std::min(kDefaultTCPMSS, send_window); 400 QuicByteCount bytes_in_packet = min(kDefaultTCPMSS, send_window);
398 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet, 401 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet,
399 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA); 402 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA);
400 EXPECT_EQ(send_window, sender_->AvailableSendWindow()); 403 EXPECT_EQ(send_window, sender_->AvailableSendWindow());
401 404
402 // Send a data packet with retransmittable data, and ensure that the 405 // Send a data packet with retransmittable data, and ensure that the
403 // congestion window has shrunk. 406 // congestion window has shrunk.
404 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet, 407 sender_->OnPacketSent(clock_.Now(), sequence_number_++, bytes_in_packet,
405 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA); 408 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
406 EXPECT_GT(send_window, sender_->AvailableSendWindow()); 409 EXPECT_GT(send_window, sender_->AvailableSendWindow());
407 } 410 }
408 411
409 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) { 412 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) {
410 QuicTcpCongestionWindow congestion_window = sender_->congestion_window(); 413 QuicTcpCongestionWindow congestion_window = sender_->congestion_window();
411 QuicConfig config; 414 QuicConfig config;
412 config.set_server_initial_congestion_window(2 * congestion_window, 415 config.set_server_initial_congestion_window(2 * congestion_window,
413 2 * congestion_window); 416 2 * congestion_window);
414 EXPECT_EQ(2 * congestion_window, config.server_initial_congestion_window()); 417 EXPECT_EQ(2 * congestion_window, config.server_initial_congestion_window());
415 418
416 sender_->SetFromConfig(config, true); 419 sender_->SetFromConfig(config, true);
417 EXPECT_EQ(2 * congestion_window, sender_->congestion_window()); 420 EXPECT_EQ(2 * congestion_window, sender_->congestion_window());
418 } 421 }
419 422
420 } // namespace test 423 } // namespace test
421 } // namespace net 424 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/congestion_control/tcp_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698