OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // The tests in this file attempt to verify the following through simulation: | 5 // The tests in this file attempt to verify the following through simulation: |
6 // a) That a server experiencing overload will actually benefit from the | 6 // a) That a server experiencing overload will actually benefit from the |
7 // anti-DDoS throttling logic, i.e. that its traffic spike will subside | 7 // anti-DDoS throttling logic, i.e. that its traffic spike will subside |
8 // and be distributed over a longer period of time; | 8 // and be distributed over a longer period of time; |
9 // b) That "well-behaved" clients of a server under DDoS attack actually | 9 // b) That "well-behaved" clients of a server under DDoS attack actually |
10 // benefit from the anti-DDoS throttling logic; and | 10 // benefit from the anti-DDoS throttling logic; and |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 TimeDelta current_jitter = TimeDelta::FromMilliseconds( | 418 TimeDelta current_jitter = TimeDelta::FromMilliseconds( |
419 request_jitter_.InMilliseconds() * base::RandDouble()); | 419 request_jitter_.InMilliseconds() * base::RandDouble()); |
420 if (base::RandInt(0, 1)) { | 420 if (base::RandInt(0, 1)) { |
421 effective_delay -= current_jitter; | 421 effective_delay -= current_jitter; |
422 } else { | 422 } else { |
423 effective_delay += current_jitter; | 423 effective_delay += current_jitter; |
424 } | 424 } |
425 | 425 |
426 if (throttler_entry_->fake_now() - time_of_last_attempt_ > | 426 if (throttler_entry_->fake_now() - time_of_last_attempt_ > |
427 effective_delay) { | 427 effective_delay) { |
428 if (!throttler_entry_->IsDuringExponentialBackoff()) { | 428 if (!throttler_entry_->ShouldRejectRequest(0)) { |
429 int status_code = server_->HandleRequest(); | 429 int status_code = server_->HandleRequest(); |
430 MockURLRequestThrottlerHeaderAdapter response_headers(status_code); | 430 MockURLRequestThrottlerHeaderAdapter response_headers(status_code); |
431 throttler_entry_->UpdateWithResponse("", &response_headers); | 431 throttler_entry_->UpdateWithResponse("", &response_headers); |
432 | 432 |
433 if (status_code == 200) { | 433 if (status_code == 200) { |
434 if (results_) | 434 if (results_) |
435 results_->AddSuccess(); | 435 results_->AddSuccess(); |
436 | 436 |
437 if (last_attempt_was_failure_) { | 437 if (last_attempt_was_failure_) { |
438 last_downtime_duration_ = | 438 last_downtime_duration_ = |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 trials[i].PrintTrialDescription(); | 743 trials[i].PrintTrialDescription(); |
744 trials[i].stats.ReportTrialResult(increase_ratio); | 744 trials[i].stats.ReportTrialResult(increase_ratio); |
745 } | 745 } |
746 | 746 |
747 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); | 747 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); |
748 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); | 748 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); |
749 } | 749 } |
750 | 750 |
751 } // namespace | 751 } // namespace |
752 } // namespace net | 752 } // namespace net |
OLD | NEW |