OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_QUIC_QUIC_MULTIPATH_SENT_PACKET_MANAGER_H_ | |
6 #define NET_QUIC_QUIC_MULTIPATH_SENT_PACKET_MANAGER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "net/base/net_export.h" | |
11 #include "net/quic/quic_protocol.h" | |
12 #include "net/quic/quic_sent_packet_manager.h" | |
13 #include "net/quic/quic_sent_packet_manager_interface.h" | |
14 | |
15 namespace net { | |
16 | |
17 namespace test { | |
18 class QuicConnectionPeer; | |
19 class QuicMultipathSentPacketManagerPeer; | |
20 } // namespace test | |
21 | |
22 // A connection level sent packet manager which manages a sent packet manager | |
23 // per path. The main duties of multipath sent packet manager comprise: | |
24 // (1) manages a pending retransmission queue shared among all paths; | |
25 // (2) records mapping of packets transmitted on different paths; | |
26 // (3) consults paths which should timeout on a retransmission timeout. | |
27 // TODO(fayang): Currently above duties are not fully implemented, need to | |
28 // finish them. | |
29 class NET_EXPORT_PRIVATE QuicMultipathSentPacketManager | |
30 : public QuicSentPacketManagerInterface { | |
31 public: | |
32 // Multipath sent packet manager takes ownership of |manager|. | |
33 explicit QuicMultipathSentPacketManager( | |
34 QuicSentPacketManagerInterface* manager, | |
35 QuicConnectionCloseDelegateInterface* delegate); | |
36 ~QuicMultipathSentPacketManager() override; | |
37 | |
38 // Start implementation of QuicSentPacketManagerInterface. | |
39 // Sets all paths from |config|. | |
40 void SetFromConfig(const QuicConfig& config) override; | |
41 | |
42 // Resumes connection state on the default path. | |
43 void ResumeConnectionState( | |
44 const CachedNetworkParameters& cached_network_params, | |
45 bool max_bandwidth_resumption) override; | |
46 | |
47 // Sets number of active streams of all paths. | |
48 void SetNumOpenStreams(size_t num_streams) override; | |
49 | |
50 // Sets max pacing rate of the default path. | |
51 void SetMaxPacingRate(QuicBandwidth max_pacing_rate) override; | |
52 | |
53 void SetHandshakeConfirmed() override; | |
54 | |
55 // Directs |ack_frame| to the appropriate path sent packet manager. | |
56 void OnIncomingAck(const QuicAckFrame& ack_frame, | |
57 QuicTime ack_receive_time) override; | |
58 | |
59 // Requests retransmission of all unacked packets of |retransmission_type| on | |
60 // the default path. | |
61 void RetransmitUnackedPackets(TransmissionType retransmission_type) override; | |
62 | |
63 // Tries to retransmit the oldest pending packet across all paths. The | |
64 // retransmission is sent on the path that has a TLP timer pending. | |
65 bool MaybeRetransmitTailLossProbe() override; | |
66 | |
67 // Removes the retransmittable frames from all unencrypted packets on the | |
68 // default path to ensure they don't get retransmitted. | |
69 void NeuterUnencryptedPackets() override; | |
70 | |
71 // Returns true if there are pending retransmissions. | |
72 bool HasPendingRetransmissions() const override; | |
73 | |
74 // Retrieves the next pending retransmission. Caller must ensure that | |
75 // there are pending retransmissions prior to calling this function. | |
76 PendingRetransmission NextPendingRetransmission() override; | |
77 | |
78 // Returns true if the any path has unacked packets. | |
79 bool HasUnackedPackets() const override; | |
80 | |
81 // Returns the smallest packet number of a serialized packet which has not | |
82 // been acked on |path_id|. | |
83 QuicPacketNumber GetLeastUnacked(QuicPathId path_id) const override; | |
84 | |
85 // Called when a packet has been sent to the peer. If this packet is a | |
86 // retransmission on a different path than the original packet, records the | |
87 // mapping in |transmissions_map_|. Retransmittable frames are transfered from | |
88 // original packet to the sent packet. | |
89 bool OnPacketSent(SerializedPacket* serialized_packet, | |
90 QuicPathId original_path_id, | |
91 QuicPacketNumber original_packet_number, | |
92 QuicTime sent_time, | |
93 TransmissionType transmission_type, | |
94 HasRetransmittableData has_retransmittable_data) override; | |
95 | |
96 // Called when the retransmission timer expires. | |
97 void OnRetransmissionTimeout() override; | |
98 | |
99 // Returns the earliest time the next packet can be sent. Sets |path_id| to be | |
100 // the path on which the next packet should be sent. | |
101 QuicTime::Delta TimeUntilSend(QuicTime now, | |
102 HasRetransmittableData retransmittable, | |
103 QuicPathId* path_id) override; | |
104 | |
105 // Returns the earliest retransmission time of all paths. | |
106 const QuicTime GetRetransmissionTime() const override; | |
107 | |
108 // Returns the rtt stats of the default path. | |
109 const RttStats* GetRttStats() const override; | |
110 | |
111 // Returns the estimated bandwidth on default path calculated by the | |
112 // congestion algorithm. | |
113 QuicBandwidth BandwidthEstimate() const override; | |
114 | |
115 // Returns the sustained bandwidth recorder on the default path. | |
116 const QuicSustainedBandwidthRecorder* SustainedBandwidthRecorder() | |
117 const override; | |
118 | |
119 // Returns the size of the current congestion window on default path in number | |
120 // of kDefaultTCPMSS-sized segments. | |
121 QuicPacketCount GetCongestionWindowInTcpMss() const override; | |
122 | |
123 // Determines the number of packets of length |max_packet_length| which fit in | |
124 // the congestion windows for all paths, and returns the max number of packets | |
125 // across all paths. | |
126 QuicPacketCount EstimateMaxPacketsInFlight( | |
127 QuicByteCount max_packet_length) const override; | |
128 | |
129 // Returns the size of the current congestion window size on the default path | |
130 // in bytes. | |
131 QuicByteCount GetCongestionWindowInBytes() const override; | |
132 | |
133 // Returns the size of the slow start congestion window in number of 1460 byte | |
134 // TCP segments on the default path. | |
135 QuicPacketCount GetSlowStartThresholdInTcpMss() const override; | |
136 | |
137 // No longer retransmit data for |stream_id| on all paths and any pending | |
138 // retransmissions in pending_retransmissions_. | |
139 void CancelRetransmissionsForStream(QuicStreamId stream_id) override; | |
140 | |
141 void OnConnectionMigration(QuicPathId path_id, | |
142 PeerAddressChangeType type) override; | |
143 | |
144 bool IsHandshakeConfirmed() const override; | |
145 | |
146 // Sets debug delegate for all active paths. | |
147 void SetDebugDelegate(DebugDelegate* debug_delegate) override; | |
148 | |
149 QuicPacketNumber GetLargestObserved(QuicPathId path_id) const override; | |
150 | |
151 QuicPacketNumber GetLargestSentPacket(QuicPathId path_id) const override; | |
152 | |
153 QuicPacketNumber GetLeastPacketAwaitedByPeer( | |
154 QuicPathId path_id) const override; | |
155 | |
156 // Sets network change visitor for all active paths. | |
157 void SetNetworkChangeVisitor(NetworkChangeVisitor* visitor) override; | |
158 | |
159 // Returns true if the default path is in slow start. | |
160 bool InSlowStart() const override; | |
161 | |
162 // These two methods return the consecutive RTO or TLP count of the default | |
163 // path. | |
164 size_t GetConsecutiveRtoCount() const override; | |
165 size_t GetConsecutiveTlpCount() const override; | |
166 | |
167 private: | |
168 friend class test::QuicConnectionPeer; | |
169 friend class test::QuicMultipathSentPacketManagerPeer; | |
170 | |
171 // State of per path sent packet manager. | |
172 // TODO(fayang): Need to add a state that path can receive acks but cannot | |
173 // send data. | |
174 enum PathSentPacketManagerState { | |
175 ACTIVE, // We both send packets and receiving acks on this path. | |
176 CLOSING, // We stop sending packets and receiving acks on this path. There | |
177 // are retransmittable frames in the unacked packets map. | |
178 }; | |
179 | |
180 // PathSentPacketManagerInfo contains sent packet manager and its state. | |
181 struct NET_EXPORT_PRIVATE PathSentPacketManagerInfo { | |
182 PathSentPacketManagerInfo(); | |
183 PathSentPacketManagerInfo(QuicSentPacketManagerInterface* manager, | |
184 PathSentPacketManagerState state); | |
185 PathSentPacketManagerInfo(const PathSentPacketManagerInfo& other); | |
186 | |
187 QuicSentPacketManagerInterface* manager; | |
188 PathSentPacketManagerState state; | |
189 }; | |
190 | |
191 // Returns path sent packet manager if it exists for |path_id|, returns | |
192 // nullptr otherwise. | |
193 QuicSentPacketManagerInterface* MaybeGetSentPacketManagerForPath( | |
194 QuicPathId path_id) const; | |
195 | |
196 // Returns path sent packet manager if it exists and |path_id| is ACTIVE, | |
197 // returns nullptr otherwise. | |
198 QuicSentPacketManagerInterface* MaybeGetSentPacketManagerForActivePath( | |
199 QuicPathId path_id) const; | |
200 | |
201 // Returns the path which has the earliest retransmission time. | |
202 QuicPathId DetermineRetransmissionTimeoutPath() const; | |
203 | |
204 // Close the connection on unrecoverable path errors. | |
205 void OnUnrecoverablePathError(QuicPathId path_id); | |
206 | |
207 // Current path sent packet managers info, index is path id. | |
208 std::vector<PathSentPacketManagerInfo> path_managers_info_; | |
209 | |
210 // Does not own this delegate. | |
211 QuicConnectionCloseDelegateInterface* delegate_; | |
212 | |
213 DISALLOW_COPY_AND_ASSIGN(QuicMultipathSentPacketManager); | |
214 }; | |
215 | |
216 } // namespace net | |
217 | |
218 #endif // NET_QUIC_QUIC_MULTIPATH_SENT_PACKET_MANAGER_H_ | |
OLD | NEW |