OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // A test only class to enable simulations of send algorithms. | 5 // A test only class to enable simulations of send algorithms. |
6 | 6 |
7 #ifndef NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 7 #ifndef NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
8 #define NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 8 #define NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/format_macros.h" | 15 #include "base/format_macros.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "net/quic/congestion_control/send_algorithm_interface.h" | 17 #include "net/quic/congestion_control/send_algorithm_interface.h" |
18 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
19 #include "net/quic/quic_time.h" | 19 #include "net/quic/quic_time.h" |
20 #include "net/quic/test_tools/mock_clock.h" | 20 #include "net/quic/test_tools/mock_clock.h" |
21 #include "net/quic/test_tools/quic_test_utils.h" | 21 #include "net/quic/test_tools/quic_test_utils.h" |
22 | 22 |
23 using base::StringPrintf; | 23 using base::StringPrintf; |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 | 26 |
27 class SendAlgorithmSimulator { | 27 class SendAlgorithmSimulator { |
28 public: | 28 public: |
29 struct Sender { | 29 struct Sender { |
30 Sender(SendAlgorithmInterface* send_algorithm, RttStats* rtt_stats); | 30 Sender(SendAlgorithmInterface* send_algorithm, RttStats* rtt_stats); |
31 | 31 |
32 void RecordStats() { | 32 void RecordStats() { |
33 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); | 33 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); |
34 max_cwnd = std::max(max_cwnd, cwnd); | 34 max_cwnd = std::max(max_cwnd, cwnd); |
35 min_cwnd = std::min(min_cwnd, cwnd); | 35 min_cwnd = std::min(min_cwnd, cwnd); |
36 if (last_cwnd > cwnd) { | 36 if (last_cwnd > cwnd) { |
37 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); | 37 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); |
38 } | 38 } |
39 last_cwnd = cwnd; | 39 last_cwnd = cwnd; |
40 } | 40 } |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 QuicBandwidth bandwidth_; | 190 QuicBandwidth bandwidth_; |
191 QuicTime::Delta rtt_; | 191 QuicTime::Delta rtt_; |
192 size_t buffer_size_; // In bytes. | 192 size_t buffer_size_; // In bytes. |
193 | 193 |
194 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); | 194 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); |
195 }; | 195 }; |
196 | 196 |
197 } // namespace net | 197 } // namespace net |
198 | 198 |
199 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 199 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
OLD | NEW |