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

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

Issue 136453013: Fixes QUIC's Cubic sender to use correct alpha when in Reno mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "net/quic/congestion_control/cubic.h" 7 #include "net/quic/congestion_control/cubic.h"
8 #include "net/quic/test_tools/mock_clock.h" 8 #include "net/quic/test_tools/mock_clock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace net { 11 namespace net {
12 namespace test { 12 namespace test {
13 13
14 const float kBeta = 0.7; // Default Cubic backoff factor.
15 const uint32 kNumConnections = 2;
16 const float kNConnectionBeta = (kNumConnections - 1 + kBeta) / kNumConnections;
17 const float kNConnectionAlpha = 3 * kNumConnections * kNumConnections *
18 (1 - kNConnectionBeta) / (1 + kNConnectionBeta);
19
14 class CubicTest : public ::testing::Test { 20 class CubicTest : public ::testing::Test {
15 protected: 21 protected:
16 CubicTest() 22 CubicTest()
17 : one_ms_(QuicTime::Delta::FromMilliseconds(1)), 23 : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
18 hundred_ms_(QuicTime::Delta::FromMilliseconds(100)), 24 hundred_ms_(QuicTime::Delta::FromMilliseconds(100)),
19 cubic_(&clock_) { 25 cubic_(&clock_) {
20 } 26 }
21 const QuicTime::Delta one_ms_; 27 const QuicTime::Delta one_ms_;
22 const QuicTime::Delta hundred_ms_; 28 const QuicTime::Delta hundred_ms_;
23 MockClock clock_; 29 MockClock clock_;
24 Cubic cubic_; 30 Cubic cubic_;
25 }; 31 };
26 32
27 TEST_F(CubicTest, AboveOrgin) { 33 TEST_F(CubicTest, AboveOrigin) {
28 // Convex growth. 34 // Convex growth.
29 const QuicTime::Delta rtt_min = hundred_ms_; 35 const QuicTime::Delta rtt_min = hundred_ms_;
30 uint32 current_cwnd = 10; 36 uint32 current_cwnd = 10;
31 uint32 expected_cwnd = current_cwnd + 1; 37 uint32 expected_cwnd = current_cwnd + 1;
32 // Initialize the state. 38 // Initialize the state.
33 clock_.AdvanceTime(one_ms_); 39 clock_.AdvanceTime(one_ms_);
34 EXPECT_EQ(expected_cwnd, 40 EXPECT_EQ(expected_cwnd,
35 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min)); 41 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
36 current_cwnd = expected_cwnd; 42 current_cwnd = expected_cwnd;
37 // Normal TCP phase. 43 // Normal TCP phase.
38 for (int i = 0; i < 48; ++i) { 44 for (int i = 0; i < 48; ++i) {
39 for (uint32 n = 1; n < current_cwnd; ++n) { 45 for (uint32 n = 1; n < current_cwnd / kNConnectionAlpha; ++n) {
40 // Call once per ACK. 46 // Call once per ACK.
41 EXPECT_EQ(current_cwnd, 47 EXPECT_NEAR(current_cwnd,
42 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min)); 48 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min), 1);
43 } 49 }
44 clock_.AdvanceTime(hundred_ms_); 50 clock_.AdvanceTime(hundred_ms_);
45 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min); 51 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
46 EXPECT_EQ(expected_cwnd, current_cwnd); 52 EXPECT_NEAR(expected_cwnd, current_cwnd, 1);
47 expected_cwnd++; 53 expected_cwnd++;
48 } 54 }
49 // Cubic phase. 55 // Cubic phase.
50 for (int j = 48; j < 100; ++j) { 56 for (int j = 48; j < 100; ++j) {
51 for (uint32 n = 1; n < current_cwnd; ++n) { 57 for (uint32 n = 1; n < current_cwnd; ++n) {
52 // Call once per ACK. 58 // Call once per ACK.
53 EXPECT_EQ(current_cwnd, 59 EXPECT_EQ(current_cwnd,
54 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min)); 60 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
55 } 61 }
56 clock_.AdvanceTime(hundred_ms_); 62 clock_.AdvanceTime(hundred_ms_);
57 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min); 63 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
58 } 64 }
59 float elapsed_time_s = 10.0f + 0.1f; // We need to add the RTT here. 65 float elapsed_time_s = 10.0f + 0.1f; // We need to add the RTT here.
60 expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410) 66 expected_cwnd = 11 + (elapsed_time_s * elapsed_time_s * elapsed_time_s * 410)
61 / 1024; 67 / 1024;
62 EXPECT_EQ(expected_cwnd, current_cwnd); 68 EXPECT_EQ(expected_cwnd, current_cwnd);
63 } 69 }
64 70
65 TEST_F(CubicTest, LossEvents) { 71 TEST_F(CubicTest, LossEvents) {
66 const QuicTime::Delta rtt_min = hundred_ms_; 72 const QuicTime::Delta rtt_min = hundred_ms_;
67 uint32 current_cwnd = 422; 73 uint32 current_cwnd = 422;
68 uint32 expected_cwnd = current_cwnd + 1; 74 uint32 expected_cwnd = current_cwnd + 1;
69 // Initialize the state. 75 // Initialize the state.
70 clock_.AdvanceTime(one_ms_); 76 clock_.AdvanceTime(one_ms_);
71 EXPECT_EQ(expected_cwnd, 77 EXPECT_EQ(expected_cwnd,
72 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min)); 78 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
73 expected_cwnd = current_cwnd * 939 / 1024; 79 expected_cwnd = static_cast<int>(current_cwnd * kNConnectionBeta);
74 EXPECT_EQ(expected_cwnd, 80 EXPECT_EQ(expected_cwnd,
75 cubic_.CongestionWindowAfterPacketLoss(current_cwnd)); 81 cubic_.CongestionWindowAfterPacketLoss(current_cwnd));
76 expected_cwnd = current_cwnd * 939 / 1024; 82 expected_cwnd = static_cast<int>(current_cwnd * kNConnectionBeta);
77 EXPECT_EQ(expected_cwnd, 83 EXPECT_EQ(expected_cwnd,
78 cubic_.CongestionWindowAfterPacketLoss(current_cwnd)); 84 cubic_.CongestionWindowAfterPacketLoss(current_cwnd));
79 } 85 }
80 86
81 TEST_F(CubicTest, BelowOrgin) { 87 TEST_F(CubicTest, BelowOrigin) {
82 // Concave growth. 88 // Concave growth.
83 const QuicTime::Delta rtt_min = hundred_ms_; 89 const QuicTime::Delta rtt_min = hundred_ms_;
84 uint32 current_cwnd = 422; 90 uint32 current_cwnd = 422;
85 uint32 expected_cwnd = current_cwnd + 1; 91 uint32 expected_cwnd = current_cwnd + 1;
86 // Initialize the state. 92 // Initialize the state.
87 clock_.AdvanceTime(one_ms_); 93 clock_.AdvanceTime(one_ms_);
88 EXPECT_EQ(expected_cwnd, 94 EXPECT_EQ(expected_cwnd,
89 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min)); 95 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
90 expected_cwnd = current_cwnd * 939 / 1024; 96 expected_cwnd = static_cast<int>(current_cwnd * kNConnectionBeta);
91 EXPECT_EQ(expected_cwnd, 97 EXPECT_EQ(expected_cwnd,
92 cubic_.CongestionWindowAfterPacketLoss(current_cwnd)); 98 cubic_.CongestionWindowAfterPacketLoss(current_cwnd));
93 current_cwnd = expected_cwnd; 99 current_cwnd = expected_cwnd;
94 // First update after epoch. 100 // First update after loss to initialize the epoch.
95 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min); 101 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
96 // Cubic phase. 102 // Cubic phase.
97 for (int i = 0; i < 54; ++i) { 103 for (int i = 0; i < 40 ; ++i) {
98 for (uint32 n = 1; n < current_cwnd; ++n) {
99 // Call once per ACK.
100 EXPECT_EQ(current_cwnd,
101 cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min));
102 }
103 clock_.AdvanceTime(hundred_ms_); 104 clock_.AdvanceTime(hundred_ms_);
104 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min); 105 current_cwnd = cubic_.CongestionWindowAfterAck(current_cwnd, rtt_min);
105 } 106 }
106 expected_cwnd = 440; 107 expected_cwnd = 422;
107 EXPECT_EQ(expected_cwnd, current_cwnd); 108 EXPECT_EQ(expected_cwnd, current_cwnd);
108 } 109 }
109 110
110 } // namespace test 111 } // namespace test
111 } // namespace net 112 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/cubic.cc ('k') | net/quic/congestion_control/tcp_cubic_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698