blob: 11d31005449534f3d35df0af1a8a8e0a19f8aaec [file] [log] [blame]
Klaus Schneider9e5122b2019-03-19 17:03:25 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2016-2019, Regents of the University of California,
4 * Colorado State University,
5 * University Pierre & Marie Curie, Sorbonne University.
6 *
7 * This file is part of ndn-tools (Named Data Networking Essential Tools).
8 * See AUTHORS.md for complete list of ndn-tools authors and contributors.
9 *
10 * ndn-tools is free software: you can redistribute it and/or modify it under the terms
11 * of the GNU General Public License as published by the Free Software Foundation,
12 * either version 3 of the License, or (at your option) any later version.
13 *
14 * ndn-tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16 * PURPOSE. See the GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * ndn-tools, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
20 *
21 * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
22 *
23 * @author Klaus Schneider
24 */
25
26#ifndef NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_CUBIC_HPP
27#define NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_CUBIC_HPP
28
29#include "pipeline-interests-adaptive.hpp"
30
31namespace ndn {
32namespace chunks {
33
34class PipelineInterestsCubicOptions : public PipelineInterestsAdaptiveOptions
35{
36public:
37 explicit
38 PipelineInterestsCubicOptions(const PipelineInterestsAdaptiveOptions& options =
39 PipelineInterestsAdaptiveOptions())
40 : PipelineInterestsAdaptiveOptions(options)
41 {
42 }
43
44public:
45 bool enableFastConv = false; ///< use cubic fast convergence
46 double cubicBeta = 0.7; ///< multiplicative decrease factor (from Linux kernel: 717/1024)
47};
48
49std::ostream&
50operator<<(std::ostream& os, const PipelineInterestsCubicOptions& options);
51
52/**
53 * @brief Implements Cubic window increase and decrease.
54 *
55 * This implementation follows the RFC8312 https://tools.ietf.org/html/rfc8312
56 * and the Linux kernel implementation https://github.com/torvalds/linux/blob/master/net/ipv4/tcp_cubic.c
57 */
58class PipelineInterestsCubic : public PipelineInterestsAdaptive
59{
60public:
61 using Options = PipelineInterestsCubicOptions;
62
63public:
64 PipelineInterestsCubic(Face& face, RttEstimator& rttEstimator,
65 const Options& options = Options());
66
67private:
68 void
69 increaseWindow() final;
70
71 void
72 decreaseWindow() final;
73
74private:
75 const Options m_cubicOptions;
76
77 double m_wmax = 0.0; ///< window size before last window decrease
78 double m_lastWmax = 0.0; ///< last wmax
79 time::steady_clock::TimePoint m_lastDecrease; ///< time of last window decrease
80};
81
82} // namespace chunks
83} // namespace ndn
84
85#endif // NDN_TOOLS_CHUNKS_CATCHUNKS_PIPELINE_INTERESTS_CUBIC_HPP