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