| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/macros.h" | 16 #include "base/macros.h" |
| 17 #include "net/base/linked_hash_map.h" | 17 #include "net/base/linked_hash_map.h" |
| 18 #include "net/base/net_export.h" | 18 #include "net/base/net_export.h" |
| 19 #include "net/quic/core/congestion_control/general_loss_algorithm.h" | 19 #include "net/quic/core/congestion_control/general_loss_algorithm.h" |
| 20 #include "net/quic/core/congestion_control/loss_detection_interface.h" | 20 #include "net/quic/core/congestion_control/loss_detection_interface.h" |
| 21 #include "net/quic/core/congestion_control/pacing_sender.h" | 21 #include "net/quic/core/congestion_control/pacing_sender.h" |
| 22 #include "net/quic/core/congestion_control/rtt_stats.h" | 22 #include "net/quic/core/congestion_control/rtt_stats.h" |
| 23 #include "net/quic/core/congestion_control/send_algorithm_interface.h" | 23 #include "net/quic/core/congestion_control/send_algorithm_interface.h" |
| 24 #include "net/quic/core/quic_protocol.h" | 24 #include "net/quic/core/quic_packets.h" |
| 25 #include "net/quic/core/quic_sent_packet_manager_interface.h" | 25 #include "net/quic/core/quic_sent_packet_manager_interface.h" |
| 26 #include "net/quic/core/quic_unacked_packet_map.h" | 26 #include "net/quic/core/quic_unacked_packet_map.h" |
| 27 | 27 |
| 28 namespace net { | 28 namespace net { |
| 29 | 29 |
| 30 namespace test { | 30 namespace test { |
| 31 class QuicConnectionPeer; | 31 class QuicConnectionPeer; |
| 32 class QuicSentPacketManagerPeer; | 32 class QuicSentPacketManagerPeer; |
| 33 } // namespace test | 33 } // namespace test |
| 34 | 34 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // Removes the retransmittable frames from all unencrypted packets to ensure | 113 // Removes the retransmittable frames from all unencrypted packets to ensure |
| 114 // they don't get retransmitted. | 114 // they don't get retransmitted. |
| 115 void NeuterUnencryptedPackets() override; | 115 void NeuterUnencryptedPackets() override; |
| 116 | 116 |
| 117 // Returns true if there are pending retransmissions. | 117 // Returns true if there are pending retransmissions. |
| 118 // Not const because retransmissions may be cancelled before returning. | 118 // Not const because retransmissions may be cancelled before returning. |
| 119 bool HasPendingRetransmissions() const override; | 119 bool HasPendingRetransmissions() const override; |
| 120 | 120 |
| 121 // Retrieves the next pending retransmission. You must ensure that | 121 // Retrieves the next pending retransmission. You must ensure that |
| 122 // there are pending retransmissions prior to calling this function. | 122 // there are pending retransmissions prior to calling this function. |
| 123 PendingRetransmission NextPendingRetransmission() override; | 123 QuicPendingRetransmission NextPendingRetransmission() override; |
| 124 | 124 |
| 125 bool HasUnackedPackets() const override; | 125 bool HasUnackedPackets() const override; |
| 126 | 126 |
| 127 // Returns the smallest packet number of a serialized packet which has not | 127 // Returns the smallest packet number of a serialized packet which has not |
| 128 // been acked by the peer. | 128 // been acked by the peer. |
| 129 QuicPacketNumber GetLeastUnacked(QuicPathId) const override; | 129 QuicPacketNumber GetLeastUnacked(QuicPathId) const override; |
| 130 | 130 |
| 131 // Called when we have sent bytes to the peer. This informs the manager both | 131 // Called when we have sent bytes to the peer. This informs the manager both |
| 132 // the number of bytes sent and if they were retransmitted. Returns true if | 132 // the number of bytes sent and if they were retransmitted. Returns true if |
| 133 // the sender should reset the retransmission timer. | 133 // the sender should reset the retransmission timer. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) override; | 201 void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) override; |
| 202 | 202 |
| 203 bool InSlowStart() const override; | 203 bool InSlowStart() const override; |
| 204 | 204 |
| 205 size_t GetConsecutiveRtoCount() const override; | 205 size_t GetConsecutiveRtoCount() const override; |
| 206 | 206 |
| 207 size_t GetConsecutiveTlpCount() const override; | 207 size_t GetConsecutiveTlpCount() const override; |
| 208 | 208 |
| 209 void OnApplicationLimited() override; | 209 void OnApplicationLimited() override; |
| 210 | 210 |
| 211 const SendAlgorithmInterface* GetSendAlgorithm() const override; |
| 212 |
| 211 private: | 213 private: |
| 212 friend class test::QuicConnectionPeer; | 214 friend class test::QuicConnectionPeer; |
| 213 friend class test::QuicSentPacketManagerPeer; | 215 friend class test::QuicSentPacketManagerPeer; |
| 214 | 216 |
| 215 // The retransmission timer is a single timer which switches modes depending | 217 // The retransmission timer is a single timer which switches modes depending |
| 216 // upon connection state. | 218 // upon connection state. |
| 217 enum RetransmissionTimeoutMode { | 219 enum RetransmissionTimeoutMode { |
| 218 // A conventional TCP style RTO. | 220 // A conventional TCP style RTO. |
| 219 RTO_MODE, | 221 RTO_MODE, |
| 220 // A tail loss probe. By default, QUIC sends up to two before RTOing. | 222 // A tail loss probe. By default, QUIC sends up to two before RTOing. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 250 | 252 |
| 251 // Returns the timer for a new tail loss probe. | 253 // Returns the timer for a new tail loss probe. |
| 252 const QuicTime::Delta GetTailLossProbeDelay() const; | 254 const QuicTime::Delta GetTailLossProbeDelay() const; |
| 253 | 255 |
| 254 // Returns the retransmission timeout, after which a full RTO occurs. | 256 // Returns the retransmission timeout, after which a full RTO occurs. |
| 255 const QuicTime::Delta GetRetransmissionDelay() const; | 257 const QuicTime::Delta GetRetransmissionDelay() const; |
| 256 | 258 |
| 257 // Returns the newest transmission associated with a packet. | 259 // Returns the newest transmission associated with a packet. |
| 258 QuicPacketNumber GetNewestRetransmission( | 260 QuicPacketNumber GetNewestRetransmission( |
| 259 QuicPacketNumber packet_number, | 261 QuicPacketNumber packet_number, |
| 260 const TransmissionInfo& transmission_info) const; | 262 const QuicTransmissionInfo& transmission_info) const; |
| 261 | 263 |
| 262 // Update the RTT if the ack is for the largest acked packet number. | 264 // Update the RTT if the ack is for the largest acked packet number. |
| 263 // Returns true if the rtt was updated. | 265 // Returns true if the rtt was updated. |
| 264 bool MaybeUpdateRTT(const QuicAckFrame& ack_frame, QuicTime ack_receive_time); | 266 bool MaybeUpdateRTT(const QuicAckFrame& ack_frame, QuicTime ack_receive_time); |
| 265 | 267 |
| 266 // Invokes the loss detection algorithm and loses and retransmits packets if | 268 // Invokes the loss detection algorithm and loses and retransmits packets if |
| 267 // necessary. | 269 // necessary. |
| 268 void InvokeLossDetection(QuicTime time); | 270 void InvokeLossDetection(QuicTime time); |
| 269 | 271 |
| 270 // Invokes OnCongestionEvent if |rtt_updated| is true, there are pending acks, | 272 // Invokes OnCongestionEvent if |rtt_updated| is true, there are pending acks, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 284 // landed. | 286 // landed. |
| 285 // The packet needs no longer to be retransmitted, but the packet remains | 287 // The packet needs no longer to be retransmitted, but the packet remains |
| 286 // pending if it is and the congestion control does not consider the packet | 288 // pending if it is and the congestion control does not consider the packet |
| 287 // acked. | 289 // acked. |
| 288 void MarkPacketNotRetransmittable(QuicPacketNumber packet_number, | 290 void MarkPacketNotRetransmittable(QuicPacketNumber packet_number, |
| 289 QuicTime::Delta ack_delay_time); | 291 QuicTime::Delta ack_delay_time); |
| 290 | 292 |
| 291 // Removes the retransmittability and in flight properties from the packet at | 293 // Removes the retransmittability and in flight properties from the packet at |
| 292 // |info| due to receipt by the peer. | 294 // |info| due to receipt by the peer. |
| 293 void MarkPacketHandled(QuicPacketNumber packet_number, | 295 void MarkPacketHandled(QuicPacketNumber packet_number, |
| 294 TransmissionInfo* info, | 296 QuicTransmissionInfo* info, |
| 295 QuicTime::Delta ack_delay_time); | 297 QuicTime::Delta ack_delay_time); |
| 296 | 298 |
| 297 // Request that |packet_number| be retransmitted after the other pending | 299 // Request that |packet_number| be retransmitted after the other pending |
| 298 // retransmissions. Does not add it to the retransmissions if it's already | 300 // retransmissions. Does not add it to the retransmissions if it's already |
| 299 // a pending retransmission. | 301 // a pending retransmission. |
| 300 void MarkForRetransmission(QuicPacketNumber packet_number, | 302 void MarkForRetransmission(QuicPacketNumber packet_number, |
| 301 TransmissionType transmission_type); | 303 TransmissionType transmission_type); |
| 302 | 304 |
| 303 // Notify observers that packet with TransmissionInfo |info| is a spurious | 305 // Notify observers that packet with QuicTransmissionInfo |info| is a spurious |
| 304 // retransmission. It is caller's responsibility to guarantee the packet with | 306 // retransmission. It is caller's responsibility to guarantee the packet with |
| 305 // TransmissionInfo |info| is a spurious retransmission before calling this | 307 // QuicTransmissionInfo |info| is a spurious retransmission before calling |
| 306 // function. | 308 // this function. |
| 307 void RecordOneSpuriousRetransmission(const TransmissionInfo& info); | 309 void RecordOneSpuriousRetransmission(const QuicTransmissionInfo& info); |
| 308 | 310 |
| 309 // Notify observers about spurious retransmits of packet with TransmissionInfo | 311 // Notify observers about spurious retransmits of packet with |
| 310 // |info|. | 312 // QuicTransmissionInfo |info|. |
| 311 void RecordSpuriousRetransmissions(const TransmissionInfo& info, | 313 void RecordSpuriousRetransmissions(const QuicTransmissionInfo& info, |
| 312 QuicPacketNumber acked_packet_number); | 314 QuicPacketNumber acked_packet_number); |
| 313 | 315 |
| 314 // Returns mutable TransmissionInfo associated with |packet_number|, which | 316 // Returns mutable QuicTransmissionInfo associated with |packet_number|, which |
| 315 // must be unacked. | 317 // must be unacked. |
| 316 TransmissionInfo* GetMutableTransmissionInfo(QuicPacketNumber packet_number); | 318 QuicTransmissionInfo* GetMutableTransmissionInfo( |
| 319 QuicPacketNumber packet_number); |
| 317 | 320 |
| 318 // Remove any packets no longer needed for retransmission, congestion, or | 321 // Remove any packets no longer needed for retransmission, congestion, or |
| 319 // RTT measurement purposes. | 322 // RTT measurement purposes. |
| 320 void RemoveObsoletePackets(); | 323 void RemoveObsoletePackets(); |
| 321 | 324 |
| 322 // Sets the send algorithm to the given congestion control type and points the | 325 // Sets the send algorithm to the given congestion control type and points the |
| 323 // pacing sender at |send_algorithm_|. Can be called any number of times. | 326 // pacing sender at |send_algorithm_|. Can be called any number of times. |
| 324 void SetSendAlgorithm(CongestionControlType congestion_control_type); | 327 void SetSendAlgorithm(CongestionControlType congestion_control_type); |
| 325 | 328 |
| 326 // Sets the send algorithm to |send_algorithm| and points the pacing sender at | 329 // Sets the send algorithm to |send_algorithm| and points the pacing sender at |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 // Records bandwidth from server to client in normal operation, over periods | 417 // Records bandwidth from server to client in normal operation, over periods |
| 415 // of time with no loss events. | 418 // of time with no loss events. |
| 416 QuicSustainedBandwidthRecorder sustained_bandwidth_recorder_; | 419 QuicSustainedBandwidthRecorder sustained_bandwidth_recorder_; |
| 417 | 420 |
| 418 DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager); | 421 DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager); |
| 419 }; | 422 }; |
| 420 | 423 |
| 421 } // namespace net | 424 } // namespace net |
| 422 | 425 |
| 423 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ | 426 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ |
| OLD | NEW |