Chromium Code Reviews| 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 <vector> | 12 #include <vector> |
| 12 | 13 |
| 13 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/format_macros.h" | |
| 16 #include "base/strings/stringprintf.h" | |
| 14 #include "net/quic/congestion_control/send_algorithm_interface.h" | 17 #include "net/quic/congestion_control/send_algorithm_interface.h" |
| 15 #include "net/quic/quic_protocol.h" | 18 #include "net/quic/quic_protocol.h" |
| 16 #include "net/quic/quic_time.h" | 19 #include "net/quic/quic_time.h" |
| 17 #include "net/quic/test_tools/mock_clock.h" | 20 #include "net/quic/test_tools/mock_clock.h" |
| 18 #include "net/quic/test_tools/quic_test_utils.h" | 21 #include "net/quic/test_tools/quic_test_utils.h" |
| 19 | 22 |
| 23 using base::StringPrintf; | |
| 24 | |
| 20 namespace net { | 25 namespace net { |
| 21 | 26 |
| 22 class SendAlgorithmSimulator { | 27 class SendAlgorithmSimulator { |
| 23 public: | 28 public: |
| 24 struct Sender { | 29 struct Sender { |
| 25 Sender(SendAlgorithmInterface* send_algorithm, RttStats* rtt_stats); | 30 Sender(SendAlgorithmInterface* send_algorithm, RttStats* rtt_stats); |
| 26 | 31 |
| 27 void RecordStats() { | 32 void RecordStats() { |
| 28 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); | 33 QuicByteCount cwnd = send_algorithm->GetCongestionWindow(); |
| 29 max_cwnd = std::max(max_cwnd, cwnd); | 34 max_cwnd = std::max(max_cwnd, cwnd); |
| 30 min_cwnd = std::min(min_cwnd, cwnd); | 35 min_cwnd = std::min(min_cwnd, cwnd); |
| 31 if (last_cwnd > cwnd) { | 36 if (last_cwnd > cwnd) { |
| 32 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); | 37 max_cwnd_drop = std::max(max_cwnd_drop, last_cwnd - cwnd); |
| 33 } | 38 } |
| 34 last_cwnd = cwnd; | 39 last_cwnd = cwnd; |
| 35 } | 40 } |
| 36 | 41 |
| 42 std::string DebugString() { | |
| 43 return StringPrintf("observed goodput(bytes/s):%" PRId64 " cwnd:%" PRIu64 | |
| 44 " max_cwnd:%" PRIu64 " min_cwnd:%" PRIu64 | |
| 45 " max_cwnd_drop:%" PRIu64, | |
| 46 last_transfer_bandwidth.ToBytesPerSecond(), | |
| 47 send_algorithm->GetCongestionWindow(), | |
| 48 max_cwnd, min_cwnd, max_cwnd_drop); | |
| 49 } | |
|
Ryan Hamilton
2014/07/17 00:02:46
I suspect you'll need to move this to the .cc file
ramant (doing other things)
2014/07/18 18:02:25
I am surprised, not sure why compiler's didn't com
| |
| 50 | |
| 37 SendAlgorithmInterface* send_algorithm; | 51 SendAlgorithmInterface* send_algorithm; |
| 38 RttStats* rtt_stats; | 52 RttStats* rtt_stats; |
| 39 | 53 |
| 40 // Last sequence number the sender sent. | 54 // Last sequence number the sender sent. |
| 41 QuicPacketSequenceNumber last_sent; | 55 QuicPacketSequenceNumber last_sent; |
| 42 // Last packet sequence number acked. | 56 // Last packet sequence number acked. |
| 43 QuicPacketSequenceNumber last_acked; | 57 QuicPacketSequenceNumber last_acked; |
| 44 // Packet sequence number to ack up to. | 58 // Packet sequence number to ack up to. |
| 45 QuicPacketSequenceNumber next_acked; | 59 QuicPacketSequenceNumber next_acked; |
| 46 | 60 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 QuicBandwidth bandwidth_; | 190 QuicBandwidth bandwidth_; |
| 177 QuicTime::Delta rtt_; | 191 QuicTime::Delta rtt_; |
| 178 size_t buffer_size_; // In bytes. | 192 size_t buffer_size_; // In bytes. |
| 179 | 193 |
| 180 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); | 194 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); |
| 181 }; | 195 }; |
| 182 | 196 |
| 183 } // namespace net | 197 } // namespace net |
| 184 | 198 |
| 185 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 199 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
| OLD | NEW |