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

Side by Side Diff: net/quic/congestion_control/send_algorithm_simulator.cc

Issue 530343003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0828
Patch Set: Created 6 years, 3 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/congestion_control/send_algorithm_simulator.h" 5 #include "net/quic/congestion_control/send_algorithm_simulator.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/rand_util.h" 10 #include "base/rand_util.h"
11 #include "net/quic/crypto/quic_random.h" 11 #include "net/quic/crypto/quic_random.h"
12 12
13 using std::list; 13 using std::list;
14 using std::make_pair;
14 using std::max; 15 using std::max;
15 using std::min; 16 using std::min;
16 using std::vector; 17 using std::vector;
17 18
18 namespace net { 19 namespace net {
19 20
20 namespace { 21 namespace {
21 22
22 const QuicByteCount kPacketSize = 1200; 23 const QuicByteCount kPacketSize = 1200;
23 24
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return true; 238 return true;
238 } 239 }
239 last_packet = it->sequence_number; 240 last_packet = it->sequence_number;
240 } 241 }
241 return false; 242 return false;
242 } 243 }
243 244
244 void SendAlgorithmSimulator::HandlePendingAck(Transfer* transfer) { 245 void SendAlgorithmSimulator::HandlePendingAck(Transfer* transfer) {
245 Sender* sender = transfer->sender; 246 Sender* sender = transfer->sender;
246 DCHECK_LT(sender->last_acked, sender->next_acked); 247 DCHECK_LT(sender->last_acked, sender->next_acked);
247 SendAlgorithmInterface::CongestionMap acked_packets; 248 SendAlgorithmInterface::CongestionVector acked_packets;
248 SendAlgorithmInterface::CongestionMap lost_packets; 249 SendAlgorithmInterface::CongestionVector lost_packets;
249 DVLOG(1) << "Acking packets from:" << sender->last_acked 250 DVLOG(1) << "Acking packets from:" << sender->last_acked
250 << " to " << sender->next_acked 251 << " to " << sender->next_acked
251 << " bytes_in_flight:" << transfer->bytes_in_flight 252 << " bytes_in_flight:" << transfer->bytes_in_flight
252 << " Now():" << (clock_->Now().ToDebuggingValue() / 1000) << "ms"; 253 << " Now():" << (clock_->Now().ToDebuggingValue() / 1000) << "ms";
253 // Some entries may be missing from the sent_packets_ array, if they were 254 // Some entries may be missing from the sent_packets_ array, if they were
254 // dropped due to buffer overruns. 255 // dropped due to buffer overruns.
255 SentPacket largest_observed; 256 SentPacket largest_observed;
256 list<SentPacket>::iterator it = sent_packets_.begin(); 257 list<SentPacket>::iterator it = sent_packets_.begin();
257 while (sender->last_acked < sender->next_acked) { 258 while (sender->last_acked < sender->next_acked) {
258 ++sender->last_acked; 259 ++sender->last_acked;
259 TransmissionInfo info = TransmissionInfo(); 260 TransmissionInfo info = TransmissionInfo();
260 info.bytes_sent = kPacketSize; 261 info.bytes_sent = kPacketSize;
261 info.in_flight = true; 262 info.in_flight = true;
262 // Find the next SentPacket for this transfer. 263 // Find the next SentPacket for this transfer.
263 while (it->transfer != transfer) { 264 while (it->transfer != transfer) {
264 DCHECK(it != sent_packets_.end()); 265 DCHECK(it != sent_packets_.end());
265 ++it; 266 ++it;
266 } 267 }
267 // If it's missing from the array, it's a loss. 268 // If it's missing from the array, it's a loss.
268 if (it->sequence_number > sender->last_acked) { 269 if (it->sequence_number > sender->last_acked) {
269 DVLOG(1) << "Lost packet:" << sender->last_acked 270 DVLOG(1) << "Lost packet:" << sender->last_acked
270 << " dropped by buffer overflow."; 271 << " dropped by buffer overflow.";
271 lost_packets[sender->last_acked] = info; 272 lost_packets.push_back(make_pair(sender->last_acked, info));
272 continue; 273 continue;
273 } 274 }
274 if (it->lost) { 275 if (it->lost) {
275 lost_packets[sender->last_acked] = info; 276 lost_packets.push_back(make_pair(sender->last_acked, info));
276 } else { 277 } else {
277 acked_packets[sender->last_acked] = info; 278 acked_packets.push_back(make_pair(sender->last_acked, info));
278 } 279 }
279 // This packet has been acked or lost, remove it from sent_packets_. 280 // This packet has been acked or lost, remove it from sent_packets_.
280 largest_observed = *it; 281 largest_observed = *it;
281 sent_packets_.erase(it++); 282 sent_packets_.erase(it++);
282 } 283 }
283 284
284 DCHECK(largest_observed.ack_time.IsInitialized()); 285 DCHECK(largest_observed.ack_time.IsInitialized());
285 DVLOG(1) << "Updating RTT from send_time:" 286 DVLOG(1) << "Updating RTT from send_time:"
286 << largest_observed.send_time.ToDebuggingValue() << " to ack_time:" 287 << largest_observed.send_time.ToDebuggingValue() << " to ack_time:"
287 << largest_observed.ack_time.ToDebuggingValue(); 288 << largest_observed.ack_time.ToDebuggingValue();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 364 }
364 transfer->bytes_in_flight += kPacketSize; 365 transfer->bytes_in_flight += kPacketSize;
365 } 366 }
366 367
367 // Advance the time by |delta| without sending anything. 368 // Advance the time by |delta| without sending anything.
368 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { 369 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) {
369 clock_->AdvanceTime(delta); 370 clock_->AdvanceTime(delta);
370 } 371 }
371 372
372 } // namespace net 373 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_interface.h ('k') | net/quic/congestion_control/tcp_cubic_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698