route: remove redundant function
refs: #4811
Change-Id: I31b1031f57a344e7c3176b917ffbad2f6b2bd821
diff --git a/src/route/routing-table-calculator.cpp b/src/route/routing-table-calculator.cpp
index eeaf4d2..492c39b 100644
--- a/src/route/routing-table-calculator.cpp
+++ b/src/route/routing-table-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -425,8 +425,8 @@
const double HyperbolicRoutingCalculator::UNKNOWN_RADIUS = -1.0;
void
-HyperbolicRoutingCalculator::calculatePaths(Map& map, RoutingTable& rt,
- Lsdb& lsdb, AdjacencyList& adjacencies)
+HyperbolicRoutingCalculator::calculatePath(Map& map, RoutingTable& rt,
+ Lsdb& lsdb, AdjacencyList& adjacencies)
{
NLSR_LOG_TRACE("Calculating hyperbolic paths");
@@ -468,12 +468,12 @@
ndn::optional<ndn::Name> destRouterName = map.getRouterNameByMappingNo(dest);
if (destRouterName) {
- double distance = getHyperbolicDistance(map, lsdb, srcRouterName, *destRouterName);
+ double distance = getHyperbolicDistance(lsdb, srcRouterName, *destRouterName);
// Could not compute distance
if (distance == UNKNOWN_DISTANCE) {
NLSR_LOG_WARN("Could not calculate hyperbolic distance from " << srcRouterName << " to " <<
- *destRouterName);
+ *destRouterName);
continue;
}
@@ -485,8 +485,7 @@
}
double
-HyperbolicRoutingCalculator::getHyperbolicDistance(Map& map, Lsdb& lsdb,
- ndn::Name src, ndn::Name dest)
+HyperbolicRoutingCalculator::getHyperbolicDistance(Lsdb& lsdb, ndn::Name src, ndn::Name dest)
{
NLSR_LOG_TRACE("Calculating hyperbolic distance from " << src << " to " << dest);
diff --git a/src/route/routing-table-calculator.hpp b/src/route/routing-table-calculator.hpp
index 6024fbd..0812aad 100644
--- a/src/route/routing-table-calculator.hpp
+++ b/src/route/routing-table-calculator.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -215,11 +215,11 @@
}
void
- calculatePaths(Map& map, RoutingTable& rt, Lsdb& lsdb, AdjacencyList& adjacencies);
+ calculatePath(Map& map, RoutingTable& rt, Lsdb& lsdb, AdjacencyList& adjacencies);
private:
double
- getHyperbolicDistance(Map& map, Lsdb& lsdb, ndn::Name src, ndn::Name dest);
+ getHyperbolicDistance(Lsdb& lsdb, ndn::Name src, ndn::Name dest);
void
addNextHop(ndn::Name destinationRouter, std::string faceUri, double cost, RoutingTable& rt);
diff --git a/src/route/routing-table.cpp b/src/route/routing-table.cpp
index 9c4ea77..48ef422 100644
--- a/src/route/routing-table.cpp
+++ b/src/route/routing-table.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -80,13 +80,13 @@
|| (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN)) {
calculateLsRoutingTable(pnlsr);
}
- //calculate hyperbolic routing
+ // calculate hyperbolic
if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_ON) {
- calculateHypRoutingTable(pnlsr);
+ calculateHypRoutingTable(pnlsr, false);
}
//calculate dry hyperbolic routing
if (pnlsr.getConfParameter().getHyperbolicState() == HYPERBOLIC_STATE_DRY_RUN) {
- calculateHypDryRoutingTable(pnlsr);
+ calculateHypRoutingTable(pnlsr, true);
}
// Inform the NPT that updates have been made
NLSR_LOG_DEBUG("Calling Update NPT With new Route");
@@ -134,11 +134,11 @@
LinkStateRoutingTableCalculator calculator(nRouters);
- calculator.calculatePath(map, std::ref(*this), nlsr);
+ calculator.calculatePath(map, *this, nlsr);
}
void
-RoutingTable::calculateHypRoutingTable(Nlsr& nlsr)
+RoutingTable::calculateHypRoutingTable(Nlsr& nlsr, bool isDryRun)
{
Map map;
map.createFromCoordinateLsdb(nlsr.getLsdb().getCoordinateLsdb().begin(),
@@ -147,27 +147,10 @@
size_t nRouters = map.getMapSize();
- HyperbolicRoutingCalculator calculator(nRouters, false,
+ HyperbolicRoutingCalculator calculator(nRouters, isDryRun,
nlsr.getConfParameter().getRouterPrefix());
- calculator.calculatePaths(map, std::ref(*this),
- nlsr.getLsdb(), nlsr.getAdjacencyList());
-}
-
-void
-RoutingTable::calculateHypDryRoutingTable(Nlsr& nlsr)
-{
- Map map;
- map.createFromAdjLsdb(nlsr.getLsdb().getAdjLsdb().begin(), nlsr.getLsdb().getAdjLsdb().end());
- map.writeLog();
-
- size_t nRouters = map.getMapSize();
-
- HyperbolicRoutingCalculator calculator(nRouters, true,
- nlsr.getConfParameter().getRouterPrefix());
-
- calculator.calculatePaths(map, std::ref(*this),
- nlsr.getLsdb(), nlsr.getAdjacencyList());
+ calculator.calculatePath(map, *this, nlsr.getLsdb(), nlsr.getAdjacencyList());
}
void
diff --git a/src/route/routing-table.hpp b/src/route/routing-table.hpp
index cd7b5f5..5572aed 100644
--- a/src/route/routing-table.hpp
+++ b/src/route/routing-table.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California
*
* This file is part of NLSR (Named-data Link State Routing).
@@ -118,11 +118,7 @@
/*! \brief Calculates a HR routing table. */
void
- calculateHypRoutingTable(Nlsr& pnlsr);
-
- /*! \brief Calculates a dry-run HR routing table. */
- void
- calculateHypDryRoutingTable(Nlsr& pnlsr);
+ calculateHypRoutingTable(Nlsr& pnlsr, bool isDryRun);
void
clearRoutingTable();
diff --git a/tests/test-hyperbolic-calculator.cpp b/tests/test-hyperbolic-calculator.cpp
index 4b8cce7..c4f39e2 100644
--- a/tests/test-hyperbolic-calculator.cpp
+++ b/tests/test-hyperbolic-calculator.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
- * Copyright (c) 2014-2018, The University of Memphis,
+ * Copyright (c) 2014-2019, The University of Memphis,
* Regents of the University of California,
* Arizona Board of Regents.
*
@@ -106,7 +106,7 @@
void runTest(const double& expectedCost)
{
HyperbolicRoutingCalculator calculator(map.getMapSize(), false, ROUTER_A_NAME);
- calculator.calculatePaths(map, routingTable, lsdb, adjacencies);
+ calculator.calculatePath(map, routingTable, lsdb, adjacencies);
RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);