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

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

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

Powered by Google App Engine
This is Rietveld 408576698