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

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

Issue 399763004: QUIC test only change to add track the observed loss rate in (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/congestion_control/send_algorithm_simulator.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 16 matching lines...) Expand all
27 RttStats* rtt_stats) 27 RttStats* rtt_stats)
28 : send_algorithm(send_algorithm), 28 : send_algorithm(send_algorithm),
29 rtt_stats(rtt_stats), 29 rtt_stats(rtt_stats),
30 last_sent(0), 30 last_sent(0),
31 last_acked(0), 31 last_acked(0),
32 next_acked(1), 32 next_acked(1),
33 max_cwnd(0), 33 max_cwnd(0),
34 min_cwnd(100000), 34 min_cwnd(100000),
35 max_cwnd_drop(0), 35 max_cwnd_drop(0),
36 last_cwnd(0), 36 last_cwnd(0),
37 last_transfer_bandwidth(QuicBandwidth::Zero()) {} 37 last_transfer_bandwidth(QuicBandwidth::Zero()),
38 last_transfer_loss_rate(0) {}
38 39
39 SendAlgorithmSimulator::SendAlgorithmSimulator( 40 SendAlgorithmSimulator::SendAlgorithmSimulator(
40 MockClock* clock, 41 MockClock* clock,
41 QuicBandwidth bandwidth, 42 QuicBandwidth bandwidth,
42 QuicTime::Delta rtt) 43 QuicTime::Delta rtt)
43 : clock_(clock), 44 : clock_(clock),
44 lose_next_ack_(false), 45 lose_next_ack_(false),
45 forward_loss_rate_(0), 46 forward_loss_rate_(0),
46 reverse_loss_rate_(0), 47 reverse_loss_rate_(0),
47 loss_correlation_(0), 48 loss_correlation_(0),
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 clock_->Now()); 262 clock_->Now());
262 sender->send_algorithm->OnCongestionEvent( 263 sender->send_algorithm->OnCongestionEvent(
263 true, transfer->bytes_in_flight, acked_packets, lost_packets); 264 true, transfer->bytes_in_flight, acked_packets, lost_packets);
264 DCHECK_LE(kPacketSize * (acked_packets.size() + lost_packets.size()), 265 DCHECK_LE(kPacketSize * (acked_packets.size() + lost_packets.size()),
265 transfer->bytes_in_flight); 266 transfer->bytes_in_flight);
266 transfer->bytes_in_flight -= 267 transfer->bytes_in_flight -=
267 kPacketSize * (acked_packets.size() + lost_packets.size()); 268 kPacketSize * (acked_packets.size() + lost_packets.size());
268 269
269 sender->RecordStats(); 270 sender->RecordStats();
270 transfer->bytes_acked += acked_packets.size() * kPacketSize; 271 transfer->bytes_acked += acked_packets.size() * kPacketSize;
272 transfer->bytes_lost += lost_packets.size() * kPacketSize;
271 if (transfer->bytes_acked >= transfer->num_bytes) { 273 if (transfer->bytes_acked >= transfer->num_bytes) {
272 // Remove completed transfers and record transfer bandwidth. 274 // Remove completed transfers and record transfer bandwidth.
273 QuicTime::Delta transfer_time = 275 QuicTime::Delta transfer_time =
274 clock_->Now().Subtract(transfer->start_time); 276 clock_->Now().Subtract(transfer->start_time);
277 sender->last_transfer_loss_rate = static_cast<float>(transfer->bytes_lost) /
278 (transfer->bytes_lost + transfer->bytes_acked);
275 sender->last_transfer_bandwidth = 279 sender->last_transfer_bandwidth =
276 QuicBandwidth::FromBytesAndTimeDelta(transfer->num_bytes, 280 QuicBandwidth::FromBytesAndTimeDelta(transfer->num_bytes,
277 transfer_time); 281 transfer_time);
278 for (vector<Transfer>::iterator it = pending_transfers_.begin(); 282 for (vector<Transfer>::iterator it = pending_transfers_.begin();
279 it != pending_transfers_.end(); ++it) { 283 it != pending_transfers_.end(); ++it) {
280 if (transfer == &(*it)) { 284 if (transfer == &(*it)) {
281 pending_transfers_.erase(it); 285 pending_transfers_.erase(it);
282 break; 286 break;
283 } 287 }
284 } 288 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 } 333 }
330 transfer->bytes_in_flight += kPacketSize; 334 transfer->bytes_in_flight += kPacketSize;
331 } 335 }
332 336
333 // Advance the time by |delta| without sending anything. 337 // Advance the time by |delta| without sending anything.
334 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) { 338 void SendAlgorithmSimulator::AdvanceTime(QuicTime::Delta delta) {
335 clock_->AdvanceTime(delta); 339 clock_->AdvanceTime(delta);
336 } 340 }
337 341
338 } // namespace net 342 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/send_algorithm_simulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698