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

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

Issue 11958018: Queueing QUIC frames to be resent instead of packets and packing RST frames with acks and congestio… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/quic/quic_connection.cc » ('j') | net/quic/quic_connection.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The entity that handles framing writes for a Quic client or server. 5 // The entity that handles framing writes for a Quic client or server.
6 // Each QuicSession will have a connection associated with it. 6 // Each QuicSession will have a connection associated with it.
7 // 7 //
8 // On the server side, the Dispatcher handles the raw reads, and hands off 8 // On the server side, the Dispatcher handles the raw reads, and hands off
9 // packets via ProcessUdpPacket for framing and processing. 9 // packets via ProcessUdpPacket for framing and processing.
10 // 10 //
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface { 130 class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface {
131 public: 131 public:
132 // Constructs a new QuicConnection for the specified |guid| and |address|. 132 // Constructs a new QuicConnection for the specified |guid| and |address|.
133 // |helper| will be owned by this connection. 133 // |helper| will be owned by this connection.
134 QuicConnection(QuicGuid guid, 134 QuicConnection(QuicGuid guid,
135 IPEndPoint address, 135 IPEndPoint address,
136 QuicConnectionHelperInterface* helper); 136 QuicConnectionHelperInterface* helper);
137 virtual ~QuicConnection(); 137 virtual ~QuicConnection();
138 138
139 static void DeleteEnclosedFrame(QuicFrame* frame);
139 140
140 // Send the data payload to the peer. 141 // Send the data payload to the peer.
141 // Returns a pair with the number of bytes consumed from data, and a boolean 142 // Returns a pair with the number of bytes consumed from data, and a boolean
142 // indicating if the fin bit was consumed. This does not indicate the data 143 // indicating if the fin bit was consumed. This does not indicate the data
143 // has been sent on the wire: it may have been turned into a packet and queued 144 // has been sent on the wire: it may have been turned into a packet and queued
144 // if the socket was unexpectedly blocked. 145 // if the socket was unexpectedly blocked.
145 QuicConsumedData SendStreamData(QuicStreamId id, 146 QuicConsumedData SendStreamData(QuicStreamId id,
146 base::StringPiece data, 147 base::StringPiece data,
147 QuicStreamOffset offset, 148 QuicStreamOffset offset,
148 bool fin, 149 bool fin,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 bool ShouldSimulateLostPacket(); 227 bool ShouldSimulateLostPacket();
227 228
228 // Sets up a packet with an QuicAckFrame and sends it out. 229 // Sets up a packet with an QuicAckFrame and sends it out.
229 void SendAck(); 230 void SendAck();
230 231
231 protected: 232 protected:
232 // Send a packet to the peer. If should_resend is true, this packet contains 233 // Send a packet to the peer. If should_resend is true, this packet contains
233 // data, and contents will be resent with a new sequence number if we don't 234 // data, and contents will be resent with a new sequence number if we don't
234 // get an ack. If force is true, then the packet will be sent immediately and 235 // get an ack. If force is true, then the packet will be sent immediately and
235 // the send scheduler will not be consulted. If is_retransmit is true, this 236 // the send scheduler will not be consulted. If is_retransmit is true, this
236 // packet is being retransmitted with a new sequence number. 237 // packet is being retransmitted with a new sequence number. Always takes
238 // ownership of packet.
237 // TODO(wtc): none of the callers check the return value. 239 // TODO(wtc): none of the callers check the return value.
238 virtual bool SendPacket(QuicPacketSequenceNumber number, 240 virtual bool SendPacket(QuicPacketSequenceNumber number,
239 QuicPacket* packet, 241 QuicPacket* packet,
240 bool should_resend, 242 bool should_resend,
241 bool force, 243 bool force,
242 bool is_retransmit); 244 bool is_retransmit);
243 245
244 // Make sure an ack we got from our peer is sane. 246 // Make sure an ack we got from our peer is sane.
245 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); 247 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
246 248
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 retransmit(retransmit) { 280 retransmit(retransmit) {
279 } 281 }
280 282
281 QuicPacketSequenceNumber sequence_number; 283 QuicPacketSequenceNumber sequence_number;
282 QuicPacket* packet; 284 QuicPacket* packet;
283 bool resend; 285 bool resend;
284 bool retransmit; 286 bool retransmit;
285 }; 287 };
286 288
287 struct UnackedPacket { 289 struct UnackedPacket {
288 explicit UnackedPacket(QuicPacket* packet) 290 explicit UnackedPacket(QuicFrames unacked_frames);
289 : packet(packet), 291 UnackedPacket(QuicFrames unacked_frames, std::string data);
290 number_nacks(0) { 292 ~UnackedPacket();
291 } 293
292 QuicPacket* packet; 294 QuicFrames frames;
293 uint8 number_nacks; 295 uint8 number_nacks;
296 // Data referenced by the StringPiece of a QuicStreamFrame.
297 std::string data;
294 }; 298 };
295 299
296 typedef std::list<QueuedPacket> QueuedPacketList; 300 typedef std::list<QueuedPacket> QueuedPacketList;
297 typedef base::hash_map<QuicPacketSequenceNumber, 301 typedef base::hash_map<QuicPacketSequenceNumber,
298 UnackedPacket> UnackedPacketMap; 302 UnackedPacket*> UnackedPacketMap;
299 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; 303 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap;
300 304
301 // The amount of time we wait before resending a packet. 305 // The amount of time we wait before resending a packet.
302 static const QuicTime::Delta DefaultResendTime() { 306 static const QuicTime::Delta DefaultResendTime() {
303 return QuicTime::Delta::FromMilliseconds(500); 307 return QuicTime::Delta::FromMilliseconds(500);
304 } 308 }
305 309
310 static void DeleteUnackedPacket(UnackedPacket* unacked);
311 static bool ShouldResend(const QuicFrame& frame);
312
306 // Checks if a packet can be written now, and sets the timer if necessary. 313 // Checks if a packet can be written now, and sets the timer if necessary.
307 bool CanWrite(bool is_retransmit); 314 bool CanWrite(bool is_retransmit);
308 315
309 // Writes as much queued data as possible. The connection must not be 316 // Writes as much queued data as possible. The connection must not be
310 // blocked when this is called. 317 // blocked when this is called.
311 bool WriteData(); 318 bool WriteData();
312 319
313 // If a packet can be revived from the current FEC group, then 320 // If a packet can be revived from the current FEC group, then
314 // revive and process the packet. 321 // revive and process the packet.
315 void MaybeProcessRevivedPacket(); 322 void MaybeProcessRevivedPacket();
(...skipping 27 matching lines...) Expand all
343 bool should_send_congestion_feedback_; 350 bool should_send_congestion_feedback_;
344 QuicAckFrame outgoing_ack_; 351 QuicAckFrame outgoing_ack_;
345 QuicCongestionFeedbackFrame outgoing_congestion_feedback_; 352 QuicCongestionFeedbackFrame outgoing_congestion_feedback_;
346 353
347 // Track some client state so we can do less bookkeeping 354 // Track some client state so we can do less bookkeeping
348 QuicPacketSequenceNumber largest_seen_packet_with_ack_; 355 QuicPacketSequenceNumber largest_seen_packet_with_ack_;
349 QuicPacketSequenceNumber peer_largest_observed_packet_; 356 QuicPacketSequenceNumber peer_largest_observed_packet_;
350 QuicPacketSequenceNumber peer_least_packet_awaiting_ack_; 357 QuicPacketSequenceNumber peer_least_packet_awaiting_ack_;
351 358
352 // When new packets are created which may be resent, they are added 359 // When new packets are created which may be resent, they are added
353 // to this map, which contains owning pointers. 360 // to this map, which contains owning pointers to the contained frames.
354 UnackedPacketMap unacked_packets_; 361 UnackedPacketMap unacked_packets_;
355 362
356 // When packets could not be sent because the socket was not writable, 363 // When packets could not be sent because the socket was not writable,
357 // they are added to this list. For packets that are not resendable, this 364 // they are added to this list. All corresponding frames are in
358 // list contains owning pointers, since they are not added to 365 // unacked_packets_ if they are to be resent.
359 // unacked_packets_.
360 QueuedPacketList queued_packets_; 366 QueuedPacketList queued_packets_;
361 367
368 // Pending control frames, besides the ack and congestion control frames.
369 QuicFrames queued_control_frames_;
370
362 // True when the socket becomes unwritable. 371 // True when the socket becomes unwritable.
363 bool write_blocked_; 372 bool write_blocked_;
364 373
365 FecGroupMap group_map_; 374 FecGroupMap group_map_;
366 QuicPacketHeader revived_header_; 375 QuicPacketHeader revived_header_;
367 scoped_array<char> revived_payload_; 376 scoped_array<char> revived_payload_;
368 377
369 QuicConnectionVisitorInterface* visitor_; 378 QuicConnectionVisitorInterface* visitor_;
370 QuicPacketCreator packet_creator_; 379 QuicPacketCreator packet_creator_;
371 380
(...skipping 16 matching lines...) Expand all
388 bool received_truncated_ack_; 397 bool received_truncated_ack_;
389 398
390 bool send_ack_in_response_to_packet_; 399 bool send_ack_in_response_to_packet_;
391 400
392 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 401 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
393 }; 402 };
394 403
395 } // namespace net 404 } // namespace net
396 405
397 #endif // NET_QUIC_QUIC_CONNECTION_H_ 406 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_connection.cc » ('j') | net/quic/quic_connection.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698