blob: 080e675c6fddb7560e9447101c724f4c21604b67 [file] [log] [blame]
Eric Newberry8821d3e2018-07-04 16:42:01 -04001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011-2018 Regents of the University of California.
4 *
5 * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
6 * contributors.
7 *
8 * ndnSIM is free software: you can redistribute it and/or modify it under the terms
9 * of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 **/
19
20#ifndef NDN_CONSUMER_PCON_H
21#define NDN_CONSUMER_PCON_H
22
23#include "ns3/ndnSIM/model/ndn-common.hpp"
24
25#include "ndn-consumer-window.hpp"
26
27namespace ns3 {
28namespace ndn {
29
schneiderklausaf97d0f2018-07-18 18:58:14 -070030enum CcAlgorithm {
31 AIMD,
32 BIC,
33 CUBIC
34};
35
Eric Newberry8821d3e2018-07-04 16:42:01 -040036/**
37 * @ingroup ndn-apps
schneiderklausaf97d0f2018-07-18 18:58:14 -070038 * \brief NDN consumer application with more advanced congestion control options
Eric Newberry8821d3e2018-07-04 16:42:01 -040039 *
schneiderklausaf97d0f2018-07-18 18:58:14 -070040 * This app uses the algorithms from "A Practical Congestion Control Scheme for Named
41 * Data Networking" (https://dl.acm.org/citation.cfm?id=2984369).
42 *
43 * It implements slow start, conservative window adaptation (RFC 6675),
44 * and 3 different TCP algorithms: AIMD, BIC, and CUBIC (RFC 8312).
Eric Newberry8821d3e2018-07-04 16:42:01 -040045 */
46class ConsumerPcon : public ConsumerWindow {
47public:
48 static TypeId
49 GetTypeId();
50
51 ConsumerPcon();
52
53 virtual void
54 OnData(shared_ptr<const Data> data) override;
55
56 virtual void
57 OnTimeout(uint32_t sequenceNum) override;
58
59private:
60 void
61 WindowIncrease();
62
63 void
64 WindowDecrease();
65
schneiderklausaf97d0f2018-07-18 18:58:14 -070066 void
67 CubicIncrease();
68
69 void
70 CubicDecrease();
71
72 void
73 BicIncrease();
74
75 void
76 BicDecrease();
77
Eric Newberry8821d3e2018-07-04 16:42:01 -040078private:
schneiderklausaf97d0f2018-07-18 18:58:14 -070079 CcAlgorithm m_ccAlgorithm;
Eric Newberry8821d3e2018-07-04 16:42:01 -040080 double m_beta;
schneiderklausaf97d0f2018-07-18 18:58:14 -070081 double m_addRttSuppress;
82 bool m_reactToCongestionMarks;
83 bool m_useCwa;
Eric Newberry8821d3e2018-07-04 16:42:01 -040084
85 double m_ssthresh;
86 uint32_t m_highData;
87 double m_recPoint;
schneiderklausaf97d0f2018-07-18 18:58:14 -070088
89 // TCP CUBIC Parameters //
90 static constexpr double CUBIC_C = 0.4;
91 bool m_useCubicFastConv;
92 double m_cubicBeta;
93
94 double m_cubicWmax;
95 double m_cubicLastWmax;
96 time::steady_clock::TimePoint m_cubicLastDecrease;
97
98 // TCP BIC Parameters //
99 //! Regular TCP behavior (including slow start) until this window size
100 static constexpr uint32_t BIC_LOW_WINDOW = 14;
101
102 //! Sets the maximum (linear) increase of TCP BIC. Should be between 8 and 64.
103 static constexpr uint32_t BIC_MAX_INCREMENT = 16;
104
105 // BIC variables:
106 double m_bicMinWin; //!< last minimum cwnd
107 double m_bicMaxWin; //!< last maximum cwnd
108 double m_bicTargetWin;
109 double m_bicSsCwnd;
110 double m_bicSsTarget;
111 bool m_isBicSs; //!< whether we are currently in the BIC slow start phase
Eric Newberry8821d3e2018-07-04 16:42:01 -0400112};
113
114} // namespace ndn
115} // namespace ns3
116
117#endif // NDN_CONSUMER_PCON_H