| 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_flags.h" |
| 9 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
| 10 #include "net/quic/test_tools/mock_clock.h" | 11 #include "net/quic/test_tools/mock_clock.h" |
| 11 #include "net/quic/test_tools/quic_test_utils.h" | 12 #include "net/quic/test_tools/quic_test_utils.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 using testing::Return; | 15 using testing::Return; |
| 15 using testing::StrictMock; | 16 using testing::StrictMock; |
| 16 using testing::_; | 17 using testing::_; |
| 17 | 18 |
| 18 namespace net { | 19 namespace net { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); | 193 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); |
| 193 CheckPacketIsSentImmediately(); | 194 CheckPacketIsSentImmediately(); |
| 194 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 195 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 195 } | 196 } |
| 196 | 197 |
| 197 TEST_F(PacingSenderTest, InitialBurst) { | 198 TEST_F(PacingSenderTest, InitialBurst) { |
| 198 // Configure pacing rate of 1 packet per 1 ms. | 199 // Configure pacing rate of 1 packet per 1 ms. |
| 199 InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( | 200 InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( |
| 200 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); | 201 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); |
| 201 | 202 |
| 203 if (FLAGS_quic_limit_pacing_burst) { |
| 204 EXPECT_CALL(*mock_sender_, GetCongestionWindow()) |
| 205 .WillOnce(Return(10 * kDefaultTCPMSS)); |
| 206 } |
| 202 // Update the RTT and verify that the first 10 packets aren't paced. | 207 // Update the RTT and verify that the first 10 packets aren't paced. |
| 203 UpdateRtt(); | 208 UpdateRtt(); |
| 204 | 209 |
| 205 // Send 10 packets, and verify that they are not paced. | 210 // Send 10 packets, and verify that they are not paced. |
| 206 for (int i = 0 ; i < kInitialBurstPackets; ++i) { | 211 for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
| 207 CheckPacketIsSentImmediately(); | 212 CheckPacketIsSentImmediately(); |
| 208 } | 213 } |
| 209 | 214 |
| 210 // The first packet was a "make up", then we sent two packets "into the | 215 // The first packet was a "make up", then we sent two packets "into the |
| 211 // future", so the delay should be 2ms. | 216 // future", so the delay should be 2ms. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 228 CheckPacketIsSentImmediately(); | 233 CheckPacketIsSentImmediately(); |
| 229 CheckPacketIsSentImmediately(); | 234 CheckPacketIsSentImmediately(); |
| 230 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 235 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 231 } | 236 } |
| 232 | 237 |
| 233 TEST_F(PacingSenderTest, InitialBurstNoRttMeasurement) { | 238 TEST_F(PacingSenderTest, InitialBurstNoRttMeasurement) { |
| 234 // Configure pacing rate of 1 packet per 1 ms. | 239 // Configure pacing rate of 1 packet per 1 ms. |
| 235 InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( | 240 InitPacingRate(10, QuicBandwidth::FromBytesAndTimeDelta( |
| 236 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); | 241 kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); |
| 237 | 242 |
| 243 if (FLAGS_quic_limit_pacing_burst) { |
| 244 EXPECT_CALL(*mock_sender_, GetCongestionWindow()) |
| 245 .WillOnce(Return(10 * kDefaultTCPMSS)); |
| 246 } |
| 238 // Send 10 packets, and verify that they are not paced. | 247 // Send 10 packets, and verify that they are not paced. |
| 239 for (int i = 0 ; i < kInitialBurstPackets; ++i) { | 248 for (int i = 0 ; i < kInitialBurstPackets; ++i) { |
| 240 CheckPacketIsSentImmediately(); | 249 CheckPacketIsSentImmediately(); |
| 241 } | 250 } |
| 242 | 251 |
| 243 // The first packet was a "make up", then we sent two packets "into the | 252 // The first packet was a "make up", then we sent two packets "into the |
| 244 // future", so the delay should be 2ms. | 253 // future", so the delay should be 2ms. |
| 245 CheckPacketIsSentImmediately(); | 254 CheckPacketIsSentImmediately(); |
| 246 CheckPacketIsSentImmediately(); | 255 CheckPacketIsSentImmediately(); |
| 247 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 256 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 265 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); | 274 CheckPacketIsDelayed(QuicTime::Delta::FromMilliseconds(2)); |
| 266 } | 275 } |
| 267 | 276 |
| 268 TEST_F(PacingSenderTest, FastSending) { | 277 TEST_F(PacingSenderTest, FastSending) { |
| 269 // Ensure the pacing sender paces, even when the inter-packet spacing is less | 278 // Ensure the pacing sender paces, even when the inter-packet spacing is less |
| 270 // than the pacing granularity. | 279 // than the pacing granularity. |
| 271 InitPacingRate(10, | 280 InitPacingRate(10, |
| 272 QuicBandwidth::FromBytesAndTimeDelta( | 281 QuicBandwidth::FromBytesAndTimeDelta( |
| 273 2 * kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); | 282 2 * kMaxPacketSize, QuicTime::Delta::FromMilliseconds(1))); |
| 274 | 283 |
| 284 if (FLAGS_quic_limit_pacing_burst) { |
| 285 EXPECT_CALL(*mock_sender_, GetCongestionWindow()) |
| 286 .WillOnce(Return(10 * kDefaultTCPMSS)); |
| 287 } |
| 275 // Update the RTT and verify that the first 10 packets aren't paced. | 288 // Update the RTT and verify that the first 10 packets aren't paced. |
| 276 UpdateRtt(); | 289 UpdateRtt(); |
| 277 | 290 |
| 278 // Send 10 packets, and verify that they are not paced. | 291 // Send 10 packets, and verify that they are not paced. |
| 279 for (int i = 0; i < kInitialBurstPackets; ++i) { | 292 for (int i = 0; i < kInitialBurstPackets; ++i) { |
| 280 CheckPacketIsSentImmediately(); | 293 CheckPacketIsSentImmediately(); |
| 281 } | 294 } |
| 282 | 295 |
| 283 // The first packet was a "make up", then we sent two packets "into the | 296 // The first packet was a "make up", then we sent two packets "into the |
| 284 // future", since it's 2 packets/ms, so the delay should be 1.5ms. | 297 // future", since it's 2 packets/ms, so the delay should be 1.5ms. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 300 // The first packet was a "make up", then we sent two packets "into the | 313 // The first packet was a "make up", then we sent two packets "into the |
| 301 // future", so the delay should be 1.5ms. | 314 // future", so the delay should be 1.5ms. |
| 302 CheckPacketIsSentImmediately(); | 315 CheckPacketIsSentImmediately(); |
| 303 CheckPacketIsSentImmediately(); | 316 CheckPacketIsSentImmediately(); |
| 304 CheckPacketIsSentImmediately(); | 317 CheckPacketIsSentImmediately(); |
| 305 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(1500)); | 318 CheckPacketIsDelayed(QuicTime::Delta::FromMicroseconds(1500)); |
| 306 } | 319 } |
| 307 | 320 |
| 308 } // namespace test | 321 } // namespace test |
| 309 } // namespace net | 322 } // namespace net |
| OLD | NEW |