**breaking** route: consolidate routing tlv into route

refs: #5116

Plus some misc improvements

Change-Id: Id0902fec65160b4368b1b5066f460433aced98ed
diff --git a/tests/route/test-hyperbolic-calculator.cpp b/tests/route/test-hyperbolic-calculator.cpp
new file mode 100644
index 0000000..a697e2e
--- /dev/null
+++ b/tests/route/test-hyperbolic-calculator.cpp
@@ -0,0 +1,199 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2020,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "../test-common.hpp"
+
+#include "route/routing-table-calculator.hpp"
+
+#include "adjacency-list.hpp"
+#include "lsdb.hpp"
+#include "nlsr.hpp"
+#include "route/map.hpp"
+#include "route/routing-table.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+namespace nlsr {
+namespace test {
+
+using std::shared_ptr;
+using ndn::time::system_clock;
+static const system_clock::TimePoint MAX_TIME = system_clock::TimePoint::max();
+
+class HyperbolicCalculatorFixture : public BaseFixture
+{
+public:
+  HyperbolicCalculatorFixture()
+    : face(m_ioService, m_keyChain)
+    , conf(face, m_keyChain)
+    , nlsr(face, m_keyChain, conf)
+    , routingTable(nlsr.m_routingTable)
+    , adjacencies(conf.getAdjacencyList())
+    , lsdb(nlsr.m_lsdb)
+  {
+  }
+
+  // Triangle topology with routers A, B, C connected
+  void setUpTopology(std::vector<double> anglesA, std::vector<double> anglesB,
+                     std::vector<double> anglesC)
+  {
+    Adjacent a(ROUTER_A_NAME, ndn::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent b(ROUTER_B_NAME, ndn::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent c(ROUTER_C_NAME, ndn::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+
+    // Router A
+    adjacencies.insert(b);
+    adjacencies.insert(c);
+
+    AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencies);
+    lsdb.installAdjLsa(adjA);
+
+
+    CoordinateLsa coordA(adjA.getOriginRouter(), 1, MAX_TIME, 16.23, anglesA);
+    lsdb.installCoordinateLsa(coordA);
+
+    // Router B
+    a.setFaceId(1);
+    c.setFaceId(2);
+
+    AdjacencyList adjacencyListB;
+    adjacencyListB.insert(a);
+    adjacencyListB.insert(c);
+
+    AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
+    lsdb.installAdjLsa(adjB);
+
+    CoordinateLsa coordB(adjB.getOriginRouter(), 1, MAX_TIME, 16.59, anglesB);
+    lsdb.installCoordinateLsa(coordB);
+
+    // Router C
+    a.setFaceId(1);
+    b.setFaceId(2);
+
+    AdjacencyList adjacencyListC;
+    adjacencyListC.insert(a);
+    adjacencyListC.insert(b);
+
+    AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
+    lsdb.installAdjLsa(adjC);
+
+    CoordinateLsa coordC(adjC.getOriginRouter(), 1, MAX_TIME, 14.11, anglesC);
+    lsdb.installCoordinateLsa(coordC);
+
+    map.createFromAdjLsdb(lsdb.getAdjLsdb().begin(), lsdb.getAdjLsdb().end());
+  }
+
+  void runTest(const double& expectedCost)
+  {
+    HyperbolicRoutingCalculator calculator(map.getMapSize(), false, ROUTER_A_NAME);
+    calculator.calculatePath(map, routingTable, lsdb, adjacencies);
+
+    RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+
+    // Router A should be able to get to B through B with cost 0 and to B through C
+    NexthopList& bHopList = entryB->getNexthopList();
+    BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
+
+    for (std::set<NextHop, NextHopComparator>::iterator it = bHopList.begin(); it != bHopList.end(); ++it) {
+      std::string faceUri = it->getConnectingFaceUri();
+      uint64_t cost = it->getRouteCostAsAdjustedInteger();
+
+      BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == 0) ||
+                  (faceUri == ROUTER_C_FACE && cost == applyHyperbolicFactorAndRound(expectedCost)));
+    }
+
+    RoutingTableEntry* entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
+
+    // Router A should be able to get to C through C with cost 0 and to C through B
+    NexthopList& cHopList = entryC->getNexthopList();
+    BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
+
+    for (std::set<NextHop, NextHopComparator>::iterator it = cHopList.begin(); it != cHopList.end(); ++it) {
+      std::string faceUri = it->getConnectingFaceUri();
+      uint64_t cost = it->getRouteCostAsAdjustedInteger();
+
+      BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == applyHyperbolicFactorAndRound(expectedCost)) ||
+                  (faceUri == ROUTER_C_FACE && cost == 0));
+    }
+  }
+
+  uint64_t
+  applyHyperbolicFactorAndRound(double d)
+  {
+    // Hyperbolic costs in the tests were calculated with 1*10^-9 precision.
+    // A factor larger than 1*10^9 will cause the tests to fail.
+    BOOST_REQUIRE(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR <= 1000000000);
+    return round(NextHop::HYPERBOLIC_COST_ADJUSTMENT_FACTOR*d);
+  }
+
+public:
+  ndn::util::DummyClientFace face;
+  ConfParameter conf;
+  Nlsr nlsr;
+  Map map;
+
+  RoutingTable& routingTable;
+  AdjacencyList& adjacencies;
+  Lsdb& lsdb;
+
+  static const ndn::Name ROUTER_A_NAME;
+  static const ndn::Name ROUTER_B_NAME;
+  static const ndn::Name ROUTER_C_NAME;
+
+  static const std::string ROUTER_A_FACE;
+  static const std::string ROUTER_B_FACE;
+  static const std::string ROUTER_C_FACE;
+};
+
+const ndn::Name HyperbolicCalculatorFixture::ROUTER_A_NAME = "/ndn/router/a";
+const ndn::Name HyperbolicCalculatorFixture::ROUTER_B_NAME = "/ndn/router/b";
+const ndn::Name HyperbolicCalculatorFixture::ROUTER_C_NAME = "/ndn/router/c";
+
+const std::string HyperbolicCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
+const std::string HyperbolicCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
+const std::string HyperbolicCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
+
+BOOST_FIXTURE_TEST_SUITE(TestHyperbolicRoutingCalculator, HyperbolicCalculatorFixture)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  std::vector<double> anglesA = {2.97},
+                      anglesB = {3.0},
+                      anglesC = {2.99};
+  setUpTopology(anglesA, anglesB, anglesC);
+
+  runTest(20.103356956);
+}
+
+BOOST_AUTO_TEST_CASE(BasicMultipleAngles)
+{
+  std::vector<double> anglesA = {2.97,1.22},
+                      anglesB = {3.0, 0.09},
+                      anglesC = {321, 2.99};
+  setUpTopology(anglesA, anglesB, anglesC);
+
+  runTest(30.655296361);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace nlsr
diff --git a/tests/route/test-link-state-calculator.cpp b/tests/route/test-link-state-calculator.cpp
new file mode 100644
index 0000000..a0d04df
--- /dev/null
+++ b/tests/route/test-link-state-calculator.cpp
@@ -0,0 +1,323 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2014-2020,  The University of Memphis,
+ *                           Regents of the University of California,
+ *                           Arizona Board of Regents.
+ *
+ * This file is part of NLSR (Named-data Link State Routing).
+ * See AUTHORS.md for complete list of NLSR authors and contributors.
+ *
+ * NLSR is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "route/routing-table-calculator.hpp"
+
+#include "adjacency-list.hpp"
+#include "lsdb.hpp"
+#include "nlsr.hpp"
+#include "../test-common.hpp"
+#include "route/map.hpp"
+#include "route/routing-table.hpp"
+#include "adjacent.hpp"
+
+#include <ndn-cxx/util/dummy-client-face.hpp>
+
+namespace nlsr {
+namespace test {
+
+static const ndn::time::system_clock::TimePoint MAX_TIME =
+  ndn::time::system_clock::TimePoint::max();
+
+class LinkStateCalculatorFixture : public BaseFixture
+{
+public:
+  LinkStateCalculatorFixture()
+    : face(m_ioService, m_keyChain)
+    , conf(face, m_keyChain)
+    , confProcessor(conf)
+    , nlsr(face, m_keyChain, conf)
+    , routingTable(nlsr.m_routingTable)
+    , lsdb(nlsr.m_lsdb)
+  {
+    setUpTopology();
+  }
+
+  // Triangle topology with routers A, B, C connected
+  void setUpTopology()
+  {
+    Adjacent a(ROUTER_A_NAME, ndn::FaceUri(ROUTER_A_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent b(ROUTER_B_NAME, ndn::FaceUri(ROUTER_B_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+    Adjacent c(ROUTER_C_NAME, ndn::FaceUri(ROUTER_C_FACE), 0, Adjacent::STATUS_ACTIVE, 0, 0);
+
+    // Router A
+    b.setLinkCost(LINK_AB_COST);
+    c.setLinkCost(LINK_AC_COST);
+
+    AdjacencyList& adjacencyListA = conf.getAdjacencyList();
+    adjacencyListA.insert(b);
+    adjacencyListA.insert(c);
+
+    AdjLsa adjA(a.getName(), 1, MAX_TIME, 2, adjacencyListA);
+    lsdb.installAdjLsa(adjA);
+
+    // Router B
+    a.setLinkCost(LINK_AB_COST);
+    c.setLinkCost(LINK_BC_COST);
+
+    AdjacencyList adjacencyListB;
+    adjacencyListB.insert(a);
+    adjacencyListB.insert(c);
+
+    AdjLsa adjB(b.getName(), 1, MAX_TIME, 2, adjacencyListB);
+    lsdb.installAdjLsa(adjB);
+
+    // Router C
+    a.setLinkCost(LINK_AC_COST);
+    b.setLinkCost(LINK_BC_COST);
+
+    AdjacencyList adjacencyListC;
+    adjacencyListC.insert(a);
+    adjacencyListC.insert(b);
+
+    AdjLsa adjC(c.getName(), 1, MAX_TIME, 2, adjacencyListC);
+    lsdb.installAdjLsa(adjC);
+
+    map.createFromAdjLsdb(lsdb.getAdjLsdb().begin(), lsdb.getAdjLsdb().end());
+  }
+
+public:
+  ndn::util::DummyClientFace face;
+  ConfParameter conf;
+  DummyConfFileProcessor confProcessor;
+  Nlsr nlsr;
+  Map map;
+
+  RoutingTable& routingTable;
+  Lsdb& lsdb;
+
+  static const ndn::Name ROUTER_A_NAME;
+  static const ndn::Name ROUTER_B_NAME;
+  static const ndn::Name ROUTER_C_NAME;
+
+  static const std::string ROUTER_A_FACE;
+  static const std::string ROUTER_B_FACE;
+  static const std::string ROUTER_C_FACE;
+
+  static const double LINK_AB_COST;
+  static const double LINK_AC_COST;
+  static const double LINK_BC_COST;
+};
+
+const ndn::Name LinkStateCalculatorFixture::ROUTER_A_NAME = "/ndn/site/%C1.Router/this-router";
+const ndn::Name LinkStateCalculatorFixture::ROUTER_B_NAME = "/ndn/site/%C1.Router/b";
+const ndn::Name LinkStateCalculatorFixture::ROUTER_C_NAME = "/ndn/site/%C1.Router/c";
+
+const std::string LinkStateCalculatorFixture::ROUTER_A_FACE = "udp4://10.0.0.1";
+const std::string LinkStateCalculatorFixture::ROUTER_B_FACE = "udp4://10.0.0.2";
+const std::string LinkStateCalculatorFixture::ROUTER_C_FACE = "udp4://10.0.0.3";
+
+const double LinkStateCalculatorFixture::LINK_AB_COST = 5;
+const double LinkStateCalculatorFixture::LINK_AC_COST = 10;
+const double LinkStateCalculatorFixture::LINK_BC_COST = 17;
+
+BOOST_FIXTURE_TEST_SUITE(TestLinkStateRoutingCalculator, LinkStateCalculatorFixture)
+
+BOOST_AUTO_TEST_CASE(Basic)
+{
+  LinkStateRoutingTableCalculator calculator(map.getMapSize());
+  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+
+  RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+  BOOST_REQUIRE(entryB != nullptr);
+
+  // Router A should be able to get to B through B and to B through C
+  NexthopList& bHopList = entryB->getNexthopList();
+  BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
+
+  for (const NextHop& hop : bHopList) {
+    std::string faceUri = hop.getConnectingFaceUri();
+    uint64_t cost = hop.getRouteCostAsAdjustedInteger();
+
+    BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == LINK_AB_COST) ||
+                (faceUri == ROUTER_C_FACE && cost == LINK_AC_COST + LINK_BC_COST));
+
+  }
+
+  RoutingTableEntry* entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
+  BOOST_REQUIRE(entryC != nullptr);
+
+  // Router A should be able to get to C through C and to C through B
+  NexthopList& cHopList = entryC->getNexthopList();
+  BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
+
+  for (const NextHop& hop : cHopList) {
+    std::string faceUri = hop.getConnectingFaceUri();
+    uint64_t cost = hop.getRouteCostAsAdjustedInteger();
+
+    BOOST_CHECK((faceUri == ROUTER_C_FACE && cost == LINK_AC_COST) ||
+                (faceUri == ROUTER_B_FACE && cost == LINK_AB_COST + LINK_BC_COST));
+  }
+}
+
+BOOST_AUTO_TEST_CASE(Asymmetric)
+{
+  // Asymmetric link cost between B and C
+  ndn::Name key = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
+  AdjLsa* lsa = nlsr.m_lsdb.findAdjLsa(key);
+  BOOST_REQUIRE(lsa != nullptr);
+
+  auto c = lsa->m_adl.findAdjacent(ROUTER_C_NAME);
+  BOOST_REQUIRE(c != conf.getAdjacencyList().end());
+
+  double higherLinkCost = LINK_BC_COST + 1;
+  c->setLinkCost(higherLinkCost);
+
+  // Calculation should consider the link between B and C as having cost = higherLinkCost
+  LinkStateRoutingTableCalculator calculator(map.getMapSize());
+  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+
+  RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+  BOOST_REQUIRE(entryB != nullptr);
+
+  // Router A should be able to get to B through B and to B through C
+  NexthopList& bHopList = entryB->getNexthopList();
+  BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
+
+  for (const NextHop& hop : bHopList) {
+    std::string faceUri = hop.getConnectingFaceUri();
+    uint64_t cost = hop.getRouteCostAsAdjustedInteger();
+
+    BOOST_CHECK((faceUri == ROUTER_B_FACE && cost == LINK_AB_COST) ||
+                (faceUri == ROUTER_C_FACE && cost == LINK_AC_COST + higherLinkCost));
+
+  }
+
+  RoutingTableEntry* entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
+  BOOST_REQUIRE(entryC != nullptr);
+
+  // Router A should be able to get to C through C and to C through B
+  NexthopList& cHopList = entryC->getNexthopList();
+  BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
+
+  for (const NextHop& hop : cHopList) {
+    std::string faceUri = hop.getConnectingFaceUri();
+    uint64_t cost = hop.getRouteCostAsAdjustedInteger();
+
+    BOOST_CHECK((faceUri == ROUTER_C_FACE && cost == LINK_AC_COST) ||
+                (faceUri == ROUTER_B_FACE && cost == LINK_AB_COST + higherLinkCost));
+  }
+}
+
+BOOST_AUTO_TEST_CASE(NonAdjacentCost)
+{
+  // Asymmetric link cost between B and C
+  ndn::Name key = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
+  auto lsa = nlsr.m_lsdb.findAdjLsa(key);
+  BOOST_REQUIRE(lsa != nullptr);
+
+  auto c = lsa->m_adl.findAdjacent(ROUTER_C_NAME);
+  BOOST_REQUIRE(c != conf.getAdjacencyList().end());
+
+  // Break the link between B - C by setting it to a NON_ADJACENT_COST.
+  c->setLinkCost(Adjacent::NON_ADJACENT_COST);
+
+  // Calculation should consider the link between B and C as down
+  LinkStateRoutingTableCalculator calculator(map.getMapSize());
+  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+
+  // Router A should be able to get to B through B but not through C
+  RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+  BOOST_REQUIRE(entryB != nullptr);
+
+  auto bHopList = entryB->getNexthopList();
+  BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 1);
+
+  const auto nextHopForB = bHopList.getNextHops().begin();
+
+  BOOST_CHECK(nextHopForB->getConnectingFaceUri() == ROUTER_B_FACE &&
+              nextHopForB->getRouteCostAsAdjustedInteger() == LINK_AB_COST);
+
+  // Router A should be able to get to C through C but not through B
+  auto entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
+  BOOST_REQUIRE(entryC != nullptr);
+
+  NexthopList& cHopList = entryC->getNexthopList();
+  BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 1);
+
+  const auto nextHopForC = cHopList.getNextHops().begin();
+
+  BOOST_CHECK(nextHopForC->getConnectingFaceUri() == ROUTER_C_FACE &&
+              nextHopForC->getRouteCostAsAdjustedInteger() == LINK_AC_COST);
+}
+
+BOOST_AUTO_TEST_CASE(AsymmetricZeroCostLink)
+{
+  // Asymmetric and zero link cost between B - C, and B - A.
+  ndn::Name keyB = ndn::Name(ROUTER_B_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
+  auto lsaB = nlsr.m_lsdb.findAdjLsa(keyB);
+  BOOST_REQUIRE(lsaB != nullptr);
+
+  auto c = lsaB->m_adl.findAdjacent(ROUTER_C_NAME);
+  BOOST_REQUIRE(c != conf.getAdjacencyList().end());
+  // Re-adjust link cost to 0 from B-C. However, this should not set B-C cost 0 because C-B
+  // cost is greater that 0 i.e. 17
+  c->setLinkCost(0);
+
+  auto a = lsaB->m_adl.findAdjacent(ROUTER_A_NAME);
+  BOOST_REQUIRE(a != conf.getAdjacencyList().end());
+
+  ndn::Name keyA = ndn::Name(ROUTER_A_NAME).append(boost::lexical_cast<std::string>(Lsa::Type::ADJACENCY));
+  auto lsaA = nlsr.m_lsdb.findAdjLsa(keyA);
+  BOOST_REQUIRE(lsaA != nullptr);
+
+  auto b = lsaA->m_adl.findAdjacent(ROUTER_B_NAME);
+  BOOST_REQUIRE(b != conf.getAdjacencyList().end());
+
+  // Re-adjust link cost to 0 from both the direction i.e B-A and A-B
+  a->setLinkCost(0);
+  b->setLinkCost(0);
+
+  // Calculation should consider 0 link-cost between B and C
+  LinkStateRoutingTableCalculator calculator(map.getMapSize());
+  calculator.calculatePath(map, routingTable, conf, lsdb.getAdjLsdb());
+
+  // Router A should be able to get to B through B and C
+  RoutingTableEntry* entryB = routingTable.findRoutingTableEntry(ROUTER_B_NAME);
+  BOOST_REQUIRE(entryB != nullptr);
+
+  // Node can have neighbors with zero cost, so the nexthop count should be 2
+  NexthopList& bHopList = entryB->getNexthopList();
+  BOOST_REQUIRE_EQUAL(bHopList.getNextHops().size(), 2);
+
+  const auto nextHopForB = bHopList.getNextHops().begin();
+  // Check if the next hop via B is through A or not after the cost adjustment
+  BOOST_CHECK(nextHopForB->getConnectingFaceUri() == ROUTER_B_FACE &&
+              nextHopForB->getRouteCostAsAdjustedInteger() == 0);
+
+  // Router A should be able to get to C through C and B
+  auto entryC = routingTable.findRoutingTableEntry(ROUTER_C_NAME);
+  BOOST_REQUIRE(entryC != nullptr);
+
+  NexthopList& cHopList = entryC->getNexthopList();
+  BOOST_REQUIRE_EQUAL(cHopList.getNextHops().size(), 2);
+
+  const auto nextHopForC = cHopList.getNextHops().begin();
+  // Check if the nextHop from C is via A or not
+  BOOST_CHECK(nextHopForC->getConnectingFaceUri() == ROUTER_C_FACE &&
+              nextHopForC->getRouteCostAsAdjustedInteger() == LINK_AC_COST);
+
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace test
+} // namespace nlsr
diff --git a/tests/route/test-map-entry.cpp b/tests/route/test-map-entry.cpp
deleted file mode 100644
index 0429dde..0000000
--- a/tests/route/test-map-entry.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * 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).
- * See AUTHORS.md for complete list of NLSR authors and contributors.
- *
- * NLSR is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Foundation,
- * either version 3 of the License, or (at your option) any later version.
- *
- * NLSR is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE.  See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * \author Ashlesh Gawande <agawande@memphis.edu>
- **/
-
-#include "route/map.hpp"
-#include "tests/boost-test.hpp"
-
-namespace nlsr {
-namespace test {
-
-BOOST_AUTO_TEST_SUITE(TestMapEntry)
-
-BOOST_AUTO_TEST_CASE(MapEntryConstructorAndGetters)
-{
-  std::string rtr = "r0";
-
-  MapEntry me1(rtr, 1);
-
-  BOOST_CHECK_EQUAL(me1.getRouter(), "r0");
-
-  BOOST_CHECK_EQUAL(me1.getMappingNumber(), 1);
-}
-
-BOOST_AUTO_TEST_SUITE_END()
-
-} // namespace test
-} // namespace nlsr
diff --git a/tests/route/test-nexthop-list.cpp b/tests/route/test-nexthop-list.cpp
index 5bdef4d..9ab8572 100644
--- a/tests/route/test-nexthop-list.cpp
+++ b/tests/route/test-nexthop-list.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2020,  The University of Memphis,
  *                           Regents of the University of California,
  *                           Arizona Board of Regents.
  *
@@ -17,7 +17,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- **/
+ */
 
 #include "route/nexthop-list.hpp"
 #include "route/nexthop.hpp"
@@ -101,7 +101,7 @@
   NexthopList::iterator it = list.begin();
   BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), hopA.getConnectingFaceUri());
 
-  list.reset();
+  list.clear();
   list.addNextHop(hopZ);
   list.addNextHop(hopA);
 
@@ -118,7 +118,7 @@
   shortUriHop.setRouteCost(25);
   shortUriHop.setConnectingFaceUri("AAA");
 
-  list.reset();
+  list.clear();
   list.addNextHop(longUriHop);
   list.addNextHop(shortUriHop);
 
diff --git a/tests/route/test-nexthop.cpp b/tests/route/test-nexthop.cpp
index 3a6a5fd..a11c221 100644
--- a/tests/route/test-nexthop.cpp
+++ b/tests/route/test-nexthop.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2020,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -16,9 +16,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * \author Ashlesh Gawande <agawande@memphis.edu>
- **/
+ */
 
 #include "route/nexthop.hpp"
 #include "tests/boost-test.hpp"
@@ -102,6 +100,50 @@
   BOOST_CHECK(hop1.getRouteCostAsAdjustedInteger() > hop2.getRouteCostAsAdjustedInteger());
 }
 
