| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // after all |Requester| objects. | 120 // after all |Requester| objects. |
| 121 class Server : public DiscreteTimeSimulation::Actor { | 121 class Server : public DiscreteTimeSimulation::Actor { |
| 122 public: | 122 public: |
| 123 Server(int max_queries_per_tick, double request_drop_ratio) | 123 Server(int max_queries_per_tick, double request_drop_ratio) |
| 124 : max_queries_per_tick_(max_queries_per_tick), | 124 : max_queries_per_tick_(max_queries_per_tick), |
| 125 request_drop_ratio_(request_drop_ratio), | 125 request_drop_ratio_(request_drop_ratio), |
| 126 num_overloaded_ticks_remaining_(0), | 126 num_overloaded_ticks_remaining_(0), |
| 127 num_current_tick_queries_(0), | 127 num_current_tick_queries_(0), |
| 128 num_overloaded_ticks_(0), | 128 num_overloaded_ticks_(0), |
| 129 max_experienced_queries_per_tick_(0), | 129 max_experienced_queries_per_tick_(0), |
| 130 mock_request_(context_.CreateRequest( | 130 mock_request_(context_.CreateRequest(GURL(), DEFAULT_PRIORITY, NULL)) {} |
| 131 GURL(), DEFAULT_PRIORITY, NULL, NULL)) {} | |
| 132 | 131 |
| 133 void SetDowntime(const TimeTicks& start_time, const TimeDelta& duration) { | 132 void SetDowntime(const TimeTicks& start_time, const TimeDelta& duration) { |
| 134 start_downtime_ = start_time; | 133 start_downtime_ = start_time; |
| 135 end_downtime_ = start_time + duration; | 134 end_downtime_ = start_time + duration; |
| 136 } | 135 } |
| 137 | 136 |
| 138 void AdvanceTime(const TimeTicks& absolute_time) override { | 137 void AdvanceTime(const TimeTicks& absolute_time) override { |
| 139 now_ = absolute_time; | 138 now_ = absolute_time; |
| 140 } | 139 } |
| 141 | 140 |
| (...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 trials[i].PrintTrialDescription(); | 748 trials[i].PrintTrialDescription(); |
| 750 trials[i].stats.ReportTrialResult(increase_ratio); | 749 trials[i].stats.ReportTrialResult(increase_ratio); |
| 751 } | 750 } |
| 752 | 751 |
| 753 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); | 752 VerboseOut("Average increase ratio was %.4f\n", average_increase_ratio); |
| 754 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); | 753 VerboseOut("Maximum increase ratio was %.4f\n", max_increase_ratio); |
| 755 } | 754 } |
| 756 | 755 |
| 757 } // namespace | 756 } // namespace |
| 758 } // namespace net | 757 } // namespace net |
| OLD | NEW |