OLD | NEW |
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 // |
11 // On the client side, the Connection handles the raw reads, as well as the | 11 // On the client side, the Connection handles the raw reads, as well as the |
12 // processing. | 12 // processing. |
13 // | 13 // |
14 // Note: this class is not thread-safe. | 14 // Note: this class is not thread-safe. |
15 | 15 |
16 #ifndef NET_QUIC_QUIC_CONNECTION_H_ | 16 #ifndef NET_QUIC_QUIC_CONNECTION_H_ |
17 #define NET_QUIC_QUIC_CONNECTION_H_ | 17 #define NET_QUIC_QUIC_CONNECTION_H_ |
18 | 18 |
| 19 #include <deque> |
19 #include <list> | 20 #include <list> |
20 #include <map> | 21 #include <map> |
21 #include <queue> | 22 #include <queue> |
22 #include <set> | 23 #include <set> |
23 #include <vector> | 24 #include <vector> |
24 | 25 |
25 #include "base/containers/hash_tables.h" | 26 #include "base/containers/hash_tables.h" |
26 #include "net/base/ip_endpoint.h" | 27 #include "net/base/ip_endpoint.h" |
27 #include "net/base/linked_hash_map.h" | 28 #include "net/base/linked_hash_map.h" |
28 #include "net/quic/congestion_control/quic_congestion_manager.h" | 29 #include "net/quic/congestion_control/quic_congestion_manager.h" |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 RetransmissionTimeComparator> | 505 RetransmissionTimeComparator> |
505 RetransmissionTimeouts; | 506 RetransmissionTimeouts; |
506 | 507 |
507 // Selects and updates the version of the protocol being used by selecting a | 508 // 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 | 509 // version from |available_versions| which is also supported. Returns true if |
509 // such a version exists, false otherwise. | 510 // such a version exists, false otherwise. |
510 bool SelectMutualVersion(const QuicTagVector& available_versions); | 511 bool SelectMutualVersion(const QuicTagVector& available_versions); |
511 // Sends a version negotiation packet to the peer. | 512 // Sends a version negotiation packet to the peer. |
512 void SendVersionNegotiationPacket(); | 513 void SendVersionNegotiationPacket(); |
513 | 514 |
514 void SetupRetransmission(QuicPacketSequenceNumber sequence_number); | 515 void SetupRetransmission(QuicPacketSequenceNumber sequence_number, |
| 516 EncryptionLevel level); |
515 bool IsRetransmission(QuicPacketSequenceNumber sequence_number); | 517 bool IsRetransmission(QuicPacketSequenceNumber sequence_number); |
516 | 518 |
517 void SetupAbandonFecTimer(QuicPacketSequenceNumber sequence_number); | 519 void SetupAbandonFecTimer(QuicPacketSequenceNumber sequence_number); |
518 | 520 |
519 // Drop packet corresponding to |sequence_number| by deleting entries from | 521 // Drop packet corresponding to |sequence_number| by deleting entries from |
520 // |unacked_packets_| and |retransmission_map_|, if present. We need to drop | 522 // |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 | 523 // all packets with encryption level NONE after the default level has been set |
522 // to FORWARD_SECURE. | 524 // to FORWARD_SECURE. |
523 void DropPacket(QuicPacketSequenceNumber sequence_number); | 525 void DropPacket(QuicPacketSequenceNumber sequence_number); |
524 | 526 |
525 // Writes as many queued packets as possible. The connection must not be | 527 // Writes as many queued packets as possible. The connection must not be |
526 // blocked when this is called. | 528 // blocked when this is called. |
527 bool WriteQueuedPackets(); | 529 bool WriteQueuedPackets(); |
528 | 530 |
| 531 // Queues |packet| in the hopes that it can be decrypted in the |
| 532 // future, when a new key is installed. |
| 533 void QueueUndecryptablePacket(const QuicEncryptedPacket& packet); |
| 534 |
| 535 // Attempts to process any queued undecryptable packets. |
| 536 void MaybeProcessUndecryptablePackets(); |
| 537 |
529 // If a packet can be revived from the current FEC group, then | 538 // If a packet can be revived from the current FEC group, then |
530 // revive and process the packet. | 539 // revive and process the packet. |
531 void MaybeProcessRevivedPacket(); | 540 void MaybeProcessRevivedPacket(); |
532 | 541 |
533 void HandleAckForSentPackets(const QuicAckFrame& incoming_ack, | 542 void HandleAckForSentPackets(const QuicAckFrame& incoming_ack, |
534 SequenceNumberSet* acked_packets); | 543 SequenceNumberSet* acked_packets); |
535 void HandleAckForSentFecPackets(const QuicAckFrame& incoming_ack, | 544 void HandleAckForSentFecPackets(const QuicAckFrame& incoming_ack, |
536 SequenceNumberSet* acked_packets); | 545 SequenceNumberSet* acked_packets); |
537 | 546 |
538 // These two are called by OnAckFrame. | 547 // These two are called by OnAckFrame. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 // When new packets are created which may be retransmitted, they are added | 599 // When new packets are created which may be retransmitted, they are added |
591 // to this map, which contains owning pointers to the contained frames. | 600 // to this map, which contains owning pointers to the contained frames. |
592 UnackedPacketMap unacked_packets_; | 601 UnackedPacketMap unacked_packets_; |
593 | 602 |
594 // Pending fec packets that have not been acked yet. These packets need to be | 603 // 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 | 604 // cleared out of the cgst_window after a timeout since FEC packets are never |
596 // retransmitted. | 605 // retransmitted. |
597 // Ask: What should be the timeout for these packets? | 606 // Ask: What should be the timeout for these packets? |
598 UnackedPacketMap unacked_fec_packets_; | 607 UnackedPacketMap unacked_fec_packets_; |
599 | 608 |
| 609 // Collection of packets which were received before encryption was |
| 610 // established, but which could not be decrypted. We buffer these on |
| 611 // the assumption that they could not be processed because they were |
| 612 // sent with the INITIAL encryption and the CHLO message was lost. |
| 613 std::deque<QuicEncryptedPacket*> undecryptable_packets_; |
| 614 |
600 // Heap of packets that we might need to retransmit, and the time at | 615 // 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 | 616 // 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)) | 617 // 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 | 618 // 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 | 619 // priority queue of lists of packets to be retransmitted, where list x |
605 // contains all packets that have been retransmitted x times. | 620 // contains all packets that have been retransmitted x times. |
606 RetransmissionTimeouts retransmission_timeouts_; | 621 RetransmissionTimeouts retransmission_timeouts_; |
607 | 622 |
608 // Map from sequence number to the retransmission info. | 623 // Map from sequence number to the retransmission info. |
609 RetransmissionMap retransmission_map_; | 624 RetransmissionMap retransmission_map_; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 // Set to true if the udp packet headers have a new self or peer address. | 691 // 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. | 692 // This is checked later on validating a data or version negotiation packet. |
678 bool address_migrating_; | 693 bool address_migrating_; |
679 | 694 |
680 DISALLOW_COPY_AND_ASSIGN(QuicConnection); | 695 DISALLOW_COPY_AND_ASSIGN(QuicConnection); |
681 }; | 696 }; |
682 | 697 |
683 } // namespace net | 698 } // namespace net |
684 | 699 |
685 #endif // NET_QUIC_QUIC_CONNECTION_H_ | 700 #endif // NET_QUIC_QUIC_CONNECTION_H_ |
OLD | NEW |