summaryrefslogtreecommitdiffstats
path: root/net/quic/congestion_control/send_algorithm_interface.cc
blob: bc3ee8fa9e5072eba0174a3126b266818ff7bb57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "net/quic/congestion_control/send_algorithm_interface.h"

#include "net/quic/congestion_control/tcp_cubic_bytes_sender.h"
#include "net/quic/congestion_control/tcp_cubic_sender.h"
#include "net/quic/quic_flags.h"
#include "net/quic/quic_protocol.h"

namespace net {

class RttStats;

// Factory for send side congestion control algorithm.
SendAlgorithmInterface* SendAlgorithmInterface::Create(
    const QuicClock* clock,
    const RttStats* rtt_stats,
    CongestionControlType congestion_control_type,
    QuicConnectionStats* stats,
    QuicPacketCount initial_congestion_window) {
  const QuicPacketCount max_congestion_window =
      FLAGS_quic_limit_max_cwnd_to_receive_buffer
          ? (kDefaultSocketReceiveBuffer * kUsableRecieveBufferFraction) /
                kDefaultTCPMSS
          : kMaxTcpCongestionWindow;
  switch (congestion_control_type) {
    case kCubic:
      return new TcpCubicSender(clock, rtt_stats, false /* don't use Reno */,
                                initial_congestion_window,
                                max_congestion_window, stats);
    case kCubicBytes:
      return new TcpCubicBytesSender(
          clock, rtt_stats, false /* don't use Reno */,
          initial_congestion_window, max_congestion_window, stats);
    case kReno:
      return new TcpCubicSender(clock, rtt_stats, true /* use Reno */,
                                initial_congestion_window,
                                max_congestion_window, stats);
    case kRenoBytes:
      return new TcpCubicBytesSender(clock, rtt_stats, true /* use Reno */,
                                     initial_congestion_window,
                                     max_congestion_window, stats);
    case kBBR:
  // TODO(rtenneti): Enable BbrTcpSender.
#if 0
      return new BbrTcpSender(clock, rtt_stats, initial_congestion_window,
                              max_congestion_window, stats, true);
#endif
      LOG(DFATAL) << "BbrTcpSender is not supported.";
      return nullptr;
  }
  return nullptr;
}

}  // namespace net