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

Side by Side Diff: net/quic/core/congestion_control/bbr_sender_test.cc

Issue 2825083003: Landing Recent QUIC changes until Mon Apr 17 2017 (Closed)
Patch Set: Format Created 3 years, 8 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/core/congestion_control/bbr_sender.h" 5 #include "net/quic/core/congestion_control/bbr_sender.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 "BBR sender", 83 "BBR sender",
84 Perspective::IS_SERVER, 84 Perspective::IS_SERVER,
85 /*connection_id=*/GetPeerInMemoryConnectionId(42)), 85 /*connection_id=*/GetPeerInMemoryConnectionId(42)),
86 competing_receiver_(&simulator_, 86 competing_receiver_(&simulator_,
87 "Competing receiver", 87 "Competing receiver",
88 "Competing sender", 88 "Competing sender",
89 Perspective::IS_SERVER, 89 Perspective::IS_SERVER,
90 /*connection_id=*/GetPeerInMemoryConnectionId(43)), 90 /*connection_id=*/GetPeerInMemoryConnectionId(43)),
91 receiver_multiplexer_("Receiver multiplexer", 91 receiver_multiplexer_("Receiver multiplexer",
92 {&receiver_, &competing_receiver_}) { 92 {&receiver_, &competing_receiver_}) {
93 // TODO(ianswett): Determine why tests become flaky with CWND based on SRTT.
94 FLAGS_quic_reloadable_flag_quic_bbr_base_cwnd_on_srtt = false;
93 rtt_stats_ = bbr_sender_.connection()->sent_packet_manager().GetRttStats(); 95 rtt_stats_ = bbr_sender_.connection()->sent_packet_manager().GetRttStats();
94 sender_ = SetupBbrSender(&bbr_sender_); 96 sender_ = SetupBbrSender(&bbr_sender_);
95 97
96 clock_ = simulator_.GetClock(); 98 clock_ = simulator_.GetClock();
97 simulator_.set_random_generator(&random_); 99 simulator_.set_random_generator(&random_);
98 100
99 uint64_t seed = QuicRandom::GetInstance()->RandUint64(); 101 uint64_t seed = QuicRandom::GetInstance()->RandUint64();
100 random_.set_seed(seed); 102 random_.set_seed(seed);
101 QUIC_LOG(INFO) << "BbrSenderTest simulator set up. Seed: " << seed; 103 QUIC_LOG(INFO) << "BbrSenderTest simulator set up. Seed: " << seed;
102 } 104 }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 284
283 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(30)); 285 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(30));
284 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); 286 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode);
285 ExpectApproxEq(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth, 287 ExpectApproxEq(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth,
286 0.01f); 288 0.01f);
287 EXPECT_GE(bbr_sender_.connection()->GetStats().packets_lost, 0u); 289 EXPECT_GE(bbr_sender_.connection()->GetStats().packets_lost, 0u);
288 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); 290 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited);
289 } 291 }
290 292
291 // Test a simple long data transfer with 2 rtts of aggregation. 293 // Test a simple long data transfer with 2 rtts of aggregation.
292 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregation) { 294 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregationBytes) {
293 QuicFlagSaver flags; 295 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true;
294 FLAGS_quic_reloadable_flag_quic_bbr_ack_spacing2 = true;
295 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; 296 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false;
296 CreateDefaultSetup(); 297 CreateDefaultSetup();
297 // 2 RTTs of aggregation, with a max of 10kb. 298 // 2 RTTs of aggregation, with a max of 10kb.
298 EnableAggregation(10 * 1024, 2 * kTestRtt); 299 EnableAggregation(10 * 1024, 2 * kTestRtt);
299 300
300 // Transfer 12MB. 301 // Transfer 12MB.
301 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); 302 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35));
302 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); 303 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode);
303 // It's possible to read a bandwidth as much as 50% too high with aggregation. 304 // It's possible to read a bandwidth as much as 50% too high with aggregation.
304 EXPECT_LE(kTestLinkBandwidth * 0.99f, 305 EXPECT_LE(kTestLinkBandwidth * 0.99f,
305 sender_->ExportDebugState().max_bandwidth); 306 sender_->ExportDebugState().max_bandwidth);
306 // TODO(ianswett): Tighten this bound once we understand why BBR is 307 // TODO(ianswett): Tighten this bound once we understand why BBR is
307 // overestimating bandwidth with aggregation. b/36022633 308 // overestimating bandwidth with aggregation. b/36022633
308 EXPECT_GE(kTestLinkBandwidth * 1.5f, 309 EXPECT_GE(kTestLinkBandwidth * 1.5f,
309 sender_->ExportDebugState().max_bandwidth); 310 sender_->ExportDebugState().max_bandwidth);
310 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures 311 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures
311 // bandwidth higher than the link rate. 312 // bandwidth higher than the link rate.
313 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited);
312 // The margin here is high, because the aggregation greatly increases 314 // The margin here is high, because the aggregation greatly increases
313 // smoothed rtt. 315 // smoothed rtt.
314 EXPECT_GE(kTestRtt * 4, rtt_stats_->smoothed_rtt()); 316 EXPECT_GE(kTestRtt * 4, rtt_stats_->smoothed_rtt());
315 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); 317 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f);
316 } 318 }
317 319
318 // Test a simple long data transfer with 2 rtts of aggregation. 320 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregationKeepSending) {
319 TEST_F(BbrSenderTest, SimpleTransfer2RTTAggregationBytes) { 321 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = false;
320 FLAGS_quic_reloadable_flag_quic_bbr_ack_spacing2 = false;
321 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true;
322 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false; 322 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = false;
323 FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate = true;
323 CreateDefaultSetup(); 324 CreateDefaultSetup();
324 // 2 RTTs of aggregation, with a max of 10kb. 325 // 2 RTTs of aggregation, with a max of 10kb.
325 EnableAggregation(10 * 1024, 2 * kTestRtt); 326 EnableAggregation(10 * 1024, 2 * kTestRtt);
326 327
327 // Transfer 12MB. 328 // Transfer 12MB.
328 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35)); 329 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35));
329 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode); 330 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode);
330 // It's possible to read a bandwidth as much as 50% too high with aggregation. 331 // It's possible to read a bandwidth as much as 50% too high with aggregation.
331 EXPECT_LE(kTestLinkBandwidth * 0.99f, 332 EXPECT_LE(kTestLinkBandwidth * 0.95f,
332 sender_->ExportDebugState().max_bandwidth); 333 sender_->ExportDebugState().max_bandwidth);
333 // TODO(ianswett): Tighten this bound once we understand why BBR is 334 // TODO(ianswett): Tighten this bound once we understand why BBR is
334 // overestimating bandwidth with aggregation. b/36022633 335 // overestimating bandwidth with aggregation. b/36022633
335 EXPECT_GE(kTestLinkBandwidth * 1.5f, 336 EXPECT_GE(kTestLinkBandwidth * 1.5f,
336 sender_->ExportDebugState().max_bandwidth); 337 sender_->ExportDebugState().max_bandwidth);
337 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures 338 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures
338 // bandwidth higher than the link rate. 339 // bandwidth higher than the link rate.
339 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); 340 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited);
340 // The margin here is high, because the aggregation greatly increases 341 // The margin here is high, because the aggregation greatly increases
341 // smoothed rtt. 342 // smoothed rtt.
342 EXPECT_GE(kTestRtt * 4, rtt_stats_->smoothed_rtt()); 343 EXPECT_GE(kTestRtt * 4.5, rtt_stats_->smoothed_rtt());
343 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); 344 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f);
344 } 345 }
345 346
346 // Test a simple long data transfer with 2 rtts of aggregation. 347 // Test a simple long data transfer with 2 rtts of aggregation.
347 TEST_F(BbrSenderTest, SimpleTransferAckDecimation) { 348 TEST_F(BbrSenderTest, SimpleTransferAckDecimation) {
348 FLAGS_quic_reloadable_flag_quic_bbr_ack_spacing2 = false;
349 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true; 349 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = true;
350 // Decrease the CWND gain so extra CWND is required with stretch acks. 350 // Decrease the CWND gain so extra CWND is required with stretch acks.
351 base::SetFlag(&FLAGS_quic_bbr_cwnd_gain, 1.0); 351 SetQuicFlag(&FLAGS_quic_bbr_cwnd_gain, 1.0);
352 sender_ = new BbrSender( 352 sender_ = new BbrSender(
353 rtt_stats_, 353 rtt_stats_,
354 QuicSentPacketManagerPeer::GetUnackedPacketMap( 354 QuicSentPacketManagerPeer::GetUnackedPacketMap(
355 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())), 355 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())),
356 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets, 356 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets,
357 &random_); 357 &random_);
358 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_); 358 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_);
359 // Enable Ack Decimation on the receiver. 359 // Enable Ack Decimation on the receiver.
360 QuicConnectionPeer::SetAckMode(receiver_.connection(), 360 QuicConnectionPeer::SetAckMode(receiver_.connection(),
361 QuicConnection::AckMode::ACK_DECIMATION); 361 QuicConnection::AckMode::ACK_DECIMATION);
(...skipping 11 matching lines...) Expand all
373 sender_->ExportDebugState().max_bandwidth); 373 sender_->ExportDebugState().max_bandwidth);
374 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures 374 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures
375 // bandwidth higher than the link rate. 375 // bandwidth higher than the link rate.
376 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited); 376 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited);
377 // The margin here is high, because the aggregation greatly increases 377 // The margin here is high, because the aggregation greatly increases
378 // smoothed rtt. 378 // smoothed rtt.
379 EXPECT_GE(kTestRtt * 2, rtt_stats_->smoothed_rtt()); 379 EXPECT_GE(kTestRtt * 2, rtt_stats_->smoothed_rtt());
380 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f); 380 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f);
381 } 381 }
382 382
383 TEST_F(BbrSenderTest, SimpleTransferAckDecimationKeepSending) {
384 FLAGS_quic_reloadable_flag_quic_bbr_ack_aggregation_bytes = false;
385 FLAGS_quic_reloadable_flag_quic_bbr_add_tso_cwnd = true;
386 FLAGS_quic_reloadable_flag_quic_bbr_keep_sending_at_recent_rate = true;
387 // Decrease the CWND gain so extra CWND is required with stretch acks.
388 SetQuicFlag(&FLAGS_quic_bbr_cwnd_gain, 1.0);
389 sender_ = new BbrSender(
390 rtt_stats_,
391 QuicSentPacketManagerPeer::GetUnackedPacketMap(
392 QuicConnectionPeer::GetSentPacketManager(bbr_sender_.connection())),
393 kInitialCongestionWindowPackets, kDefaultMaxCongestionWindowPackets,
394 &random_);
395 QuicConnectionPeer::SetSendAlgorithm(bbr_sender_.connection(), sender_);
396 // Enable Ack Decimation on the receiver.
397 QuicConnectionPeer::SetAckMode(receiver_.connection(),
398 QuicConnection::AckMode::ACK_DECIMATION);
399 CreateDefaultSetup();
400
401 // Transfer 12MB.
402 DoSimpleTransfer(12 * 1024 * 1024, QuicTime::Delta::FromSeconds(35));
403 EXPECT_EQ(BbrSender::PROBE_BW, sender_->ExportDebugState().mode);
404 // It's possible to read a bandwidth as much as 50% too high with aggregation.
405 EXPECT_LE(kTestLinkBandwidth * 0.95f,
406 sender_->ExportDebugState().max_bandwidth);
407 // TODO(ianswett): Tighten this bound once we understand why BBR is
408 // overestimating bandwidth with aggregation. b/36022633
409 EXPECT_GE(kTestLinkBandwidth * 1.5f,
410 sender_->ExportDebugState().max_bandwidth);
411 // TODO(ianswett): Expect 0 packets are lost once BBR no longer measures
412 // bandwidth higher than the link rate.
413 EXPECT_FALSE(sender_->ExportDebugState().last_sample_is_app_limited);
414 // The margin here is high, because the aggregation greatly increases
415 // smoothed rtt.
416 EXPECT_GE(kTestRtt * 2, rtt_stats_->smoothed_rtt());
417 ExpectApproxEq(kTestRtt, rtt_stats_->min_rtt(), 0.1f);
418 }
419
383 // Test the number of losses incurred by the startup phase in a situation when 420 // Test the number of losses incurred by the startup phase in a situation when
384 // the buffer is less than BDP. 421 // the buffer is less than BDP.
385 TEST_F(BbrSenderTest, PacketLossOnSmallBufferStartup) { 422 TEST_F(BbrSenderTest, PacketLossOnSmallBufferStartup) {
386 CreateSmallBufferSetup(); 423 CreateSmallBufferSetup();
387 424
388 DriveOutOfStartup(); 425 DriveOutOfStartup();
389 float loss_rate = 426 float loss_rate =
390 static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) / 427 static_cast<float>(bbr_sender_.connection()->GetStats().packets_lost) /
391 bbr_sender_.connection()->GetStats().packets_sent; 428 bbr_sender_.connection()->GetStats().packets_sent;
392 EXPECT_LE(loss_rate, 0.27); 429 EXPECT_LE(loss_rate, 0.27);
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 sender_->ResumeConnectionState(params, false); 761 sender_->ResumeConnectionState(params, false);
725 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth); 762 EXPECT_EQ(kTestLinkBandwidth, sender_->ExportDebugState().max_bandwidth);
726 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate()); 763 EXPECT_EQ(kTestLinkBandwidth, sender_->BandwidthEstimate());
727 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f); 764 ExpectApproxEq(kTestRtt, sender_->ExportDebugState().min_rtt, 0.01f);
728 765
729 DriveOutOfStartup(); 766 DriveOutOfStartup();
730 } 767 }
731 768
732 } // namespace test 769 } // namespace test
733 } // namespace net 770 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/congestion_control/bbr_sender.cc ('k') | net/quic/core/congestion_control/cubic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698