+const uint8_t NexthopData[] =
+{
+  // Header
+  0x8f, 0x1d,
+  // Uri
+  0x8d, 0x11, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x2f, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f,
+  0x70, 0x2f, 0x74, 0x6c, 0x76,
+  // Cost
+  0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66
+};
+
+BOOST_AUTO_TEST_CASE(NexthopEncode)
+{
+  NextHop nexthops1;
+  nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
+  nexthops1.setRouteCost(1.65);
+
+  const ndn::Block& wire = nexthops1.wireEncode();
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(NexthopData,
+                                  NexthopData + sizeof(NexthopData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(NexthopDecode)
+{
+  NextHop nexthops1;
+
+  nexthops1.wireDecode(ndn::Block(NexthopData, sizeof(NexthopData)));
+
+  BOOST_REQUIRE_EQUAL(nexthops1.getConnectingFaceUri(), "/test/nexthop/tlv");
+  BOOST_REQUIRE_EQUAL(nexthops1.getRouteCost(), 1.65);
+}
+
+BOOST_AUTO_TEST_CASE(AdjacencyOutputStream)
+{
+  NextHop nexthops1;
+  nexthops1.setConnectingFaceUri("/test/nexthop/tlv");
+  nexthops1.setRouteCost(99);
+
+  std::ostringstream os;
+  os << nexthops1;
+  BOOST_CHECK_EQUAL(os.str(), "NextHop(Uri: /test/nexthop/tlv, Cost: 99)");
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace test
diff --git a/tests/route/test-routing-table-entry.cpp b/tests/route/test-routing-table-entry.cpp
index 574abc2..c17b981 100644
--- a/tests/route/test-routing-table-entry.cpp
+++ b/tests/route/test-routing-table-entry.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2019,  The University of Memphis,
+/*
+ * Copyright (c) 2014-2020,  The University of Memphis,
  *                           Regents of the University of California
  *
  * This file is part of NLSR (Named-data Link State Routing).
@@ -16,9 +16,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * \author Ashlesh Gawande <agawande@memphis.edu>
- **/
+ */
 
 #include "route/routing-table-entry.hpp"
 #include "tests/boost-test.hpp"
@@ -35,6 +33,134 @@
   BOOST_CHECK_EQUAL(rte1.getDestination(), "router1");
 }
 
+const uint8_t RoutingTableEntryWithNexthopsData[] =
+{
+  // Header
+  0x91, 0x35,
+  // Destination Name
+  0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31, 0x8f, 0x14,
+  // Nexthop
+  0x8d, 0x08, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x31, 0x86, 0x08, 0x3f, 0xfa,
+  0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x8f, 0x14, 0x8d, 0x08,
+  // Nexthop
+  0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x32, 0x86, 0x08, 0x3f, 0xfa, 0x66, 0x66,
+  0x66, 0x66, 0x66, 0x66
+};
+
+const uint8_t RoutingTableEntryWithoutNexthopsData[] =
+{
+  // Header
+  0x91, 0x09,
+  // Destination Name
+  0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31
+};
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithNexthops)
+{
+  RoutingTableEntry rte(ndn::Name("dest1"));
+
+  NextHop nexthops1;
+  nexthops1.setConnectingFaceUri("nexthop1");
+  nexthops1.setRouteCost(1.65);
+  rte.getNexthopList().addNextHop(nexthops1);
+
+  NextHop nexthops2;
+  nexthops2.setConnectingFaceUri("nexthop2");
+  nexthops2.setRouteCost(1.65);
+  rte.getNexthopList().addNextHop(nexthops2);
+
+  const ndn::Block& wire = rte.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithNexthopsData,
+                                  RoutingTableEntryWithNexthopsData +
+                                    sizeof(RoutingTableEntryWithNexthopsData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithNexthops)
+{
+  RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithNexthopsData,
+                                   sizeof(RoutingTableEntryWithNexthopsData)));
+  BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
+
+  BOOST_CHECK(rte.getNexthopList().size() != 0);
+  auto it = rte.getNexthopList().begin();
+  BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop1");
+  BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
+
+  it++;
+  BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop2");
+  BOOST_CHECK_EQUAL(it->getRouteCost(), 1.65);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryEncodeWithoutNexthops)
+{
+  RoutingTableEntry rte(ndn::Name("dest1"));
+
+  auto wire = rte.wireEncode();
+
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableEntryWithoutNexthopsData,
+                                  RoutingTableEntryWithoutNexthopsData +
+                                    sizeof(RoutingTableEntryWithoutNexthopsData),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryDecodeWithoutNexthops)
+{
+  RoutingTableEntry rte(ndn::Block(RoutingTableEntryWithoutNexthopsData,
+                                   sizeof(RoutingTableEntryWithoutNexthopsData)));
+
+  BOOST_CHECK_EQUAL(rte.getDestination(), "dest1");
+  BOOST_CHECK(rte.getNexthopList().size() == 0);
+}
+
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryClear)
+{
+  RoutingTableEntry rte(ndn::Name("dest1"));
+
+  NextHop nexthops1;
+  nexthops1.setConnectingFaceUri("nexthop1");
+  nexthops1.setRouteCost(99);
+  rte.getNexthopList().addNextHop(nexthops1);
+
+  BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 1);
+
+  auto it = rte.getNexthopList().begin();
+  BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop1");
+  BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
+
+  rte.getNexthopList().clear();
+  BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 0);
+
+  NextHop nexthops2;
+  nexthops2.setConnectingFaceUri("nexthop2");
+  nexthops2.setRouteCost(99);
+  rte.getNexthopList().addNextHop(nexthops2);
+
+  BOOST_CHECK_EQUAL(rte.getNexthopList().size(), 1);
+  it =  rte.getNexthopList().begin();
+  BOOST_CHECK_EQUAL(it->getConnectingFaceUri(), "nexthop2");
+  BOOST_CHECK_EQUAL(it->getRouteCost(), 99);
+}
+
+BOOST_AUTO_TEST_CASE(RoutingTableEntryOutputStream)
+{
+  RoutingTableEntry rte(ndn::Name("dest1"));
+
+  NextHop nexthops1;
+  nexthops1.setConnectingFaceUri("nexthop1");
+  nexthops1.setRouteCost(99);
+  rte.getNexthopList().addNextHop(nexthops1);
+
+  std::ostringstream os;
+  os << rte;
+
+  BOOST_CHECK_EQUAL(os.str(),
+                    "  Destination: /dest1\n"
+                    "    NextHop(Uri: nexthop1, Cost: 99)\n");
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
 } // namespace test
