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

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

Issue 2064543002: Add a new rate based sending connection option which uses the pacing rate to keep the bytes_in_flig… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@124273380
Patch Set: Rebase. Created 4 years, 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/pacing_sender.h" 5 #include "net/quic/congestion_control/pacing_sender.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
(...skipping 25 matching lines...) Expand all
36 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(9)); 36 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(9));
37 } 37 }
38 38
39 ~PacingSenderTest() override {} 39 ~PacingSenderTest() override {}
40 40
41 void InitPacingRate(QuicPacketCount burst_size, QuicBandwidth bandwidth) { 41 void InitPacingRate(QuicPacketCount burst_size, QuicBandwidth bandwidth) {
42 pacing_sender_.reset(); 42 pacing_sender_.reset();
43 mock_sender_ = new StrictMock<MockSendAlgorithm>(); 43 mock_sender_ = new StrictMock<MockSendAlgorithm>();
44 pacing_sender_.reset(new PacingSender( 44 pacing_sender_.reset(new PacingSender(
45 mock_sender_, QuicTime::Delta::FromMilliseconds(1), burst_size)); 45 mock_sender_, QuicTime::Delta::FromMilliseconds(1), burst_size));
46 EXPECT_CALL(*mock_sender_, PacingRate()).WillRepeatedly(Return(bandwidth)); 46 EXPECT_CALL(*mock_sender_, PacingRate(_)).WillRepeatedly(Return(bandwidth));
47 } 47 }
48 48
49 void CheckPacketIsSentImmediately(HasRetransmittableData retransmittable_data, 49 void CheckPacketIsSentImmediately(HasRetransmittableData retransmittable_data,
50 QuicByteCount bytes_in_flight, 50 QuicByteCount bytes_in_flight,
51 bool in_recovery) { 51 bool in_recovery) {
52 // In order for the packet to be sendable, the underlying sender must 52 // In order for the packet to be sendable, the underlying sender must
53 // permit it to be sent immediately. 53 // permit it to be sent immediately.
54 for (int i = 0; i < 2; ++i) { 54 for (int i = 0; i < 2; ++i) {
55 EXPECT_CALL(*mock_sender_, TimeUntilSend(clock_.Now(), bytes_in_flight)) 55 EXPECT_CALL(*mock_sender_, TimeUntilSend(clock_.Now(), bytes_in_flight))
56 .WillOnce(Return(zero_time_)); 56 .WillOnce(Return(zero_time_));
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 356
357 EXPECT_CALL(*mock_sender_, SetMaxCongestionWindow(kBytes)); 357 EXPECT_CALL(*mock_sender_, SetMaxCongestionWindow(kBytes));
358 pacing_sender_->SetMaxCongestionWindow(kBytes); 358 pacing_sender_->SetMaxCongestionWindow(kBytes);
359 359
360 SendAlgorithmInterface::CongestionVector packets; 360 SendAlgorithmInterface::CongestionVector packets;
361 EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytes, packets, packets)); 361 EXPECT_CALL(*mock_sender_, OnCongestionEvent(true, kBytes, packets, packets));
362 pacing_sender_->OnCongestionEvent(true, kBytes, packets, packets); 362 pacing_sender_->OnCongestionEvent(true, kBytes, packets, packets);
363 363
364 EXPECT_CALL(*mock_sender_, OnPacketSent(kTime, kBytes, 123u, kBytes, 364 EXPECT_CALL(*mock_sender_, OnPacketSent(kTime, kBytes, 123u, kBytes,
365 HAS_RETRANSMITTABLE_DATA)); 365 HAS_RETRANSMITTABLE_DATA));
366 EXPECT_CALL(*mock_sender_, PacingRate()).WillOnce(Return(kBandwidth)); 366 EXPECT_CALL(*mock_sender_, PacingRate(_)).WillOnce(Return(kBandwidth));
367 pacing_sender_->OnPacketSent(kTime, kBytes, 123u, kBytes, 367 pacing_sender_->OnPacketSent(kTime, kBytes, 123u, kBytes,
368 HAS_RETRANSMITTABLE_DATA); 368 HAS_RETRANSMITTABLE_DATA);
369 369
370 EXPECT_CALL(*mock_sender_, OnRetransmissionTimeout(true)); 370 EXPECT_CALL(*mock_sender_, OnRetransmissionTimeout(true));
371 pacing_sender_->OnRetransmissionTimeout(true); 371 pacing_sender_->OnRetransmissionTimeout(true);
372 372
373 EXPECT_CALL(*mock_sender_, OnConnectionMigration()); 373 EXPECT_CALL(*mock_sender_, OnConnectionMigration());
374 pacing_sender_->OnConnectionMigration(); 374 pacing_sender_->OnConnectionMigration();
375 375
376 EXPECT_CALL(*mock_sender_, TimeUntilSend(kTime, kBytes)) 376 EXPECT_CALL(*mock_sender_, TimeUntilSend(kTime, kBytes))
377 .WillOnce(Return(kTimeDelta)); 377 .WillOnce(Return(kTimeDelta));
378 pacing_sender_->TimeUntilSend(kTime, kBytes); 378 pacing_sender_->TimeUntilSend(kTime, kBytes);
379 379
380 EXPECT_CALL(*mock_sender_, PacingRate()).WillOnce(Return(kBandwidth)); 380 EXPECT_CALL(*mock_sender_, PacingRate(_)).WillOnce(Return(kBandwidth));
381 EXPECT_EQ(kBandwidth, pacing_sender_->PacingRate()); 381 EXPECT_EQ(kBandwidth, pacing_sender_->PacingRate(0));
382 382
383 EXPECT_CALL(*mock_sender_, BandwidthEstimate()).WillOnce(Return(kBandwidth)); 383 EXPECT_CALL(*mock_sender_, BandwidthEstimate()).WillOnce(Return(kBandwidth));
384 EXPECT_EQ(kBandwidth, pacing_sender_->BandwidthEstimate()); 384 EXPECT_EQ(kBandwidth, pacing_sender_->BandwidthEstimate());
385 385
386 EXPECT_CALL(*mock_sender_, RetransmissionDelay()) 386 EXPECT_CALL(*mock_sender_, RetransmissionDelay())
387 .WillOnce(Return(kTimeDelta)); 387 .WillOnce(Return(kTimeDelta));
388 EXPECT_EQ(kTimeDelta, pacing_sender_->RetransmissionDelay()); 388 EXPECT_EQ(kTimeDelta, pacing_sender_->RetransmissionDelay());
389 389
390 EXPECT_CALL(*mock_sender_, GetCongestionWindow()).WillOnce(Return(kBytes)); 390 EXPECT_CALL(*mock_sender_, GetCongestionWindow()).WillOnce(Return(kBytes));
391 EXPECT_EQ(kBytes, pacing_sender_->GetCongestionWindow()); 391 EXPECT_EQ(kBytes, pacing_sender_->GetCongestionWindow());
392 392
393 EXPECT_CALL(*mock_sender_, InSlowStart()).WillOnce(Return(true)); 393 EXPECT_CALL(*mock_sender_, InSlowStart()).WillOnce(Return(true));
394 EXPECT_TRUE(pacing_sender_->InSlowStart()); 394 EXPECT_TRUE(pacing_sender_->InSlowStart());
395 395
396 EXPECT_CALL(*mock_sender_, InRecovery()).WillOnce(Return(true)); 396 EXPECT_CALL(*mock_sender_, InRecovery()).WillOnce(Return(true));
397 EXPECT_TRUE(pacing_sender_->InRecovery()); 397 EXPECT_TRUE(pacing_sender_->InRecovery());
398 398
399 EXPECT_CALL(*mock_sender_, GetSlowStartThreshold()).WillOnce(Return(kBytes)); 399 EXPECT_CALL(*mock_sender_, GetSlowStartThreshold()).WillOnce(Return(kBytes));
400 EXPECT_EQ(kBytes, pacing_sender_->GetSlowStartThreshold()); 400 EXPECT_EQ(kBytes, pacing_sender_->GetSlowStartThreshold());
401 401
402 EXPECT_CALL(*mock_sender_, GetCongestionControlType()) 402 EXPECT_CALL(*mock_sender_, GetCongestionControlType())
403 .WillOnce(Return(kReno)); 403 .WillOnce(Return(kReno));
404 EXPECT_EQ(kReno, pacing_sender_->GetCongestionControlType()); 404 EXPECT_EQ(kReno, pacing_sender_->GetCongestionControlType());
405 } 405 }
406 406
407 } // namespace test 407 } // namespace test
408 } // namespace net 408 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/pacing_sender.cc ('k') | net/quic/congestion_control/send_algorithm_interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698