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