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