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

Unified Diff: net/quic/quic_packet_entropy_manager.h

Issue 20227003: Land Recent QUIC changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Land Recent QUIC changes Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_packet_entropy_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_packet_entropy_manager.h
diff --git a/net/quic/quic_packet_entropy_manager.h b/net/quic/quic_packet_entropy_manager.h
deleted file mode 100644
index fb205a47b169035b1b64a6538727437b875a05a2..0000000000000000000000000000000000000000
--- a/net/quic/quic_packet_entropy_manager.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Manages the packet entropy calculation for both sent and received packets
-// for a connection.
-
-#ifndef NET_QUIC_QUIC_PACKET_ENTROPY_MANAGER_H_
-#define NET_QUIC_QUIC_PACKET_ENTROPY_MANAGER_H_
-
-#include "net/base/linked_hash_map.h"
-#include "net/quic/quic_framer.h"
-#include "net/quic/quic_protocol.h"
-
-namespace net {
-
-// Records all sent and received packets by a connection to track the cumulative
-// entropy of both sent and received packets separately. It is used by the
-// connection to validate an ack frame sent by the peer as a preventive measure
-// against the optimistic ack attack. Also, called by the framer when it
-// truncates an ack frame to get the correct entropy value for the ack frame
-// being serialized.
-class NET_EXPORT_PRIVATE QuicPacketEntropyManager :
- public QuicReceivedEntropyHashCalculatorInterface {
- public:
- QuicPacketEntropyManager();
- virtual ~QuicPacketEntropyManager();
-
- // Record the received entropy hash against |sequence_number|.
- void RecordReceivedPacketEntropyHash(QuicPacketSequenceNumber sequence_number,
- QuicPacketEntropyHash entropy_hash);
-
- // Record |entropy_hash| for sent packet corresponding to |sequence_number|.
- void RecordSentPacketEntropyHash(QuicPacketSequenceNumber sequence_number,
- QuicPacketEntropyHash entropy_hash);
-
- // QuicReceivedEntropyHashCalculatorInterface
- // Called by QuicFramer, when the outgoing ack gets truncated, to recalculate
- // the received entropy hash for the truncated ack frame.
- virtual QuicPacketEntropyHash ReceivedEntropyHash(
- QuicPacketSequenceNumber sequence_number) const OVERRIDE;
-
- QuicPacketEntropyHash SentEntropyHash(
- QuicPacketSequenceNumber sequence_number) const;
-
- QuicPacketSequenceNumber LargestReceivedSequenceNumber() const;
-
- // Recalculate the received entropy hash and clears old packet entropies,
- // now that the sender sent us the |entropy_hash| for packets up to,
- // but not including, |peer_least_unacked|.
- void RecalculateReceivedEntropyHash(
- QuicPacketSequenceNumber peer_least_unacked,
- QuicPacketEntropyHash entropy_hash);
-
- // Returns true if |entropy_hash| matches the expected sent entropy hash
- // up to |sequence_number| removing sequence numbers from |missing_packets|.
- bool IsValidEntropy(QuicPacketSequenceNumber sequence_number,
- const SequenceNumberSet& missing_packets,
- QuicPacketEntropyHash entropy_hash) const;
-
- // Removes not required entries from |sent_packets_entropy_| before
- // |sequence_number|.
- void ClearSentEntropyBefore(QuicPacketSequenceNumber sequence_number);
-
- QuicPacketEntropyHash sent_packets_entropy_hash() const {
- return sent_packets_entropy_hash_;
- }
-
- QuicPacketEntropyHash received_packets_entropy_hash() const {
- return received_packets_entropy_hash_;
- }
-
- private:
- typedef linked_hash_map<QuicPacketSequenceNumber,
- std::pair<QuicPacketEntropyHash,
- QuicPacketEntropyHash> > SentEntropyMap;
- typedef std::map<QuicPacketSequenceNumber,
- QuicPacketEntropyHash> ReceivedEntropyMap;
-
- // Linked hash map from sequence numbers to the sent entropy hash up to the
- // sequence number in the key.
- SentEntropyMap sent_packets_entropy_;
-
- // Cumulative hash of entropy of all sent packets.
- QuicPacketEntropyHash sent_packets_entropy_hash_;
-
- // TODO(satyamshekhar): Can be optimized using an interval set like data
- // structure.
- // Map of received sequence numbers to their corresponding entropy.
- // Every received packet has an entry, and packets without the entropy bit set
- // have an entropy value of 0.
- // TODO(ianswett): When the entropy flag is off, the entropy should not be 0.
- ReceivedEntropyMap received_packets_entropy_;
-
- // Cumulative hash of entropy of all received packets.
- QuicPacketEntropyHash received_packets_entropy_hash_;
-
- // The largest sequence number cleared by RecalculateReceivedEntropyHash.
- // Received entropy cannot be calculated for numbers less than it.
- QuicPacketSequenceNumber largest_received_sequence_number_;
-};
-
-} // namespace net
-
-#endif // NET_QUIC_QUIC_PACKET_ENTROPY_MANAGER_H_
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_packet_entropy_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698