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