Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/pacing_sender.h" | 5 #include "net/quic/congestion_control/pacing_sender.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
| 10 #include "net/quic/test_tools/mock_clock.h" | 10 #include "net/quic/test_tools/mock_clock.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 187 | 187 |
| 188 // Wake up too early. | 188 // Wake up too early. |
| 189 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 189 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 190 | 190 |
| 191 // Wake up early, but after enough time has passed to permit a send. | 191 // Wake up early, but after enough time has passed to permit a send. |
| 192 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 192 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 193 CheckPacketIsSentImmediately(); | 193 CheckPacketIsSentImmediately(); |
| 194 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 194 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 // TODO(ianswett): Remove this test. | |
|
ramant (doing other things)
2015/02/17 18:52:53
Please don't remove this code. It is shared with t
asanka
2015/02/18 17:17:37
Can you summarize the current state of this test?
ramant (doing other things)
2015/02/23 21:53:07
Checked with Ian. He said this test can be removed
| |
| 198 TEST_F(PacingSenderTest, DISABLED_CongestionAvoidanceSending) { | |
| 199 // Configure pacing rate of 1 packet per 1 ms. | |
| 200 EXPECT_CALL(*mock_sender_, PacingRate()) | |
| 201 .WillRepeatedly(Return(QuicBandwidth::FromBytesAndTimeDelta( | |
| 202 kMaxPacketSize * 1.25, QuicTime::Delta::FromMilliseconds(2)))); | |
| 203 | |
| 204 // Now update the RTT and verify that packets are actually paced. | |
| 205 UpdateRtt(); | |
| 206 | |
| 207 CheckPacketIsSentImmediately(); | |
| 208 CheckPacketIsSentImmediately(); | |
| 209 | |
| 210 // The first packet was a "make up", then we sent two packets "into the | |
| 211 // future", so the delay should be 2200us. | |
| 212 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(2200)); | |
| 213 | |
| 214 // Wake up on time. | |
| 215 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(2200)); | |
| 216 CheckPacketIsSentImmediately(); | |
| 217 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(1600)); | |
| 218 CheckAckIsSentImmediately(); | |
| 219 | |
| 220 // Wake up late. | |
| 221 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(4)); | |
| 222 CheckPacketIsSentImmediately(); | |
| 223 CheckPacketIsSentImmediately(); | |
| 224 CheckPacketIsSentImmediately(); | |
| 225 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(2400)); | |
| 226 | |
| 227 // Wake up really late. | |
| 228 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(8)); | |
| 229 CheckPacketIsSentImmediately(); | |
| 230 CheckPacketIsSentImmediately(); | |
| 231 CheckPacketIsSentImmediately(); | |
| 232 CheckPacketIsSentImmediately(); | |
| 233 CheckPacketIsSentImmediately(); | |
| 234 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(2400)); | |
| 235 | |
| 236 // Wake up really late again, but application pause partway through. | |
| 237 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(8)); | |
| 238 CheckPacketIsSentImmediately(); | |
| 239 CheckPacketIsSentImmediately(); | |
| 240 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(100)); | |
| 241 CheckPacketIsSentImmediately(); | |
| 242 CheckPacketIsSentImmediately(); | |
| 243 CheckPacketIsSentImmediately(); | |
| 244 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(2200)); | |
| 245 | |
| 246 // Wake up too early. | |
| 247 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(2200)); | |
| 248 | |
| 249 // Wake up early, but after enough time has passed to permit a send. | |
| 250 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1200)); | |
| 251 CheckPacketIsSentImmediately(); | |
| 252 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(2600)); | |
| 253 } | |
| 254 | |
| 255 TEST_F(PacingSenderTest, InitialBurst) { | 197 TEST_F(PacingSenderTest, InitialBurst) { |
| 256 // Configure pacing rate of 1 packet per 1 ms. | 198 // Configure pacing rate of 1 packet per 1 ms. |
| 257 InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( | 199 InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( |
| 258 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); | 200 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); |
| 259 | 201 |
| 260 // Update the RTT and verify that the first 10 packets aren't paced. | 202 // Update the RTT and verify that the first 10 packets aren't paced. |
| 261 UpdateRtt(); | 203 UpdateRtt(); |
| 262 | 204 |
| 263 // Send 10 packets, and verify that they are not paced. | 205 // Send 10 packets, and verify that they are not paced. |
| 264 for (int i = 0 ; i < kInitialBurstPackets; ++i) { | 206 for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 // The first packet was a "make up", then we sent two packets "into the | 300 // The first packet was a "make up", then we sent two packets "into the |
| 359 // future", so the delay should be 1.5ms. | 301 // future", so the delay should be 1.5ms. |
| 360 CheckPacketIsSentImmediately(); | 302 CheckPacketIsSentImmediately(); |
| 361 CheckPacketIsSentImmediately(); | 303 CheckPacketIsSentImmediately(); |
| 362 CheckPacketIsSentImmediately(); | 304 CheckPacketIsSentImmediately(); |
| 363 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(1500)); | 305 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(1500)); |
| 364 } | 306 } |
| 365 | 307 |
| 366 } // namespace test | 308 } // namespace test |
| 367 } // namespace net | 309 } // namespace net |
| OLD | NEW |