| Index: net/quic/congestion_control/cubic_test.cc
|
| diff --git a/net/quic/congestion_control/cubic_test.cc b/net/quic/congestion_control/cubic_test.cc
|
| index bb5e93dffb703d8d29342a95dbfd7ae695e8504f..7844c26704f90ec9270aa10ceb1afc1633c43639 100644
|
| --- a/net/quic/congestion_control/cubic_test.cc
|
| +++ b/net/quic/congestion_control/cubic_test.cc
|
| @@ -5,6 +5,7 @@
|
| #include "base/basictypes.h"
|
| #include "base/logging.h"
|
| #include "net/quic/congestion_control/cubic.h"
|
| +#include "net/quic/quic_connection_stats.h"
|
| #include "net/quic/test_tools/mock_clock.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -22,11 +23,12 @@ class CubicTest : public ::testing::Test {
|
| CubicTest()
|
| : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
|
| hundred_ms_(QuicTime::Delta::FromMilliseconds(100)),
|
| - cubic_(&clock_) {
|
| + cubic_(&clock_, &stats_) {
|
| }
|
| const QuicTime::Delta one_ms_;
|
| const QuicTime::Delta hundred_ms_;
|
| MockClock clock_;
|
| + QuicConnectionStats stats_;
|
| Cubic cubic_;
|
| };
|
|
|
| @@ -53,7 +55,7 @@ TEST_F(CubicTest, AboveOrigin) {
|
| expected_cwnd++;
|
| }
|
| // Cubic phase.
|
| - for (int j = 48; j < 100; ++j) {
|
| + for (int i = 0; i < 52; ++i) {
|
| for (uint32 n = 1; n < current_cwnd; ++n) {
|
| // Call once per ACK.
|
| EXPECT_EQ(current_cwnd,
|
| @@ -62,12 +64,58 @@ TEST_F(CubicTest, AboveOrigin) {
|
| clock_.AdvanceTime(hundred_ms_);
|
| current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| }
|
| - float elapsed_time_s = 10.0f + 0.1f; // We need to add the RTT here.
|
| + // Total time elapsed so far; add min_rtt (0.1s) here as well.
|
| + float elapsed_time_s = 10.0f + 0.1f;
|
| + // expected_cwnd is initial value of cwnd + K * t^3, where K = 0.4.
|
| expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410)
|
| / 1024;
|
| EXPECT_EQ(expected_cwnd, current_cwnd);
|
| }
|
|
|
| +TEST_F(CubicTest, CwndIncreaseStatsDuringConvexRegion) {
|
| + const QuicTime::Delta rtt_min = hundred_ms_;
|
| + uint32 current_cwnd = 10;
|
| + uint32 expected_cwnd = current_cwnd + 1;
|
| + // Initialize controller state.
|
| + clock_.AdvanceTime(one_ms_);
|
| + expected_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| + current_cwnd = expected_cwnd;
|
| + // Testing Reno mode increase.
|
| + for (int i = 0; i < 48; ++i) {
|
| + for (uint32 n = 1; n < current_cwnd / kNConnectionAlpha; ++n) {
|
| + // Call once per ACK, causing cwnd growth in Reno mode.
|
| + cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| + }
|
| + // Advance current time so that cwnd update is allowed to happen by Cubic.
|
| + clock_.AdvanceTime(hundred_ms_);
|
| + current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| + EXPECT_NEAR(expected_cwnd - 10, stats_.cwnd_increase_reno_mode, 1);
|
| + EXPECT_NEAR(1u, stats_.cwnd_increase_cubic_mode, 1);
|
| + expected_cwnd++;
|
| + }
|
| + uint32 old_cwnd = current_cwnd;
|
| + stats_.cwnd_increase_cubic_mode = 0;
|
| + stats_.cwnd_increase_reno_mode = 0;
|
| +
|
| + // Testing Cubic mode increase.
|
| + for (int i = 0; i < 52; ++i) {
|
| + for (uint32 n = 1; n < current_cwnd; ++n) {
|
| + // Call once per ACK.
|
| + cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| + }
|
| + clock_.AdvanceTime(hundred_ms_);
|
| + current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| + }
|
| + // Total time elapsed so far; add min_rtt (0.1s) here as well.
|
| + float elapsed_time_s = 10.0f + 0.1f;
|
| + // expected_cwnd is initial value of cwnd + K * t^3, where K = 0.4.
|
| + expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410)
|
| + / 1024;
|
| + EXPECT_EQ(expected_cwnd - old_cwnd, stats_.cwnd_increase_cubic_mode);
|
| + EXPECT_EQ(0u, stats_.cwnd_increase_reno_mode);
|
| +}
|
| +
|
| +
|
| TEST_F(CubicTest, LossEvents) {
|
| const QuicTime::Delta rtt_min = hundred_ms_;
|
| uint32 current_cwnd = 422;
|
| @@ -99,13 +147,18 @@ TEST_F(CubicTest, BelowOrigin) {
|
| current_cwnd = expected_cwnd;
|
| // First update after loss to initialize the epoch.
|
| current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| + uint32 old_cwnd = current_cwnd;
|
| // Cubic phase.
|
| + stats_.cwnd_increase_cubic_mode = 0;
|
| + stats_.cwnd_increase_reno_mode = 0;
|
| for (int i = 0; i < 40 ; ++i) {
|
| clock_.AdvanceTime(hundred_ms_);
|
| current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
|
| }
|
| expected_cwnd = 422;
|
| EXPECT_EQ(expected_cwnd, current_cwnd);
|
| + EXPECT_EQ(expected_cwnd - old_cwnd, stats_.cwnd_increase_cubic_mode);
|
| + EXPECT_EQ(0u, stats_.cwnd_increase_reno_mode);
|
| }
|
|
|
| } // namespace test
|
|
|