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

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

Issue 16256017: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix for Android DEBUG builds with DEATH_TEST Created 7 years, 6 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
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // sent immediately and the send scheduler will not be consulted. 424 // sent immediately and the send scheduler will not be consulted.
425 bool WritePacket(EncryptionLevel level, 425 bool WritePacket(EncryptionLevel level,
426 QuicPacketSequenceNumber sequence_number, 426 QuicPacketSequenceNumber sequence_number,
427 QuicPacket* packet, 427 QuicPacket* packet,
428 HasRetransmittableData retransmittable, 428 HasRetransmittableData retransmittable,
429 Force force); 429 Force force);
430 430
431 // Make sure an ack we got from our peer is sane. 431 // Make sure an ack we got from our peer is sane.
432 bool ValidateAckFrame(const QuicAckFrame& incoming_ack); 432 bool ValidateAckFrame(const QuicAckFrame& incoming_ack);
433 433
434 // These two are called by OnAckFrame to update the appropriate internal
435 // state.
436 //
437 // Updates internal state based on incoming_ack.received_info
438 void UpdatePacketInformationReceivedByPeer(
439 const QuicAckFrame& incoming_ack);
440 // Updates internal state based in incoming_ack.sent_info
441 void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack);
442
443 QuicConnectionHelperInterface* helper() { return helper_.get(); } 434 QuicConnectionHelperInterface* helper() { return helper_.get(); }
444 435
445 protected: 436 protected:
446 QuicFramer framer_; 437 QuicFramer framer_;
447 438
448 private: 439 private:
449 friend class test::QuicConnectionPeer; 440 friend class test::QuicConnectionPeer;
450 441
451 // Packets which have not been written to the wire. 442 // Packets which have not been written to the wire.
452 // Owns the QuicPacket* packet. 443 // Owns the QuicPacket* packet.
(...skipping 10 matching lines...) Expand all
463 454
464 QuicPacketSequenceNumber sequence_number; 455 QuicPacketSequenceNumber sequence_number;
465 QuicPacket* packet; 456 QuicPacket* packet;
466 const EncryptionLevel encryption_level; 457 const EncryptionLevel encryption_level;
467 HasRetransmittableData retransmittable; 458 HasRetransmittableData retransmittable;
468 }; 459 };
469 460
470 struct RetransmissionInfo { 461 struct RetransmissionInfo {
471 explicit RetransmissionInfo(QuicPacketSequenceNumber sequence_number) 462 explicit RetransmissionInfo(QuicPacketSequenceNumber sequence_number)
472 : sequence_number(sequence_number), 463 : sequence_number(sequence_number),
473 scheduled_time(QuicTime::Zero()),
474 number_nacks(0), 464 number_nacks(0),
475 number_retransmissions(0) { 465 number_retransmissions(0) {
476 } 466 }
477 467
478 QuicPacketSequenceNumber sequence_number; 468 QuicPacketSequenceNumber sequence_number;
479 QuicTime scheduled_time;
480 size_t number_nacks; 469 size_t number_nacks;
481 size_t number_retransmissions; 470 size_t number_retransmissions;
482 }; 471 };
483 472
484 class RetransmissionInfoComparator { 473 struct RetransmissionTime {
474 RetransmissionTime(QuicPacketSequenceNumber sequence_number,
475 const QuicTime& scheduled_time,
476 bool for_fec)
477 : sequence_number(sequence_number),
478 scheduled_time(scheduled_time),
479 for_fec(for_fec) { }
480
481 QuicPacketSequenceNumber sequence_number;
482 QuicTime scheduled_time;
483 bool for_fec;
484 };
485
486 class RetransmissionTimeComparator {
485 public: 487 public:
486 bool operator()(const RetransmissionInfo& lhs, 488 bool operator()(const RetransmissionTime& lhs,
487 const RetransmissionInfo& rhs) const { 489 const RetransmissionTime& rhs) const {
488 DCHECK(lhs.scheduled_time.IsInitialized() && 490 DCHECK(lhs.scheduled_time.IsInitialized() &&
489 rhs.scheduled_time.IsInitialized()); 491 rhs.scheduled_time.IsInitialized());
490 return lhs.scheduled_time > rhs.scheduled_time; 492 return lhs.scheduled_time > rhs.scheduled_time;
491 } 493 }
492 }; 494 };
493 495
494 typedef std::list<QueuedPacket> QueuedPacketList; 496 typedef std::list<QueuedPacket> QueuedPacketList;
495 typedef linked_hash_map<QuicPacketSequenceNumber, 497 typedef linked_hash_map<QuicPacketSequenceNumber,
496 RetransmittableFrames*> UnackedPacketMap; 498 RetransmittableFrames*> UnackedPacketMap;
497 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap; 499 typedef std::map<QuicFecGroupNumber, QuicFecGroup*> FecGroupMap;
498 typedef base::hash_map<QuicPacketSequenceNumber, 500 typedef base::hash_map<QuicPacketSequenceNumber,
499 RetransmissionInfo> RetransmissionMap; 501 RetransmissionInfo> RetransmissionMap;
500 typedef std::priority_queue<RetransmissionInfo, 502 typedef std::priority_queue<RetransmissionTime,
501 std::vector<RetransmissionInfo>, 503 std::vector<RetransmissionTime>,
502 RetransmissionInfoComparator> 504 RetransmissionTimeComparator>
503 RetransmissionTimeouts; 505 RetransmissionTimeouts;
504 506
505 // Selects and updates the version of the protocol being used by selecting a 507 // Selects and updates the version of the protocol being used by selecting a
506 // version from |available_versions| which is also supported. Returns true if 508 // version from |available_versions| which is also supported. Returns true if
507 // such a version exists, false otherwise. 509 // such a version exists, false otherwise.
508 bool SelectMutualVersion(const QuicTagVector& available_versions); 510 bool SelectMutualVersion(const QuicTagVector& available_versions);
509 // Sends a version negotiation packet to the peer. 511 // Sends a version negotiation packet to the peer.
510 void SendVersionNegotiationPacket(); 512 void SendVersionNegotiationPacket();
511 513
512 void MaybeSetupRetransmission(QuicPacketSequenceNumber sequence_number); 514 void SetupRetransmission(QuicPacketSequenceNumber sequence_number);
513 bool IsRetransmission(QuicPacketSequenceNumber sequence_number); 515 bool IsRetransmission(QuicPacketSequenceNumber sequence_number);
514 516
517 void SetupAbandonFecTimer(QuicPacketSequenceNumber sequence_number);
518
515 // Drop packet corresponding to |sequence_number| by deleting entries from 519 // Drop packet corresponding to |sequence_number| by deleting entries from
516 // |unacked_packets_| and |retransmission_map_|, if present. We need to drop 520 // |unacked_packets_| and |retransmission_map_|, if present. We need to drop
517 // all packets with encryption level NONE after the default level has been set 521 // all packets with encryption level NONE after the default level has been set
518 // to FORWARD_SECURE. 522 // to FORWARD_SECURE.
519 void DropPacket(QuicPacketSequenceNumber sequence_number); 523 void DropPacket(QuicPacketSequenceNumber sequence_number);
520 524
521 // Writes as many queued packets as possible. The connection must not be 525 // Writes as many queued packets as possible. The connection must not be
522 // blocked when this is called. 526 // blocked when this is called.
523 bool WriteQueuedPackets(); 527 bool WriteQueuedPackets();
524 528
525 // If a packet can be revived from the current FEC group, then 529 // If a packet can be revived from the current FEC group, then
526 // revive and process the packet. 530 // revive and process the packet.
527 void MaybeProcessRevivedPacket(); 531 void MaybeProcessRevivedPacket();
528 532
533 void HandleAckForSentPackets(const QuicAckFrame& incoming_ack,
534 SequenceNumberSet* acked_packets);
535 void HandleAckForSentFecPackets(const QuicAckFrame& incoming_ack,
536 SequenceNumberSet* acked_packets);
537
538 // These two are called by OnAckFrame.
539 //
540 // Updates internal state based on incoming_ack.received_info
541 void UpdatePacketInformationReceivedByPeer(
542 const QuicAckFrame& incoming_ack);
543 // Updates internal state based on incoming_ack.sent_info
544 void UpdatePacketInformationSentByPeer(const QuicAckFrame& incoming_ack);
545
529 void UpdateOutgoingAck(); 546 void UpdateOutgoingAck();
530 547
531 void MaybeSendAckInResponseToPacket(); 548 void MaybeSendAckInResponseToPacket();
532 549
550 void MaybeAbandonFecPacket(QuicPacketSequenceNumber sequence_number);
551
533 // Get the FEC group associate with the last processed packet or NULL, if the 552 // Get the FEC group associate with the last processed packet or NULL, if the
534 // group has already been deleted. 553 // group has already been deleted.
535 QuicFecGroup* GetFecGroup(); 554 QuicFecGroup* GetFecGroup();
536 555
537 // Closes any FEC groups protecting packets before |sequence_number|. 556 // Closes any FEC groups protecting packets before |sequence_number|.
538 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number); 557 void CloseFecGroupsBefore(QuicPacketSequenceNumber sequence_number);
539 558
540 scoped_ptr<QuicConnectionHelperInterface> helper_; 559 scoped_ptr<QuicConnectionHelperInterface> helper_;
541 EncryptionLevel encryption_level_; 560 EncryptionLevel encryption_level_;
542 const QuicClock* clock_; 561 const QuicClock* clock_;
(...skipping 22 matching lines...) Expand all
565 // Least sequence number which the peer is still waiting for. 584 // Least sequence number which the peer is still waiting for.
566 QuicPacketSequenceNumber least_packet_awaited_by_peer_; 585 QuicPacketSequenceNumber least_packet_awaited_by_peer_;
567 // Least sequence number of the the packet sent by the peer for which it 586 // Least sequence number of the the packet sent by the peer for which it
568 // hasn't received an ack. 587 // hasn't received an ack.
569 QuicPacketSequenceNumber peer_least_packet_awaiting_ack_; 588 QuicPacketSequenceNumber peer_least_packet_awaiting_ack_;
570 589
571 // When new packets are created which may be retransmitted, they are added 590 // When new packets are created which may be retransmitted, they are added
572 // to this map, which contains owning pointers to the contained frames. 591 // to this map, which contains owning pointers to the contained frames.
573 UnackedPacketMap unacked_packets_; 592 UnackedPacketMap unacked_packets_;
574 593
594 // Pending fec packets that have not been acked yet. These packets need to be
595 // cleared out of the cgst_window after a timeout since FEC packets are never
596 // retransmitted.
597 // Ask: What should be the timeout for these packets?
598 UnackedPacketMap unacked_fec_packets_;
599
575 // Heap of packets that we might need to retransmit, and the time at 600 // Heap of packets that we might need to retransmit, and the time at
576 // which we should retransmit them. Every time a packet is sent it is added 601 // which we should retransmit them. Every time a packet is sent it is added
577 // to this heap which is O(log(number of pending packets to be retransmitted)) 602 // to this heap which is O(log(number of pending packets to be retransmitted))
578 // which might be costly. This should be optimized to O(1) by maintaining a 603 // which might be costly. This should be optimized to O(1) by maintaining a
579 // priority queue of lists of packets to be retransmitted, where list x 604 // priority queue of lists of packets to be retransmitted, where list x
580 // contains all packets that have been retransmitted x times. 605 // contains all packets that have been retransmitted x times.
581 RetransmissionTimeouts retransmission_timeouts_; 606 RetransmissionTimeouts retransmission_timeouts_;
582 607
583 // Map from sequence number to the retransmission info. 608 // Map from sequence number to the retransmission info.
584 RetransmissionMap retransmission_map_; 609 RetransmissionMap retransmission_map_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 // Set to true if the udp packet headers have a new self or peer address. 676 // Set to true if the udp packet headers have a new self or peer address.
652 // This is checked later on validating a data or version negotiation packet. 677 // This is checked later on validating a data or version negotiation packet.
653 bool address_migrating_; 678 bool address_migrating_;
654 679
655 DISALLOW_COPY_AND_ASSIGN(QuicConnection); 680 DISALLOW_COPY_AND_ASSIGN(QuicConnection);
656 }; 681 };
657 682
658 } // namespace net 683 } // namespace net
659 684
660 #endif // NET_QUIC_QUIC_CONNECTION_H_ 685 #endif // NET_QUIC_QUIC_CONNECTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698