akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
Nick Gordon | feae557 | 2017-01-13 12:06:26 -0600 | [diff] [blame] | 3 | * Copyright (c) 2014-2017, The University of Memphis, |
Vince Lehman | 41b173e | 2015-05-07 14:13:26 -0500 | [diff] [blame] | 4 | * Regents of the University of California, |
| 5 | * Arizona Board of Regents. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 6 | * |
| 7 | * This file is part of NLSR (Named-data Link State Routing). |
| 8 | * See AUTHORS.md for complete list of NLSR authors and contributors. |
| 9 | * |
| 10 | * NLSR 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 | * NLSR 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 | * NLSR, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>. |
akmhoque | 3d06e79 | 2014-05-27 16:23:20 -0500 | [diff] [blame] | 20 | **/ |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 21 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 22 | #include "routing-table-calculator.hpp" |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 23 | #include "lsdb.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 24 | #include "map.hpp" |
| 25 | #include "lsa.hpp" |
| 26 | #include "nexthop.hpp" |
| 27 | #include "nlsr.hpp" |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 28 | #include "logger.hpp" |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 29 | |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 30 | #include <iostream> |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 31 | #include <boost/math/constants/constants.hpp> |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 32 | #include <cmath> |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 33 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 34 | namespace nlsr { |
| 35 | |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 36 | INIT_LOGGER("RoutingTableCalculator"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 37 | |
| 38 | void |
| 39 | RoutingTableCalculator::allocateAdjMatrix() |
| 40 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 41 | adjMatrix = new double*[m_nRouters]; |
| 42 | |
| 43 | for (size_t i = 0; i < m_nRouters; ++i) { |
| 44 | adjMatrix[i] = new double[m_nRouters]; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 45 | } |
| 46 | } |
| 47 | |
| 48 | void |
| 49 | RoutingTableCalculator::initMatrix() |
| 50 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 51 | for (size_t i = 0; i < m_nRouters; i++) { |
| 52 | for (size_t j = 0; j < m_nRouters; j++) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 53 | adjMatrix[i][j] = 0; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 54 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 55 | } |
| 56 | } |
| 57 | |
| 58 | void |
| 59 | RoutingTableCalculator::makeAdjMatrix(Nlsr& pnlsr, Map pMap) |
| 60 | { |
| 61 | std::list<AdjLsa> adjLsdb = pnlsr.getLsdb().getAdjLsdb(); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 62 | // For each LSA represented in the map |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 63 | for (std::list<AdjLsa>::iterator it = adjLsdb.begin(); it != adjLsdb.end() ; it++) { |
| 64 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 65 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 66 | ndn::optional<int32_t> row = pMap.getMappingNoByRouterName((*it).getOrigRouter()); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 67 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 68 | std::list<Adjacent> adl = (*it).getAdl().getAdjList(); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 69 | // For each adjacency represented in the LSA |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 70 | for (std::list<Adjacent>::iterator itAdl = adl.begin(); itAdl != adl.end() ; itAdl++) { |
| 71 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 72 | ndn::optional<int32_t> col = pMap.getMappingNoByRouterName((*itAdl).getName()); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 73 | double cost = (*itAdl).getLinkCost(); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 74 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 75 | if (row && col && *row < static_cast<int32_t>(m_nRouters) |
| 76 | && *col < static_cast<int32_t>(m_nRouters)) |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 77 | { |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 78 | adjMatrix[*row][*col] = cost; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 79 | } |
| 80 | } |
| 81 | } |
Vince Lehman | 41b173e | 2015-05-07 14:13:26 -0500 | [diff] [blame] | 82 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 83 | // Links that do not have the same cost for both directions should |
| 84 | // have their costs corrected: |
Vince Lehman | 41b173e | 2015-05-07 14:13:26 -0500 | [diff] [blame] | 85 | // |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 86 | // If the cost of one side of the link is 0, both sides of the |
| 87 | // link should have their cost corrected to 0. |
Vince Lehman | 41b173e | 2015-05-07 14:13:26 -0500 | [diff] [blame] | 88 | // |
| 89 | // Otherwise, both sides of the link should use the larger of the two costs. |
| 90 | // |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 91 | // Additionally, this means that we can halve the amount of space |
| 92 | // that the matrix uses by only maintaining a triangle. |
| 93 | // - But that is not yet implemented. |
Vince Lehman | 41b173e | 2015-05-07 14:13:26 -0500 | [diff] [blame] | 94 | for (size_t row = 0; row < m_nRouters; ++row) { |
| 95 | for (size_t col = 0; col < m_nRouters; ++col) { |
| 96 | double toCost = adjMatrix[row][col]; |
| 97 | double fromCost = adjMatrix[col][row]; |
| 98 | |
| 99 | if (fromCost != toCost) { |
| 100 | double correctedCost = 0.0; |
| 101 | |
| 102 | if (toCost != 0 && fromCost != 0) { |
| 103 | // If both sides of the link are up, use the larger cost |
| 104 | correctedCost = std::max(toCost, fromCost); |
| 105 | } |
| 106 | |
| 107 | _LOG_WARN("Cost between [" << row << "][" << col << "] and [" << col << "][" << row << |
| 108 | "] are not the same (" << toCost << " != " << fromCost << "). " << |
| 109 | "Correcting to cost: " << correctedCost); |
| 110 | |
| 111 | adjMatrix[row][col] = correctedCost; |
| 112 | adjMatrix[col][row] = correctedCost; |
| 113 | } |
| 114 | } |
| 115 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | void |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 119 | RoutingTableCalculator::writeAdjMatrixLog() |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 120 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 121 | for (size_t i = 0; i < m_nRouters; i++) { |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 122 | std::string line=""; |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 123 | for (size_t j = 0; j < m_nRouters; j++) { |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 124 | line += boost::lexical_cast<std::string>(adjMatrix[i][j]); |
| 125 | line += " "; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 126 | } |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 127 | _LOG_DEBUG(line); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 128 | } |
| 129 | } |
| 130 | |
| 131 | void |
| 132 | RoutingTableCalculator::adjustAdMatrix(int source, int link, double linkCost) |
| 133 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 134 | for (int i = 0; i < static_cast<int>(m_nRouters); i++) { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 135 | if (i == link) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 136 | adjMatrix[source][i] = linkCost; |
| 137 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 138 | else { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 139 | adjMatrix[source][i] = 0; |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | int |
| 145 | RoutingTableCalculator::getNumOfLinkfromAdjMatrix(int sRouter) |
| 146 | { |
| 147 | int noLink = 0; |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 148 | |
| 149 | for (size_t i = 0; i < m_nRouters; i++) { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 150 | if (adjMatrix[sRouter][i] > 0) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 151 | noLink++; |
| 152 | } |
| 153 | } |
| 154 | return noLink; |
| 155 | } |
| 156 | |
| 157 | void |
| 158 | RoutingTableCalculator::getLinksFromAdjMatrix(int* links, |
| 159 | double* linkCosts, int source) |
| 160 | { |
| 161 | int j = 0; |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 162 | |
| 163 | for (size_t i = 0; i < m_nRouters; i++) { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 164 | if (adjMatrix[source][i] > 0) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 165 | links[j] = i; |
| 166 | linkCosts[j] = adjMatrix[source][i]; |
| 167 | j++; |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | void |
| 173 | RoutingTableCalculator::freeAdjMatrix() |
| 174 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 175 | for (size_t i = 0; i < m_nRouters; ++i) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 176 | delete [] adjMatrix[i]; |
| 177 | } |
| 178 | delete [] adjMatrix; |
| 179 | } |
| 180 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 181 | void |
| 182 | RoutingTableCalculator::allocateLinks() |
| 183 | { |
| 184 | links = new int[vNoLink]; |
| 185 | } |
| 186 | |
| 187 | void |
| 188 | RoutingTableCalculator::allocateLinkCosts() |
| 189 | { |
| 190 | linkCosts = new double[vNoLink]; |
| 191 | } |
| 192 | |
| 193 | |
| 194 | void |
| 195 | RoutingTableCalculator::freeLinks() |
| 196 | { |
| 197 | delete [] links; |
| 198 | } |
| 199 | void |
| 200 | RoutingTableCalculator::freeLinksCosts() |
| 201 | { |
| 202 | delete [] linkCosts; |
| 203 | } |
| 204 | |
| 205 | void |
| 206 | LinkStateRoutingTableCalculator::calculatePath(Map& pMap, |
| 207 | RoutingTable& rt, Nlsr& pnlsr) |
| 208 | { |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 209 | _LOG_DEBUG("LinkStateRoutingTableCalculator::calculatePath Called"); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 210 | allocateAdjMatrix(); |
| 211 | initMatrix(); |
| 212 | makeAdjMatrix(pnlsr, pMap); |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 213 | writeAdjMatrixLog(); |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 214 | ndn::optional<int32_t> sourceRouter = |
| 215 | pMap.getMappingNoByRouterName(pnlsr.getConfParameter().getRouterPrefix()); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 216 | allocateParent(); // These two matrices are used in Dijkstra's algorithm. |
| 217 | allocateDistance(); // |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 218 | // We only bother to do the calculation if we have a router by that name. |
| 219 | if (sourceRouter && pnlsr.getConfParameter().getMaxFacesPerPrefix() == 1) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 220 | // In the single path case we can simply run Dijkstra's algorithm. |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 221 | doDijkstraPathCalculation(*sourceRouter); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 222 | // Inform the routing table of the new next hops. |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 223 | addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, *sourceRouter); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 224 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 225 | else { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 226 | // Multi Path |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 227 | setNoLink(getNumOfLinkfromAdjMatrix(*sourceRouter)); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 228 | allocateLinks(); |
| 229 | allocateLinkCosts(); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 230 | // Gets a sparse listing of adjacencies for path calculation |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 231 | getLinksFromAdjMatrix(links, linkCosts, *sourceRouter); |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 232 | for (int i = 0 ; i < vNoLink; i++) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 233 | // Simulate that only the current neighbor is accessible |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 234 | adjustAdMatrix(*sourceRouter, links[i], linkCosts[i]); |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 235 | writeAdjMatrixLog(); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 236 | // Do Dijkstra's algorithm using the current neighbor as your start. |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 237 | doDijkstraPathCalculation(*sourceRouter); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 238 | // Update the routing table with the calculations. |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 239 | addAllLsNextHopsToRoutingTable(pnlsr, rt, pMap, *sourceRouter); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 240 | } |
| 241 | freeLinks(); |
| 242 | freeLinksCosts(); |
| 243 | } |
| 244 | freeParent(); |
| 245 | freeDistance(); |
| 246 | freeAdjMatrix(); |
| 247 | } |
| 248 | |
| 249 | void |
| 250 | LinkStateRoutingTableCalculator::doDijkstraPathCalculation(int sourceRouter) |
| 251 | { |
| 252 | int i; |
| 253 | int v, u; |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 254 | int* Q = new int[m_nRouters]; // Each cell represents the router with that mapping no. |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 255 | int head = 0; |
Nick Gordon | e98480b | 2017-05-24 11:23:03 -0500 | [diff] [blame] | 256 | // Initiate the parent |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 257 | for (i = 0 ; i < static_cast<int>(m_nRouters); i++) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 258 | m_parent[i] = EMPTY_PARENT; |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 259 | // Array where the ith element is the distance to the router with mapping no i. |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 260 | m_distance[i] = INF_DISTANCE; |
| 261 | Q[i] = i; |
| 262 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 263 | if (sourceRouter != NO_MAPPING_NUM) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 264 | // Distance to source from source is always 0. |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 265 | m_distance[sourceRouter] = 0; |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 266 | sortQueueByDistance(Q, m_distance, head, m_nRouters); |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 267 | // While we haven't visited every node. |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 268 | while (head < static_cast<int>(m_nRouters)) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 269 | u = Q[head]; // Set u to be the current node pointed to by head. |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 270 | if (m_distance[u] == INF_DISTANCE) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 271 | break; // This can only happen when there are no accessible nodes. |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 272 | } |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 273 | // Iterate over the adjacent nodes to u. |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 274 | for (v = 0 ; v < static_cast<int>(m_nRouters); v++) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 275 | // If the current node is accessible. |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 276 | if (adjMatrix[u][v] > 0) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 277 | // And we haven't visited it yet. |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 278 | if (isNotExplored(Q, v, head + 1, m_nRouters)) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 279 | // And if the distance to this node + from this node to v |
| 280 | // is less than the distance from our source node to v |
| 281 | // that we got when we built the adj LSAs |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 282 | if (m_distance[u] + adjMatrix[u][v] < m_distance[v]) { |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 283 | // Set the new distance |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 284 | m_distance[v] = m_distance[u] + adjMatrix[u][v] ; |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 285 | // Set how we get there. |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 286 | m_parent[v] = u; |
| 287 | } |
| 288 | } |
| 289 | } |
| 290 | } |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 291 | // Increment the head position, resort the list by distance from where we are. |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 292 | head++; |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 293 | sortQueueByDistance(Q, m_distance, head, m_nRouters); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | delete [] Q; |
| 297 | } |
| 298 | |
| 299 | void |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 300 | LinkStateRoutingTableCalculator::addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt, |
| 301 | Map& pMap, uint32_t sourceRouter) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 302 | { |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 303 | _LOG_DEBUG("LinkStateRoutingTableCalculator::addAllNextHopsToRoutingTable Called"); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 304 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 305 | int nextHopRouter = 0; |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 306 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 307 | // For each router we have |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 308 | for (size_t i = 0; i < m_nRouters ; i++) { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 309 | if (i != sourceRouter) { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 310 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 311 | // Obtain the next hop that was determined by the algorithm |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 312 | nextHopRouter = getLsNextHop(i, sourceRouter); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 313 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 314 | // If this router is accessible at all |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 315 | if (nextHopRouter != NO_NEXT_HOP) { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 316 | |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 317 | // Fetch its distance |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 318 | double routeCost = m_distance[i]; |
Nick G | 97e3494 | 2016-07-11 14:46:27 -0500 | [diff] [blame] | 319 | // Fetch its actual name |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 320 | ndn::optional<ndn::Name> nextHopRouterName= pMap.getRouterNameByMappingNo(nextHopRouter); |
| 321 | if (nextHopRouterName) { |
| 322 | std::string nextHopFace = |
| 323 | pnlsr.getAdjacencyList().getAdjacent(*nextHopRouterName).getFaceUri().toString(); |
| 324 | // Add next hop to routing table |
| 325 | NextHop nh(nextHopFace, routeCost); |
| 326 | rt.addNextHop(*(pMap.getRouterNameByMappingNo(i)), nh); |
| 327 | |
| 328 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | int |
| 335 | LinkStateRoutingTableCalculator::getLsNextHop(int dest, int source) |
| 336 | { |
| 337 | int nextHop = NO_NEXT_HOP; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 338 | while (m_parent[dest] != EMPTY_PARENT) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 339 | nextHop = dest; |
| 340 | dest = m_parent[dest]; |
| 341 | } |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 342 | if (dest != source) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 343 | nextHop = NO_NEXT_HOP; |
| 344 | } |
| 345 | return nextHop; |
| 346 | } |
| 347 | |
| 348 | void |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 349 | LinkStateRoutingTableCalculator::sortQueueByDistance(int* Q, |
akmhoque | 2f42335 | 2014-06-03 11:49:35 -0500 | [diff] [blame] | 350 | double* dist, |
| 351 | int start, int element) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 352 | { |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 353 | for (int i = start ; i < element ; i++) { |
| 354 | for (int j = i + 1; j < element; j++) { |
| 355 | if (dist[Q[j]] < dist[Q[i]]) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 356 | int tempU = Q[j]; |
| 357 | Q[j] = Q[i]; |
| 358 | Q[i] = tempU; |
| 359 | } |
| 360 | } |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | int |
| 365 | LinkStateRoutingTableCalculator::isNotExplored(int* Q, |
| 366 | int u, int start, int element) |
| 367 | { |
| 368 | int ret = 0; |
akmhoque | 157b0a4 | 2014-05-13 00:26:37 -0500 | [diff] [blame] | 369 | for (int i = start; i < element; i++) { |
| 370 | if (Q[i] == u) { |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 371 | ret = 1; |
| 372 | break; |
| 373 | } |
| 374 | } |
| 375 | return ret; |
| 376 | } |
| 377 | |
| 378 | void |
| 379 | LinkStateRoutingTableCalculator::allocateParent() |
| 380 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 381 | m_parent = new int[m_nRouters]; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 382 | } |
| 383 | |
| 384 | void |
| 385 | LinkStateRoutingTableCalculator::allocateDistance() |
| 386 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 387 | m_distance = new double[m_nRouters]; |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 388 | } |
| 389 | |
| 390 | void |
| 391 | LinkStateRoutingTableCalculator::freeParent() |
| 392 | { |
| 393 | delete [] m_parent; |
| 394 | } |
| 395 | |
| 396 | void LinkStateRoutingTableCalculator::freeDistance() |
| 397 | { |
| 398 | delete [] m_distance; |
| 399 | } |
| 400 | |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 401 | const double HyperbolicRoutingCalculator::MATH_PI = boost::math::constants::pi<double>(); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 402 | |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 403 | const double HyperbolicRoutingCalculator::UNKNOWN_DISTANCE = -1.0; |
| 404 | const double HyperbolicRoutingCalculator::UNKNOWN_RADIUS = -1.0; |
| 405 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 406 | void |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 407 | HyperbolicRoutingCalculator::calculatePaths(Map& map, RoutingTable& rt, |
| 408 | Lsdb& lsdb, AdjacencyList& adjacencies) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 409 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 410 | _LOG_TRACE("Calculating hyperbolic paths"); |
| 411 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 412 | ndn::optional<int32_t> thisRouter = map.getMappingNoByRouterName(m_thisRouterName); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 413 | |
| 414 | // Iterate over directly connected neighbors |
| 415 | std::list<Adjacent> neighbors = adjacencies.getAdjList(); |
| 416 | for (std::list<Adjacent>::iterator adj = neighbors.begin(); adj != neighbors.end(); ++adj) { |
| 417 | |
| 418 | // Don't calculate nexthops using an inactive router |
| 419 | if (adj->getStatus() == Adjacent::STATUS_INACTIVE) { |
| 420 | _LOG_TRACE(adj->getName() << " is inactive; not using it as a nexthop"); |
| 421 | continue; |
| 422 | } |
| 423 | |
| 424 | ndn::Name srcRouterName = adj->getName(); |
| 425 | |
| 426 | // Don't calculate nexthops for this router to other routers |
| 427 | if (srcRouterName == m_thisRouterName) { |
| 428 | continue; |
| 429 | } |
| 430 | |
Nick Gordon | e9733ed | 2017-04-26 10:48:39 -0500 | [diff] [blame] | 431 | std::string srcFaceUri = adj->getFaceUri().toString(); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 432 | |
| 433 | // Install nexthops for this router to the neighbor; direct neighbors have a 0 cost link |
| 434 | addNextHop(srcRouterName, srcFaceUri, 0, rt); |
| 435 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 436 | ndn::optional<int32_t> src = map.getMappingNoByRouterName(srcRouterName); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 437 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 438 | if (!src) { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 439 | _LOG_WARN(adj->getName() << " does not exist in the router map!"); |
| 440 | continue; |
| 441 | } |
| 442 | |
| 443 | // Get hyperbolic distance from direct neighbor to every other router |
| 444 | for (int dest = 0; dest < static_cast<int>(m_nRouters); ++dest) { |
| 445 | // Don't calculate nexthops to this router or from a router to itself |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 446 | if (thisRouter && dest != *thisRouter && dest != *src) { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 447 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 448 | ndn::optional<ndn::Name> destRouterName = map.getRouterNameByMappingNo(dest); |
| 449 | if (destRouterName) { |
| 450 | double distance = getHyperbolicDistance(map, lsdb, srcRouterName, *destRouterName); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 451 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 452 | // Could not compute distance |
| 453 | if (distance == UNKNOWN_DISTANCE) { |
| 454 | _LOG_WARN("Could not calculate hyperbolic distance from " << srcRouterName << " to " << |
| 455 | *destRouterName); |
| 456 | continue; |
| 457 | } |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 458 | |
Nick Gordon | e40377d | 2017-08-11 15:10:02 -0500 | [diff] [blame] | 459 | addNextHop(*destRouterName, srcFaceUri, distance, rt); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 460 | } |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 461 | } |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 462 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 463 | } |
| 464 | } |
| 465 | |
| 466 | double |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 467 | HyperbolicRoutingCalculator::getHyperbolicDistance(Map& map, Lsdb& lsdb, |
| 468 | ndn::Name src, ndn::Name dest) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 469 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 470 | _LOG_TRACE("Calculating hyperbolic distance from " << src << " to " << dest); |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 471 | |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 472 | double distance = UNKNOWN_DISTANCE; |
| 473 | |
| 474 | ndn::Name srcLsaKey = src; |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame^] | 475 | srcLsaKey.append(std::to_string(Lsa::Type::COORDINATE)); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 476 | |
| 477 | CoordinateLsa* srcLsa = lsdb.findCoordinateLsa(srcLsaKey); |
| 478 | |
| 479 | ndn::Name destLsaKey = dest; |
Nick Gordon | 727d483 | 2017-10-13 18:04:25 -0500 | [diff] [blame^] | 480 | destLsaKey.append(std::to_string(Lsa::Type::COORDINATE)); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 481 | |
| 482 | CoordinateLsa* destLsa = lsdb.findCoordinateLsa(destLsaKey); |
| 483 | |
| 484 | // Coordinate LSAs do not exist for these routers |
Nick Gordon | e9733ed | 2017-04-26 10:48:39 -0500 | [diff] [blame] | 485 | if (srcLsa == nullptr || destLsa == nullptr) { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 486 | return UNKNOWN_DISTANCE; |
akmhoque | dcee936 | 2014-08-05 22:58:01 -0500 | [diff] [blame] | 487 | } |
| 488 | |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 489 | std::vector<double> srcTheta = srcLsa->getCorTheta(); |
| 490 | std::vector<double> destTheta = destLsa->getCorTheta(); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 491 | |
| 492 | double srcRadius = srcLsa->getCorRadius(); |
| 493 | double destRadius = destLsa->getCorRadius(); |
| 494 | |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 495 | double diffTheta = calculateAngularDistance(srcTheta, destTheta); |
| 496 | |
| 497 | if (srcRadius == UNKNOWN_RADIUS || destRadius == UNKNOWN_RADIUS || |
| 498 | diffTheta == UNKNOWN_DISTANCE) { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 499 | return UNKNOWN_DISTANCE; |
| 500 | } |
| 501 | |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 502 | // double r_i, double r_j, double delta_theta, double zeta = 1 (default) |
| 503 | distance = calculateHyperbolicDistance(srcRadius, destRadius, diffTheta); |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 504 | |
| 505 | _LOG_TRACE("Distance from " << src << " to " << dest << " is " << distance); |
| 506 | |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 507 | return distance; |
| 508 | } |
| 509 | |
Muktadir R Chowdhury | b00dc2a | 2016-11-05 10:48:58 -0600 | [diff] [blame] | 510 | double |
| 511 | HyperbolicRoutingCalculator::calculateAngularDistance(std::vector<double> angleVectorI, |
| 512 | std::vector<double> angleVectorJ) |
| 513 | { |
| 514 | // It is not possible for angle vector size to be zero as ensured by conf-file-processor |
| 515 | |
| 516 | // https://en.wikipedia.org/wiki/N-sphere#Spherical_coordinates |
| 517 | |
| 518 | // Check if two vector lengths are the same |
| 519 | if (angleVectorI.size() != angleVectorJ.size()) { |
| 520 | _LOG_ERROR("Angle vector sizes do not match"); |
| 521 | return UNKNOWN_DISTANCE; |
| 522 | } |
| 523 | |
| 524 | // Check if all angles are within the [0, PI] and [0, 2PI] ranges |
| 525 | if (angleVectorI.size() > 1) { |
| 526 | for (unsigned int k = 0; k < angleVectorI.size() - 1; k++) { |
| 527 | if ((angleVectorI[k] > M_PI && angleVectorI[k] < 0.0) || |
| 528 | (angleVectorJ[k] > M_PI && angleVectorJ[k] < 0.0)) { |
| 529 | _LOG_ERROR("Angle outside [0, PI]"); |
| 530 | return UNKNOWN_DISTANCE; |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | if (angleVectorI[angleVectorI.size()-1] > 2.*M_PI || |
| 535 | angleVectorI[angleVectorI.size()-1] < 0.0) { |
| 536 | _LOG_ERROR("Angle not within [0, 2PI]"); |
| 537 | return UNKNOWN_DISTANCE; |
| 538 | } |
| 539 | |
| 540 | if (angleVectorI[angleVectorI.size()-1] > 2.*M_PI || |
| 541 | angleVectorI[angleVectorI.size()-1] < 0.0) { |
| 542 | _LOG_ERROR("Angle not within [0, 2PI]"); |
| 543 | return UNKNOWN_DISTANCE; |
| 544 | } |
| 545 | |
| 546 | // deltaTheta = arccos(vectorI . vectorJ) -> do the inner product |
| 547 | double innerProduct = 0.0; |
| 548 | |
| 549 | // Calculate x0 of the vectors |
| 550 | double x0i = std::cos(angleVectorI[0]); |
| 551 | double x0j = std::cos(angleVectorJ[0]); |
| 552 | |
| 553 | // Calculate xn of the vectors |
| 554 | double xni = std::sin(angleVectorI[angleVectorI.size() - 1]); |
| 555 | double xnj = std::sin(angleVectorJ[angleVectorJ.size() - 1]); |
| 556 | |
| 557 | // Do the aggregation of the (n-1) coordinates (if there is more than one angle) |
| 558 | // i.e contraction of all (n-1)-dimensional angular coordinates to one variable |
| 559 | for (unsigned int k = 0; k < angleVectorI.size() - 1; k++) { |
| 560 | xni *= std::sin(angleVectorI[k]); |
| 561 | xnj *= std::sin(angleVectorJ[k]); |
| 562 | } |
| 563 | innerProduct += (x0i * x0j) + (xni * xnj); |
| 564 | |
| 565 | // If d > 1 |
| 566 | if (angleVectorI.size() > 1) { |
| 567 | for (unsigned int m = 1; m < angleVectorI.size(); m++) { |
| 568 | // calculate euclidean coordinates given the angles and assuming R_sphere = 1 |
| 569 | double xmi = std::cos(angleVectorI[m]); |
| 570 | double xmj = std::cos(angleVectorJ[m]); |
| 571 | for (unsigned int l = 0; l < m; l++) { |
| 572 | xmi *= std::sin(angleVectorI[l]); |
| 573 | xmj *= std::sin(angleVectorJ[l]); |
| 574 | } |
| 575 | innerProduct += xmi * xmj; |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | // ArcCos of the inner product gives the angular distance |
| 580 | // between two points on a d-dimensional sphere |
| 581 | return std::acos(innerProduct); |
| 582 | } |
| 583 | |
| 584 | double |
| 585 | HyperbolicRoutingCalculator::calculateHyperbolicDistance(double rI, double rJ, |
| 586 | double deltaTheta) |
| 587 | { |
| 588 | if (deltaTheta == UNKNOWN_DISTANCE) { |
| 589 | return UNKNOWN_DISTANCE; |
| 590 | } |
| 591 | |
| 592 | // Usually, we set zeta = 1 in all experiments |
| 593 | double zeta = 1; |
| 594 | |
| 595 | if (deltaTheta <= 0.0 || rI <= 0.0 || rJ <= 0.0) { |
| 596 | _LOG_ERROR("Delta theta or rI or rJ is <= 0"); |
| 597 | return UNKNOWN_DISTANCE; |
| 598 | } |
| 599 | |
| 600 | double xij = (1. / zeta) * std::acosh(std::cosh(zeta*rI) * std::cosh(zeta*rJ) - |
| 601 | std::sinh(zeta*rI)*std::sinh(zeta*rJ)*std::cos(deltaTheta)); |
| 602 | return xij; |
| 603 | } |
| 604 | |
| 605 | void |
| 606 | HyperbolicRoutingCalculator::addNextHop(ndn::Name dest, std::string faceUri, |
| 607 | double cost, RoutingTable& rt) |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 608 | { |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 609 | NextHop hop(faceUri, cost); |
Vince Lehman | 20fe4a9 | 2014-09-09 15:57:59 -0500 | [diff] [blame] | 610 | hop.setHyperbolic(true); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 611 | |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 612 | _LOG_TRACE("Calculated " << hop << " for destination: " << dest); |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 613 | |
Vince Lehman | 9a70903 | 2014-09-13 16:28:07 -0500 | [diff] [blame] | 614 | if (m_isDryRun) { |
| 615 | rt.addNextHopToDryTable(dest, hop); |
| 616 | } |
| 617 | else { |
| 618 | rt.addNextHop(dest, hop); |
| 619 | } |
akmhoque | 5335346 | 2014-04-22 08:43:45 -0500 | [diff] [blame] | 620 | } |
| 621 | |
Nick Gordon | fad8e25 | 2016-08-11 14:21:38 -0500 | [diff] [blame] | 622 | } // namespace nlsr |