| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ | 5 #ifndef NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ |
| 6 #define NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ | 6 #define NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <list> | 9 #include <list> |
| 10 #include <map> | 10 #include <map> |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 RTO_MODE, | 199 RTO_MODE, |
| 200 TLP_MODE, | 200 TLP_MODE, |
| 201 HANDSHAKE_MODE, | 201 HANDSHAKE_MODE, |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 struct TransmissionInfo { | 204 struct TransmissionInfo { |
| 205 TransmissionInfo() | 205 TransmissionInfo() |
| 206 : retransmittable_frames(NULL), | 206 : retransmittable_frames(NULL), |
| 207 sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER), | 207 sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER), |
| 208 sent_time(QuicTime::Zero()), | 208 sent_time(QuicTime::Zero()), |
| 209 previous_transmissions(NULL) { } | 209 previous_transmissions(NULL), |
| 210 pending(false) { } |
| 210 TransmissionInfo(RetransmittableFrames* retransmittable_frames, | 211 TransmissionInfo(RetransmittableFrames* retransmittable_frames, |
| 211 QuicSequenceNumberLength sequence_number_length) | 212 QuicSequenceNumberLength sequence_number_length) |
| 212 : retransmittable_frames(retransmittable_frames), | 213 : retransmittable_frames(retransmittable_frames), |
| 213 sequence_number_length(sequence_number_length), | 214 sequence_number_length(sequence_number_length), |
| 214 sent_time(QuicTime::Zero()), | 215 sent_time(QuicTime::Zero()), |
| 215 previous_transmissions(NULL) { | 216 previous_transmissions(NULL), |
| 217 pending(false) { |
| 216 } | 218 } |
| 217 | 219 |
| 218 RetransmittableFrames* retransmittable_frames; | 220 RetransmittableFrames* retransmittable_frames; |
| 219 QuicSequenceNumberLength sequence_number_length; | 221 QuicSequenceNumberLength sequence_number_length; |
| 220 // Zero when the packet is serialized, non-zero once it's sent. | 222 // Zero when the packet is serialized, non-zero once it's sent. |
| 221 QuicTime sent_time; | 223 QuicTime sent_time; |
| 222 // Stores all previous transmissions if the packet has been retransmitted, | 224 // Stores all previous transmissions if the packet has been retransmitted, |
| 223 // and is NULL otherwise. | 225 // and is NULL otherwise. |
| 224 SequenceNumberSet* previous_transmissions; | 226 SequenceNumberSet* previous_transmissions; |
| 227 // Pending packets have not been abandoned or lost. |
| 228 bool pending; |
| 225 }; | 229 }; |
| 226 | 230 |
| 227 typedef linked_hash_map<QuicPacketSequenceNumber, | 231 typedef linked_hash_map<QuicPacketSequenceNumber, |
| 228 TransmissionInfo> UnackedPacketMap; | 232 TransmissionInfo> UnackedPacketMap; |
| 229 typedef linked_hash_map<QuicPacketSequenceNumber, | 233 typedef linked_hash_map<QuicPacketSequenceNumber, |
| 230 TransmissionType> PendingRetransmissionMap; | 234 TransmissionType> PendingRetransmissionMap; |
| 231 | 235 |
| 232 static bool HasCryptoHandshake(const TransmissionInfo& transmission_info); | 236 static bool HasCryptoHandshake(const TransmissionInfo& transmission_info); |
| 233 | 237 |
| 238 // Returns true if there are unacked packets that are pending. |
| 239 bool HasPendingPackets() const; |
| 240 |
| 234 // Process the incoming ack looking for newly ack'd data packets. | 241 // Process the incoming ack looking for newly ack'd data packets. |
| 235 void HandleAckForSentPackets(const ReceivedPacketInfo& received_info); | 242 void HandleAckForSentPackets(const ReceivedPacketInfo& received_info); |
| 236 | 243 |
| 237 // Called when a packet is timed out, such as an RTO. Removes the bytes from | 244 // Called when a packet is timed out, such as an RTO. Removes the bytes from |
| 238 // the congestion manager, but does not change the congestion window size. | 245 // the congestion manager, but does not change the congestion window size. |
| 239 virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number); | 246 virtual void OnPacketAbandoned(UnackedPacketMap::iterator it); |
| 240 | 247 |
| 241 // Returns the current retransmission mode. | 248 // Returns the current retransmission mode. |
| 242 RetransmissionTimeoutMode GetRetransmissionMode() const; | 249 RetransmissionTimeoutMode GetRetransmissionMode() const; |
| 243 | 250 |
| 244 // Retransmits all crypto stream packets. | 251 // Retransmits all crypto stream packets. |
| 245 void RetransmitCryptoPackets(); | 252 void RetransmitCryptoPackets(); |
| 246 | 253 |
| 247 // Retransmits the oldest pending packet. | 254 // Retransmits the oldest pending packet. |
| 248 void RetransmitOldestPacket(); | 255 void RetransmitOldestPacket(); |
| 249 | 256 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 277 | 284 |
| 278 // Removes entries from the unacked packet map. | 285 // Removes entries from the unacked packet map. |
| 279 void DiscardPacket(QuicPacketSequenceNumber sequence_number); | 286 void DiscardPacket(QuicPacketSequenceNumber sequence_number); |
| 280 | 287 |
| 281 // Request that |sequence_number| be retransmitted after the other pending | 288 // Request that |sequence_number| be retransmitted after the other pending |
| 282 // retransmissions. Does not add it to the retransmissions if it's already | 289 // retransmissions. Does not add it to the retransmissions if it's already |
| 283 // a pending retransmission. | 290 // a pending retransmission. |
| 284 void MarkForRetransmission(QuicPacketSequenceNumber sequence_number, | 291 void MarkForRetransmission(QuicPacketSequenceNumber sequence_number, |
| 285 TransmissionType transmission_type); | 292 TransmissionType transmission_type); |
| 286 | 293 |
| 287 // Returns the length of the serialized sequence number for | |
| 288 // the packet |sequence_number|. | |
| 289 QuicSequenceNumberLength GetSequenceNumberLength( | |
| 290 QuicPacketSequenceNumber sequence_number) const; | |
| 291 | |
| 292 // Clears up to |num_to_clear| previous transmissions in order to make room | 294 // Clears up to |num_to_clear| previous transmissions in order to make room |
| 293 // in the ack frame for new acks. | 295 // in the ack frame for new acks. |
| 294 void ClearPreviousRetransmissions(size_t num_to_clear); | 296 void ClearPreviousRetransmissions(size_t num_to_clear); |
| 295 | 297 |
| 296 void CleanupPacketHistory(); | 298 void CleanupPacketHistory(); |
| 297 | 299 |
| 298 // Removes |sequence_number| as a previous transmission of any other packets. | 300 // Removes |sequence_number| as a previous transmission of any other packets. |
| 299 void RemovePreviousTransmission(QuicPacketSequenceNumber sequence_number); | 301 void RemovePreviousTransmission(QuicPacketSequenceNumber sequence_number); |
| 300 | 302 |
| 301 // Newly serialized retransmittable and fec packets are added to this map, | 303 // Newly serialized retransmittable and fec packets are added to this map, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 319 // An AckNotifier can register to be informed when ACKs have been received for | 321 // An AckNotifier can register to be informed when ACKs have been received for |
| 320 // all packets that a given block of data was sent in. The AckNotifierManager | 322 // all packets that a given block of data was sent in. The AckNotifierManager |
| 321 // maintains the currently active notifiers. | 323 // maintains the currently active notifiers. |
| 322 AckNotifierManager ack_notifier_manager_; | 324 AckNotifierManager ack_notifier_manager_; |
| 323 | 325 |
| 324 const QuicClock* clock_; | 326 const QuicClock* clock_; |
| 325 scoped_ptr<SendAlgorithmInterface> send_algorithm_; | 327 scoped_ptr<SendAlgorithmInterface> send_algorithm_; |
| 326 // Tracks the send time, size, and nack count of sent packets. Packets are | 328 // Tracks the send time, size, and nack count of sent packets. Packets are |
| 327 // removed after 5 seconds and they've been removed from pending_packets_. | 329 // removed after 5 seconds and they've been removed from pending_packets_. |
| 328 SendAlgorithmInterface::SentPacketsMap packet_history_map_; | 330 SendAlgorithmInterface::SentPacketsMap packet_history_map_; |
| 329 // Packets that are outstanding and have not been abandoned or lost. | |
| 330 SequenceNumberSet pending_packets_; | |
| 331 QuicTime::Delta rtt_sample_; // RTT estimate from the most recent ACK. | 331 QuicTime::Delta rtt_sample_; // RTT estimate from the most recent ACK. |
| 332 // Number of outstanding crypto handshake packets. | 332 // Number of outstanding crypto handshake packets. |
| 333 size_t pending_crypto_packet_count_; | 333 size_t pending_crypto_packet_count_; |
| 334 // Number of times the RTO timer has fired in a row without receiving an ack. | 334 // Number of times the RTO timer has fired in a row without receiving an ack. |
| 335 size_t consecutive_rto_count_; | 335 size_t consecutive_rto_count_; |
| 336 // Number of times the tail loss probe has been sent. | 336 // Number of times the tail loss probe has been sent. |
| 337 size_t consecutive_tlp_count_; | 337 size_t consecutive_tlp_count_; |
| 338 // Number of times the crypto handshake has been retransmitted. | 338 // Number of times the crypto handshake has been retransmitted. |
| 339 size_t consecutive_crypto_retransmission_count_; | 339 size_t consecutive_crypto_retransmission_count_; |
| 340 // Maximum number of tail loss probes to send before firing an RTO. | 340 // Maximum number of tail loss probes to send before firing an RTO. |
| 341 size_t max_tail_loss_probes_; | 341 size_t max_tail_loss_probes_; |
| 342 bool using_pacing_; | 342 bool using_pacing_; |
| 343 | 343 |
| 344 DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager); | 344 DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager); |
| 345 }; | 345 }; |
| 346 | 346 |
| 347 } // namespace net | 347 } // namespace net |
| 348 | 348 |
| 349 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ | 349 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ |
| OLD | NEW |