Eric Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 1 | /* -*- 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 | |
| 27 | namespace ns3 { |
| 28 | namespace ndn { |
| 29 | |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 30 | enum CcAlgorithm { |
| 31 | AIMD, |
| 32 | BIC, |
| 33 | CUBIC |
| 34 | }; |
| 35 | |
Eric Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 36 | /** |
| 37 | * @ingroup ndn-apps |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 38 | * \brief NDN consumer application with more advanced congestion control options |
Eric Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 39 | * |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 40 | * 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 Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 45 | */ |
| 46 | class ConsumerPcon : public ConsumerWindow { |
| 47 | public: |
| 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 | |
| 59 | private: |
| 60 | void |
| 61 | WindowIncrease(); |
| 62 | |
| 63 | void |
| 64 | WindowDecrease(); |
| 65 | |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 66 | void |
| 67 | CubicIncrease(); |
| 68 | |
| 69 | void |
| 70 | CubicDecrease(); |
| 71 | |
| 72 | void |
| 73 | BicIncrease(); |
| 74 | |
| 75 | void |
| 76 | BicDecrease(); |
| 77 | |
Eric Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 78 | private: |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 79 | CcAlgorithm m_ccAlgorithm; |
Eric Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 80 | double m_beta; |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 81 | double m_addRttSuppress; |
| 82 | bool m_reactToCongestionMarks; |
| 83 | bool m_useCwa; |
Eric Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 84 | |
| 85 | double m_ssthresh; |
| 86 | uint32_t m_highData; |
| 87 | double m_recPoint; |
schneiderklaus | af97d0f | 2018-07-18 18:58:14 -0700 | [diff] [blame] | 88 | |
| 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 Newberry | 8821d3e | 2018-07-04 16:42:01 -0400 | [diff] [blame] | 112 | }; |
| 113 | |
| 114 | } // namespace ndn |
| 115 | } // namespace ns3 |
| 116 | |
| 117 | #endif // NDN_CONSUMER_PCON_H |