diff --git a/tests/route/test-routing-table.cpp b/tests/route/test-routing-table.cpp
index f8a7df5..0bce153 100644
--- a/tests/route/test-routing-table.cpp
+++ b/tests/route/test-routing-table.cpp
@@ -1,5 +1,5 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
+/*
  * Copyright (c) 2014-2020,  The University of Memphis,
  *                           Regents of the University of California
  *
@@ -16,9 +16,7 @@
  *
  * You should have received a copy of the GNU General Public License along with
  * NLSR, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
- *
- * \author Ashlesh Gawande <agawande@memphis.edu>
- **/
+ */
 
 #include "route/routing-table.hpp"
 #include "nlsr.hpp"
@@ -30,23 +28,106 @@
 namespace nlsr {
 namespace test {
 
-BOOST_FIXTURE_TEST_SUITE(TestRoutingTable, BaseFixture)
-
-BOOST_AUTO_TEST_CASE(RoutingTableAddNextHop)
+class RoutingTableFixture
 {
+public:
+  RoutingTableFixture()
+    : conf(face, keyChain)
+    , nlsr(face, keyChain, conf)
+    , rt(nlsr.m_routingTable)
+  {
+  }
+
+public:
   ndn::util::DummyClientFace face;
   ndn::KeyChain keyChain;
-  ConfParameter conf(face, keyChain);
-  Nlsr nlsr(face, keyChain, conf);
+  ConfParameter conf;
+  Nlsr nlsr;
 
-  RoutingTable rt1(m_scheduler, nlsr.m_fib, nlsr.m_lsdb,
-                   nlsr.m_namePrefixTable, conf);
+  RoutingTable& rt;
+};
 
+BOOST_AUTO_TEST_SUITE(TestRoutingTable)
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableAddNextHop, RoutingTableFixture)
+{
   NextHop nh1;
   const std::string DEST_ROUTER = "destRouter";
-  rt1.addNextHop(DEST_ROUTER, nh1);
+  rt.addNextHop(DEST_ROUTER, nh1);
 
-  BOOST_CHECK_EQUAL(rt1.findRoutingTableEntry(DEST_ROUTER)->getDestination(), DEST_ROUTER);
+  BOOST_CHECK_EQUAL(rt.findRoutingTableEntry(DEST_ROUTER)->getDestination(), DEST_ROUTER);
+}
+
+const uint8_t RoutingTableData1[] =
+{
+  // Header
+  0x90, 0x20,
+  // Routing table entry
+  0x91, 0x1e,
+  // Destination
+  0x07, 0x07, 0x08, 0x05, 0x64, 0x65, 0x73, 0x74, 0x31, 0x8f, 0x13,
+  // Nexthop
+  0x8d, 0x07, 0x6e, 0x65, 0x78, 0x74, 0x68, 0x6f, 0x70, 0x86, 0x08, 0x3f, 0xfa, 0x66,
+  0x66, 0x66, 0x66, 0x66, 0x66
+};
+
+const uint8_t RoutingTableData2[] =
+{
+  // Header
+  0x90, 0x00
+};
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableEncode1, RoutingTableFixture)
+{
+  NextHop nexthops;
+  nexthops.setConnectingFaceUri("nexthop");
+  nexthops.setRouteCost(1.65);
+  rt.addNextHop("dest1", nexthops);
+
+  auto wire = rt.wireEncode();
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData1,
+                                  RoutingTableData1 + sizeof(RoutingTableData1),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableEncode2, RoutingTableFixture)
+{
+  auto wire = rt.wireEncode();
+  BOOST_REQUIRE_EQUAL_COLLECTIONS(RoutingTableData2,
+                                  RoutingTableData2 + sizeof(RoutingTableData2),
+                                  wire.begin(), wire.end());
+}
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableDecode1, RoutingTableFixture)
+{
+  RoutingTableStatus rtStatus(ndn::Block(RoutingTableData1, sizeof(RoutingTableData1)));
+
+  auto it1 = rtStatus.m_rTable.begin();
+
+  ndn::Name des1 = it1->getDestination();
+  BOOST_CHECK_EQUAL(des1, "dest1");
+
+  auto it2 = it1->getNexthopList().begin();
+  BOOST_CHECK_EQUAL(it2->getConnectingFaceUri(), "nexthop");
+  BOOST_CHECK_EQUAL(it2->getRouteCost(), 1.65);
+
+  BOOST_CHECK_EQUAL(rtStatus.m_rTable.size(), 1);
+}
+
+BOOST_FIXTURE_TEST_CASE(RoutingTableOutputStream, RoutingTableFixture)
+{
+  NextHop nexthops;
+  nexthops.setConnectingFaceUri("nexthop");
+  nexthops.setRouteCost(99);
+  rt.addNextHop("dest1", nexthops);
+
+  std::ostringstream os;
+  os << rt;
+
+  BOOST_CHECK_EQUAL(os.str(),
+                    "Routing Table:\n"
+                    "  Destination: /dest1\n"
+                    "    NextHop(Uri: nexthop, Cost: 99)\n");
 }
 
 BOOST_AUTO_TEST_SUITE_END()