OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/rtt_stats.h" | 5 #include "net/quic/congestion_control/rtt_stats.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 // Update once with a 20ms RTT. | 166 // Update once with a 20ms RTT. |
167 QuicTime::Delta doubled_rtt = initial_rtt.Multiply(2); | 167 QuicTime::Delta doubled_rtt = initial_rtt.Multiply(2); |
168 rtt_stats_.UpdateRtt(doubled_rtt, QuicTime::Delta::Zero(), QuicTime::Zero()); | 168 rtt_stats_.UpdateRtt(doubled_rtt, QuicTime::Delta::Zero(), QuicTime::Zero()); |
169 EXPECT_EQ(initial_rtt.Multiply(1.125), rtt_stats_.SmoothedRtt()); | 169 EXPECT_EQ(initial_rtt.Multiply(1.125), rtt_stats_.SmoothedRtt()); |
170 | 170 |
171 // Expire the smoothed metrics, increasing smoothed rtt and mean deviation. | 171 // Expire the smoothed metrics, increasing smoothed rtt and mean deviation. |
172 rtt_stats_.ExpireSmoothedMetrics(); | 172 rtt_stats_.ExpireSmoothedMetrics(); |
173 EXPECT_EQ(doubled_rtt, rtt_stats_.SmoothedRtt()); | 173 EXPECT_EQ(doubled_rtt, rtt_stats_.SmoothedRtt()); |
174 EXPECT_EQ(initial_rtt.Multiply(0.875), rtt_stats_.mean_deviation()); | 174 EXPECT_EQ(initial_rtt.Multiply(0.875), rtt_stats_.mean_deviation()); |
| 175 |
| 176 // Now go back down to 5ms and expire the smoothed metrics, and ensure the |
| 177 // mean deviation increases to 15ms. |
| 178 QuicTime::Delta half_rtt = initial_rtt.Multiply(0.5); |
| 179 rtt_stats_.UpdateRtt(half_rtt, QuicTime::Delta::Zero(), QuicTime::Zero()); |
| 180 EXPECT_GT(doubled_rtt, rtt_stats_.SmoothedRtt()); |
| 181 EXPECT_LT(initial_rtt, rtt_stats_.mean_deviation()); |
175 } | 182 } |
176 | 183 |
177 } // namespace test | 184 } // namespace test |
178 } // namespace net | 185 } // namespace net |
OLD | NEW |