| 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 void set_loss_correlation(float loss_correlation) { | 127 void set_loss_correlation(float loss_correlation) { |
| 128 DCHECK_LT(loss_correlation, 1.0f); | 128 DCHECK_LT(loss_correlation, 1.0f); |
| 129 loss_correlation_ = loss_correlation; | 129 loss_correlation_ = loss_correlation; |
| 130 } | 130 } |
| 131 | 131 |
| 132 void set_buffer_size(size_t buffer_size_bytes) { | 132 void set_buffer_size(size_t buffer_size_bytes) { |
| 133 buffer_size_ = buffer_size_bytes; | 133 buffer_size_ = buffer_size_bytes; |
| 134 } | 134 } |
| 135 | 135 |
| 136 void set_delayed_ack_timer(QuicTime::Delta delayed_ack_timer) { |
| 137 delayed_ack_timer_ = delayed_ack_timer; |
| 138 } |
| 139 |
| 136 // Advance the time by |delta| without sending anything. | 140 // Advance the time by |delta| without sending anything. |
| 137 void AdvanceTime(QuicTime::Delta delta); | 141 void AdvanceTime(QuicTime::Delta delta); |
| 138 | 142 |
| 139 // Adds a pending sender. The send will run when TransferBytes is called. | 143 // Adds a pending sender. The send will run when TransferBytes is called. |
| 140 // Adding two transfers with the same sender is unsupported. | 144 // Adding two transfers with the same sender is unsupported. |
| 141 void AddTransfer(Sender* sender, size_t num_bytes); | 145 void AddTransfer(Sender* sender, size_t num_bytes); |
| 142 | 146 |
| 143 // Adds a pending sending to start at the specified time. | 147 // Adds a pending sending to start at the specified time. |
| 144 void AddTransfer(Sender* sender, size_t num_bytes, QuicTime start_time); | 148 void AddTransfer(Sender* sender, size_t num_bytes, QuicTime start_time); |
| 145 | 149 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 166 // and populates transfer if the send time is not infinite. | 170 // and populates transfer if the send time is not infinite. |
| 167 PacketEvent NextSendEvent(); | 171 PacketEvent NextSendEvent(); |
| 168 | 172 |
| 169 // NextAckTime takes into account packet loss in both forward and reverse | 173 // NextAckTime takes into account packet loss in both forward and reverse |
| 170 // direction, as well as delayed ack behavior. | 174 // direction, as well as delayed ack behavior. |
| 171 PacketEvent NextAckEvent(); | 175 PacketEvent NextAckEvent(); |
| 172 | 176 |
| 173 // Sets the next acked. | 177 // Sets the next acked. |
| 174 QuicTime::Delta FindNextAcked(Transfer* transfer); | 178 QuicTime::Delta FindNextAcked(Transfer* transfer); |
| 175 | 179 |
| 180 // Sets the |next_acked| packet for the |transfer| starting at the specified |
| 181 // |last_acked|. Returns QuicTime::Delta::Infinite and doesn't set |
| 182 // |next_acked| if there is no ack after |last_acked|. |
| 183 QuicTime::Delta FindNextAck(const Transfer* transfer, |
| 184 QuicPacketSequenceNumber last_acked, |
| 185 QuicPacketSequenceNumber* next_acked) const; |
| 186 |
| 187 // Returns true if any of the packets |transfer| is waiting for less than |
| 188 // next_acked have been lost. |
| 189 bool HasRecentLostPackets(const Transfer* transfer, |
| 190 QuicPacketSequenceNumber next_acked) const; |
| 191 |
| 176 // Process all the acks that should have arrived by the current time, and | 192 // Process all the acks that should have arrived by the current time, and |
| 177 // lose any packets that are missing. Returns the number of bytes acked. | 193 // lose any packets that are missing. Returns the number of bytes acked. |
| 178 void HandlePendingAck(Transfer* transfer); | 194 void HandlePendingAck(Transfer* transfer); |
| 179 | 195 |
| 180 void SendDataNow(Transfer* transfer); | 196 void SendDataNow(Transfer* transfer); |
| 181 | 197 |
| 182 // List of all pending transfers waiting to use the connection. | 198 // List of all pending transfers waiting to use the connection. |
| 183 std::vector<Transfer> pending_transfers_; | 199 std::vector<Transfer> pending_transfers_; |
| 184 | 200 |
| 185 MockClock* clock_; | 201 MockClock* clock_; |
| 186 // Whether the next ack should be lost. | 202 // Whether the next ack should be lost. |
| 187 bool lose_next_ack_; | 203 bool lose_next_ack_; |
| 188 // The times acks are expected, assuming acks are not lost and every packet | 204 // The times acks are expected, assuming acks are not lost and every packet |
| 189 // is acked. | 205 // is acked. |
| 190 std::list<SentPacket> sent_packets_; | 206 std::list<SentPacket> sent_packets_; |
| 191 | 207 |
| 192 test::SimpleRandom simple_random_; | 208 test::SimpleRandom simple_random_; |
| 193 float forward_loss_rate_; // Loss rate on the forward path. | 209 float forward_loss_rate_; // Loss rate on the forward path. |
| 194 float reverse_loss_rate_; // Loss rate on the reverse path. | 210 float reverse_loss_rate_; // Loss rate on the reverse path. |
| 195 float loss_correlation_; // Likelihood the subsequent packet is lost. | 211 float loss_correlation_; // Likelihood the subsequent packet is lost. |
| 196 QuicBandwidth bandwidth_; | 212 QuicBandwidth bandwidth_; |
| 197 QuicTime::Delta rtt_; | 213 QuicTime::Delta rtt_; |
| 198 size_t buffer_size_; // In bytes. | 214 size_t buffer_size_; // In bytes. |
| 215 QuicTime::Delta delayed_ack_timer_; |
| 199 | 216 |
| 200 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); | 217 DISALLOW_COPY_AND_ASSIGN(SendAlgorithmSimulator); |
| 201 }; | 218 }; |
| 202 | 219 |
| 203 } // namespace net | 220 } // namespace net |
| 204 | 221 |
| 205 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ | 222 #endif // NET_QUIC_CONGESTION_CONTROL_SEND_ALGORITHM_SIMULATOR_H_ |
| OLD | NEW |