| 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 #ifndef NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ | 5 #ifndef NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ |
| 6 #define NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ | 6 #define NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
| 11 | 11 |
| 12 namespace net { | 12 namespace net { |
| 13 | 13 |
| 14 // Class which tracks unacked packets for three purposes: | 14 // Class which tracks unacked packets for three purposes: |
| 15 // 1) Track retransmittable data, including multiple transmissions of frames. | 15 // 1) Track retransmittable data, including multiple transmissions of frames. |
| 16 // 2) Track packets and bytes in flight for congestion control. | 16 // 2) Track packets and bytes in flight for congestion control. |
| 17 // 3) Track sent time of packets to provide RTT measurements from acks. | 17 // 3) Track sent time of packets to provide RTT measurements from acks. |
| 18 class NET_EXPORT_PRIVATE QuicUnackedPacketMap { | 18 class NET_EXPORT_PRIVATE QuicUnackedPacketMap { |
| 19 public: | 19 public: |
| 20 QuicUnackedPacketMap(); | 20 QuicUnackedPacketMap(); |
| 21 ~QuicUnackedPacketMap(); | 21 ~QuicUnackedPacketMap(); |
| 22 | 22 |
| 23 // Adds |serialized_packet| to the map. Does not mark it in flight. | 23 // Adds |serialized_packet| to the map and marks it as sent at |sent_time|. |
| 24 void AddPacket(const SerializedPacket& serialized_packet); | 24 // Marks the packet as in flight if |set_in_flight| is true. |
| 25 | 25 // Packets marked as in flight are expected to be marked as missing when they |
| 26 // Called when a packet is retransmitted with a new sequence number. | 26 // don't arrive, indicating the need for retransmission. |
| 27 // |old_sequence_number| will remain unacked, but will have no | 27 // |old_sequence_number| is the sequence number of the previous transmission, |
| 28 // retransmittable data associated with it. |new_sequence_number| will | 28 // or 0 if there was none. |
| 29 // be both unacked and associated with retransmittable data. | 29 void AddSentPacket(const SerializedPacket& serialized_packet, |
| 30 void OnRetransmittedPacket(QuicPacketSequenceNumber old_sequence_number, | 30 QuicPacketSequenceNumber old_sequence_number, |
| 31 QuicPacketSequenceNumber new_sequence_number, | 31 TransmissionType transmission_type, |
| 32 TransmissionType transmission_type); | 32 QuicTime sent_time, |
| 33 QuicByteCount bytes_sent, |
| 34 bool set_in_flight); |
| 33 | 35 |
| 34 // Returns true if the packet |sequence_number| is unacked. | 36 // Returns true if the packet |sequence_number| is unacked. |
| 35 bool IsUnacked(QuicPacketSequenceNumber sequence_number) const; | 37 bool IsUnacked(QuicPacketSequenceNumber sequence_number) const; |
| 36 | 38 |
| 37 // Sets the nack count to the max of the current nack count and |min_nacks|. | 39 // Sets the nack count to the max of the current nack count and |min_nacks|. |
| 38 void NackPacket(QuicPacketSequenceNumber sequence_number, | 40 void NackPacket(QuicPacketSequenceNumber sequence_number, |
| 39 size_t min_nacks); | 41 size_t min_nacks); |
| 40 | 42 |
| 41 // Marks |sequence_number| as no longer in flight. | 43 // Marks |sequence_number| as no longer in flight. |
| 42 void RemoveFromInFlight(QuicPacketSequenceNumber sequence_number); | 44 void RemoveFromInFlight(QuicPacketSequenceNumber sequence_number); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 67 | 69 |
| 68 // Returns the sum of bytes from all packets in flight. | 70 // Returns the sum of bytes from all packets in flight. |
| 69 QuicByteCount bytes_in_flight() const { | 71 QuicByteCount bytes_in_flight() const { |
| 70 return bytes_in_flight_; | 72 return bytes_in_flight_; |
| 71 } | 73 } |
| 72 | 74 |
| 73 // Returns the smallest sequence number of a serialized packet which has not | 75 // Returns the smallest sequence number of a serialized packet which has not |
| 74 // been acked by the peer. If there are no unacked packets, returns 0. | 76 // been acked by the peer. If there are no unacked packets, returns 0. |
| 75 QuicPacketSequenceNumber GetLeastUnacked() const; | 77 QuicPacketSequenceNumber GetLeastUnacked() const; |
| 76 | 78 |
| 77 // Sets a packet as sent with the sent time |sent_time|. Marks the packet | |
| 78 // as in flight if |set_in_flight| is true. | |
| 79 // Packets marked as in flight are expected to be marked as missing when they | |
| 80 // don't arrive, indicating the need for retransmission. | |
| 81 void SetSent(QuicPacketSequenceNumber sequence_number, | |
| 82 QuicTime sent_time, | |
| 83 QuicByteCount bytes_sent, | |
| 84 bool set_in_flight); | |
| 85 | |
| 86 // Restores the in flight status for a packet that was previously sent. | 79 // Restores the in flight status for a packet that was previously sent. |
| 87 void RestoreInFlight(QuicPacketSequenceNumber sequence_number); | 80 void RestoreInFlight(QuicPacketSequenceNumber sequence_number); |
| 88 | 81 |
| 89 // Clears all previous transmissions in order to make room in the ack frame | 82 // Clears all previous transmissions in order to make room in the ack frame |
| 90 // for newly acked packets. | 83 // for newly acked packets. |
| 91 void ClearAllPreviousRetransmissions(); | 84 void ClearAllPreviousRetransmissions(); |
| 92 | 85 |
| 93 typedef std::deque<TransmissionInfo> UnackedPacketMap; | 86 typedef std::deque<TransmissionInfo> UnackedPacketMap; |
| 94 | 87 |
| 95 typedef UnackedPacketMap::const_iterator const_iterator; | 88 typedef UnackedPacketMap::const_iterator const_iterator; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 123 |
| 131 // Increases the largest observed. Any packets less or equal to | 124 // Increases the largest observed. Any packets less or equal to |
| 132 // |largest_acked_packet| are discarded if they are only for the RTT purposes. | 125 // |largest_acked_packet| are discarded if they are only for the RTT purposes. |
| 133 void IncreaseLargestObserved(QuicPacketSequenceNumber largest_observed); | 126 void IncreaseLargestObserved(QuicPacketSequenceNumber largest_observed); |
| 134 | 127 |
| 135 // Remove any packets no longer needed for retransmission, congestion, or | 128 // Remove any packets no longer needed for retransmission, congestion, or |
| 136 // RTT measurement purposes. | 129 // RTT measurement purposes. |
| 137 void RemoveObsoletePackets(); | 130 void RemoveObsoletePackets(); |
| 138 | 131 |
| 139 private: | 132 private: |
| 133 // Called when a packet is retransmitted with a new sequence number. |
| 134 // |old_sequence_number| will remain unacked, but will have no |
| 135 // retransmittable data associated with it. A transmission info will be |
| 136 // created for |new_sequence_number| and returned. |
| 137 TransmissionInfo OnRetransmittedPacket( |
| 138 QuicPacketSequenceNumber old_sequence_number, |
| 139 QuicPacketSequenceNumber new_sequence_number, |
| 140 TransmissionType transmission_type); |
| 141 |
| 140 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info); | 142 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info); |
| 141 | 143 |
| 142 // Returns true if the packet no longer has a purpose in the map. | 144 // Returns true if the packet no longer has a purpose in the map. |
| 143 bool IsPacketUseless(QuicPacketSequenceNumber sequence_number, | 145 bool IsPacketUseless(QuicPacketSequenceNumber sequence_number, |
| 144 const TransmissionInfo& info) const; | 146 const TransmissionInfo& info) const; |
| 145 // Returns true if the packet is useless or it's only purpose is RTT | 147 // Returns true if the packet is useless or it's only purpose is RTT |
| 146 // measurement, and it's old enough that is unlikely to ever happen. | 148 // measurement, and it's old enough that is unlikely to ever happen. |
| 147 bool IsPacketRemovable(QuicPacketSequenceNumber sequence_number, | 149 bool IsPacketRemovable(QuicPacketSequenceNumber sequence_number, |
| 148 const TransmissionInfo& info) const; | 150 const TransmissionInfo& info) const; |
| 149 | 151 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 165 size_t bytes_in_flight_; | 167 size_t bytes_in_flight_; |
| 166 // Number of retransmittable crypto handshake packets. | 168 // Number of retransmittable crypto handshake packets. |
| 167 size_t pending_crypto_packet_count_; | 169 size_t pending_crypto_packet_count_; |
| 168 | 170 |
| 169 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap); | 171 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap); |
| 170 }; | 172 }; |
| 171 | 173 |
| 172 } // namespace net | 174 } // namespace net |
| 173 | 175 |
| 174 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ | 176 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ |
| OLD | NEW |