OLD | NEW |
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 #include "net/quic/quic_connection.h" | 5 #include "net/quic/quic_connection.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 scheduler_(new QuicSendScheduler(clock_, kTCP)), | 85 scheduler_(new QuicSendScheduler(clock_, kTCP)), |
86 packets_resent_since_last_ack_(0), | 86 packets_resent_since_last_ack_(0), |
87 connected_(true), | 87 connected_(true), |
88 received_truncated_ack_(false) { | 88 received_truncated_ack_(false) { |
89 options()->max_num_packets = kMaxPacketsToSerializeAtOnce; | 89 options()->max_num_packets = kMaxPacketsToSerializeAtOnce; |
90 helper_->SetConnection(this); | 90 helper_->SetConnection(this); |
91 helper_->SetTimeoutAlarm(timeout_); | 91 helper_->SetTimeoutAlarm(timeout_); |
92 framer_.set_visitor(this); | 92 framer_.set_visitor(this); |
93 memset(&last_header_, 0, sizeof(last_header_)); | 93 memset(&last_header_, 0, sizeof(last_header_)); |
94 outgoing_ack_.sent_info.least_unacked = 0; | 94 outgoing_ack_.sent_info.least_unacked = 0; |
95 outgoing_ack_.received_info.largest_received = 0; | 95 outgoing_ack_.received_info.largest_observed = 0; |
96 | 96 |
97 /* | 97 /* |
98 if (FLAGS_fake_packet_loss_percentage > 0) { | 98 if (FLAGS_fake_packet_loss_percentage > 0) { |
99 int32 seed = RandomBase::WeakSeed32(); | 99 int32 seed = RandomBase::WeakSeed32(); |
100 LOG(INFO) << "Seeding packet loss with " << seed; | 100 LOG(INFO) << "Seeding packet loss with " << seed; |
101 random_.reset(new MTRandom(seed)); | 101 random_.reset(new MTRandom(seed)); |
102 } | 102 } |
103 */ | 103 */ |
104 } | 104 } |
105 | 105 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 helper_->SetSendAlarm(delay); | 200 helper_->SetSendAlarm(delay); |
201 } | 201 } |
202 } | 202 } |
203 | 203 |
204 void QuicConnection::OnCongestionFeedbackFrame( | 204 void QuicConnection::OnCongestionFeedbackFrame( |
205 const QuicCongestionFeedbackFrame& feedback) { | 205 const QuicCongestionFeedbackFrame& feedback) { |
206 scheduler_->OnIncomingQuicCongestionFeedbackFrame(feedback); | 206 scheduler_->OnIncomingQuicCongestionFeedbackFrame(feedback); |
207 } | 207 } |
208 | 208 |
209 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { | 209 bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) { |
210 if (incoming_ack.received_info.largest_received > | 210 if (incoming_ack.received_info.largest_observed > |
211 packet_creator_.sequence_number()) { | 211 packet_creator_.sequence_number()) { |
212 DLOG(ERROR) << "Client acked unsent packet:" | 212 DLOG(ERROR) << "Client observed unsent packet:" |
213 << incoming_ack.received_info.largest_received << " vs " | 213 << incoming_ack.received_info.largest_observed << " vs " |
214 << packet_creator_.sequence_number(); | 214 << packet_creator_.sequence_number(); |
215 // We got an error for data we have not sent. Error out. | 215 // We got an error for data we have not sent. Error out. |
216 return false; | 216 return false; |
217 } | 217 } |
218 | 218 |
219 // We can't have too many unacked packets, or our ack frames go over | 219 // We can't have too many unacked packets, or our ack frames go over |
220 // kMaxPacketSize. | 220 // kMaxPacketSize. |
221 DCHECK_LE(incoming_ack.received_info.missing_packets.size(), | 221 DCHECK_LE(incoming_ack.received_info.missing_packets.size(), |
222 kMaxUnackedPackets); | 222 kMaxUnackedPackets); |
223 | 223 |
(...skipping 15 matching lines...) Expand all Loading... |
239 } | 239 } |
240 | 240 |
241 return true; | 241 return true; |
242 } | 242 } |
243 | 243 |
244 void QuicConnection::UpdatePacketInformationReceivedByPeer( | 244 void QuicConnection::UpdatePacketInformationReceivedByPeer( |
245 const QuicAckFrame& incoming_ack) { | 245 const QuicAckFrame& incoming_ack) { |
246 QuicConnectionVisitorInterface::AckedPackets acked_packets; | 246 QuicConnectionVisitorInterface::AckedPackets acked_packets; |
247 | 247 |
248 // Initialize the lowest unacked packet to the lower of the next outgoing | 248 // Initialize the lowest unacked packet to the lower of the next outgoing |
249 // sequence number and the largest received packed in the incoming ack. | 249 // sequence number and the largest observed packet in the incoming ack. |
250 QuicPacketSequenceNumber lowest_unacked = min( | 250 QuicPacketSequenceNumber lowest_unacked = min( |
251 packet_creator_.sequence_number() + 1, | 251 packet_creator_.sequence_number() + 1, |
252 incoming_ack.received_info.largest_received + 1); | 252 incoming_ack.received_info.largest_observed + 1); |
253 | 253 |
254 int resent_packets = 0; | 254 int resent_packets = 0; |
255 | 255 |
256 // Go through the packets we have not received an ack for and see if this | 256 // Go through the packets we have not received an ack for and see if this |
257 // incoming_ack shows they've been seen by the peer. | 257 // incoming_ack shows they've been seen by the peer. |
258 UnackedPacketMap::iterator it = unacked_packets_.begin(); | 258 UnackedPacketMap::iterator it = unacked_packets_.begin(); |
259 while (it != unacked_packets_.end()) { | 259 while (it != unacked_packets_.end()) { |
260 if (!incoming_ack.received_info.IsAwaitingPacket(it->first)) { | 260 if (!incoming_ack.received_info.IsAwaitingPacket(it->first)) { |
261 // Packet was acked, so remove it from our unacked packet list. | 261 // Packet was acked, so remove it from our unacked packet list. |
262 DVLOG(1) << "Got an ack for " << it->first; | 262 DVLOG(1) << "Got an ack for " << it->first; |
(...skipping 16 matching lines...) Expand all Loading... |
279 // seen at the time of this ack being sent out. See if it's our new | 279 // seen at the time of this ack being sent out. See if it's our new |
280 // lowest unacked packet. | 280 // lowest unacked packet. |
281 DVLOG(1) << "still missing " << it->first; | 281 DVLOG(1) << "still missing " << it->first; |
282 if (it->first < lowest_unacked) { | 282 if (it->first < lowest_unacked) { |
283 lowest_unacked = it->first; | 283 lowest_unacked = it->first; |
284 } | 284 } |
285 | 285 |
286 // Determine if this packet is being explicitly nacked and, if so, if it | 286 // Determine if this packet is being explicitly nacked and, if so, if it |
287 // is worth resending. | 287 // is worth resending. |
288 QuicPacketSequenceNumber resend_number = 0; | 288 QuicPacketSequenceNumber resend_number = 0; |
289 if (it->first < incoming_ack.received_info.largest_received) { | 289 if (it->first < incoming_ack.received_info.largest_observed) { |
290 // The peer got packets after this sequence number. This is an explicit | 290 // The peer got packets after this sequence number. This is an explicit |
291 // nack. | 291 // nack. |
292 ++(it->second.number_nacks); | 292 ++(it->second.number_nacks); |
293 if (it->second.number_nacks >= kNumberOfNacksBeforeResend && | 293 if (it->second.number_nacks >= kNumberOfNacksBeforeResend && |
294 resent_packets < kMaxResendPerAck) { | 294 resent_packets < kMaxResendPerAck) { |
295 resend_number = it->first; | 295 resend_number = it->first; |
296 } | 296 } |
297 } | 297 } |
298 | 298 |
299 ++it; | 299 ++it; |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 << " delta:" << delta.ToMicroseconds(); | 767 << " delta:" << delta.ToMicroseconds(); |
768 if (delta >= timeout_) { | 768 if (delta >= timeout_) { |
769 SendConnectionClose(QUIC_CONNECTION_TIMED_OUT); | 769 SendConnectionClose(QUIC_CONNECTION_TIMED_OUT); |
770 return true; | 770 return true; |
771 } | 771 } |
772 helper_->SetTimeoutAlarm(timeout_.Subtract(delta)); | 772 helper_->SetTimeoutAlarm(timeout_.Subtract(delta)); |
773 return false; | 773 return false; |
774 } | 774 } |
775 | 775 |
776 } // namespace net | 776 } // namespace net |
OLD | NEW |