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

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

Issue 23597045: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged QuicPriority to RequestPriority changes Created 7 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/quic_client_session.h » ('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 27 matching lines...) Expand all
38 receiver_(new TcpReceiver()), 38 receiver_(new TcpReceiver()),
39 sequence_number_(1), 39 sequence_number_(1),
40 acked_sequence_number_(0) { 40 acked_sequence_number_(0) {
41 } 41 }
42 42
43 void SendAvailableCongestionWindow() { 43 void SendAvailableCongestionWindow() {
44 QuicByteCount bytes_to_send = sender_->AvailableCongestionWindow(); 44 QuicByteCount bytes_to_send = sender_->AvailableCongestionWindow();
45 while (bytes_to_send > 0) { 45 while (bytes_to_send > 0) {
46 QuicByteCount bytes_in_packet = std::min(kMaxPacketSize, bytes_to_send); 46 QuicByteCount bytes_in_packet = std::min(kMaxPacketSize, bytes_to_send);
47 sender_->SentPacket(clock_.Now(), sequence_number_++, bytes_in_packet, 47 sender_->SentPacket(clock_.Now(), sequence_number_++, bytes_in_packet,
48 NOT_RETRANSMISSION); 48 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
49 bytes_to_send -= bytes_in_packet; 49 bytes_to_send -= bytes_in_packet;
50 if (bytes_to_send > 0) { 50 if (bytes_to_send > 0) {
51 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), NOT_RETRANSMISSION, 51 EXPECT_TRUE(sender_->TimeUntilSend(clock_.Now(), NOT_RETRANSMISSION,
52 HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero()); 52 HAS_RETRANSMITTABLE_DATA, NOT_HANDSHAKE).IsZero());
53 } 53 }
54 } 54 }
55 } 55 }
56 // Normal is that TCP acks every other segment. 56 // Normal is that TCP acks every other segment.
57 void AckNPackets(int n) { 57 void AckNPackets(int n) {
58 for (int i = 0; i < n; ++i) { 58 for (int i = 0; i < n; ++i) {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 // Send our full congestion window. 345 // Send our full congestion window.
346 SendAvailableCongestionWindow(); 346 SendAvailableCongestionWindow();
347 AckNPackets(2); 347 AckNPackets(2);
348 } 348 }
349 349
350 QuicByteCount expected_congestion_window = 350 QuicByteCount expected_congestion_window =
351 kMaxCongestionWindowTCP * kMaxPacketSize; 351 kMaxCongestionWindowTCP * kMaxPacketSize;
352 EXPECT_EQ(expected_congestion_window, sender_->CongestionWindow()); 352 EXPECT_EQ(expected_congestion_window, sender_->CongestionWindow());
353 } 353 }
354 354
355 TEST_F(TcpCubicSenderTest, CongestionWindowNotAffectedByAcks) {
356 QuicByteCount congestion_window = sender_->AvailableCongestionWindow();
357
358 // Send a packet with no retransmittable data, and ensure that the congestion
359 // window doesn't change.
360 QuicByteCount bytes_in_packet = std::min(kMaxPacketSize, congestion_window);
361 sender_->SentPacket(clock_.Now(), sequence_number_++, bytes_in_packet,
362 NOT_RETRANSMISSION, NO_RETRANSMITTABLE_DATA);
363 EXPECT_EQ(congestion_window, sender_->AvailableCongestionWindow());
364
365 // Send a data packet with retransmittable data, and ensure that the
366 // congestion window has shrunk.
367 sender_->SentPacket(clock_.Now(), sequence_number_++, bytes_in_packet,
368 NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
369 EXPECT_GT(congestion_window, sender_->AvailableCongestionWindow());
370 }
371
355 } // namespace test 372 } // namespace test
356 } // namespace net 373 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender.cc ('k') | net/quic/quic_client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698