| OLD | NEW |
| 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 // 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } else { | 420 } else { |
| 421 effective_delay += current_jitter; | 421 effective_delay += current_jitter; |
| 422 } | 422 } |
| 423 | 423 |
| 424 if (throttler_entry_->ImplGetTimeNow() - time_of_last_attempt_ > | 424 if (throttler_entry_->ImplGetTimeNow() - time_of_last_attempt_ > |
| 425 effective_delay) { | 425 effective_delay) { |
| 426 if (!throttler_entry_->ShouldRejectRequest( | 426 if (!throttler_entry_->ShouldRejectRequest( |
| 427 server_->mock_request(), | 427 server_->mock_request(), |
| 428 server_->context().network_delegate())) { | 428 server_->context().network_delegate())) { |
| 429 int status_code = server_->HandleRequest(); | 429 int status_code = server_->HandleRequest(); |
| 430 MockURLRequestThrottlerHeaderAdapter response_headers(status_code); | 430 throttler_entry_->UpdateWithResponse(status_code); |
| 431 throttler_entry_->UpdateWithResponse(std::string(), &response_headers); | |
| 432 | 431 |
| 433 if (status_code == 200) { | 432 if (status_code == 200) { |
| 434 if (results_) | 433 if (results_) |
| 435 results_->AddSuccess(); | 434 results_->AddSuccess(); |
| 436 | 435 |
| 437 if (last_attempt_was_failure_) { | 436 if (last_attempt_was_failure_) { |
| 438 last_downtime_duration_ = | 437 last_downtime_duration_ = |
| 439 throttler_entry_->ImplGetTimeNow() - time_of_last_success_; | 438 throttler_entry_->ImplGetTimeNow() - time_of_last_success_; |
| 440 } | 439 } |
| 441 | 440 |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 trials[i].PrintTrialDescription(); | 742 trials[i].PrintTrialDescription(); |
| 744 trials[i].stats.ReportTrialResult(increase_ratio); | 743 trials[i].stats.ReportTrialResult(increase_ratio); |
| 745 } | 744 } |
| 746 | 745 |
| 747 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); | 746 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); |
| 748 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); | 747 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); |
| 749 } | 748 } |
| 750 | 749 |
| 751 } // namespace | 750 } // namespace |
| 752 } // namespace net | 751 } // namespace net |
| OLD | NEW |