| Index: net/tools/quic/quic_time_wait_list_manager.h
|
| diff --git a/net/tools/quic/quic_time_wait_list_manager.h b/net/tools/quic/quic_time_wait_list_manager.h
|
| index 46540457c24ae388497f375af9dd7ff3776e9c7d..3b291239b6813fa52eb0998cab57139e32a38c4d 100644
|
| --- a/net/tools/quic/quic_time_wait_list_manager.h
|
| +++ b/net/tools/quic/quic_time_wait_list_manager.h
|
| @@ -2,8 +2,9 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
| //
|
| -// Handles packets for guids in time wait state by discarding the packet and
|
| -// sending the clients a public reset packet with exponential backoff.
|
| +// Handles packets for connection_ids in time wait state by discarding the
|
| +// packet and sending the clients a public reset packet with exponential
|
| +// backoff.
|
|
|
| #ifndef NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
|
| #define NET_TOOLS_QUIC_QUIC_TIME_WAIT_LIST_MANAGER_H_
|
| @@ -24,21 +25,22 @@
|
| namespace net {
|
| namespace tools {
|
|
|
| -class GuidCleanUpAlarm;
|
| +class ConnectionIdCleanUpAlarm;
|
| class QuicServerSessionVisitor;
|
|
|
| namespace test {
|
| class QuicTimeWaitListManagerPeer;
|
| } // namespace test
|
|
|
| -// Maintains a list of all guids that have been recently closed. A guid lives in
|
| -// this state for kTimeWaitPeriod. All packets received for guids in this state
|
| -// are handed over to the QuicTimeWaitListManager by the QuicDispatcher.
|
| -// Decides whether to send a public reset packet, a copy of the previously sent
|
| -// connection close packet, or nothing to the client which sent a packet
|
| -// with the guid in time wait state. After the guid expires its time wait
|
| -// period, a new connection/session will be created if a packet is received
|
| -// for this guid.
|
| +// Maintains a list of all connection_ids that have been recently closed. A
|
| +// connection_id lives in this state for kTimeWaitPeriod. All packets received
|
| +// for connection_ids in this state are handed over to the
|
| +// QuicTimeWaitListManager by the QuicDispatcher. Decides whether to send a
|
| +// public reset packet, a copy of the previously sent connection close packet,
|
| +// or nothing to the client which sent a packet with the connection_id in time
|
| +// wait state. After the connection_id expires its time wait period, a new
|
| +// connection/session will be created if a packet is received for this
|
| +// connection_id.
|
| class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
|
| public:
|
| // writer - the entity that writes to the socket. (Owned by the dispatcher)
|
| @@ -50,28 +52,29 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
|
| const QuicVersionVector& supported_versions);
|
| virtual ~QuicTimeWaitListManager();
|
|
|
| - // Adds the given guid to time wait state for kTimeWaitPeriod. Henceforth,
|
| - // any packet bearing this guid should not be processed while the guid remains
|
| - // in this list. If a non-NULL |close_packet| is provided, it is sent again
|
| - // when packets are received for added guids. If NULL, a public reset packet
|
| - // is sent with the specified |version|. DCHECKs that guid is not already on
|
| - // the list.
|
| - void AddGuidToTimeWait(QuicGuid guid,
|
| - QuicVersion version,
|
| - QuicEncryptedPacket* close_packet); // Owned.
|
| -
|
| - // Returns true if the guid is in time wait state, false otherwise. Packets
|
| - // received for this guid should not lead to creation of new QuicSessions.
|
| - bool IsGuidInTimeWait(QuicGuid guid) const;
|
| -
|
| - // Called when a packet is received for a guid that is in time wait state.
|
| - // Sends a public reset packet to the client which sent this guid. Sending
|
| - // of the public reset packet is throttled by using exponential back off.
|
| - // DCHECKs for the guid to be in time wait state.
|
| - // virtual to override in tests.
|
| + // Adds the given connection_id to time wait state for kTimeWaitPeriod.
|
| + // Henceforth, any packet bearing this connection_id should not be processed
|
| + // while the connection_id remains in this list. If a non-NULL |close_packet|
|
| + // is provided, it is sent again when packets are received for added
|
| + // connection_ids. If NULL, a public reset packet is sent with the specified
|
| + // |version|. DCHECKs that connection_id is not already on the list.
|
| + void AddConnectionIdToTimeWait(QuicConnectionId connection_id,
|
| + QuicVersion version,
|
| + QuicEncryptedPacket* close_packet); // Owned.
|
| +
|
| + // Returns true if the connection_id is in time wait state, false otherwise.
|
| + // Packets received for this connection_id should not lead to creation of new
|
| + // QuicSessions.
|
| + bool IsConnectionIdInTimeWait(QuicConnectionId connection_id) const;
|
| +
|
| + // Called when a packet is received for a connection_id that is in time wait
|
| + // state. Sends a public reset packet to the client which sent this
|
| + // connection_id. Sending of the public reset packet is throttled by using
|
| + // exponential back off. DCHECKs for the connection_id to be in time wait
|
| + // state. virtual to override in tests.
|
| virtual void ProcessPacket(const IPEndPoint& server_address,
|
| const IPEndPoint& client_address,
|
| - QuicGuid guid,
|
| + QuicConnectionId connection_id,
|
| QuicPacketSequenceNumber sequence_number);
|
|
|
| // Called by the dispatcher when the underlying socket becomes writable again,
|
| @@ -79,12 +82,13 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
|
| // send because the underlying socket was write blocked.
|
| virtual void OnCanWrite() OVERRIDE;
|
|
|
| - // Used to delete guid entries that have outlived their time wait period.
|
| - void CleanUpOldGuids();
|
| + // Used to delete connection_id entries that have outlived their time wait
|
| + // period.
|
| + void CleanUpOldConnectionIds();
|
|
|
| - // Given a GUID that exists in the time wait list, returns the QuicVersion
|
| - // associated with it.
|
| - QuicVersion GetQuicVersionFromGuid(QuicGuid guid);
|
| + // Given a ConnectionId that exists in the time wait list, returns the
|
| + // QuicVersion associated with it.
|
| + QuicVersion GetQuicVersionFromConnectionId(QuicConnectionId connection_id);
|
|
|
| private:
|
| friend class test::QuicTimeWaitListManagerPeer;
|
| @@ -92,14 +96,14 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
|
| // Internal structure to store pending public reset packets.
|
| class QueuedPacket;
|
|
|
| - // Decides if a packet should be sent for this guid based on the number of
|
| - // received packets.
|
| + // Decides if a packet should be sent for this connection_id based on the
|
| + // number of received packets.
|
| bool ShouldSendResponse(int received_packet_count);
|
|
|
| // Creates a public reset packet and sends it or queues it to be sent later.
|
| void SendPublicReset(const IPEndPoint& server_address,
|
| const IPEndPoint& client_address,
|
| - QuicGuid guid,
|
| + QuicConnectionId connection_id,
|
| QuicPacketSequenceNumber rejected_sequence_number);
|
|
|
| // Either sends the packet and deletes it or makes pending_packets_queue_ the
|
| @@ -113,15 +117,16 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
|
| bool WriteToWire(QueuedPacket* packet);
|
|
|
| // Register the alarm with the epoll server to wake up at appropriate time.
|
| - void SetGuidCleanUpAlarm();
|
| -
|
| - // A map from a recently closed guid to the number of packets received after
|
| - // the termination of the connection bound to the guid.
|
| - struct GuidData {
|
| - GuidData(int num_packets_,
|
| - QuicVersion version_,
|
| - QuicTime time_added_,
|
| - QuicEncryptedPacket* close_packet)
|
| + void SetConnectionIdCleanUpAlarm();
|
| +
|
| + // A map from a recently closed connection_id to the number of packets
|
| + // received after the termination of the connection bound to the
|
| + // connection_id.
|
| + struct ConnectionIdData {
|
| + ConnectionIdData(int num_packets_,
|
| + QuicVersion version_,
|
| + QuicTime time_added_,
|
| + QuicEncryptedPacket* close_packet)
|
| : num_packets(num_packets_),
|
| version(version_),
|
| time_added(time_added_),
|
| @@ -132,24 +137,24 @@ class QuicTimeWaitListManager : public QuicBlockedWriterInterface {
|
| QuicEncryptedPacket* close_packet;
|
| };
|
|
|
| - // linked_hash_map allows lookup by Guid and traversal in add order.
|
| - typedef linked_hash_map<QuicGuid, GuidData> GuidMap;
|
| - GuidMap guid_map_;
|
| + // linked_hash_map allows lookup by ConnectionId and traversal in add order.
|
| + typedef linked_hash_map<QuicConnectionId, ConnectionIdData> ConnectionIdMap;
|
| + ConnectionIdMap connection_id_map_;
|
|
|
| // Pending public reset packets that need to be sent out to the client
|
| // when we are given a chance to write by the dispatcher.
|
| std::deque<QueuedPacket*> pending_packets_queue_;
|
|
|
| - // Used to schedule alarms to delete old guids which have been in the list for
|
| - // too long.
|
| + // Used to schedule alarms to delete old connection_ids which have been in the
|
| + // list for too long.
|
| EpollServer* epoll_server_;
|
|
|
| - // Time period for which guids should remain in time wait state.
|
| + // Time period for which connection_ids should remain in time wait state.
|
| const QuicTime::Delta kTimeWaitPeriod_;
|
|
|
| - // Alarm registered with the epoll server to clean up guids that have out
|
| - // lived their duration in time wait state.
|
| - scoped_ptr<GuidCleanUpAlarm> guid_clean_up_alarm_;
|
| + // Alarm registered with the epoll server to clean up connection_ids that have
|
| + // out lived their duration in time wait state.
|
| + scoped_ptr<ConnectionIdCleanUpAlarm> connection_id_clean_up_alarm_;
|
|
|
| // Clock to efficiently measure approximate time from the epoll server.
|
| QuicEpollClock clock_;
|
|
|