akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 1 | #ifndef CONF_PARAMETER_HPP |
| 2 | #define CONF_PARAMETER_HPP |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 3 | |
| 4 | #include <iostream> |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 5 | #include <boost/cstdint.hpp> |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 6 | #include <ndn-cxx/common.hpp> |
| 7 | #include <ndn-cxx/face.hpp> |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 8 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 9 | #include "logger.hpp" |
| 10 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 11 | namespace nlsr { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 12 | |
| 13 | enum { |
| 14 | LSA_REFRESH_TIME_MIN = 240, |
| 15 | LSA_REFRESH_TIME_DEFAULT = 1800, |
| 16 | LSA_REFRESH_TIME_MAX = 7200 |
| 17 | }; |
| 18 | |
| 19 | enum { |
| 20 | HELLO_RETRIES_MIN = 1, |
| 21 | HELLO_RETRIES_DEFAULT = 3, |
| 22 | HELLO_RETRIES_MAX = 15 |
| 23 | }; |
| 24 | |
| 25 | enum { |
| 26 | HELLO_TIMEOUT_MIN = 1, |
| 27 | HELLO_TIMEOUT_DEFAULT = 3, |
| 28 | HELLO_TIMEOUT_MAX = 15 |
| 29 | }; |
| 30 | |
| 31 | enum { |
| 32 | HELLO_INTERVAL_MIN = 30, |
| 33 | HELLO_INTERVAL_DEFAULT = 60, |
| 34 | HELLO_INTERVAL_MAX =90 |
| 35 | }; |
| 36 | |
| 37 | enum { |
| 38 | MAX_FACES_PER_PREFIX_MIN = 0, |
| 39 | MAX_FACES_PER_PREFIX_MAX = 60 |
| 40 | }; |
| 41 | |
| 42 | enum { |
| 43 | HYPERBOLIC_STATE_OFF = 0, |
| 44 | HYPERBOLIC_STATE_ON = 1, |
| 45 | HYPERBOLIC_STATE_DRY_RUN = 2 |
| 46 | }; |
| 47 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 48 | class ConfParameter |
| 49 | { |
| 50 | |
| 51 | public: |
| 52 | ConfParameter() |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 53 | : m_lsaRefreshTime(LSA_REFRESH_TIME_DEFAULT) |
| 54 | , m_routerDeadInterval(2*LSA_REFRESH_TIME_DEFAULT) |
| 55 | , m_logLevel("INFO") |
| 56 | , m_interestRetryNumber(HELLO_RETRIES_DEFAULT) |
| 57 | , m_interestResendTime(HELLO_TIMEOUT_DEFAULT) |
| 58 | , m_infoInterestInterval(HELLO_INTERVAL_DEFAULT) |
| 59 | , m_hyperbolicState(HYPERBOLIC_STATE_OFF) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 60 | , m_corR(0) |
| 61 | , m_corTheta(0) |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 62 | , m_maxFacesPerPrefix(MAX_FACES_PER_PREFIX_MIN) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 63 | {} |
| 64 | |
| 65 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 66 | setNetwork(const ndn::Name& networkName) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 67 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 68 | m_network = networkName; |
| 69 | m_chronosyncPrefix = m_network; |
| 70 | m_chronosyncPrefix.append("nlsr"); |
| 71 | m_chronosyncPrefix.append("sync"); |
| 72 | |
| 73 | m_lsaPrefix = m_network; |
| 74 | m_lsaPrefix.append("nlsr"); |
| 75 | m_lsaPrefix.append("LSA"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 76 | } |
| 77 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 78 | const ndn::Name& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 79 | getNetwork() |
| 80 | { |
| 81 | return m_network; |
| 82 | } |
| 83 | |
| 84 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 85 | setRouterName(const ndn::Name& routerName) |
| 86 | { |
| 87 | m_routerName = routerName; |
| 88 | } |
| 89 | |
| 90 | const ndn::Name& |
| 91 | getRouterName() |
| 92 | { |
| 93 | return m_routerName; |
| 94 | } |
| 95 | |
| 96 | void |
| 97 | setSiteName(const ndn::Name& siteName) |
| 98 | { |
| 99 | m_siteName = siteName; |
| 100 | } |
| 101 | |
| 102 | const ndn::Name& |
| 103 | getSiteName() |
| 104 | { |
| 105 | return m_siteName; |
| 106 | } |
| 107 | |
| 108 | void |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 109 | buildRouterPrefix() |
| 110 | { |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 111 | m_routerPrefix = m_network; |
| 112 | m_routerPrefix.append(m_siteName); |
| 113 | m_routerPrefix.append(m_routerName); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 114 | } |
| 115 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 116 | const ndn::Name& |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 117 | getRouterPrefix() |
| 118 | { |
| 119 | return m_routerPrefix; |
| 120 | } |
| 121 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 122 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 123 | const ndn::Name& |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 124 | getChronosyncPrefix() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 125 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 126 | return m_chronosyncPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 127 | } |
| 128 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 129 | const ndn::Name& |
| 130 | getLsaPrefix() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 131 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 132 | return m_lsaPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 136 | setLsaRefreshTime(int32_t lrt) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 137 | { |
| 138 | m_lsaRefreshTime = lrt; |
| 139 | m_routerDeadInterval = 2 * m_lsaRefreshTime; |
| 140 | } |
| 141 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 142 | int32_t |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 143 | getLsaRefreshTime() |
| 144 | { |
| 145 | return m_lsaRefreshTime; |
| 146 | } |
| 147 | |
| 148 | void |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 149 | setRouterDeadInterval(int64_t rdt) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 150 | { |
| 151 | m_routerDeadInterval = rdt; |
| 152 | } |
| 153 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 154 | int64_t |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 155 | getRouterDeadInterval() |
| 156 | { |
| 157 | return m_routerDeadInterval; |
| 158 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 159 | |
| 160 | void |
| 161 | setLogLevel(const std::string& logLevel) |
| 162 | { |
| 163 | m_logLevel = logLevel; |
| 164 | } |
| 165 | |
| 166 | const std::string& |
| 167 | getLogLevel() |
| 168 | { |
| 169 | return m_logLevel; |
| 170 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 171 | |
| 172 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 173 | setInterestRetryNumber(uint32_t irn) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 174 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 175 | m_interestRetryNumber = irn; |
| 176 | } |
| 177 | |
| 178 | uint32_t |
| 179 | getInterestRetryNumber() |
| 180 | { |
| 181 | return m_interestRetryNumber; |
| 182 | } |
| 183 | |
| 184 | void |
| 185 | setInterestResendTime(int32_t irt) |
| 186 | { |
| 187 | m_interestResendTime = irt; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 188 | } |
| 189 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 190 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 191 | getInterestResendTime() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 192 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 193 | return m_interestResendTime; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 194 | } |
| 195 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 196 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 197 | getInfoInterestInterval() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 198 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 199 | return m_infoInterestInterval; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 203 | setInfoInterestInterval(int32_t iii) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 204 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 205 | m_infoInterestInterval = iii; |
| 206 | } |
| 207 | |
| 208 | void |
| 209 | setHyperbolicState(int32_t ihc) |
| 210 | { |
| 211 | m_hyperbolicState = ihc; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 212 | } |
| 213 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 214 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 215 | getHyperbolicState() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 216 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 217 | return m_hyperbolicState; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 218 | } |
| 219 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 220 | bool |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 221 | setCorR(double cr) |
| 222 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 223 | if ( cr >= 0 ) { |
| 224 | m_corR = cr; |
| 225 | return true; |
| 226 | } |
| 227 | return false; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | double |
| 231 | getCorR() |
| 232 | { |
| 233 | return m_corR; |
| 234 | } |
| 235 | |
| 236 | void |
| 237 | setCorTheta(double ct) |
| 238 | { |
| 239 | m_corTheta = ct; |
| 240 | } |
| 241 | |
| 242 | double |
| 243 | getCorTheta() |
| 244 | { |
| 245 | return m_corTheta; |
| 246 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 247 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 248 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 249 | setMaxFacesPerPrefix(int32_t mfpp) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 250 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 251 | m_maxFacesPerPrefix = mfpp; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 252 | } |
| 253 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 254 | int32_t |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 255 | getMaxFacesPerPrefix() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 256 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 257 | return m_maxFacesPerPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | void |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 261 | setLogDir(const std::string& logDir) |
| 262 | { |
| 263 | m_logDir = logDir; |
| 264 | } |
| 265 | |
| 266 | const std::string& |
| 267 | getLogDir() |
| 268 | { |
| 269 | return m_logDir; |
| 270 | } |
| 271 | |
| 272 | void |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 273 | setSeqFileDir(const std::string& ssfd) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 274 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 275 | m_seqFileDir = ssfd; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 276 | } |
| 277 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 278 | const std::string& |
| 279 | getSeqFileDir() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 280 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 281 | return m_seqFileDir; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 282 | } |
| 283 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 284 | void |
| 285 | writeLog(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 286 | |
| 287 | private: |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 288 | ndn::Name m_routerName; |
| 289 | ndn::Name m_siteName; |
| 290 | ndn::Name m_network; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 291 | |
akmhoque | 31d1d4b | 2014-05-05 22:08:14 -0500 | [diff] [blame] | 292 | ndn::Name m_routerPrefix; |
| 293 | ndn::Name m_lsaRouterPrefix; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 294 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 295 | ndn::Name m_chronosyncPrefix; |
| 296 | ndn::Name m_lsaPrefix; |
| 297 | |
| 298 | int32_t m_lsaRefreshTime; |
| 299 | int64_t m_routerDeadInterval; |
| 300 | std::string m_logLevel; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 301 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 302 | uint32_t m_interestRetryNumber; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 303 | int32_t m_interestResendTime; |
| 304 | |
| 305 | |
| 306 | int32_t m_infoInterestInterval; |
| 307 | |
| 308 | int32_t m_hyperbolicState; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 309 | double m_corR; |
| 310 | double m_corTheta; |
| 311 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 312 | int32_t m_maxFacesPerPrefix; |
| 313 | |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 314 | std::string m_logDir; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 315 | std::string m_seqFileDir; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 316 | |
| 317 | }; |
| 318 | |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 319 | inline std::ostream& |
| 320 | operator<<(std::ostream& os, ConfParameter& cfp) |
| 321 | { |
akmhoque | 674b0b1 | 2014-05-20 14:33:28 -0500 | [diff] [blame] | 322 | os << "Router Name: " << cfp.getRouterName() << std::endl; |
| 323 | os << "Site Name: " << cfp.getSiteName() << std::endl; |
| 324 | os << "Network: " << cfp.getNetwork() << std::endl; |
| 325 | os << "Router Prefix: " << cfp.getRouterPrefix() << std::endl; |
| 326 | os << "ChronoSync sync Prifex: " << cfp.getChronosyncPrefix() << std::endl; |
| 327 | os << "ChronoSync LSA prefix: " << cfp.getLsaPrefix() << std::endl; |
| 328 | os << "Interest Retry number: " << cfp.getInterestRetryNumber() << std::endl; |
| 329 | os << "Interest Resend second: " << cfp.getInterestResendTime() << std::endl; |
| 330 | os << "Info Interest Interval: " << cfp.getInfoInterestInterval() << std::endl; |
| 331 | os << "LSA refresh time: " << cfp.getLsaRefreshTime() << std::endl; |
| 332 | os << "Max Faces Per Prefix: " << cfp.getMaxFacesPerPrefix() << std::endl; |
| 333 | os << "Hyperbolic ROuting: " << cfp.getHyperbolicState() << std::endl; |
| 334 | os << "Hyp R: " << cfp.getCorR() << std::endl; |
| 335 | os << "Hyp theta: " << cfp.getCorTheta() << std::endl; |
| 336 | os << "Log Directory: " << cfp.getLogDir() << std::endl; |
| 337 | os << "Seq Directory: " << cfp.getSeqFileDir() << std::endl; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 338 | return os; |
| 339 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 340 | |
| 341 | } // namespace nlsr |
| 342 | |
akmhoque | fdbddb1 | 2014-05-02 18:35:19 -0500 | [diff] [blame] | 343 | #endif //CONF_PARAMETER_HPP |