Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
Klaus Schneider | 7072e16 | 2017-09-16 13:43:00 -0700 | [diff] [blame] | 2 | /* |
Chavoosh Ghasemi | d8f9af2 | 2019-02-28 09:47:26 -0800 | [diff] [blame] | 3 | * Copyright (c) 2016-2019, Regents of the University of California, |
Davide Pesavento | 92998fe | 2017-01-18 21:04:52 -0500 | [diff] [blame] | 4 | * Colorado State University, |
| 5 | * University Pierre & Marie Curie, Sorbonne University. |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 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 Wentao Shang |
| 24 | * @author Steve DiBenedetto |
| 25 | * @author Andrea Tosatto |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 26 | * @author Davide Pesavento |
| 27 | * @author Weiwei Liu |
Klaus Schneider | 7072e16 | 2017-09-16 13:43:00 -0700 | [diff] [blame] | 28 | * @author Klaus Schneider |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 29 | * @author Chavoosh Ghasemi |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 30 | */ |
| 31 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 32 | #include "consumer.hpp" |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 33 | #include "discover-version.hpp" |
Junxiao Shi | f860649 | 2017-07-23 03:44:34 +0000 | [diff] [blame] | 34 | #include "options.hpp" |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 35 | #include "pipeline-interests-aimd.hpp" |
| 36 | #include "pipeline-interests-cubic.hpp" |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 37 | #include "pipeline-interests-fixed.hpp" |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 38 | #include "statistics-collector.hpp" |
Junxiao Shi | f860649 | 2017-07-23 03:44:34 +0000 | [diff] [blame] | 39 | #include "core/version.hpp" |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 40 | |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 41 | #include <fstream> |
Junxiao Shi | f860649 | 2017-07-23 03:44:34 +0000 | [diff] [blame] | 42 | #include <ndn-cxx/security/validator-null.hpp> |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 43 | |
| 44 | namespace ndn { |
| 45 | namespace chunks { |
| 46 | |
| 47 | static int |
Davide Pesavento | da85e25 | 2019-03-18 11:42:01 -0400 | [diff] [blame] | 48 | main(int argc, char* argv[]) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 49 | { |
| 50 | std::string programName(argv[0]); |
| 51 | Options options; |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 52 | std::string pipelineType("cubic"); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 53 | size_t maxPipelineSize(1); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 54 | std::string uri; |
| 55 | |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 56 | // congestion control parameters |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 57 | bool disableCwa(false), resetCwndToInit(false), |
| 58 | ignoreCongMarks(false), enableFastConv(false); |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 59 | int initCwnd(1), initSsthresh(std::numeric_limits<int>::max()), k(8); |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 60 | double aiStep(1.0), rtoAlpha(0.125), rtoBeta(0.25), aimdBeta(0.5), cubicBeta(0.7); |
Davide Pesavento | 0da1f44 | 2019-07-26 17:38:13 -0400 | [diff] [blame^] | 61 | time::milliseconds::rep minRto(200), maxRto(60000); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 62 | std::string cwndPath, rttPath; |
| 63 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 64 | namespace po = boost::program_options; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 65 | po::options_description basicDesc("Basic Options"); |
| 66 | basicDesc.add_options() |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 67 | ("help,h", "print this help message and exit") |
Klaus Schneider | 7072e16 | 2017-09-16 13:43:00 -0700 | [diff] [blame] | 68 | ("pipeline-type,p", po::value<std::string>(&pipelineType)->default_value(pipelineType), |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 69 | "type of Interest pipeline to use; valid values are: 'fixed', 'aimd', 'cubic'") |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 70 | ("fresh,f", po::bool_switch(&options.mustBeFresh), "only return fresh content") |
Davide Pesavento | 0da1f44 | 2019-07-26 17:38:13 -0400 | [diff] [blame^] | 71 | ("lifetime,l", po::value<time::milliseconds::rep>()->default_value(options.interestLifetime.count()), |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 72 | "lifetime of expressed Interests, in milliseconds") |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 73 | ("retries,r", po::value<int>(&options.maxRetriesOnTimeoutOrNack)->default_value(options.maxRetriesOnTimeoutOrNack), |
| 74 | "maximum number of retries in case of Nack or timeout (-1 = no limit)") |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 75 | ("quiet,q", po::bool_switch(&options.isQuiet), "suppress all diagnostic output, except fatal errors") |
| 76 | ("verbose,v", po::bool_switch(&options.isVerbose), "turn on verbose output (per segment information") |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 77 | ("version,V", "print program version and exit") |
| 78 | ; |
| 79 | |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 80 | po::options_description fixedPipeDesc("Fixed pipeline options"); |
| 81 | fixedPipeDesc.add_options() |
| 82 | ("pipeline-size,s", po::value<size_t>(&maxPipelineSize)->default_value(maxPipelineSize), |
| 83 | "size of the Interest pipeline") |
| 84 | ; |
| 85 | |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 86 | po::options_description adaptivePipeDesc("Adaptive pipeline options (AIMD & CUBIC)"); |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 87 | adaptivePipeDesc.add_options() |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 88 | ("ignore-marks", po::bool_switch(&ignoreCongMarks), |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 89 | "do not decrease the window after receiving a congestion mark") |
| 90 | ("disable-cwa", po::bool_switch(&disableCwa), |
| 91 | "disable Conservative Window Adaptation, i.e., reduce the window on " |
| 92 | "each timeout or congestion mark instead of at most once per RTT") |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 93 | ("reset-cwnd-to-init", po::bool_switch(&resetCwndToInit), |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 94 | "after a timeout or congestion mark, reset the window " |
| 95 | "to the initial value instead of resetting to ssthresh") |
| 96 | ("init-cwnd", po::value<int>(&initCwnd)->default_value(initCwnd), |
| 97 | "initial congestion window in segments") |
| 98 | ("init-ssthresh", po::value<int>(&initSsthresh), |
| 99 | "initial slow start threshold in segments (defaults to infinity)") |
| 100 | ("aimd-step", po::value<double>(&aiStep)->default_value(aiStep), |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 101 | "additive-increase step") |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 102 | ("aimd-beta", po::value<double>(&aimdBeta)->default_value(aimdBeta), |
| 103 | "multiplicative decrease factor (AIMD)") |
| 104 | ("rto-alpha", po::value<double>(&rtoAlpha)->default_value(rtoAlpha), |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 105 | "alpha value for RTO calculation") |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 106 | ("rto-beta", po::value<double>(&rtoBeta)->default_value(rtoBeta), |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 107 | "beta value for RTO calculation") |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 108 | ("rto-k", po::value<int>(&k)->default_value(k), |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 109 | "k value for RTO calculation") |
Davide Pesavento | 0da1f44 | 2019-07-26 17:38:13 -0400 | [diff] [blame^] | 110 | ("min-rto", po::value<time::milliseconds::rep>(&minRto)->default_value(minRto), |
| 111 | "minimum RTO value, in milliseconds") |
| 112 | ("max-rto", po::value<time::milliseconds::rep>(&maxRto)->default_value(maxRto), |
| 113 | "maximum RTO value, in milliseconds") |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 114 | ("log-cwnd", po::value<std::string>(&cwndPath), "log file for congestion window stats") |
| 115 | ("log-rtt", po::value<std::string>(&rttPath), "log file for round-trip time stats") |
| 116 | ; |
| 117 | |
| 118 | po::options_description cubicPipeDesc("CUBIC pipeline options"); |
| 119 | cubicPipeDesc.add_options() |
| 120 | ("fast-conv", po::bool_switch(&enableFastConv), "enable cubic fast convergence") |
| 121 | ("cubic-beta", po::value<double>(&cubicBeta), |
| 122 | "window decrease factor for CUBIC (defaults to 0.7)") |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 123 | ; |
| 124 | |
| 125 | po::options_description visibleDesc; |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 126 | visibleDesc.add(basicDesc) |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 127 | .add(fixedPipeDesc) |
| 128 | .add(adaptivePipeDesc) |
| 129 | .add(cubicPipeDesc); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 130 | |
| 131 | po::options_description hiddenDesc; |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 132 | hiddenDesc.add_options() |
| 133 | ("ndn-name,n", po::value<std::string>(&uri), "NDN name of the requested content"); |
| 134 | |
Davide Pesavento | 6752d94 | 2019-07-26 16:26:32 -0400 | [diff] [blame] | 135 | po::options_description optDesc; |
| 136 | optDesc.add(visibleDesc).add(hiddenDesc); |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 137 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 138 | po::positional_options_description p; |
| 139 | p.add("ndn-name", -1); |
| 140 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 141 | po::variables_map vm; |
| 142 | try { |
| 143 | po::store(po::command_line_parser(argc, argv).options(optDesc).positional(p).run(), vm); |
| 144 | po::notify(vm); |
| 145 | } |
| 146 | catch (const po::error& e) { |
| 147 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 148 | return 2; |
| 149 | } |
| 150 | catch (const boost::bad_any_cast& e) { |
| 151 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 152 | return 2; |
| 153 | } |
| 154 | |
| 155 | if (vm.count("help") > 0) { |
| 156 | std::cout << "Usage: " << programName << " [options] ndn:/name" << std::endl; |
| 157 | std::cout << visibleDesc; |
| 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | if (vm.count("version") > 0) { |
| 162 | std::cout << "ndncatchunks " << tools::VERSION << std::endl; |
| 163 | return 0; |
| 164 | } |
| 165 | |
| 166 | if (vm.count("ndn-name") == 0) { |
| 167 | std::cerr << "Usage: " << programName << " [options] ndn:/name" << std::endl; |
| 168 | std::cerr << visibleDesc; |
| 169 | return 2; |
| 170 | } |
| 171 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 172 | if (maxPipelineSize < 1 || maxPipelineSize > 1024) { |
| 173 | std::cerr << "ERROR: pipeline size must be between 1 and 1024" << std::endl; |
| 174 | return 2; |
| 175 | } |
| 176 | |
| 177 | if (options.maxRetriesOnTimeoutOrNack < -1 || options.maxRetriesOnTimeoutOrNack > 1024) { |
| 178 | std::cerr << "ERROR: retries value must be between -1 and 1024" << std::endl; |
| 179 | return 2; |
| 180 | } |
| 181 | |
Davide Pesavento | 0da1f44 | 2019-07-26 17:38:13 -0400 | [diff] [blame^] | 182 | options.interestLifetime = time::milliseconds(vm["lifetime"].as<time::milliseconds::rep>()); |
| 183 | if (options.interestLifetime < 0_ms) { |
Klaus Schneider | 7072e16 | 2017-09-16 13:43:00 -0700 | [diff] [blame] | 184 | std::cerr << "ERROR: lifetime cannot be negative" << std::endl; |
| 185 | return 2; |
| 186 | } |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 187 | |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 188 | if (options.isQuiet && options.isVerbose) { |
| 189 | std::cerr << "ERROR: cannot be quiet and verbose at the same time" << std::endl; |
| 190 | return 2; |
| 191 | } |
| 192 | |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 193 | try { |
| 194 | Face face; |
Chavoosh Ghasemi | bb2d280 | 2019-03-26 16:07:58 -0700 | [diff] [blame] | 195 | auto discover = make_unique<DiscoverVersion>(Name(uri), face, options); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 196 | unique_ptr<PipelineInterests> pipeline; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 197 | unique_ptr<StatisticsCollector> statsCollector; |
| 198 | unique_ptr<RttEstimator> rttEstimator; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 199 | std::ofstream statsFileCwnd; |
| 200 | std::ofstream statsFileRtt; |
| 201 | |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 202 | if (pipelineType == "fixed") { |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 203 | PipelineInterestsFixed::Options optionsPipeline(options); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 204 | optionsPipeline.maxPipelineSize = maxPipelineSize; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 205 | pipeline = make_unique<PipelineInterestsFixed>(face, optionsPipeline); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 206 | } |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 207 | else if (pipelineType == "aimd" || pipelineType == "cubic") { |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 208 | RttEstimator::Options optionsRttEst; |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 209 | optionsRttEst.alpha = rtoAlpha; |
| 210 | optionsRttEst.beta = rtoBeta; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 211 | optionsRttEst.k = k; |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 212 | optionsRttEst.initialRto = 1_s; |
| 213 | optionsRttEst.minRto = time::milliseconds(minRto); |
| 214 | optionsRttEst.maxRto = time::milliseconds(maxRto); |
| 215 | optionsRttEst.rtoBackoffMultiplier = 2; |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 216 | rttEstimator = make_unique<RttEstimator>(optionsRttEst); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 217 | |
Davide Pesavento | 7057640 | 2019-06-07 16:42:21 -0400 | [diff] [blame] | 218 | if (options.isVerbose) { |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 219 | using namespace ndn::time; |
Davide Pesavento | 7057640 | 2019-06-07 16:42:21 -0400 | [diff] [blame] | 220 | std::cerr << "RTT estimator parameters:\n" |
| 221 | << "\tAlpha = " << optionsRttEst.alpha << "\n" |
| 222 | << "\tBeta = " << optionsRttEst.beta << "\n" |
| 223 | << "\tK = " << optionsRttEst.k << "\n" |
Davide Pesavento | ba56066 | 2019-06-26 22:45:44 -0400 | [diff] [blame] | 224 | << "\tInitial RTO = " << duration_cast<milliseconds>(optionsRttEst.initialRto) << "\n" |
| 225 | << "\tMin RTO = " << duration_cast<milliseconds>(optionsRttEst.minRto) << "\n" |
| 226 | << "\tMax RTO = " << duration_cast<milliseconds>(optionsRttEst.maxRto) << "\n" |
Davide Pesavento | 7057640 | 2019-06-07 16:42:21 -0400 | [diff] [blame] | 227 | << "\tBackoff multiplier = " << optionsRttEst.rtoBackoffMultiplier << "\n"; |
| 228 | } |
| 229 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 230 | PipelineInterestsAdaptive::Options optionsPipeline(options); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 231 | optionsPipeline.disableCwa = disableCwa; |
| 232 | optionsPipeline.resetCwndToInit = resetCwndToInit; |
Davide Pesavento | 7057640 | 2019-06-07 16:42:21 -0400 | [diff] [blame] | 233 | optionsPipeline.initCwnd = initCwnd; |
| 234 | optionsPipeline.initSsthresh = initSsthresh; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 235 | optionsPipeline.aiStep = aiStep; |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 236 | optionsPipeline.mdCoef = aimdBeta; |
Chavoosh Ghasemi | 641f593 | 2017-11-06 22:45:11 +0000 | [diff] [blame] | 237 | optionsPipeline.ignoreCongMarks = ignoreCongMarks; |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 238 | |
Klaus Schneider | 9e5122b | 2019-03-19 17:03:25 -0700 | [diff] [blame] | 239 | unique_ptr<PipelineInterestsAdaptive> adaptivePipeline; |
| 240 | if (pipelineType == "aimd") { |
| 241 | adaptivePipeline = make_unique<PipelineInterestsAimd>(face, *rttEstimator, optionsPipeline); |
| 242 | } |
| 243 | else { |
| 244 | PipelineInterestsCubic::Options optionsCubic(optionsPipeline); |
| 245 | optionsCubic.enableFastConv = enableFastConv; |
| 246 | optionsCubic.cubicBeta = cubicBeta; |
| 247 | adaptivePipeline = make_unique<PipelineInterestsCubic>(face, *rttEstimator, optionsCubic); |
| 248 | } |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 249 | |
| 250 | if (!cwndPath.empty() || !rttPath.empty()) { |
| 251 | if (!cwndPath.empty()) { |
| 252 | statsFileCwnd.open(cwndPath); |
| 253 | if (statsFileCwnd.fail()) { |
| 254 | std::cerr << "ERROR: failed to open " << cwndPath << std::endl; |
| 255 | return 4; |
| 256 | } |
| 257 | } |
| 258 | if (!rttPath.empty()) { |
| 259 | statsFileRtt.open(rttPath); |
| 260 | if (statsFileRtt.fail()) { |
| 261 | std::cerr << "ERROR: failed to open " << rttPath << std::endl; |
| 262 | return 4; |
| 263 | } |
| 264 | } |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 265 | statsCollector = make_unique<StatisticsCollector>(*adaptivePipeline, *rttEstimator, |
| 266 | statsFileCwnd, statsFileRtt); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 267 | } |
| 268 | |
schneiderklaus | d8197df | 2019-03-16 11:31:40 -0700 | [diff] [blame] | 269 | pipeline = std::move(adaptivePipeline); |
Weiwei Liu | 245d791 | 2016-07-28 00:04:25 -0700 | [diff] [blame] | 270 | } |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 271 | else { |
| 272 | std::cerr << "ERROR: Interest pipeline type not valid" << std::endl; |
| 273 | return 2; |
| 274 | } |
| 275 | |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 276 | Consumer consumer(security::v2::getAcceptAllValidator()); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 277 | BOOST_ASSERT(discover != nullptr); |
Weiwei Liu | e476501 | 2016-06-01 00:10:29 -0700 | [diff] [blame] | 278 | BOOST_ASSERT(pipeline != nullptr); |
| 279 | consumer.run(std::move(discover), std::move(pipeline)); |
Weiwei Liu | 05d9209 | 2016-07-19 17:34:33 -0700 | [diff] [blame] | 280 | face.processEvents(); |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 281 | } |
| 282 | catch (const Consumer::ApplicationNackError& e) { |
| 283 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 284 | return 3; |
| 285 | } |
Davide Pesavento | f6991e1 | 2018-01-08 20:58:50 -0500 | [diff] [blame] | 286 | catch (const Consumer::DataValidationError& e) { |
| 287 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 288 | return 5; |
| 289 | } |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 290 | catch (const std::exception& e) { |
| 291 | std::cerr << "ERROR: " << e.what() << std::endl; |
| 292 | return 1; |
| 293 | } |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | } // namespace chunks |
| 299 | } // namespace ndn |
| 300 | |
| 301 | int |
Davide Pesavento | da85e25 | 2019-03-18 11:42:01 -0400 | [diff] [blame] | 302 | main(int argc, char* argv[]) |
Andrea Tosatto | 672b9a7 | 2016-01-05 16:18:20 +0100 | [diff] [blame] | 303 | { |
| 304 | return ndn::chunks::main(argc, argv); |
| 305 | } |