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> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 QuicByteCount last_cwnd; | 73 QuicByteCount last_cwnd; |
74 | 74 |
75 QuicBandwidth last_transfer_bandwidth; | 75 QuicBandwidth last_transfer_bandwidth; |
76 float last_transfer_loss_rate; | 76 float last_transfer_loss_rate; |
77 }; | 77 }; |
78 | 78 |
79 struct Transfer { | 79 struct Transfer { |
80 Transfer(Sender* sender, | 80 Transfer(Sender* sender, |
81 QuicByteCount num_bytes, | 81 QuicByteCount num_bytes, |
82 QuicTime start_time, | 82 QuicTime start_time, |
83 string name); | 83 std::string name); |
84 | 84 |
85 Sender* sender; | 85 Sender* sender; |
86 QuicByteCount num_bytes; | 86 QuicByteCount num_bytes; |
87 QuicByteCount bytes_acked; | 87 QuicByteCount bytes_acked; |
88 QuicByteCount bytes_lost; | 88 QuicByteCount bytes_lost; |
89 QuicByteCount bytes_in_flight; | 89 QuicByteCount bytes_in_flight; |
90 QuicTime start_time; | 90 QuicTime start_time; |
91 string name; | 91 std::string name; |
92 }; | 92 }; |
93 | 93 |
94 struct SentPacket { | 94 struct SentPacket { |
95 SentPacket() | 95 SentPacket() |
96 : sequence_number(0), | 96 : sequence_number(0), |
97 send_time(QuicTime::Zero()), | 97 send_time(QuicTime::Zero()), |
98 ack_time(QuicTime::Zero()), | 98 ack_time(QuicTime::Zero()), |
99 lost(false), | 99 lost(false), |
100 transfer(nullptr) {} | 100 transfer(nullptr) {} |
101 SentPacket(QuicPacketSequenceNumber sequence_number, | 101 SentPacket(QuicPacketSequenceNumber sequence_number, |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 // Advance the time by |delta| without sending anything. | 152 // Advance the time by |delta| without sending anything. |
153 void AdvanceTime(QuicTime::Delta delta); | 153 void AdvanceTime(QuicTime::Delta delta); |
154 | 154 |
155 // Adds a pending sender. The send will run when TransferBytes is called. | 155 // Adds a pending sender. The send will run when TransferBytes is called. |
156 // Adding two transfers with the same sender is unsupported. | 156 // Adding two transfers with the same sender is unsupported. |
157 void AddTransfer(Sender* sender, size_t num_bytes); | 157 void AddTransfer(Sender* sender, size_t num_bytes); |
158 | 158 |
159 // Adds a pending sending to start at the specified time. | 159 // Adds a pending sending to start at the specified time. |
160 void AddTransfer( | 160 void AddTransfer( |
161 Sender* sender, size_t num_bytes, QuicTime start_time, string name); | 161 Sender* sender, size_t num_bytes, QuicTime start_time, std::string name); |
162 | 162 |
163 // Convenience method to transfer all bytes. | 163 // Convenience method to transfer all bytes. |
164 void TransferBytes(); | 164 void TransferBytes(); |
165 | 165 |
166 // Transfers bytes through the connection until |max_bytes| are reached, | 166 // Transfers bytes through the connection until |max_bytes| are reached, |
167 // |max_time| is reached, or all senders have finished sending. If max_bytes | 167 // |max_time| is reached, or all senders have finished sending. If max_bytes |
168 // is 0, it does not apply, and if |max_time| is Zero, no time limit applies. | 168 // is 0, it does not apply, and if |max_time| is Zero, no time limit applies. |
169 void TransferBytes(QuicByteCount max_bytes, QuicTime::Delta max_time); | 169 void TransferBytes(QuicByteCount max_bytes, QuicTime::Delta max_time); |
170 | 170 |
171 private: | 171 private: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 QuicTime::Delta rtt_; | 226 QuicTime::Delta rtt_; |
227 size_t buffer_size_; // In bytes. | 227 size_t buffer_size_; // In bytes. |
228 QuicTime::Delta delayed_ack_timer_; | 228 QuicTime::Delta delayed_ack_timer_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); | 230 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); |
231 }; | 231 }; |
232 | 232 |
233 } // namespace net | 233 } // namespace net |
234 | 234 |
235 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 235 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
OLD | NEW |