| OLD | NEW |
| 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 // Manages the packet entropy calculation for both sent and received packets | 5 // Manages the packet entropy calculation for both sent and received packets |
| 6 // for a connection. | 6 // for a connection. |
| 7 | 7 |
| 8 #ifndef NET_QUIC_QUIC_RECEIVED_PACKET_MANAGER_H_ | 8 #ifndef NET_QUIC_QUIC_RECEIVED_PACKET_MANAGER_H_ |
| 9 #define NET_QUIC_QUIC_RECEIVED_PACKET_MANAGER_H_ | 9 #define NET_QUIC_QUIC_RECEIVED_PACKET_MANAGER_H_ |
| 10 | 10 |
| 11 #include "net/quic/congestion_control/receive_algorithm_interface.h" | 11 #include "net/quic/congestion_control/receive_algorithm_interface.h" |
| 12 #include "net/quic/quic_framer.h" | 12 #include "net/quic/quic_framer.h" |
| 13 #include "net/quic/quic_protocol.h" | 13 #include "net/quic/quic_protocol.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 namespace test { | 17 namespace test { |
| 18 class QuicConnectionPeer; | 18 class QuicConnectionPeer; |
| 19 class QuicReceivedPacketManagerPeer; | 19 class QuicReceivedPacketManagerPeer; |
| 20 } // namespace test | 20 } // namespace test |
| 21 | 21 |
| 22 struct QuicConnectionStats; | 22 struct QuicConnectionStats; |
| 23 | 23 |
| 24 // Records all received packets by a connection and tracks their entropy. | 24 // Records all received packets by a connection and tracks their entropy. |
| 25 // Also calculates the correct entropy for the framer when it truncates an ack | 25 // Also calculates the correct entropy for the framer when it truncates an ack |
| 26 // frame being serialized. | 26 // frame being serialized. |
| 27 class NET_EXPORT_PRIVATE QuicReceivedPacketManager : | 27 class NET_EXPORT_PRIVATE QuicReceivedPacketManager |
| 28 public QuicReceivedEntropyHashCalculatorInterface { | 28 : public QuicReceivedEntropyHashCalculatorInterface { |
| 29 public: | 29 public: |
| 30 explicit QuicReceivedPacketManager(CongestionFeedbackType congestion_type, | 30 explicit QuicReceivedPacketManager(CongestionFeedbackType congestion_type, |
| 31 QuicConnectionStats* stats); | 31 QuicConnectionStats* stats); |
| 32 virtual ~QuicReceivedPacketManager(); | 32 virtual ~QuicReceivedPacketManager(); |
| 33 | 33 |
| 34 // Updates the internal state concerning which packets have been received. | 34 // Updates the internal state concerning which packets have been received. |
| 35 // bytes: the packet size in bytes including Quic Headers. | 35 // bytes: the packet size in bytes including Quic Headers. |
| 36 // header: the packet header. | 36 // header: the packet header. |
| 37 // timestamp: the arrival time of the packet. | 37 // timestamp: the arrival time of the packet. |
| 38 void RecordPacketReceived(QuicByteCount bytes, | 38 void RecordPacketReceived(QuicByteCount bytes, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 QuicPacketSequenceNumber peer_least_packet_awaiting_ack() { | 89 QuicPacketSequenceNumber peer_least_packet_awaiting_ack() { |
| 90 return peer_least_packet_awaiting_ack_; | 90 return peer_least_packet_awaiting_ack_; |
| 91 } | 91 } |
| 92 | 92 |
| 93 private: | 93 private: |
| 94 friend class test::QuicConnectionPeer; | 94 friend class test::QuicConnectionPeer; |
| 95 friend class test::QuicReceivedPacketManagerPeer; | 95 friend class test::QuicReceivedPacketManagerPeer; |
| 96 | 96 |
| 97 typedef std::map<QuicPacketSequenceNumber, | 97 typedef std::map<QuicPacketSequenceNumber, QuicPacketEntropyHash> |
| 98 QuicPacketEntropyHash> ReceivedEntropyMap; | 98 ReceivedEntropyMap; |
| 99 | 99 |
| 100 // Record the received entropy hash against |sequence_number|. | 100 // Record the received entropy hash against |sequence_number|. |
| 101 void RecordPacketEntropyHash(QuicPacketSequenceNumber sequence_number, | 101 void RecordPacketEntropyHash(QuicPacketSequenceNumber sequence_number, |
| 102 QuicPacketEntropyHash entropy_hash); | 102 QuicPacketEntropyHash entropy_hash); |
| 103 | 103 |
| 104 // Recalculate the entropy hash and clears old packet entropies, | 104 // Recalculate the entropy hash and clears old packet entropies, |
| 105 // now that the sender sent us the |entropy_hash| for packets up to, | 105 // now that the sender sent us the |entropy_hash| for packets up to, |
| 106 // but not including, |peer_least_unacked|. | 106 // but not including, |peer_least_unacked|. |
| 107 void RecalculateEntropyHash(QuicPacketSequenceNumber peer_least_unacked, | 107 void RecalculateEntropyHash(QuicPacketSequenceNumber peer_least_unacked, |
| 108 QuicPacketEntropyHash entropy_hash); | 108 QuicPacketEntropyHash entropy_hash); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 121 // TODO(ianswett): When the entropy flag is off, the entropy should not be 0. | 121 // TODO(ianswett): When the entropy flag is off, the entropy should not be 0. |
| 122 ReceivedEntropyMap packets_entropy_; | 122 ReceivedEntropyMap packets_entropy_; |
| 123 | 123 |
| 124 // Cumulative hash of entropy of all received packets. | 124 // Cumulative hash of entropy of all received packets. |
| 125 QuicPacketEntropyHash packets_entropy_hash_; | 125 QuicPacketEntropyHash packets_entropy_hash_; |
| 126 | 126 |
| 127 // The largest sequence number cleared by RecalculateEntropyHash. | 127 // The largest sequence number cleared by RecalculateEntropyHash. |
| 128 // Received entropy cannot be calculated for numbers less than it. | 128 // Received entropy cannot be calculated for numbers less than it. |
| 129 QuicPacketSequenceNumber largest_sequence_number_; | 129 QuicPacketSequenceNumber largest_sequence_number_; |
| 130 | 130 |
| 131 | |
| 132 // Track some peer state so we can do less bookkeeping. | 131 // Track some peer state so we can do less bookkeeping. |
| 133 // Largest sequence number that the peer has observed. Mostly received, | 132 // Largest sequence number that the peer has observed. Mostly received, |
| 134 // missing in case of truncated acks. | 133 // missing in case of truncated acks. |
| 135 QuicPacketSequenceNumber peer_largest_observed_packet_; | 134 QuicPacketSequenceNumber peer_largest_observed_packet_; |
| 136 // Least sequence number which the peer is still waiting for. | 135 // Least sequence number which the peer is still waiting for. |
| 137 QuicPacketSequenceNumber least_packet_awaited_by_peer_; | 136 QuicPacketSequenceNumber least_packet_awaited_by_peer_; |
| 138 // Least sequence number of the the packet sent by the peer for which it | 137 // Least sequence number of the the packet sent by the peer for which it |
| 139 // hasn't received an ack. | 138 // hasn't received an ack. |
| 140 QuicPacketSequenceNumber peer_least_packet_awaiting_ack_; | 139 QuicPacketSequenceNumber peer_least_packet_awaiting_ack_; |
| 141 | 140 |
| 142 // Received packet information used to produce acks. | 141 // Received packet information used to produce acks. |
| 143 ReceivedPacketInfo received_info_; | 142 ReceivedPacketInfo received_info_; |
| 144 | 143 |
| 145 // The time we received the largest_observed sequence number, or zero if | 144 // The time we received the largest_observed sequence number, or zero if |
| 146 // no sequence numbers have been received since UpdateReceivedPacketInfo. | 145 // no sequence numbers have been received since UpdateReceivedPacketInfo. |
| 147 // Needed for calculating delta_time_largest_observed. | 146 // Needed for calculating delta_time_largest_observed. |
| 148 QuicTime time_largest_observed_; | 147 QuicTime time_largest_observed_; |
| 149 | 148 |
| 150 scoped_ptr<ReceiveAlgorithmInterface> receive_algorithm_; | 149 scoped_ptr<ReceiveAlgorithmInterface> receive_algorithm_; |
| 151 | 150 |
| 152 QuicConnectionStats* stats_; | 151 QuicConnectionStats* stats_; |
| 153 | 152 |
| 154 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacketManager); | 153 DISALLOW_COPY_AND_ASSIGN(QuicReceivedPacketManager); |
| 155 }; | 154 }; |
| 156 | 155 |
| 157 } // namespace net | 156 } // namespace net |
| 158 | 157 |
| 159 #endif // NET_QUIC_QUIC_RECEIVED_PACKET_MANAGER_H_ | 158 #endif // NET_QUIC_QUIC_RECEIVED_PACKET_MANAGER_H_ |
| OLD | NEW |