Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 2 | /* |
Eric Newberry | b4ef478 | 2018-06-21 00:05:46 -0700 | [diff] [blame] | 3 | * Copyright (c) 2014-2018 Arizona Board of Regents. |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 4 | * |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 17 | * |
| 18 | * Author: Jerald Paul Abraham <jeraldabraham@email.arizona.edu> |
| 19 | */ |
| 20 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 21 | #include "logger.hpp" |
| 22 | |
| 23 | #include <ndn-cxx/face.hpp> |
| 24 | #include <ndn-cxx/security/key-chain.hpp> |
| 25 | #include <ndn-cxx/security/signing-info.hpp> |
| 26 | #include <ndn-cxx/util/backports.hpp> |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 27 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 28 | #include <boost/asio/io_service.hpp> |
| 29 | #include <boost/asio/signal_set.hpp> |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 30 | #include <boost/filesystem.hpp> |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 31 | #include <boost/noncopyable.hpp> |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 32 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 33 | #include <cctype> |
| 34 | #include <cstdlib> |
| 35 | #include <fstream> |
| 36 | #include <string> |
| 37 | #include <unistd.h> |
| 38 | #include <vector> |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 39 | |
| 40 | namespace ndn { |
| 41 | |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 42 | class NdnTrafficServer : boost::noncopyable |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 43 | { |
| 44 | public: |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 45 | explicit |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 46 | NdnTrafficServer(const char* programName) |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 47 | : m_logger("NdnTrafficServer") |
| 48 | , m_programName(programName) |
| 49 | , m_hasError(false) |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 50 | , m_hasQuietLogging(false) |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 51 | , m_nRegistrationsFailed(0) |
| 52 | , m_nMaximumInterests(-1) |
| 53 | , m_nInterestsReceived(0) |
| 54 | , m_contentDelay(time::milliseconds(-1)) |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 55 | , m_instanceId(to_string(std::rand())) |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 56 | , m_face(m_ioService) |
Eric Newberry | 5145940 | 2018-06-28 00:06:18 -0700 | [diff] [blame] | 57 | , m_signalSet(m_ioService, SIGINT, SIGTERM) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 58 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | class DataTrafficConfiguration |
| 62 | { |
| 63 | public: |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 64 | DataTrafficConfiguration() |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 65 | : m_contentType(-1) |
| 66 | , m_freshnessPeriod(time::milliseconds(-1)) |
| 67 | , m_contentBytes(-1) |
| 68 | , m_contentDelay(time::milliseconds(-1)) |
| 69 | , m_nInterestsReceived(0) |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 70 | , m_signingInfo() |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 71 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 72 | } |
| 73 | |
| 74 | void |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 75 | printTrafficConfiguration(Logger& logger) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 76 | { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 77 | std::stringstream detail; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 78 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 79 | if (!m_name.empty()) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 80 | detail << "Name=" << m_name << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 81 | } |
| 82 | if (m_contentType >= 0) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 83 | detail << "ContentType=" << to_string(m_contentType) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 84 | } |
| 85 | if (m_freshnessPeriod >= time::milliseconds(0)) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 86 | detail << "FreshnessPeriod=" << |
| 87 | to_string(static_cast<int>(m_freshnessPeriod.count())) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 88 | } |
| 89 | if (m_contentBytes >= 0) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 90 | detail << "ContentBytes=" << to_string(m_contentBytes) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 91 | } |
| 92 | if (m_contentDelay >= time::milliseconds(0)) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 93 | detail << "ContentDelay=" << to_string(m_contentDelay.count()) << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 94 | } |
| 95 | if (!m_content.empty()) { |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 96 | detail << "Content=" << m_content << ", "; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 97 | } |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 98 | detail << "SigningInfo=" << m_signingInfo; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 99 | |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 100 | logger.log(detail.str(), false, false); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 101 | } |
| 102 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 103 | bool |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 104 | extractParameterValue(const std::string& detail, std::string& parameter, std::string& value) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 105 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 106 | std::string allowedCharacters = ":/+._-%"; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 107 | std::size_t i = 0; |
| 108 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 109 | parameter = ""; |
| 110 | value = ""; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 111 | while (detail[i] != '=' && i < detail.length()) { |
| 112 | parameter += detail[i]; |
| 113 | i++; |
| 114 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 115 | if (i == detail.length()) |
| 116 | return false; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 117 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 118 | i++; |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 119 | while ((std::isalnum(detail[i]) || |
| 120 | allowedCharacters.find(detail[i]) != std::string::npos) && |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 121 | i < detail.length()) { |
| 122 | value += detail[i]; |
| 123 | i++; |
| 124 | } |
| 125 | |
| 126 | if (parameter.empty() || value.empty()) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 127 | return false; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 128 | else |
| 129 | return true; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | bool |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 133 | processConfigurationDetail(const std::string& detail, |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 134 | Logger& logger, |
| 135 | int lineNumber) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 136 | { |
| 137 | std::string parameter, value; |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 138 | if (extractParameterValue(detail, parameter, value)) { |
| 139 | if (parameter == "Name") { |
| 140 | m_name = value; |
| 141 | } |
| 142 | else if (parameter == "ContentType") { |
| 143 | m_contentType = std::stoi(value); |
| 144 | } |
| 145 | else if (parameter == "FreshnessPeriod") { |
| 146 | m_freshnessPeriod = time::milliseconds(std::stoi(value)); |
| 147 | } |
| 148 | else if (parameter == "ContentDelay") { |
| 149 | m_contentDelay = time::milliseconds(std::stoi(value)); |
| 150 | } |
| 151 | else if (parameter == "ContentBytes") { |
| 152 | m_contentBytes = std::stoi(value); |
| 153 | } |
| 154 | else if (parameter == "Content") { |
| 155 | m_content = value; |
| 156 | } |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 157 | else if (parameter == "SigningInfo") { |
| 158 | m_signingInfo = security::SigningInfo(value); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 159 | } |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 160 | else { |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 161 | logger.log("Line " + to_string(lineNumber) + |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 162 | " \t- Invalid Parameter='" + parameter + "'", false, true); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 163 | } |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 164 | } |
| 165 | else { |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 166 | logger.log("Line " + to_string(lineNumber) + |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 167 | " \t- Improper Traffic Configuration Line - " + detail, false, true); |
| 168 | return false; |
| 169 | } |
| 170 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 171 | return true; |
| 172 | } |
| 173 | |
| 174 | bool |
| 175 | checkTrafficDetailCorrectness() |
| 176 | { |
| 177 | return true; |
| 178 | } |
| 179 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 180 | private: |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 181 | std::string m_name; |
| 182 | int m_contentType; |
| 183 | time::milliseconds m_freshnessPeriod; |
| 184 | int m_contentBytes; |
| 185 | time::milliseconds m_contentDelay; |
| 186 | std::string m_content; |
| 187 | int m_nInterestsReceived; |
Spencer Lee | ef56143 | 2015-12-13 19:40:22 -0700 | [diff] [blame] | 188 | security::SigningInfo m_signingInfo; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 189 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 190 | friend class NdnTrafficServer; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 191 | }; |
| 192 | |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 193 | void |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 194 | usage() const |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 195 | { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 196 | std::cout << "Usage:\n" |
| 197 | << " " << m_programName << " [options] <Traffic_Configuration_File>\n" |
| 198 | << "\n" |
| 199 | << "Respond to Interests as per provided Traffic Configuration File.\n" |
| 200 | << "Multiple prefixes can be configured for handling.\n" |
| 201 | << "Set environment variable NDN_TRAFFIC_LOGFOLDER to redirect output to a log file.\n" |
| 202 | << "\n" |
| 203 | << "Options:\n" |
| 204 | << " [-d interval] - set delay before responding to interest, in milliseconds\n" |
| 205 | << " [-c count] - specify maximum number of interests to be satisfied\n" |
| 206 | << " [-q] - quiet mode: no interest reception/data generation logging\n" |
| 207 | << " [-h] - print this help text and exit\n"; |
| 208 | exit(EXIT_FAILURE); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 209 | } |
| 210 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 211 | void |
| 212 | setMaximumInterests(int maximumInterests) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 213 | { |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 214 | if (maximumInterests < 0) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 215 | usage(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 216 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 217 | m_nMaximumInterests = maximumInterests; |
| 218 | } |
| 219 | |
| 220 | bool |
| 221 | hasError() const |
| 222 | { |
| 223 | return m_hasError; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | void |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 227 | setContentDelay(int contentDelay) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 228 | { |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 229 | if (contentDelay < 0) { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 230 | usage(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 231 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 232 | m_contentDelay = time::milliseconds(contentDelay); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 233 | } |
| 234 | |
| 235 | void |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 236 | setConfigurationFile(const char* configurationFile) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 237 | { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 238 | m_configurationFile = configurationFile; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | void |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 242 | setQuietLogging() |
| 243 | { |
| 244 | m_hasQuietLogging = true; |
| 245 | } |
| 246 | |
| 247 | void |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 248 | signalHandler() |
| 249 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 250 | logStatistics(); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 251 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 252 | m_face.shutdown(); |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 253 | m_ioService.stop(); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 254 | |
| 255 | exit(m_hasError ? EXIT_FAILURE : EXIT_SUCCESS); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | void |
| 259 | logStatistics() |
| 260 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 261 | m_logger.log("\n\n== Interest Traffic Report ==\n", false, true); |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 262 | m_logger.log("Total Traffic Pattern Types = " + |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 263 | to_string(m_trafficPatterns.size()), false, true); |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 264 | m_logger.log("Total Interests Received = " + |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 265 | to_string(m_nInterestsReceived), false, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 266 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 267 | if (m_nInterestsReceived < m_nMaximumInterests) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 268 | m_hasError = true; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 269 | } |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 270 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 271 | for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++) { |
| 272 | m_logger.log("\nTraffic Pattern Type #" + to_string(patternId + 1), false, true); |
| 273 | m_trafficPatterns[patternId].printTrafficConfiguration(m_logger); |
| 274 | m_logger.log("Total Interests Received = " + to_string( |
| 275 | m_trafficPatterns[patternId].m_nInterestsReceived) + "\n", false, true); |
| 276 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | bool |
| 280 | checkTrafficPatternCorrectness() |
| 281 | { |
| 282 | return true; |
| 283 | } |
| 284 | |
| 285 | void |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 286 | parseConfigurationFile() |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 287 | { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 288 | std::string patternLine; |
| 289 | std::ifstream patternFile; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 290 | m_logger.log("Analyzing Traffic Configuration File: " + m_configurationFile, true, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 291 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 292 | patternFile.open(m_configurationFile.c_str()); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 293 | if (patternFile.is_open()) { |
| 294 | int lineNumber = 0; |
| 295 | while (getline(patternFile, patternLine)) { |
| 296 | lineNumber++; |
| 297 | if (std::isalpha(patternLine[0])) { |
| 298 | DataTrafficConfiguration dataData; |
| 299 | bool shouldSkipLine = false; |
| 300 | if (dataData.processConfigurationDetail(patternLine, m_logger, lineNumber)) { |
| 301 | while (getline(patternFile, patternLine) && std::isalpha(patternLine[0])) { |
| 302 | lineNumber++; |
| 303 | if (!dataData.processConfigurationDetail(patternLine, m_logger, lineNumber)) { |
| 304 | shouldSkipLine = true; |
| 305 | break; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 306 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 307 | } |
| 308 | lineNumber++; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 309 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 310 | else { |
| 311 | shouldSkipLine = true; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 312 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 313 | if (!shouldSkipLine) { |
| 314 | if (dataData.checkTrafficDetailCorrectness()) { |
| 315 | m_trafficPatterns.push_back(dataData); |
| 316 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 317 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 318 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 319 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 320 | patternFile.close(); |
| 321 | |
| 322 | if (!checkTrafficPatternCorrectness()) { |
| 323 | m_logger.log("ERROR - Traffic Configuration Provided Is Not Proper - " + |
| 324 | m_configurationFile, false, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 325 | exit(EXIT_FAILURE); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 326 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 327 | |
| 328 | m_logger.log("Traffic Configuration File Processing Completed\n", true, false); |
| 329 | for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++) { |
| 330 | m_logger.log("Traffic Pattern Type #" + |
| 331 | to_string(patternId + 1), false, false); |
| 332 | m_trafficPatterns[patternId].printTrafficConfiguration(m_logger); |
| 333 | m_logger.log("", false, false); |
| 334 | } |
| 335 | } |
| 336 | else { |
| 337 | m_logger.log("ERROR - Unable To Open Traffic Configuration File: " + |
| 338 | m_configurationFile, false, true); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 339 | exit(EXIT_FAILURE); |
| 340 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | void |
| 344 | initializeTrafficConfiguration() |
| 345 | { |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 346 | if (boost::filesystem::exists(boost::filesystem::path(m_configurationFile))) { |
| 347 | if (boost::filesystem::is_regular_file(boost::filesystem::path(m_configurationFile))) { |
| 348 | parseConfigurationFile(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 349 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 350 | else { |
| 351 | m_logger.log("ERROR - Traffic Configuration File Is Not A Regular File: " + |
| 352 | m_configurationFile, false, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 353 | exit(EXIT_FAILURE); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 354 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 355 | } |
| 356 | else { |
| 357 | m_logger.log("ERROR - Traffic Configuration File Does Not Exist: " + |
| 358 | m_configurationFile, false, true); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 359 | exit(EXIT_FAILURE); |
| 360 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 361 | } |
| 362 | |
| 363 | static std::string |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 364 | getRandomByteString(std::size_t randomSize) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 365 | { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 366 | std::string randomString; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 367 | for (std::size_t i = 0; i < randomSize; i++) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 368 | randomString += static_cast<char>(std::rand() % 128); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 369 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 370 | return randomString; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 371 | } |
| 372 | |
| 373 | void |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 374 | onInterest(const Name& name, const Interest& interest, int patternId) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 375 | { |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 376 | auto& pattern = m_trafficPatterns[patternId]; |
| 377 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 378 | if (m_nMaximumInterests < 0 || m_nInterestsReceived < m_nMaximumInterests) { |
| 379 | Data data(interest.getName()); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 380 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 381 | if (pattern.m_contentType >= 0) |
| 382 | data.setContentType(pattern.m_contentType); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 383 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 384 | if (pattern.m_freshnessPeriod >= time::milliseconds(0)) |
| 385 | data.setFreshnessPeriod(pattern.m_freshnessPeriod); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 386 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 387 | std::string content; |
| 388 | if (pattern.m_contentBytes >= 0) |
| 389 | content = getRandomByteString(pattern.m_contentBytes); |
| 390 | if (!pattern.m_content.empty()) |
| 391 | content = pattern.m_content; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 392 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 393 | data.setContent(reinterpret_cast<const uint8_t*>(content.c_str()), content.length()); |
| 394 | m_keyChain.sign(data, pattern.m_signingInfo); |
Spencer Lee | e7a5b74 | 2015-10-29 02:18:11 -0700 | [diff] [blame] | 395 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 396 | m_nInterestsReceived++; |
| 397 | pattern.m_nInterestsReceived++; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 398 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 399 | if (!m_hasQuietLogging) { |
| 400 | std::string logLine = |
| 401 | "Interest Received - PatternType=" + to_string(patternId + 1) + |
| 402 | ", GlobalID=" + to_string(m_nInterestsReceived) + |
| 403 | ", LocalID=" + to_string(pattern.m_nInterestsReceived) + |
| 404 | ", Name=" + pattern.m_name; |
| 405 | m_logger.log(logLine, true, false); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 406 | } |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 407 | |
| 408 | if (pattern.m_contentDelay > time::milliseconds(-1)) |
| 409 | usleep(pattern.m_contentDelay.count() * 1000); |
| 410 | if (m_contentDelay > time::milliseconds(-1)) |
| 411 | usleep(m_contentDelay.count() * 1000); |
| 412 | m_face.put(data); |
| 413 | } |
| 414 | if (m_nMaximumInterests >= 0 && m_nInterestsReceived == m_nMaximumInterests) { |
| 415 | logStatistics(); |
Eric Newberry | b4ef478 | 2018-06-21 00:05:46 -0700 | [diff] [blame] | 416 | for (auto registeredPrefix : m_registeredPrefixes) { |
| 417 | m_face.unsetInterestFilter(registeredPrefix); |
| 418 | } |
Eric Newberry | 5145940 | 2018-06-28 00:06:18 -0700 | [diff] [blame] | 419 | m_signalSet.cancel(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 420 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 421 | } |
| 422 | |
| 423 | void |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 424 | onRegisterFailed(const ndn::Name& prefix, const std::string& reason, int patternId) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 425 | { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 426 | std::string logLine; |
Spencer Lee | 8e99023 | 2015-11-27 03:54:39 -0700 | [diff] [blame] | 427 | logLine += "Prefix Registration Failed - PatternType=" + to_string(patternId + 1); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 428 | logLine += ", Name=" + m_trafficPatterns[patternId].m_name; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 429 | m_logger.log(logLine, true, true); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 430 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 431 | m_nRegistrationsFailed++; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 432 | if (m_nRegistrationsFailed == m_trafficPatterns.size()) { |
| 433 | m_hasError = true; |
| 434 | signalHandler(); |
| 435 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 436 | } |
| 437 | |
| 438 | void |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 439 | run() |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 440 | { |
Eric Newberry | 5145940 | 2018-06-28 00:06:18 -0700 | [diff] [blame] | 441 | m_signalSet.async_wait(bind(&NdnTrafficServer::signalHandler, this)); |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 442 | |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 443 | m_logger.initializeLog(m_instanceId); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 444 | initializeTrafficConfiguration(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 445 | if (m_nMaximumInterests == 0) { |
| 446 | logStatistics(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 447 | return; |
| 448 | } |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 449 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 450 | for (std::size_t patternId = 0; patternId < m_trafficPatterns.size(); patternId++) { |
Eric Newberry | b4ef478 | 2018-06-21 00:05:46 -0700 | [diff] [blame] | 451 | m_registeredPrefixes.push_back( |
| 452 | m_face.setInterestFilter(m_trafficPatterns[patternId].m_name, |
| 453 | bind(&NdnTrafficServer::onInterest, this, _1, _2, patternId), |
Eric Newberry | 5145940 | 2018-06-28 00:06:18 -0700 | [diff] [blame] | 454 | nullptr, |
Eric Newberry | b4ef478 | 2018-06-21 00:05:46 -0700 | [diff] [blame] | 455 | bind(&NdnTrafficServer::onRegisterFailed, this, _1, _2, patternId))); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 456 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 457 | |
| 458 | try { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 459 | m_face.processEvents(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 460 | } |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 461 | catch (const std::exception& e) { |
| 462 | m_logger.log("ERROR: " + std::string(e.what()), true, true); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 463 | m_hasError = true; |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 464 | m_ioService.stop(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 465 | } |
| 466 | } |
| 467 | |
| 468 | private: |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 469 | KeyChain m_keyChain; |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 470 | Logger m_logger; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 471 | std::string m_programName; |
| 472 | bool m_hasError; |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 473 | bool m_hasQuietLogging; |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 474 | std::size_t m_nRegistrationsFailed; |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 475 | int m_nMaximumInterests; |
| 476 | int m_nInterestsReceived; |
| 477 | time::milliseconds m_contentDelay; |
| 478 | std::string m_instanceId; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 479 | std::string m_configurationFile; |
Alexander Afanasyev | 740812e | 2014-10-30 15:37:45 -0700 | [diff] [blame] | 480 | |
Alexander Afanasyev | 976c397 | 2014-05-26 17:03:40 +0300 | [diff] [blame] | 481 | boost::asio::io_service m_ioService; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 482 | Face m_face; |
Eric Newberry | 5145940 | 2018-06-28 00:06:18 -0700 | [diff] [blame] | 483 | boost::asio::signal_set m_signalSet; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 484 | std::vector<DataTrafficConfiguration> m_trafficPatterns; |
Eric Newberry | b4ef478 | 2018-06-21 00:05:46 -0700 | [diff] [blame] | 485 | std::vector<const RegisteredPrefixId*> m_registeredPrefixes; |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 486 | }; |
| 487 | |
| 488 | } // namespace ndn |
| 489 | |
Alexander Afanasyev | fda32a3 | 2014-03-20 10:50:00 -0700 | [diff] [blame] | 490 | int |
| 491 | main(int argc, char* argv[]) |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 492 | { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 493 | std::srand(std::time(nullptr)); |
| 494 | |
| 495 | ndn::NdnTrafficServer server(argv[0]); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 496 | int option; |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 497 | while ((option = getopt(argc, argv, "hqc:d:")) != -1) { |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 498 | switch (option) { |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 499 | case 'h': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 500 | server.usage(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 501 | break; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 502 | case 'c': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 503 | server.setMaximumInterests(atoi(optarg)); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 504 | break; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 505 | case 'd': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 506 | server.setContentDelay(atoi(optarg)); |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 507 | break; |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 508 | case 'q': |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 509 | server.setQuietLogging(); |
jeraldabraham | 420dbf0 | 2014-04-25 22:58:31 -0700 | [diff] [blame] | 510 | break; |
jeraldabraham | cc3c6c9 | 2014-03-28 02:21:45 -0700 | [diff] [blame] | 511 | default: |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 512 | server.usage(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 513 | break; |
| 514 | } |
| 515 | } |
| 516 | |
| 517 | argc -= optind; |
| 518 | argv += optind; |
| 519 | |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 520 | if (!argc) { |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 521 | server.usage(); |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 522 | } |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 523 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 524 | server.setConfigurationFile(argv[0]); |
| 525 | server.run(); |
Alexander Afanasyev | a8f2a92 | 2014-02-26 14:21:56 -0800 | [diff] [blame] | 526 | |
Davide Pesavento | d0b5998 | 2015-02-27 19:15:15 +0100 | [diff] [blame] | 527 | return server.hasError() ? EXIT_FAILURE : EXIT_SUCCESS; |
Eric Newberry | c8e1858 | 2018-05-31 19:27:01 -0700 | [diff] [blame] | 528 | } |