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

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

Issue 1979763002: Landing Recent QUIC changes until Sun May 8 00:39:29 2016 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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) 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/cubic.h" 5 #include "net/quic/congestion_control/cubic.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "net/quic/quic_connection_stats.h"
9 #include "net/quic/test_tools/mock_clock.h" 8 #include "net/quic/test_tools/mock_clock.h"
10 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
11 10
12 namespace net { 11 namespace net {
13 namespace test { 12 namespace test {
14 13
15 const float kBeta = 0.7f; // Default Cubic backoff factor. 14 const float kBeta = 0.7f; // Default Cubic backoff factor.
16 const uint32_t kNumConnections = 2; 15 const uint32_t kNumConnections = 2;
17 const float kNConnectionBeta = (kNumConnections - 1 + kBeta) / kNumConnections; 16 const float kNConnectionBeta = (kNumConnections - 1 + kBeta) / kNumConnections;
18 const float kNConnectionAlpha = 3 * kNumConnections * kNumConnections * 17 const float kNConnectionAlpha = 3 * kNumConnections * kNumConnections *
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min); 62 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
64 } 63 }
65 // Total time elapsed so far; add min_rtt (0.1s) here as well. 64 // Total time elapsed so far; add min_rtt (0.1s) here as well.
66 float elapsed_time_s = 10.0f + 0.1f; 65 float elapsed_time_s = 10.0f + 0.1f;
67 // |expected_cwnd| is initial value of cwnd + K * t^3, where K = 0.4. 66 // |expected_cwnd| is initial value of cwnd + K * t^3, where K = 0.4.
68 expected_cwnd = 67 expected_cwnd =
69 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410) / 1024; 68 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410) / 1024;
70 EXPECT_EQ(expected_cwnd, current_cwnd); 69 EXPECT_EQ(expected_cwnd, current_cwnd);
71 } 70 }
72 71
73 TEST_F(CubicTest, CwndIncreaseStatsDuringConvexRegion) {
74 const QuicTime::Delta rtt_min = hundred_ms_;
75 QuicPacketCount current_cwnd = 10;
76 QuicPacketCount expected_cwnd = current_cwnd + 1;
77 // Initialize controller state.
78 clock_.AdvanceTime(one_ms_);
79 expected_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
80 current_cwnd = expected_cwnd;
81 // Testing Reno mode increase.
82 for (int i = 0; i < 48; ++i) {
83 for (QuicPacketCount n = 1; n < current_cwnd / kNConnectionAlpha; ++n) {
84 // Call once per ACK, causing cwnd growth in Reno mode.
85 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
86 }
87 // Advance current time so that cwnd update is allowed to happen by Cubic.
88 clock_.AdvanceTime(hundred_ms_);
89 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
90 expected_cwnd++;
91 }
92
93 // Testing Cubic mode increase.
94 for (int i = 0; i < 52; ++i) {
95 for (QuicPacketCount n = 1; n < current_cwnd; ++n) {
96 // Call once per ACK.
97 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
98 }
99 clock_.AdvanceTime(hundred_ms_);
100 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
101 }
102 }
103
104 TEST_F(CubicTest, LossEvents) { 72 TEST_F(CubicTest, LossEvents) {
105 const QuicTime::Delta rtt_min = hundred_ms_; 73 const QuicTime::Delta rtt_min = hundred_ms_;
106 QuicPacketCount current_cwnd = 422; 74 QuicPacketCount current_cwnd = 422;
107 QuicPacketCount expected_cwnd = current_cwnd + 1; 75 QuicPacketCount expected_cwnd = current_cwnd + 1;
108 // Initialize the state. 76 // Initialize the state.
109 clock_.AdvanceTime(one_ms_); 77 clock_.AdvanceTime(one_ms_);
110 EXPECT_EQ(expected_cwnd, 78 EXPECT_EQ(expected_cwnd,
111 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min)); 79 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
112 expected_cwnd = static_cast<QuicPacketCount>(current_cwnd * kNConnectionBeta); 80 expected_cwnd = static_cast<QuicPacketCount>(current_cwnd * kNConnectionBeta);
113 EXPECT_EQ(expected_cwnd, 81 EXPECT_EQ(expected_cwnd,
(...skipping 22 matching lines...) Expand all
136 for (int i = 0; i < 40; ++i) { 104 for (int i = 0; i < 40; ++i) {
137 clock_.AdvanceTime(hundred_ms_); 105 clock_.AdvanceTime(hundred_ms_);
138 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min); 106 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
139 } 107 }
140 expected_cwnd = 422; 108 expected_cwnd = 422;
141 EXPECT_EQ(expected_cwnd, current_cwnd); 109 EXPECT_EQ(expected_cwnd, current_cwnd);
142 } 110 }
143 111
144 } // namespace test 112 } // namespace test
145 } // namespace net 113 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/cubic_bytes_test.cc ('k') | net/quic/quic_chromium_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698