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

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

Issue 103973007: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for android compile error Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_reliable_client_stream_test.cc ('k') | net/quic/quic_sent_packet_manager.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 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 const QuicClock* clock, 72 const QuicClock* clock,
73 CongestionFeedbackType congestion_type); 73 CongestionFeedbackType congestion_type);
74 virtual ~QuicSentPacketManager(); 74 virtual ~QuicSentPacketManager();
75 75
76 virtual void SetFromConfig(const QuicConfig& config); 76 virtual void SetFromConfig(const QuicConfig& config);
77 77
78 virtual void SetMaxPacketSize(QuicByteCount max_packet_size); 78 virtual void SetMaxPacketSize(QuicByteCount max_packet_size);
79 79
80 // Called when a new packet is serialized. If the packet contains 80 // Called when a new packet is serialized. If the packet contains
81 // retransmittable data, it will be added to the unacked packet map. 81 // retransmittable data, it will be added to the unacked packet map.
82 void OnSerializedPacket(const SerializedPacket& serialized_packet, 82 void OnSerializedPacket(const SerializedPacket& serialized_packet);
83 QuicTime serialized_time);
84 83
85 // Called when a packet is retransmitted with a new sequence number. 84 // Called when a packet is retransmitted with a new sequence number.
86 // Replaces the old entry in the unacked packet map with the new 85 // Replaces the old entry in the unacked packet map with the new
87 // sequence number. 86 // sequence number.
88 void OnRetransmittedPacket(QuicPacketSequenceNumber old_sequence_number, 87 void OnRetransmittedPacket(QuicPacketSequenceNumber old_sequence_number,
89 QuicPacketSequenceNumber new_sequence_number); 88 QuicPacketSequenceNumber new_sequence_number);
90 89
91 // Processes the incoming ack and returns true if the retransmission or ack 90 // Processes the incoming ack and returns true if the retransmission or ack
92 // alarm should be reset. 91 // alarm should be reset.
93 bool OnIncomingAck(const ReceivedPacketInfo& received_info, 92 bool OnIncomingAck(const ReceivedPacketInfo& received_info,
94 QuicTime ack_receive_time); 93 QuicTime ack_receive_time);
95 94
96 // Discards any information for the packet corresponding to |sequence_number|. 95 // Discards any information for the packet corresponding to |sequence_number|.
97 // If this packet has been retransmitted, information on those packets 96 // If this packet has been retransmitted, information on those packets
98 // will be discarded as well. 97 // will be discarded as well.
99 void DiscardUnackedPacket(QuicPacketSequenceNumber sequence_number); 98 void DiscardUnackedPacket(QuicPacketSequenceNumber sequence_number);
100 99
101 // Discards all information about fec packet |sequence_number|.
102 void DiscardFecPacket(QuicPacketSequenceNumber sequence_number);
103
104 // Returns true if the non-FEC packet |sequence_number| is unacked. 100 // Returns true if the non-FEC packet |sequence_number| is unacked.
105 bool IsUnacked(QuicPacketSequenceNumber sequence_number) const; 101 bool IsUnacked(QuicPacketSequenceNumber sequence_number) const;
106 102
107 // Requests retransmission of all unacked packets of |retransmission_type|. 103 // Requests retransmission of all unacked packets of |retransmission_type|.
108 void RetransmitUnackedPackets(RetransmissionType retransmission_type); 104 void RetransmitUnackedPackets(RetransmissionType retransmission_type);
109 105
110 // Returns true if the unacked packet |sequence_number| has retransmittable 106 // Returns true if the unacked packet |sequence_number| has retransmittable
111 // frames. This will only return false if the packet has been acked, if a 107 // frames. This will only return false if the packet has been acked, if a
112 // previous transmission of this packet was ACK'd, or if this packet has been 108 // previous transmission of this packet was ACK'd, or if this packet has been
113 // retransmitted as with different sequence number. 109 // retransmitted as with different sequence number.
114 bool HasRetransmittableFrames(QuicPacketSequenceNumber sequence_number) const; 110 bool HasRetransmittableFrames(QuicPacketSequenceNumber sequence_number) const;
115 111
116 // Returns true if there are pending retransmissions. 112 // Returns true if there are pending retransmissions.
117 bool HasPendingRetransmissions() const; 113 bool HasPendingRetransmissions() const;
118 114
119 // Retrieves the next pending retransmission. 115 // Retrieves the next pending retransmission.
120 PendingRetransmission NextPendingRetransmission(); 116 PendingRetransmission NextPendingRetransmission();
121 117
122 // Returns the time the fec packet was sent.
123 QuicTime GetFecSentTime(QuicPacketSequenceNumber sequence_number) const;
124
125 // Returns true if there are any unacked packets.
126 bool HasUnackedPackets() const; 118 bool HasUnackedPackets() const;
127 119
128 // Returns the number of unacked packets which have retransmittable frames. 120 // Returns the number of unacked packets which have retransmittable frames.
129 size_t GetNumRetransmittablePackets() const; 121 size_t GetNumRetransmittablePackets() const;
130 122
131 // Returns true if there are any unacked FEC packets.
132 bool HasUnackedFecPackets() const;
133
134 // Returns the smallest sequence number of a sent packet which has not been 123 // Returns the smallest sequence number of a sent packet which has not been
135 // acked by the peer. Excludes any packets which have been retransmitted 124 // acked by the peer. Excludes any packets which have been retransmitted
136 // with a new sequence number. If all packets have been acked, returns the 125 // with a new sequence number. If all packets have been acked, returns the
137 // sequence number of the next packet that will be sent. 126 // sequence number of the next packet that will be sent.
138 QuicPacketSequenceNumber GetLeastUnackedSentPacket() const; 127 QuicPacketSequenceNumber GetLeastUnackedSentPacket() const;
139 128
140 // Returns the smallest sequence number of a sent fec packet which has not
141 // been acked by the peer. If all packets have been acked, returns the
142 // sequence number of the next packet that will be sent.
143 QuicPacketSequenceNumber GetLeastUnackedFecPacket() const;
144
145 // Returns the set of sequence numbers of all unacked packets. 129 // Returns the set of sequence numbers of all unacked packets.
130 // Test only.
146 SequenceNumberSet GetUnackedPackets() const; 131 SequenceNumberSet GetUnackedPackets() const;
147 132
148 // Returns true if |sequence_number| is a previous transmission of packet. 133 // Returns true if |sequence_number| is a previous transmission of packet.
149 bool IsPreviousTransmission(QuicPacketSequenceNumber sequence_number) const; 134 bool IsPreviousTransmission(QuicPacketSequenceNumber sequence_number) const;
150 135
151 // TODO(ianswett): Combine the congestion control related methods below with 136 // TODO(ianswett): Combine the congestion control related methods below with
152 // some of the methods above and cleanup the resulting code. 137 // some of the methods above and cleanup the resulting code.
153 // Called when we have received an ack frame from peer. 138 // Called when we have received an ack frame from peer.
154 // Returns a set containing all the sequence numbers to be nack retransmitted 139 // Returns a set containing all the sequence numbers to be nack retransmitted
155 // as a result of the ack. 140 // as a result of the ack.
(...skipping 10 matching lines...) Expand all
166 // the number of bytes sent and if they were retransmitted. 151 // the number of bytes sent and if they were retransmitted.
167 virtual void OnPacketSent(QuicPacketSequenceNumber sequence_number, 152 virtual void OnPacketSent(QuicPacketSequenceNumber sequence_number,
168 QuicTime sent_time, 153 QuicTime sent_time,
169 QuicByteCount bytes, 154 QuicByteCount bytes,
170 TransmissionType transmission_type, 155 TransmissionType transmission_type,
171 HasRetransmittableData has_retransmittable_data); 156 HasRetransmittableData has_retransmittable_data);
172 157
173 // Called when the retransmission timer expires. 158 // Called when the retransmission timer expires.
174 virtual void OnRetransmissionTimeout(); 159 virtual void OnRetransmissionTimeout();
175 160
176 // Called when the fec timout timer expires. Returns the next timeout of the
177 // FEC timer if it should be reset, and QuicTime::Zero() otherwise.
178 virtual QuicTime OnAbandonFecTimeout();
179
180 // Called when a packet is timed out, such as an RTO. Removes the bytes from 161 // Called when a packet is timed out, such as an RTO. Removes the bytes from
181 // the congestion manager, but does not change the congestion window size. 162 // the congestion manager, but does not change the congestion window size.
182 virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number); 163 virtual void OnPacketAbandoned(QuicPacketSequenceNumber sequence_number);
183 164
184 // Calculate the time until we can send the next packet to the wire. 165 // Calculate the time until we can send the next packet to the wire.
185 // Note 1: When kUnknownWaitTime is returned, there is no need to poll 166 // Note 1: When kUnknownWaitTime is returned, there is no need to poll
186 // TimeUntilSend again until we receive an OnIncomingAckFrame event. 167 // TimeUntilSend again until we receive an OnIncomingAckFrame event.
187 // Note 2: Send algorithms may or may not use |retransmit| in their 168 // Note 2: Send algorithms may or may not use |retransmit| in their
188 // calculations. 169 // calculations.
189 virtual QuicTime::Delta TimeUntilSend(QuicTime now, 170 virtual QuicTime::Delta TimeUntilSend(QuicTime now,
190 TransmissionType transmission_type, 171 TransmissionType transmission_type,
191 HasRetransmittableData retransmittable, 172 HasRetransmittableData retransmittable,
192 IsHandshake handshake); 173 IsHandshake handshake);
193 174
194 const QuicTime::Delta DefaultRetransmissionTime();
195
196 // Returns amount of time for delayed ack timer. 175 // Returns amount of time for delayed ack timer.
197 const QuicTime::Delta DelayedAckTime(); 176 const QuicTime::Delta DelayedAckTime();
198 177
199 // Returns the current RTO delay. 178 // Returns the current RTO delay.
200 const QuicTime::Delta GetRetransmissionDelay() const; 179 const QuicTime::Delta GetRetransmissionDelay() const;
201 180
202 // Returns the estimated smoothed RTT calculated by the congestion algorithm. 181 // Returns the estimated smoothed RTT calculated by the congestion algorithm.
203 const QuicTime::Delta SmoothedRtt() const; 182 const QuicTime::Delta SmoothedRtt() const;
204 183
205 // Returns the estimated bandwidth calculated by the congestion algorithm. 184 // Returns the estimated bandwidth calculated by the congestion algorithm.
206 QuicBandwidth BandwidthEstimate() const; 185 QuicBandwidth BandwidthEstimate() const;
207 186
208 // Returns the size of the current congestion window in bytes. Note, this is 187 // Returns the size of the current congestion window in bytes. Note, this is
209 // not the *available* window. Some send algorithms may not use a congestion 188 // not the *available* window. Some send algorithms may not use a congestion
210 // window and will return 0. 189 // window and will return 0.
211 QuicByteCount GetCongestionWindow() const; 190 QuicByteCount GetCongestionWindow() const;
212 191
213 // Enables pacing if it has not already been enabled, and if 192 // Enables pacing if it has not already been enabled, and if
214 // FLAGS_enable_quic_pacing is set. 193 // FLAGS_enable_quic_pacing is set.
215 void MaybeEnablePacing(); 194 void MaybeEnablePacing();
216 195
217 bool using_pacing() const { return using_pacing_; } 196 bool using_pacing() const { return using_pacing_; }
218 197
219 198
220 private: 199 private:
221 friend class test::QuicConnectionPeer; 200 friend class test::QuicConnectionPeer;
222 friend class test::QuicSentPacketManagerPeer; 201 friend class test::QuicSentPacketManagerPeer;
223 202
224 struct TransmissionInfo { 203 struct TransmissionInfo {
225 TransmissionInfo() {} 204 TransmissionInfo()
205 : retransmittable_frames(NULL),
206 sequence_number_length(PACKET_1BYTE_SEQUENCE_NUMBER),
207 sent_time(QuicTime::Zero()) { }
226 TransmissionInfo(RetransmittableFrames* retransmittable_frames, 208 TransmissionInfo(RetransmittableFrames* retransmittable_frames,
227 QuicSequenceNumberLength sequence_number_length) 209 QuicSequenceNumberLength sequence_number_length)
228 : retransmittable_frames(retransmittable_frames), 210 : retransmittable_frames(retransmittable_frames),
229 sequence_number_length(sequence_number_length) { 211 sequence_number_length(sequence_number_length),
212 sent_time(QuicTime::Zero()) {
230 } 213 }
231 214
232 RetransmittableFrames* retransmittable_frames; 215 RetransmittableFrames* retransmittable_frames;
233 QuicSequenceNumberLength sequence_number_length; 216 QuicSequenceNumberLength sequence_number_length;
217 // Zero when the packet is serialized, non-zero once it's sent.
218 QuicTime sent_time;
234 }; 219 };
235 220
236 typedef linked_hash_map<QuicPacketSequenceNumber, 221 typedef linked_hash_map<QuicPacketSequenceNumber,
237 TransmissionInfo> UnackedPacketMap; 222 TransmissionInfo> UnackedPacketMap;
238 typedef linked_hash_map<QuicPacketSequenceNumber, 223 typedef linked_hash_map<QuicPacketSequenceNumber,
239 QuicTime> UnackedFecPacketMap;
240 typedef linked_hash_map<QuicPacketSequenceNumber,
241 TransmissionType> PendingRetransmissionMap; 224 TransmissionType> PendingRetransmissionMap;
242 typedef base::hash_map<QuicPacketSequenceNumber, SequenceNumberSet*> 225 typedef base::hash_map<QuicPacketSequenceNumber, SequenceNumberSet*>
243 PreviousTransmissionMap; 226 PreviousTransmissionMap;
244 227
245 // Process the incoming ack looking for newly ack'd data packets. 228 // Process the incoming ack looking for newly ack'd data packets.
246 void HandleAckForSentPackets(const ReceivedPacketInfo& received_info); 229 void HandleAckForSentPackets(const ReceivedPacketInfo& received_info);
247 230
248 // Process the incoming ack looking for newly ack'd FEC packets.
249 void HandleAckForSentFecPackets(const ReceivedPacketInfo& received_info);
250
251 // Update the RTT if the ack is for the largest acked sequence number. 231 // Update the RTT if the ack is for the largest acked sequence number.
252 void MaybeUpdateRTT(const ReceivedPacketInfo& received_info, 232 void MaybeUpdateRTT(const ReceivedPacketInfo& received_info,
253 const QuicTime& ack_receive_time); 233 const QuicTime& ack_receive_time);
254 234
255 // Marks |sequence_number| as having been seen by the peer. Returns an 235 // Marks |sequence_number| as having been seen by the peer. Returns an
256 // iterator to the next remaining unacked packet. 236 // iterator to the next remaining unacked packet.
257 UnackedPacketMap::iterator MarkPacketReceivedByPeer( 237 UnackedPacketMap::iterator MarkPacketReceivedByPeer(
258 QuicPacketSequenceNumber sequence_number); 238 QuicPacketSequenceNumber sequence_number);
259 239
260 // Simply removes the entries, if any, from the unacked packet map 240 // Simply removes the entries, if any, from the unacked packet map
(...skipping 15 matching lines...) Expand all
276 // most recently transmitted as. 256 // most recently transmitted as.
277 QuicPacketSequenceNumber GetMostRecentTransmission( 257 QuicPacketSequenceNumber GetMostRecentTransmission(
278 QuicPacketSequenceNumber sequence_number) const; 258 QuicPacketSequenceNumber sequence_number) const;
279 259
280 // Clears up to |num_to_clear| previous transmissions in order to make room 260 // Clears up to |num_to_clear| previous transmissions in order to make room
281 // in the ack frame for new acks. 261 // in the ack frame for new acks.
282 void ClearPreviousRetransmissions(size_t num_to_clear); 262 void ClearPreviousRetransmissions(size_t num_to_clear);
283 263
284 void CleanupPacketHistory(); 264 void CleanupPacketHistory();
285 265
286 // When new packets are created which may be retransmitted, they are added 266 // Newly serialized retransmittable and fec packets are added to this map,
287 // to this map, which contains owning pointers to the contained frames. If 267 // which contains owning pointers to any contained frames. If a packet is
288 // a packet is retransmitted, this map will contain entries for both the old 268 // retransmitted, this map will contain entries for both the old and the new
289 // and the new packet. The old packet's retransmittable frames entry will be 269 // packet. The old packet's retransmittable frames entry will be NULL, while
290 // NULL, while the new packet's entry will contain the frames to retransmit. 270 // the new packet's entry will contain the frames to retransmit.
291 // If the old packet is acked before the new packet, then the old entry will 271 // If the old packet is acked before the new packet, then the old entry will
292 // be removed from the map and the new entry's retransmittable frames will be 272 // be removed from the map and the new entry's retransmittable frames will be
293 // set to NULL. 273 // set to NULL.
294 UnackedPacketMap unacked_packets_; 274 UnackedPacketMap unacked_packets_;
295 275
296 // Pending fec packets that have not been acked yet. These packets need to be
297 // cleared out of the cgst_window after a timeout since FEC packets are never
298 // retransmitted.
299 UnackedFecPacketMap unacked_fec_packets_;
300
301 // Pending retransmissions which have not been packetized and sent yet. 276 // Pending retransmissions which have not been packetized and sent yet.
302 PendingRetransmissionMap pending_retransmissions_; 277 PendingRetransmissionMap pending_retransmissions_;
303 278
304 // Map from sequence number to set of all sequence number that this packet has 279 // Map from sequence number to set of all sequence number that this packet has
305 // been transmitted as. If a packet has not been retransmitted, it will not 280 // been transmitted as. If a packet has not been retransmitted, it will not
306 // have an entry in this map. If any transmission of a packet has been acked 281 // have an entry in this map. If any transmission of a packet has been acked
307 // it will not have an entry in this map. 282 // it will not have an entry in this map.
308 PreviousTransmissionMap previous_transmissions_map_; 283 PreviousTransmissionMap previous_transmissions_map_;
309 284
310 // Tracks if the connection was created by the server. 285 // Tracks if the connection was created by the server.
(...skipping 17 matching lines...) Expand all
328 // Number of times the RTO timer has fired in a row without receiving an ack. 303 // Number of times the RTO timer has fired in a row without receiving an ack.
329 size_t consecutive_rto_count_; 304 size_t consecutive_rto_count_;
330 bool using_pacing_; 305 bool using_pacing_;
331 306
332 DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager); 307 DISALLOW_COPY_AND_ASSIGN(QuicSentPacketManager);
333 }; 308 };
334 309
335 } // namespace net 310 } // namespace net
336 311
337 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_ 312 #endif // NET_QUIC_QUIC_SENT_PACKET_MANAGER_H_
OLDNEW
« no previous file with comments | « net/quic/quic_reliable_client_stream_test.cc ('k') | net/quic/quic_sent_packet_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698