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