akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (c) 2014 University of Memphis, |
| 4 | * Regents of the University of California |
| 5 | * |
| 6 | * This file is part of NLSR (Named-data Link State Routing). |
| 7 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 8 | * |
| 9 | * NLSR is free software: you can redistribute it and/or modify it under the terms |
| 10 | * of the GNU General Public License as published by the Free Software Foundation, |
| 11 | * either version 3 of the License, or (at your option) any later version. |
| 12 | * |
| 13 | * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
| 14 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 15 | * PURPOSE. See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along with |
| 18 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
| 19 | * |
| 20 | * \author A K M Mahmudul Hoque <ahoque1@memphis.edu> |
| 21 | * |
| 22 | **/ |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 23 | #ifndef CONF_PARAMETER_HPP |
| 24 | #define CONF_PARAMETER_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 25 | |
| 26 | #include <iostream> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 27 | #include <boost/cstdint.hpp> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 28 | #include <ndn-cxx/common.hpp> |
| 29 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 30 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 31 | #include "logger.hpp" |
| 32 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 33 | namespace nlsr { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 34 | |
| 35 | enum { |
| 36 | LSA_REFRESH_TIME_MIN = 240, |
| 37 | LSA_REFRESH_TIME_DEFAULT = 1800, |
| 38 | LSA_REFRESH_TIME_MAX = 7200 |
| 39 | }; |
| 40 | |
| 41 | enum { |
| 42 | HELLO_RETRIES_MIN = 1, |
| 43 | HELLO_RETRIES_DEFAULT = 3, |
| 44 | HELLO_RETRIES_MAX = 15 |
| 45 | }; |
| 46 | |
| 47 | enum { |
| 48 | HELLO_TIMEOUT_MIN = 1, |
| 49 | HELLO_TIMEOUT_DEFAULT = 3, |
| 50 | HELLO_TIMEOUT_MAX = 15 |
| 51 | }; |
| 52 | |
| 53 | enum { |
| 54 | HELLO_INTERVAL_MIN = 30, |
| 55 | HELLO_INTERVAL_DEFAULT = 60, |
| 56 | HELLO_INTERVAL_MAX =90 |
| 57 | }; |
| 58 | |
| 59 | enum { |
| 60 | MAX_FACES_PER_PREFIX_MIN = 0, |
| 61 | MAX_FACES_PER_PREFIX_MAX = 60 |
| 62 | }; |
| 63 | |
| 64 | enum { |
| 65 | HYPERBOLIC_STATE_OFF = 0, |
| 66 | HYPERBOLIC_STATE_ON = 1, |
| 67 | HYPERBOLIC_STATE_DRY_RUN = 2 |
| 68 | }; |
| 69 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 70 | class ConfParameter |
| 71 | { |
| 72 | |
| 73 | public: |
| 74 | ConfParameter() |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 75 | : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT) |
| 76 | , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT) |
| 77 | , m_logLevel("INFO") |
| 78 | , m_interestRetryNumber(HELLO_RETRIES_DEFAULT) |
| 79 | , m_interestResendTime(HELLO_TIMEOUT_DEFAULT) |
| 80 | , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT) |
| 81 | , m_hyperbolicState(HYPERBOLIC_STATE_OFF) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 82 | , m_corR(0) |
| 83 | , m_corTheta(0) |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 84 | , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 85 | {} |
| 86 | |
| 87 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 88 | setNetwork(const ndn::Name& networkName) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 89 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 90 | m_network = networkName; |
| 91 | m_chronosyncPrefix = m_network; |
akmhoque | a816bee | 2014-06-24 14:37:40 -0500 | [diff] [blame^] | 92 | m_chronosyncPrefix.append("NLSR"); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 93 | m_chronosyncPrefix.append("sync"); |
| 94 | |
| 95 | m_lsaPrefix = m_network; |
akmhoque | a816bee | 2014-06-24 14:37:40 -0500 | [diff] [blame^] | 96 | m_lsaPrefix.append("NLSR"); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 97 | m_lsaPrefix.append("LSA"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 98 | } |
| 99 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 100 | const ndn::Name& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 101 | getNetwork() |
| 102 | { |
| 103 | return m_network; |
| 104 | } |
| 105 | |
| 106 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 107 | setRouterName(const ndn::Name& routerName) |
| 108 | { |
| 109 | m_routerName = routerName; |
| 110 | } |
| 111 | |
| 112 | const ndn::Name& |
| 113 | getRouterName() |
| 114 | { |
| 115 | return m_routerName; |
| 116 | } |
| 117 | |
| 118 | void |
| 119 | setSiteName(const ndn::Name& siteName) |
| 120 | { |
| 121 | m_siteName = siteName; |
| 122 | } |
| 123 | |
| 124 | const ndn::Name& |
| 125 | getSiteName() |
| 126 | { |
| 127 | return m_siteName; |
| 128 | } |
| 129 | |
| 130 | void |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 131 | buildRouterPrefix() |
| 132 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 133 | m_routerPrefix = m_network; |
| 134 | m_routerPrefix.append(m_siteName); |
| 135 | m_routerPrefix.append(m_routerName); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 136 | } |
| 137 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 138 | const ndn::Name& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 139 | getRouterPrefix() |
| 140 | { |
| 141 | return m_routerPrefix; |
| 142 | } |
| 143 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 144 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 145 | const ndn::Name& |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 146 | getChronosyncPrefix() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 147 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 148 | return m_chronosyncPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 149 | } |
| 150 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 151 | const ndn::Name& |
| 152 | getLsaPrefix() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 153 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 154 | return m_lsaPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 158 | setLsaRefreshTime(int32_t lrt) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 159 | { |
| 160 | m_lsaRefreshTime = lrt; |
| 161 | m_routerDeadInterval = 2 * m_lsaRefreshTime; |
| 162 | } |
| 163 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 164 | int32_t |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 165 | getLsaRefreshTime() |
| 166 | { |
| 167 | return m_lsaRefreshTime; |
| 168 | } |
| 169 | |
| 170 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 171 | setRouterDeadInterval(int64_t rdt) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 172 | { |
| 173 | m_routerDeadInterval = rdt; |
| 174 | } |
| 175 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 176 | int64_t |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 177 | getRouterDeadInterval() |
| 178 | { |
| 179 | return m_routerDeadInterval; |
| 180 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 181 | |
| 182 | void |
| 183 | setLogLevel(const std::string& logLevel) |
| 184 | { |
| 185 | m_logLevel = logLevel; |
| 186 | } |
| 187 | |
| 188 | const std::string& |
| 189 | getLogLevel() |
| 190 | { |
| 191 | return m_logLevel; |
| 192 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 193 | |
| 194 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 195 | setInterestRetryNumber(uint32_t irn) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 196 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 197 | m_interestRetryNumber = irn; |
| 198 | } |
| 199 | |
| 200 | uint32_t |
| 201 | getInterestRetryNumber() |
| 202 | { |
| 203 | return m_interestRetryNumber; |
| 204 | } |
| 205 | |
| 206 | void |
| 207 | setInterestResendTime(int32_t irt) |
| 208 | { |
| 209 | m_interestResendTime = irt; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 210 | } |
| 211 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 212 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 213 | getInterestResendTime() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 214 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 215 | return m_interestResendTime; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 216 | } |
| 217 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 218 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 219 | getInfoInterestInterval() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 220 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 221 | return m_infoInterestInterval; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 225 | setInfoInterestInterval(int32_t iii) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 226 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 227 | m_infoInterestInterval = iii; |
| 228 | } |
| 229 | |
| 230 | void |
| 231 | setHyperbolicState(int32_t ihc) |
| 232 | { |
| 233 | m_hyperbolicState = ihc; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 234 | } |
| 235 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 236 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 237 | getHyperbolicState() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 238 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 239 | return m_hyperbolicState; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 240 | } |
| 241 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 242 | bool |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 243 | setCorR(double cr) |
| 244 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 245 | if ( cr >= 0 ) { |
| 246 | m_corR = cr; |
| 247 | return true; |
| 248 | } |
| 249 | return false; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | double |
| 253 | getCorR() |
| 254 | { |
| 255 | return m_corR; |
| 256 | } |
| 257 | |
| 258 | void |
| 259 | setCorTheta(double ct) |
| 260 | { |
| 261 | m_corTheta = ct; |
| 262 | } |
| 263 | |
| 264 | double |
| 265 | getCorTheta() |
| 266 | { |
| 267 | return m_corTheta; |
| 268 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 269 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 270 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 271 | setMaxFacesPerPrefix(int32_t mfpp) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 272 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 273 | m_maxFacesPerPrefix = mfpp; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 274 | } |
| 275 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 276 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 277 | getMaxFacesPerPrefix() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 278 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 279 | return m_maxFacesPerPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | void |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 283 | setLogDir(const std::string& logDir) |
| 284 | { |
| 285 | m_logDir = logDir; |
| 286 | } |
| 287 | |
| 288 | const std::string& |
| 289 | getLogDir() |
| 290 | { |
| 291 | return m_logDir; |
| 292 | } |
| 293 | |
| 294 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 295 | setSeqFileDir(const std::string& ssfd) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 296 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 297 | m_seqFileDir = ssfd; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 298 | } |
| 299 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 300 | const std::string& |
| 301 | getSeqFileDir() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 302 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 303 | return m_seqFileDir; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 304 | } |
| 305 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 306 | void |
| 307 | writeLog(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 308 | |
| 309 | private: |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 310 | ndn::Name m_routerName; |
| 311 | ndn::Name m_siteName; |
| 312 | ndn::Name m_network; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 313 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 314 | ndn::Name m_routerPrefix; |
| 315 | ndn::Name m_lsaRouterPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 316 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 317 | ndn::Name m_chronosyncPrefix; |
| 318 | ndn::Name m_lsaPrefix; |
| 319 | |
| 320 | int32_t m_lsaRefreshTime; |
| 321 | int64_t m_routerDeadInterval; |
| 322 | std::string m_logLevel; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 323 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 324 | uint32_t m_interestRetryNumber; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 325 | int32_t m_interestResendTime; |
| 326 | |
| 327 | |
| 328 | int32_t m_infoInterestInterval; |
| 329 | |
| 330 | int32_t m_hyperbolicState; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 331 | double m_corR; |
| 332 | double m_corTheta; |
| 333 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 334 | int32_t m_maxFacesPerPrefix; |
| 335 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 336 | std::string m_logDir; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 337 | std::string m_seqFileDir; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 338 | |
| 339 | }; |
| 340 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 341 | } // namespace nlsr |
| 342 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 343 | #endif //CONF_PARAMETER_HPP |