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

Side by Side Diff: net/quic/congestion_control/cubic_bytes_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
« no previous file with comments | « net/net.gypi ('k') | net/quic/congestion_control/cubic_test.cc » ('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) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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_bytes.h" 5 #include "net/quic/congestion_control/cubic_bytes.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min); 67 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
69 } 68 }
70 // Total time elapsed so far; add min_rtt (0.1s) here as well. 69 // Total time elapsed so far; add min_rtt (0.1s) here as well.
71 float elapsed_time_s = 10.0f + 0.1f; 70 float elapsed_time_s = 10.0f + 0.1f;
72 // |expected_cwnd| is initial value of cwnd + K * t^3, where K = 0.4. 71 // |expected_cwnd| is initial value of cwnd + K * t^3, where K = 0.4.
73 expected_cwnd = 72 expected_cwnd =
74 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410) / 1024; 73 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410) / 1024;
75 EXPECT_EQ(expected_cwnd, current_cwnd / kDefaultTCPMSS); 74 EXPECT_EQ(expected_cwnd, current_cwnd / kDefaultTCPMSS);
76 } 75 }
77 76
78 TEST_F(CubicBytesTest, CwndIncreaseStatsDuringConvexRegion) {
79 const QuicTime::Delta rtt_min = hundred_ms_;
80 QuicByteCount current_cwnd = 10 * kDefaultTCPMSS;
81 QuicByteCount expected_cwnd = current_cwnd + kDefaultTCPMSS;
82 // Initialize controller state.
83 clock_.AdvanceTime(one_ms_);
84 expected_cwnd =
85 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
86 current_cwnd = expected_cwnd;
87 // Testing Reno mode increase.
88 for (int i = 0; i < 48; ++i) {
89 for (QuicPacketCount n = 1;
90 n < current_cwnd / kDefaultTCPMSS / kNConnectionAlpha; ++n) {
91 // Call once per ACK, causing cwnd growth in Reno mode.
92 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
93 }
94 // Advance current time so that cwnd update is allowed to happen by Cubic.
95 clock_.AdvanceTime(hundred_ms_);
96 current_cwnd =
97 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
98 expected_cwnd += kDefaultTCPMSS;
99 }
100
101 // Testing Cubic mode increase.
102 for (int i = 0; i < 52; ++i) {
103 for (QuicPacketCount n = 1; n < current_cwnd / kDefaultTCPMSS; ++n) {
104 // Call once per ACK.
105 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
106 }
107 clock_.AdvanceTime(hundred_ms_);
108 current_cwnd =
109 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
110 }
111 }
112
113 TEST_F(CubicBytesTest, LossEvents) { 77 TEST_F(CubicBytesTest, LossEvents) {
114 const QuicTime::Delta rtt_min = hundred_ms_; 78 const QuicTime::Delta rtt_min = hundred_ms_;
115 QuicByteCount current_cwnd = 422 * kDefaultTCPMSS; 79 QuicByteCount current_cwnd = 422 * kDefaultTCPMSS;
116 QuicPacketCount expected_cwnd = current_cwnd + kDefaultTCPMSS; 80 QuicPacketCount expected_cwnd = current_cwnd + kDefaultTCPMSS;
117 // Initialize the state. 81 // Initialize the state.
118 clock_.AdvanceTime(one_ms_); 82 clock_.AdvanceTime(one_ms_);
119 EXPECT_EQ(expected_cwnd, cubic_.CongestionWindowAfterAck( 83 EXPECT_EQ(expected_cwnd, cubic_.CongestionWindowAfterAck(
120 kDefaultTCPMSS, current_cwnd, rtt_min)); 84 kDefaultTCPMSS, current_cwnd, rtt_min));
121 expected_cwnd = static_cast<QuicPacketCount>(current_cwnd * kNConnectionBeta); 85 expected_cwnd = static_cast<QuicPacketCount>(current_cwnd * kNConnectionBeta);
122 EXPECT_EQ(expected_cwnd, 86 EXPECT_EQ(expected_cwnd,
(...skipping 24 matching lines...) Expand all
147 clock_.AdvanceTime(hundred_ms_); 111 clock_.AdvanceTime(hundred_ms_);
148 current_cwnd = 112 current_cwnd =
149 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min); 113 cubic_.CongestionWindowAfterAck(kDefaultTCPMSS, current_cwnd, rtt_min);
150 } 114 }
151 expected_cwnd = 422 * kDefaultTCPMSS; 115 expected_cwnd = 422 * kDefaultTCPMSS;
152 EXPECT_EQ(expected_cwnd, current_cwnd); 116 EXPECT_EQ(expected_cwnd, current_cwnd);
153 } 117 }
154 118
155 } // namespace test 119 } // namespace test
156 } // namespace net 120 } // namespace net
OLDNEW
« no previous file with comments | « net/net.gypi ('k') | net/quic/congestion_control/cubic_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698