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

Side by Side Diff: net/quic/quic_packet_generator.h

Issue 1784903003: Remove FEC from send path. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@114770052
Patch Set: Restore accidentally removed OnRttChanged call Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_packet_generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 // Responsible for generating packets on behalf of a QuicConnection. 5 // Responsible for generating packets on behalf of a QuicConnection.
6 // Packets are serialized just-in-time. Control frames are queued. 6 // Packets are serialized just-in-time. Control frames are queued.
7 // Ack and Feedback frames will be requested from the Connection 7 // Ack and Feedback frames will be requested from the Connection
8 // just-in-time. When a packet needs to be sent, the Generator 8 // just-in-time. When a packet needs to be sent, the Generator
9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket() 9 // will serialize a packet and pass it to QuicConnection::SendOrQueuePacket()
10 // 10 //
(...skipping 18 matching lines...) Expand all
29 // but has not been sent, then the Delegate will be asked to create 29 // but has not been sent, then the Delegate will be asked to create
30 // an Ack frame which will then be included in the packet. When 30 // an Ack frame which will then be included in the packet. When
31 // the write call completes, the current packet will be serialized 31 // the write call completes, the current packet will be serialized
32 // and sent to the Delegate, even if it is not full. 32 // and sent to the Delegate, even if it is not full.
33 // 33 //
34 // If the Generator is in batch mode, then each write operation will 34 // If the Generator is in batch mode, then each write operation will
35 // add data to the "current" packet. When the current packet becomes 35 // add data to the "current" packet. When the current packet becomes
36 // full, it will be serialized and sent to the packet. When batch 36 // full, it will be serialized and sent to the packet. When batch
37 // mode is ended via |FinishBatchOperations|, the current packet 37 // mode is ended via |FinishBatchOperations|, the current packet
38 // will be serialzied, even if it is not full. 38 // will be serialzied, even if it is not full.
39 //
40 // FEC behavior also depends on batch mode. In batch mode, FEC packets
41 // will be sent after |max_packets_per_group| have been sent, as well
42 // as after batch operations are complete. When not in batch mode,
43 // an FEC packet will be sent after each write call completes.
44 //
45 // TODO(rch): This behavior should probably be tuned. When not in batch
46 // mode, we should probably set a timer so that several independent
47 // operations can be grouped into the same FEC group.
48 //
49 // When an FEC packet is generated, it will be send to the Delegate,
50 // even if the Delegate has become unwritable after handling the
51 // data packet immediately proceeding the FEC packet.
52 39
53 #ifndef NET_QUIC_QUIC_PACKET_GENERATOR_H_ 40 #ifndef NET_QUIC_QUIC_PACKET_GENERATOR_H_
54 #define NET_QUIC_QUIC_PACKET_GENERATOR_H_ 41 #define NET_QUIC_QUIC_PACKET_GENERATOR_H_
55 42
56 #include <stddef.h> 43 #include <stddef.h>
57 #include <stdint.h> 44 #include <stdint.h>
58 45
59 #include <list> 46 #include <list>
60 47
61 #include "base/macros.h" 48 #include "base/macros.h"
(...skipping 22 matching lines...) Expand all
84 }; 71 };
85 72
86 QuicPacketGenerator(QuicConnectionId connection_id, 73 QuicPacketGenerator(QuicConnectionId connection_id,
87 QuicFramer* framer, 74 QuicFramer* framer,
88 QuicRandom* random_generator, 75 QuicRandom* random_generator,
89 QuicBufferAllocator* buffer_allocator, 76 QuicBufferAllocator* buffer_allocator,
90 DelegateInterface* delegate); 77 DelegateInterface* delegate);
91 78
92 ~QuicPacketGenerator(); 79 ~QuicPacketGenerator();
93 80
94 // Called by the connection in the event of the congestion window changing.
95 void OnCongestionWindowChange(QuicPacketCount max_packets_in_flight);
96
97 // Called by the connection when the RTT may have changed.
98 void OnRttChange(QuicTime::Delta rtt);
99
100 // Indicates that an ACK frame should be sent. 81 // Indicates that an ACK frame should be sent.
101 // If |also_send_stop_waiting| is true, then it also indicates that a 82 // If |also_send_stop_waiting| is true, then it also indicates that a
102 // STOP_WAITING frame should be sent as well. 83 // STOP_WAITING frame should be sent as well.
103 // The contents of the frame(s) will be generated via a call to the delegate 84 // The contents of the frame(s) will be generated via a call to the delegate
104 // CreateAckFrame() when the packet is serialized. 85 // CreateAckFrame() when the packet is serialized.
105 void SetShouldSendAck(bool also_send_stop_waiting); 86 void SetShouldSendAck(bool also_send_stop_waiting);
106 87
107 void AddControlFrame(const QuicFrame& frame); 88 void AddControlFrame(const QuicFrame& frame);
108 89
109 // Given some data, may consume part or all of it and pass it to the 90 // Given some data, may consume part or all of it and pass it to the
110 // packet creator to be serialized into packets. If not in batch 91 // packet creator to be serialized into packets. If not in batch
111 // mode, these packets will also be sent during this call. 92 // mode, these packets will also be sent during this call.
112 // |delegate| (if not nullptr) will be informed once all packets sent as a 93 // |delegate| (if not nullptr) will be informed once all packets sent as a
113 // result of this call are ACKed by the peer. 94 // result of this call are ACKed by the peer.
114 QuicConsumedData ConsumeData(QuicStreamId id, 95 QuicConsumedData ConsumeData(QuicStreamId id,
115 QuicIOVector iov, 96 QuicIOVector iov,
116 QuicStreamOffset offset, 97 QuicStreamOffset offset,
117 bool fin, 98 bool fin,
118 FecProtection fec_protection,
119 QuicAckListenerInterface* listener); 99 QuicAckListenerInterface* listener);
120 100
121 // Generates an MTU discovery packet of specified size. 101 // Generates an MTU discovery packet of specified size.
122 void GenerateMtuDiscoveryPacket(QuicByteCount target_mtu, 102 void GenerateMtuDiscoveryPacket(QuicByteCount target_mtu,
123 QuicAckListenerInterface* listener); 103 QuicAckListenerInterface* listener);
124 104
125 // Indicates whether batch mode is currently enabled. 105 // Indicates whether batch mode is currently enabled.
126 bool InBatchMode(); 106 bool InBatchMode();
127 // Disables flushing. 107 // Disables flushing.
128 void StartBatchOperations(); 108 void StartBatchOperations();
(...skipping 10 matching lines...) Expand all
139 119
140 // Creates a version negotiation packet which supports |supported_versions|. 120 // Creates a version negotiation packet which supports |supported_versions|.
141 // Caller owns the created packet. Also, sets the entropy hash of the 121 // Caller owns the created packet. Also, sets the entropy hash of the
142 // serialized packet to a random bool and returns that value as a member of 122 // serialized packet to a random bool and returns that value as a member of
143 // SerializedPacket. 123 // SerializedPacket.
144 QuicEncryptedPacket* SerializeVersionNegotiationPacket( 124 QuicEncryptedPacket* SerializeVersionNegotiationPacket(
145 const QuicVersionVector& supported_versions); 125 const QuicVersionVector& supported_versions);
146 126
147 // Re-serializes frames with the original packet's packet number length. 127 // Re-serializes frames with the original packet's packet number length.
148 // Used for retransmitting packets to ensure they aren't too long. 128 // Used for retransmitting packets to ensure they aren't too long.
149 // Caller must ensure that any open FEC group is closed before calling this
150 // method.
151 void ReserializeAllFrames(const PendingRetransmission& retransmission, 129 void ReserializeAllFrames(const PendingRetransmission& retransmission,
152 char* buffer, 130 char* buffer,
153 size_t buffer_len); 131 size_t buffer_len);
154 132
155 // Update the packet number length to use in future packets as soon as it 133 // Update the packet number length to use in future packets as soon as it
156 // can be safely changed. 134 // can be safely changed.
157 void UpdateSequenceNumberLength(QuicPacketNumber least_packet_awaited_by_peer, 135 void UpdateSequenceNumberLength(QuicPacketNumber least_packet_awaited_by_peer,
158 QuicPacketCount max_packets_in_flight); 136 QuicPacketCount max_packets_in_flight);
159 137
160 // Set the minimum number of bytes for the connection id length; 138 // Set the minimum number of bytes for the connection id length;
161 void SetConnectionIdLength(uint32_t length); 139 void SetConnectionIdLength(uint32_t length);
162 140
163 // Called when the FEC alarm fires.
164 void OnFecTimeout();
165
166 // Called after sending |packet_number| to determine whether an FEC alarm
167 // should be set for sending out an FEC packet. Returns a positive and finite
168 // timeout if an FEC alarm should be set, and infinite if no alarm should be
169 // set. OnFecTimeout should be called to send the FEC packet when the alarm
170 // fires.
171 QuicTime::Delta GetFecTimeout(QuicPacketNumber packet_number);
172
173 // Sets the encrypter to use for the encryption level. 141 // Sets the encrypter to use for the encryption level.
174 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter); 142 void SetEncrypter(EncryptionLevel level, QuicEncrypter* encrypter);
175 143
176 // Sets the encryption level that will be applied to new packets. 144 // Sets the encryption level that will be applied to new packets.
177 void set_encryption_level(EncryptionLevel level); 145 void set_encryption_level(EncryptionLevel level);
178 146
179 // packet number of the last created packet, or 0 if no packets have been 147 // packet number of the last created packet, or 0 if no packets have been
180 // created. 148 // created.
181 QuicPacketNumber packet_number() const; 149 QuicPacketNumber packet_number() const;
182 150
183 // Returns the maximum packet length. Note that this is the long-term maximum 151 // Returns the maximum packet length. Note that this is the long-term maximum
184 // packet length, and it may not be the maximum length of the current packet, 152 // packet length, and it may not be the maximum length of the current packet,
185 // if the generator is in the middle of the packet (in batch mode) or FEC 153 // if the generator is in the middle of the packet (in batch mode).
186 // group.
187 QuicByteCount GetMaxPacketLength() const; 154 QuicByteCount GetMaxPacketLength() const;
188 // Returns the maximum length current packet can actually have. 155 // Returns the maximum length current packet can actually have.
189 QuicByteCount GetCurrentMaxPacketLength() const; 156 QuicByteCount GetCurrentMaxPacketLength() const;
190 157
191 // Set maximum packet length sent. If |force| is set to true, all pending 158 // Set maximum packet length sent. If |force| is set to true, all pending
192 // unfinished packets and FEC groups are closed, and the change is enacted 159 // unfinished packets are closed, and the change is enacted immediately.
193 // immediately. Otherwise, it is enacted at the next opportunity. 160 // Otherwise, it is enacted at the next opportunity.
194 void SetMaxPacketLength(QuicByteCount length, bool force); 161 void SetMaxPacketLength(QuicByteCount length, bool force);
195 162
196 // Sets |path_id| to be the path on which next packet is generated. 163 // Sets |path_id| to be the path on which next packet is generated.
197 void SetCurrentPath(QuicPathId path_id, 164 void SetCurrentPath(QuicPathId path_id,
198 QuicPacketNumber least_packet_awaited_by_peer, 165 QuicPacketNumber least_packet_awaited_by_peer,
199 QuicPacketCount max_packets_in_flight); 166 QuicPacketCount max_packets_in_flight);
200 167
201 void set_debug_delegate(QuicPacketCreator::DebugDelegate* debug_delegate) { 168 void set_debug_delegate(QuicPacketCreator::DebugDelegate* debug_delegate) {
202 packet_creator_.set_debug_delegate(debug_delegate); 169 packet_creator_.set_debug_delegate(debug_delegate);
203 } 170 }
204 171
205 void set_rtt_multiplier_for_fec_timeout(float rtt_multiplier_for_fec_timeout);
206
207 FecSendPolicy fec_send_policy();
208 void set_fec_send_policy(FecSendPolicy fec_send_policy);
209
210 private: 172 private:
211 friend class test::QuicPacketGeneratorPeer; 173 friend class test::QuicPacketGeneratorPeer;
212 174
213 void SendQueuedFrames(bool flush, bool is_fec_timeout); 175 void SendQueuedFrames(bool flush);
214 176
215 // Test to see if we have pending ack, or control frames. 177 // Test to see if we have pending ack, or control frames.
216 bool HasPendingFrames() const; 178 bool HasPendingFrames() const;
217 // Returns true if addition of a pending frame (which might be 179 // Returns true if addition of a pending frame (which might be
218 // retransmittable) would still allow the resulting packet to be sent now. 180 // retransmittable) would still allow the resulting packet to be sent now.
219 bool CanSendWithNextPendingFrameAddition() const; 181 bool CanSendWithNextPendingFrameAddition() const;
220 // Add exactly one pending frame, preferring ack frames over control frames. 182 // Add exactly one pending frame, preferring ack frames over control frames.
221 // Returns true if a pending frame is successfully added. 183 // Returns true if a pending frame is successfully added.
222 // Returns false and flushes current open packet if the pending frame cannot 184 // Returns false and flushes current open packet if the pending frame cannot
223 // fit into current open packet. 185 // fit into current open packet.
(...skipping 21 matching lines...) Expand all
245 // the maximum size we are actually using now, if we are in the middle of the 207 // the maximum size we are actually using now, if we are in the middle of the
246 // packet. 208 // packet.
247 QuicByteCount max_packet_length_; 209 QuicByteCount max_packet_length_;
248 210
249 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator); 211 DISALLOW_COPY_AND_ASSIGN(QuicPacketGenerator);
250 }; 212 };
251 213
252 } // namespace net 214 } // namespace net
253 215
254 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_ 216 #endif // NET_QUIC_QUIC_PACKET_GENERATOR_H_
OLDNEW
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_packet_generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698