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

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

Issue 242593002: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Build fix. Use uint32 instead of int Created 6 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 | 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/logging.h" 5 #include "base/logging.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "net/quic/congestion_control/hybrid_slow_start.h" 7 #include "net/quic/congestion_control/hybrid_slow_start.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
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // At a typical RTT 60 ms, assuming that the inter arrival is 1 ms, 54 // At a typical RTT 60 ms, assuming that the inter arrival is 1 ms,
55 // we expect to be able to send a burst of 30 packet before we trigger the 55 // we expect to be able to send a burst of 30 packet before we trigger the
56 // ack train detection. 56 // ack train detection.
57 const int kMaxLoopCount = 5; 57 const int kMaxLoopCount = 5;
58 QuicPacketSequenceNumber sequence_number = 2; 58 QuicPacketSequenceNumber sequence_number = 2;
59 QuicPacketSequenceNumber end_sequence_number = 2; 59 QuicPacketSequenceNumber end_sequence_number = 2;
60 for (int burst = 0; burst < kMaxLoopCount; ++burst) { 60 for (int burst = 0; burst < kMaxLoopCount; ++burst) {
61 slowStart_->Reset(end_sequence_number); 61 slowStart_->Reset(end_sequence_number);
62 do { 62 do {
63 clock_.AdvanceTime(one_ms_); 63 clock_.AdvanceTime(one_ms_);
64 slowStart_->Update(rtt_, rtt_); 64 EXPECT_FALSE(slowStart_->UpdateAndMaybeExit(rtt_, rtt_));
65 EXPECT_FALSE(slowStart_->Exit());
66 } while (!slowStart_->IsEndOfRound(sequence_number++)); 65 } while (!slowStart_->IsEndOfRound(sequence_number++));
67 end_sequence_number *= 2; // Exponential growth. 66 end_sequence_number *= 2; // Exponential growth.
68 } 67 }
69 slowStart_->Reset(end_sequence_number); 68 slowStart_->Reset(end_sequence_number);
70 69
71 for (int n = 0; n < 29 && !slowStart_->IsEndOfRound(sequence_number++); ++n) { 70 for (int n = 0; n < 29 && !slowStart_->IsEndOfRound(sequence_number++); ++n) {
72 clock_.AdvanceTime(one_ms_); 71 clock_.AdvanceTime(one_ms_);
73 slowStart_->Update(rtt_, rtt_); 72 EXPECT_FALSE(slowStart_->UpdateAndMaybeExit(rtt_, rtt_));
74 EXPECT_FALSE(slowStart_->Exit());
75 } 73 }
76 clock_.AdvanceTime(one_ms_); 74 clock_.AdvanceTime(one_ms_);
77 slowStart_->Update(rtt_, rtt_); 75 EXPECT_TRUE(slowStart_->UpdateAndMaybeExit(rtt_, rtt_));
78 EXPECT_TRUE(slowStart_->Exit());
79 } 76 }
80 77
81 TEST_F(HybridSlowStartTest, Delay) { 78 TEST_F(HybridSlowStartTest, Delay) {
82 // We expect to detect the increase at +1/16 of the RTT; hence at a typical 79 // We expect to detect the increase at +1/16 of the RTT; hence at a typical
83 // RTT of 60ms the detection will happen at 63.75 ms. 80 // RTT of 60ms the detection will happen at 63.75 ms.
84 const int kHybridStartMinSamples = 8; // Number of acks required to trigger. 81 const int kHybridStartMinSamples = 8; // Number of acks required to trigger.
85 82
86 QuicPacketSequenceNumber end_sequence_number = 1; 83 QuicPacketSequenceNumber end_sequence_number = 1;
87 slowStart_->Reset(end_sequence_number++); 84 slowStart_->Reset(end_sequence_number++);
88 85
89 // Will not trigger since our lowest RTT in our burst is the same as the long 86 // Will not trigger since our lowest RTT in our burst is the same as the long
90 // term RTT provided. 87 // term RTT provided.
91 for (int n = 0; n < kHybridStartMinSamples; ++n) { 88 for (int n = 0; n < kHybridStartMinSamples; ++n) {
92 slowStart_->Update(rtt_.Add(QuicTime::Delta::FromMilliseconds(n)), rtt_); 89 EXPECT_FALSE(slowStart_->UpdateAndMaybeExit(
93 EXPECT_FALSE(slowStart_->Exit()); 90 rtt_.Add(QuicTime::Delta::FromMilliseconds(n)), rtt_));
94 } 91 }
95 slowStart_->Reset(end_sequence_number++); 92 slowStart_->Reset(end_sequence_number++);
96 for (int n = 1; n < kHybridStartMinSamples; ++n) { 93 for (int n = 1; n < kHybridStartMinSamples; ++n) {
97 slowStart_->Update(rtt_.Add(QuicTime::Delta::FromMilliseconds(n + 4)), 94 EXPECT_FALSE(slowStart_->UpdateAndMaybeExit(rtt_.Add(
98 rtt_); 95 QuicTime::Delta::FromMilliseconds(n + 4)), rtt_));
99 EXPECT_FALSE(slowStart_->Exit());
100 } 96 }
101 // Expect to trigger since all packets in this burst was above the long term 97 // Expect to trigger since all packets in this burst was above the long term
102 // RTT provided. 98 // RTT provided.
103 slowStart_->Update(rtt_.Add(QuicTime::Delta::FromMilliseconds(4)), rtt_); 99 EXPECT_TRUE(slowStart_->UpdateAndMaybeExit(rtt_.Add(
104 EXPECT_TRUE(slowStart_->Exit()); 100 QuicTime::Delta::FromMilliseconds(4)), rtt_));
105 } 101 }
106 102
107 } // namespace test 103 } // namespace test
108 } // namespace net 104 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/hybrid_slow_start.cc ('k') | net/quic/congestion_control/tcp_cubic_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698