Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Side by Side Diff: net/quic/quic_unacked_packet_map.h

Issue 515303003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix for 409191 Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_sent_packet_manager_test.cc ('k') | net/quic/quic_unacked_packet_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/base/linked_hash_map.h" 8 #include <deque>
9
9 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
10 11
11 namespace net { 12 namespace net {
12 13
13 // Class which tracks unacked packets for three purposes: 14 // Class which tracks unacked packets for three purposes:
14 // 1) Track retransmittable data, including multiple transmissions of frames. 15 // 1) Track retransmittable data, including multiple transmissions of frames.
15 // 2) Track packets and bytes in flight for congestion control. 16 // 2) Track packets and bytes in flight for congestion control.
16 // 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.
17 class NET_EXPORT_PRIVATE QuicUnackedPacketMap { 18 class NET_EXPORT_PRIVATE QuicUnackedPacketMap {
18 public: 19 public:
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return largest_observed_; 65 return largest_observed_;
65 } 66 }
66 67
67 // Returns the sum of bytes from all packets in flight. 68 // Returns the sum of bytes from all packets in flight.
68 QuicByteCount bytes_in_flight() const { 69 QuicByteCount bytes_in_flight() const {
69 return bytes_in_flight_; 70 return bytes_in_flight_;
70 } 71 }
71 72
72 // Returns the smallest sequence number of a serialized packet which has not 73 // Returns the smallest sequence number of a serialized packet which has not
73 // been acked by the peer. If there are no unacked packets, returns 0. 74 // been acked by the peer. If there are no unacked packets, returns 0.
74 QuicPacketSequenceNumber GetLeastUnackedSentPacket() const; 75 QuicPacketSequenceNumber GetLeastUnacked() const;
75 76
76 // Sets a packet as sent with the sent time |sent_time|. Marks the packet 77 // Sets a packet as sent with the sent time |sent_time|. Marks the packet
77 // as in flight if |set_in_flight| is true. 78 // as in flight if |set_in_flight| is true.
78 // Packets marked as in flight are expected to be marked as missing when they 79 // Packets marked as in flight are expected to be marked as missing when they
79 // don't arrive, indicating the need for retransmission. 80 // don't arrive, indicating the need for retransmission.
80 void SetSent(QuicPacketSequenceNumber sequence_number, 81 void SetSent(QuicPacketSequenceNumber sequence_number,
81 QuicTime sent_time, 82 QuicTime sent_time,
82 QuicByteCount bytes_sent, 83 QuicByteCount bytes_sent,
83 bool set_in_flight); 84 bool set_in_flight);
84 85
85 // Restores the in flight status for a packet that was previously sent. 86 // Restores the in flight status for a packet that was previously sent.
86 void RestoreInFlight(QuicPacketSequenceNumber sequence_number); 87 void RestoreInFlight(QuicPacketSequenceNumber sequence_number);
87 88
88 // Clears up to |num_to_clear| previous transmissions in order to make room 89 // Clears up to |num_to_clear| previous transmissions in order to make room
89 // in the ack frame for new acks. 90 // in the ack frame for new acks.
90 void ClearPreviousRetransmissions(size_t num_to_clear); 91 void ClearPreviousRetransmissions(size_t num_to_clear);
91 92
92 typedef linked_hash_map<QuicPacketSequenceNumber, 93 typedef std::deque<TransmissionInfo> UnackedPacketMap;
93 TransmissionInfo> UnackedPacketMap;
94 94
95 typedef UnackedPacketMap::const_iterator const_iterator; 95 typedef UnackedPacketMap::const_iterator const_iterator;
96 96
97 const_iterator begin() const { return unacked_packets_.begin(); } 97 const_iterator begin() const { return unacked_packets_.begin(); }
98 const_iterator end() const { return unacked_packets_.end(); } 98 const_iterator end() const { return unacked_packets_.end(); }
99 99
100 // Returns true if there are unacked packets that are in flight. 100 // Returns true if there are unacked packets that are in flight.
101 bool HasInFlightPackets() const; 101 bool HasInFlightPackets() const;
102 102
103 // Returns the TransmissionInfo associated with |sequence_number|, which 103 // Returns the TransmissionInfo associated with |sequence_number|, which
104 // must be unacked. 104 // must be unacked.
105 const TransmissionInfo& GetTransmissionInfo( 105 const TransmissionInfo& GetTransmissionInfo(
106 QuicPacketSequenceNumber sequence_number) const; 106 QuicPacketSequenceNumber sequence_number) const;
107 107
108 // Returns the time that the last unacked packet was sent. 108 // Returns the time that the last unacked packet was sent.
109 QuicTime GetLastPacketSentTime() const; 109 QuicTime GetLastPacketSentTime() const;
110 110
111 // Returns the time that the first in flight packet was sent. 111 // Returns the time that the first in flight packet was sent.
112 QuicTime GetFirstInFlightPacketSentTime() const; 112 QuicTime GetFirstInFlightPacketSentTime() const;
113 113
114 // Returns the number of unacked packets. 114 // Returns the number of unacked packets.
115 size_t GetNumUnackedPackets() const; 115 size_t GetNumUnackedPacketsDebugOnly() const;
116 116
117 // Returns true if there are multiple packets in flight. 117 // Returns true if there are multiple packets in flight.
118 bool HasMultipleInFlightPackets() const; 118 bool HasMultipleInFlightPackets() const;
119 119
120 // Returns true if there are any pending crypto packets. 120 // Returns true if there are any pending crypto packets.
121 bool HasPendingCryptoPackets() const; 121 bool HasPendingCryptoPackets() const;
122 122
123 // Removes any retransmittable frames from this transmission or an associated 123 // Removes any retransmittable frames from this transmission or an associated
124 // transmission. It removes now useless transmissions, and disconnects any 124 // transmission. It removes now useless transmissions, and disconnects any
125 // other packets from other transmissions. 125 // other packets from other transmissions.
126 void RemoveRetransmittability(QuicPacketSequenceNumber sequence_number); 126 void RemoveRetransmittability(QuicPacketSequenceNumber sequence_number);
127 127
128 // Increases the largest observed. Any packets less or equal to 128 // Increases the largest observed. Any packets less or equal to
129 // |largest_acked_packet| are discarded if they are only for the RTT purposes. 129 // |largest_acked_packet| are discarded if they are only for the RTT purposes.
130 void IncreaseLargestObserved(QuicPacketSequenceNumber largest_observed); 130 void IncreaseLargestObserved(QuicPacketSequenceNumber largest_observed);
131 131
132 // Remove any packets no longer needed for retransmission, congestion, or
133 // RTT measurement purposes.
134 void RemoveObsoletePackets();
135
132 private: 136 private:
133 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info); 137 void MaybeRemoveRetransmittableFrames(TransmissionInfo* transmission_info);
134 138
135 // Returns true if the packet no longer has a purpose in the map. 139 // Returns true if the packet no longer has a purpose in the map.
136 bool IsPacketUseless(UnackedPacketMap::const_iterator it) const; 140 bool IsPacketUseless(QuicPacketSequenceNumber sequence_number,
141 const TransmissionInfo& info) const;
137 142
138 QuicPacketSequenceNumber largest_sent_packet_; 143 QuicPacketSequenceNumber largest_sent_packet_;
139 QuicPacketSequenceNumber largest_observed_; 144 QuicPacketSequenceNumber largest_observed_;
140 145
141 // Newly serialized retransmittable and fec packets are added to this map, 146 // Newly serialized retransmittable and fec packets are added to this map,
142 // which contains owning pointers to any contained frames. If a packet is 147 // which contains owning pointers to any contained frames. If a packet is
143 // retransmitted, this map will contain entries for both the old and the new 148 // retransmitted, this map will contain entries for both the old and the new
144 // packet. The old packet's retransmittable frames entry will be NULL, while 149 // packet. The old packet's retransmittable frames entry will be NULL, while
145 // the new packet's entry will contain the frames to retransmit. 150 // the new packet's entry will contain the frames to retransmit.
146 // If the old packet is acked before the new packet, then the old entry will 151 // If the old packet is acked before the new packet, then the old entry will
147 // be removed from the map and the new entry's retransmittable frames will be 152 // be removed from the map and the new entry's retransmittable frames will be
148 // set to NULL. 153 // set to NULL.
149 UnackedPacketMap unacked_packets_; 154 UnackedPacketMap unacked_packets_;
155 // The packet at the 0th index of unacked_packets_.
156 QuicPacketSequenceNumber least_unacked_;
150 157
151 size_t bytes_in_flight_; 158 size_t bytes_in_flight_;
152 // Number of retransmittable crypto handshake packets. 159 // Number of retransmittable crypto handshake packets.
153 size_t pending_crypto_packet_count_; 160 size_t pending_crypto_packet_count_;
154 161
155 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap); 162 DISALLOW_COPY_AND_ASSIGN(QuicUnackedPacketMap);
156 }; 163 };
157 164
158 } // namespace net 165 } // namespace net
159 166
160 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_ 167 #endif // NET_QUIC_QUIC_UNACKED_PACKET_MAP_H_
OLDNEW
« no previous file with comments | « net/quic/quic_sent_packet_manager_test.cc ('k') | net/quic/quic_unacked_packet_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698