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

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

Issue 2193073003: Move shared files in net/quic/ into net/quic/core/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: io_thread_unittest.cc Created 4 years, 4 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
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/quic/congestion_control/prr_sender.h"
6
7 #include "net/quic/quic_protocol.h"
8
9 namespace net {
10
11 namespace {
12 // Constant based on TCP defaults.
13 const QuicByteCount kMaxSegmentSize = kDefaultTCPMSS;
14 } // namespace
15
16 PrrSender::PrrSender()
17 : bytes_sent_since_loss_(0),
18 bytes_delivered_since_loss_(0),
19 ack_count_since_loss_(0),
20 bytes_in_flight_before_loss_(0) {}
21
22 void PrrSender::OnPacketSent(QuicByteCount sent_bytes) {
23 bytes_sent_since_loss_ += sent_bytes;
24 }
25
26 void PrrSender::OnPacketLost(QuicByteCount bytes_in_flight) {
27 bytes_sent_since_loss_ = 0;
28 bytes_in_flight_before_loss_ = bytes_in_flight;
29 bytes_delivered_since_loss_ = 0;
30 ack_count_since_loss_ = 0;
31 }
32
33 void PrrSender::OnPacketAcked(QuicByteCount acked_bytes) {
34 bytes_delivered_since_loss_ += acked_bytes;
35 ++ack_count_since_loss_;
36 }
37
38 QuicTime::Delta PrrSender::TimeUntilSend(
39 QuicByteCount congestion_window,
40 QuicByteCount bytes_in_flight,
41 QuicByteCount slowstart_threshold) const {
42 // if (FLAGS_?? && bytes_in_flight < congestion_window) {
43 // return QuicTime::Delta::Zero();
44 // }
45 // Return QuicTime::Zero In order to ensure limited transmit always works.
46 if (bytes_sent_since_loss_ == 0 || bytes_in_flight < kMaxSegmentSize) {
47 return QuicTime::Delta::Zero();
48 }
49 if (congestion_window > bytes_in_flight) {
50 // During PRR-SSRB, limit outgoing packets to 1 extra MSS per ack, instead
51 // of sending the entire available window. This prevents burst retransmits
52 // when more packets are lost than the CWND reduction.
53 // limit = MAX(prr_delivered - prr_out, DeliveredData) + MSS
54 if (bytes_delivered_since_loss_ + ack_count_since_loss_ * kMaxSegmentSize <=
55 bytes_sent_since_loss_) {
56 return QuicTime::Delta::Infinite();
57 }
58 return QuicTime::Delta::Zero();
59 }
60 // Implement Proportional Rate Reduction (RFC6937).
61 // Checks a simplified version of the PRR formula that doesn't use division:
62 // AvailableSendWindow =
63 // CEIL(prr_delivered * ssthresh / BytesInFlightAtLoss) - prr_sent
64 if (bytes_delivered_since_loss_ * slowstart_threshold >
65 bytes_sent_since_loss_ * bytes_in_flight_before_loss_) {
66 return QuicTime::Delta::Zero();
67 }
68 return QuicTime::Delta::Infinite();
69 }
70
71 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/prr_sender.h ('k') | net/quic/congestion_control/prr_sender_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698