src: Reorganizing source code in preparation to merge NRD code
Note that as of this commit, there are several changes in location of
compiled binaries in `build/` folder:
* `nfd` has been moved to `build/bin/nfd`
* `unit-tests` has been split into `unit-tests-core` and `unit-tests-daemon`
Change-Id: I2c830c117879edbaa5457d6423c13f0273285919
Refs: #1486
diff --git a/tests/daemon/fw/broadcast-strategy.cpp b/tests/daemon/fw/broadcast-strategy.cpp
new file mode 100644
index 0000000..cde9b44
--- /dev/null
+++ b/tests/daemon/fw/broadcast-strategy.cpp
@@ -0,0 +1,129 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "fw/broadcast-strategy.hpp"
+#include "strategy-tester.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(FwBroadcastStrategy, BaseFixture)
+
+BOOST_AUTO_TEST_CASE(Forward2)
+{
+ Forwarder forwarder;
+ typedef StrategyTester<fw::BroadcastStrategy> BroadcastStrategyTester;
+ BroadcastStrategyTester strategy(forwarder);
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+ fibEntry->addNextHop(face1, 0);
+ fibEntry->addNextHop(face2, 0);
+ fibEntry->addNextHop(face3, 0);
+
+ shared_ptr<Interest> interest = makeInterest("ndn:/H0D6i5fc");
+ Pit& pit = forwarder.getPit();
+ shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
+ pitEntry->insertOrUpdateInRecord(face3, *interest);
+
+ strategy.afterReceiveInterest(*face3, *interest, fibEntry, pitEntry);
+ BOOST_CHECK_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 0);
+ BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.size(), 2);
+ bool hasFace1 = false;
+ bool hasFace2 = false;
+ for (std::vector<BroadcastStrategyTester::SendInterestArgs>::iterator it =
+ strategy.m_sendInterestHistory.begin();
+ it != strategy.m_sendInterestHistory.end(); ++it) {
+ if (it->get<1>() == face1) {
+ hasFace1 = true;
+ }
+ if (it->get<1>() == face2) {
+ hasFace2 = true;
+ }
+ }
+ BOOST_CHECK(hasFace1 && hasFace2);
+}
+
+BOOST_AUTO_TEST_CASE(RejectScope)
+{
+ Forwarder forwarder;
+ typedef StrategyTester<fw::BroadcastStrategy> BroadcastStrategyTester;
+ BroadcastStrategyTester strategy(forwarder);
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert("ndn:/localhop/uS09bub6tm").first;
+ fibEntry->addNextHop(face2, 0);
+
+ shared_ptr<Interest> interest = makeInterest("ndn:/localhop/uS09bub6tm/eG3MMoP6z");
+ Pit& pit = forwarder.getPit();
+ shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
+ pitEntry->insertOrUpdateInRecord(face1, *interest);
+
+ strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
+ BOOST_CHECK_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.size(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(RejectLoopback)
+{
+ Forwarder forwarder;
+ typedef StrategyTester<fw::BroadcastStrategy> BroadcastStrategyTester;
+ BroadcastStrategyTester strategy(forwarder);
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+ fibEntry->addNextHop(face1, 0);
+
+ shared_ptr<Interest> interest = makeInterest("ndn:/H0D6i5fc");
+ Pit& pit = forwarder.getPit();
+ shared_ptr<pit::Entry> pitEntry = pit.insert(*interest).first;
+ pitEntry->insertOrUpdateInRecord(face1, *interest);
+
+ strategy.afterReceiveInterest(*face1, *interest, fibEntry, pitEntry);
+ BOOST_CHECK_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory.size(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/fw/client-control-strategy.cpp b/tests/daemon/fw/client-control-strategy.cpp
new file mode 100644
index 0000000..c76fb52
--- /dev/null
+++ b/tests/daemon/fw/client-control-strategy.cpp
@@ -0,0 +1,96 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "fw/client-control-strategy.hpp"
+#include "strategy-tester.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(FwClientControlStrategy, BaseFixture)
+
+BOOST_AUTO_TEST_CASE(Forward3)
+{
+ Forwarder forwarder;
+ typedef StrategyTester<fw::ClientControlStrategy> ClientControlStrategyTester;
+ ClientControlStrategyTester strategy(forwarder);
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
+ shared_ptr<DummyLocalFace> face4 = make_shared<DummyLocalFace>();
+ face4->setLocalControlHeaderFeature(LOCAL_CONTROL_FEATURE_NEXT_HOP_FACE_ID);
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
+ forwarder.addFace(face4);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+ fibEntry->addNextHop(face2, 0);
+
+ Pit& pit = forwarder.getPit();
+
+ // Interest with valid NextHopFaceId
+ shared_ptr<Interest> interest1 = makeInterest("ndn:/0z8r6yDDe");
+ interest1->setNextHopFaceId(face1->getId());
+ shared_ptr<pit::Entry> pitEntry1 = pit.insert(*interest1).first;
+ pitEntry1->insertOrUpdateInRecord(face4, *interest1);
+
+ strategy.m_sendInterestHistory.clear();
+ strategy.afterReceiveInterest(*face4, *interest1, fibEntry, pitEntry1);
+ BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[0].get<1>(), face1);
+
+ // Interest without NextHopFaceId
+ shared_ptr<Interest> interest2 = makeInterest("ndn:/y6JQADGVz");
+ shared_ptr<pit::Entry> pitEntry2 = pit.insert(*interest2).first;
+ pitEntry2->insertOrUpdateInRecord(face4, *interest2);
+
+ strategy.m_sendInterestHistory.clear();
+ strategy.afterReceiveInterest(*face4, *interest2, fibEntry, pitEntry2);
+ BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(strategy.m_sendInterestHistory[0].get<1>(), face2);
+
+ // Interest with invalid NextHopFaceId
+ shared_ptr<Interest> interest3 = makeInterest("ndn:/0z8r6yDDe");
+ interest3->setNextHopFaceId(face3->getId());
+ shared_ptr<pit::Entry> pitEntry3 = pit.insert(*interest3).first;
+ pitEntry3->insertOrUpdateInRecord(face4, *interest3);
+
+ face3->close(); // face3 is closed and its FaceId becomes invalid
+ strategy.m_sendInterestHistory.clear();
+ strategy.m_rejectPendingInterestHistory.clear();
+ strategy.afterReceiveInterest(*face4, *interest3, fibEntry, pitEntry3);
+ BOOST_REQUIRE_EQUAL(strategy.m_sendInterestHistory.size(), 0);
+ BOOST_REQUIRE_EQUAL(strategy.m_rejectPendingInterestHistory.size(), 1);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/fw/dummy-strategy.hpp b/tests/daemon/fw/dummy-strategy.hpp
new file mode 100644
index 0000000..67784fc
--- /dev/null
+++ b/tests/daemon/fw/dummy-strategy.hpp
@@ -0,0 +1,86 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#ifndef NFD_TESTS_NFD_FW_DUMMY_STRATEGY_HPP
+#define NFD_TESTS_NFD_FW_DUMMY_STRATEGY_HPP
+
+#include "fw/strategy.hpp"
+
+namespace nfd {
+namespace tests {
+
+/** \brief strategy for unit testing
+ *
+ * Triggers on DummyStrategy are recorded but does nothing
+ */
+class DummyStrategy : public fw::Strategy
+{
+public:
+ DummyStrategy(Forwarder& forwarder, const Name& name)
+ : Strategy(forwarder, name)
+ {
+ }
+
+ virtual void
+ afterReceiveInterest(const Face& inFace,
+ const Interest& interest,
+ shared_ptr<fib::Entry> fibEntry,
+ shared_ptr<pit::Entry> pitEntry)
+ {
+ ++m_afterReceiveInterest_count;
+
+ if (static_cast<bool>(m_interestOutFace)) {
+ this->sendInterest(pitEntry, m_interestOutFace);
+ }
+ else {
+ this->rejectPendingInterest(pitEntry);
+ }
+ }
+
+ virtual void
+ beforeSatisfyPendingInterest(shared_ptr<pit::Entry> pitEntry,
+ const Face& inFace, const Data& data)
+ {
+ ++m_beforeSatisfyPendingInterest_count;
+ }
+
+ virtual void
+ beforeExpirePendingInterest(shared_ptr<pit::Entry> pitEntry)
+ {
+ ++m_beforeExpirePendingInterest_count;
+ }
+
+public:
+ int m_afterReceiveInterest_count;
+ int m_beforeSatisfyPendingInterest_count;
+ int m_beforeExpirePendingInterest_count;
+
+ /// outFace to use in afterReceiveInterest, nullptr to reject
+ shared_ptr<Face> m_interestOutFace;
+};
+
+} // namespace tests
+} // namespace nfd
+
+#endif // NFD_TESTS_NFD_FW_DUMMY_STRATEGY_HPP
diff --git a/tests/daemon/fw/face-table.cpp b/tests/daemon/fw/face-table.cpp
new file mode 100644
index 0000000..daf9256
--- /dev/null
+++ b/tests/daemon/fw/face-table.cpp
@@ -0,0 +1,139 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "fw/face-table.hpp"
+#include "fw/forwarder.hpp"
+
+#include "tests/test-common.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(FwFaceTable, BaseFixture)
+
+static inline void
+saveFaceId(std::vector<FaceId>& faceIds, shared_ptr<Face> face)
+{
+ faceIds.push_back(face->getId());
+}
+
+BOOST_AUTO_TEST_CASE(AddRemove)
+{
+ Forwarder forwarder;
+
+ FaceTable& faceTable = forwarder.getFaceTable();
+ std::vector<FaceId> onAddHistory;
+ std::vector<FaceId> onRemoveHistory;
+ faceTable.onAdd += bind(&saveFaceId, boost::ref(onAddHistory ), _1);
+ faceTable.onRemove += bind(&saveFaceId, boost::ref(onRemoveHistory), _1);
+
+ shared_ptr<Face> face1 = make_shared<DummyFace>();
+ shared_ptr<Face> face2 = make_shared<DummyFace>();
+
+ BOOST_CHECK_EQUAL(face1->getId(), INVALID_FACEID);
+ BOOST_CHECK_EQUAL(face2->getId(), INVALID_FACEID);
+
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ BOOST_CHECK_NE(face1->getId(), INVALID_FACEID);
+ BOOST_CHECK_NE(face2->getId(), INVALID_FACEID);
+ BOOST_CHECK_NE(face1->getId(), face2->getId());
+
+ FaceId oldId1 = face1->getId();
+ faceTable.add(face1);
+ BOOST_CHECK_EQUAL(face1->getId(), oldId1);
+ BOOST_CHECK_EQUAL(faceTable.size(), 2);
+
+ BOOST_REQUIRE_EQUAL(onAddHistory.size(), 2);
+ BOOST_CHECK_EQUAL(onAddHistory[0], face1->getId());
+ BOOST_CHECK_EQUAL(onAddHistory[1], face2->getId());
+
+ face1->close();
+
+ BOOST_CHECK_EQUAL(face1->getId(), INVALID_FACEID);
+
+ BOOST_REQUIRE_EQUAL(onRemoveHistory.size(), 1);
+ BOOST_CHECK_EQUAL(onRemoveHistory[0], onAddHistory[0]);
+}
+
+BOOST_AUTO_TEST_CASE(Enumerate)
+{
+ Forwarder forwarder;
+ FaceTable& faceTable = forwarder.getFaceTable();
+
+ shared_ptr<Face> face1 = make_shared<DummyFace>();
+ shared_ptr<Face> face2 = make_shared<DummyFace>();
+ bool hasFace1 = false, hasFace2 = false;
+
+ BOOST_CHECK_EQUAL(faceTable.size(), 0);
+ BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
+
+ faceTable.add(face1);
+ BOOST_CHECK_EQUAL(faceTable.size(), 1);
+ BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
+ hasFace1 = hasFace2 = false;
+ for (FaceTable::const_iterator it = faceTable.begin(); it != faceTable.end(); ++it) {
+ if (*it == face1) {
+ hasFace1 = true;
+ }
+ }
+ BOOST_CHECK(hasFace1);
+
+ faceTable.add(face2);
+ BOOST_CHECK_EQUAL(faceTable.size(), 2);
+ BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
+ hasFace1 = hasFace2 = false;
+ for (FaceTable::const_iterator it = faceTable.begin(); it != faceTable.end(); ++it) {
+ if (*it == face1) {
+ hasFace1 = true;
+ }
+ if (*it == face2) {
+ hasFace2 = true;
+ }
+ }
+ BOOST_CHECK(hasFace1);
+ BOOST_CHECK(hasFace2);
+
+ face1->close();
+ BOOST_CHECK_EQUAL(faceTable.size(), 1);
+ BOOST_CHECK_EQUAL(std::distance(faceTable.begin(), faceTable.end()), faceTable.size());
+ hasFace1 = hasFace2 = false;
+ for (FaceTable::const_iterator it = faceTable.begin(); it != faceTable.end(); ++it) {
+ if (*it == face1) {
+ hasFace1 = true;
+ }
+ if (*it == face2) {
+ hasFace2 = true;
+ }
+ }
+ BOOST_CHECK(!hasFace1);
+ BOOST_CHECK(hasFace2);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/fw/forwarder.cpp b/tests/daemon/fw/forwarder.cpp
new file mode 100644
index 0000000..0151460
--- /dev/null
+++ b/tests/daemon/fw/forwarder.cpp
@@ -0,0 +1,352 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "fw/forwarder.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+#include "dummy-strategy.hpp"
+
+#include "tests/test-common.hpp"
+#include "tests/limited-io.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(FwForwarder, BaseFixture)
+
+BOOST_AUTO_TEST_CASE(SimpleExchange)
+{
+ Forwarder forwarder;
+
+ Name nameA ("ndn:/A");
+ Name nameAB ("ndn:/A/B");
+ Name nameABC("ndn:/A/B/C");
+ shared_ptr<Interest> interestAB = makeInterest(nameAB);
+ interestAB->setInterestLifetime(time::seconds(4));
+ shared_ptr<Data> dataABC = makeData(nameABC);
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ face1->afterSend += bind(&boost::asio::io_service::stop, &g_io);
+ face2->afterSend += bind(&boost::asio::io_service::stop, &g_io);
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert(Name("ndn:/A")).first;
+ fibEntry->addNextHop(face2, 0);
+
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNInInterests (), 0);
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutInterests(), 0);
+ face1->receiveInterest(*interestAB);
+ g_io.run();
+ g_io.reset();
+ BOOST_REQUIRE_EQUAL(face2->m_sentInterests.size(), 1);
+ BOOST_CHECK(face2->m_sentInterests[0].getName().equals(nameAB));
+ BOOST_CHECK_EQUAL(face2->m_sentInterests[0].getIncomingFaceId(), face1->getId());
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNInInterests (), 1);
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutInterests(), 1);
+
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNInDatas (), 0);
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutDatas(), 0);
+ face2->receiveData(*dataABC);
+ g_io.run();
+ g_io.reset();
+ BOOST_REQUIRE_EQUAL(face1->m_sentDatas.size(), 1);
+ BOOST_CHECK(face1->m_sentDatas[0].getName().equals(nameABC));
+ BOOST_CHECK_EQUAL(face1->m_sentDatas[0].getIncomingFaceId(), face2->getId());
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNInDatas (), 1);
+ BOOST_CHECK_EQUAL(forwarder.getCounters().getNOutDatas(), 1);
+}
+
+class ScopeLocalhostIncomingTestForwarder : public Forwarder
+{
+public:
+ ScopeLocalhostIncomingTestForwarder()
+ {
+ }
+
+ virtual void
+ onDataUnsolicited(Face& inFace, const Data& data)
+ {
+ ++m_onDataUnsolicited_count;
+ }
+
+protected:
+ virtual void
+ dispatchToStrategy(shared_ptr<pit::Entry> pitEntry, function<void(fw::Strategy*)> f)
+ {
+ ++m_dispatchToStrategy_count;
+ }
+
+public:
+ int m_dispatchToStrategy_count;
+ int m_onDataUnsolicited_count;
+};
+
+BOOST_AUTO_TEST_CASE(ScopeLocalhostIncoming)
+{
+ ScopeLocalhostIncomingTestForwarder forwarder;
+ shared_ptr<Face> face1 = make_shared<DummyLocalFace>();
+ shared_ptr<Face> face2 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ // local face, /localhost: OK
+ forwarder.m_dispatchToStrategy_count = 0;
+ shared_ptr<Interest> i1 = makeInterest("/localhost/A1");
+ forwarder.onIncomingInterest(*face1, *i1);
+ BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 1);
+
+ // non-local face, /localhost: violate
+ forwarder.m_dispatchToStrategy_count = 0;
+ shared_ptr<Interest> i2 = makeInterest("/localhost/A2");
+ forwarder.onIncomingInterest(*face2, *i2);
+ BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 0);
+
+ // local face, non-/localhost: OK
+ forwarder.m_dispatchToStrategy_count = 0;
+ shared_ptr<Interest> i3 = makeInterest("/A3");
+ forwarder.onIncomingInterest(*face1, *i3);
+ BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 1);
+
+ // non-local face, non-/localhost: OK
+ forwarder.m_dispatchToStrategy_count = 0;
+ shared_ptr<Interest> i4 = makeInterest("/A4");
+ forwarder.onIncomingInterest(*face2, *i4);
+ BOOST_CHECK_EQUAL(forwarder.m_dispatchToStrategy_count, 1);
+
+ // local face, /localhost: OK
+ forwarder.m_onDataUnsolicited_count = 0;
+ shared_ptr<Data> d1 = makeData("/localhost/B1");
+ forwarder.onIncomingData(*face1, *d1);
+ BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 1);
+
+ // non-local face, /localhost: OK
+ forwarder.m_onDataUnsolicited_count = 0;
+ shared_ptr<Data> d2 = makeData("/localhost/B2");
+ forwarder.onIncomingData(*face2, *d2);
+ BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 0);
+
+ // local face, non-/localhost: OK
+ forwarder.m_onDataUnsolicited_count = 0;
+ shared_ptr<Data> d3 = makeData("/B3");
+ forwarder.onIncomingData(*face1, *d3);
+ BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 1);
+
+ // non-local face, non-/localhost: OK
+ forwarder.m_onDataUnsolicited_count = 0;
+ shared_ptr<Data> d4 = makeData("/B4");
+ forwarder.onIncomingData(*face2, *d4);
+ BOOST_CHECK_EQUAL(forwarder.m_onDataUnsolicited_count, 1);
+}
+
+BOOST_AUTO_TEST_CASE(ScopeLocalhostOutgoing)
+{
+ Forwarder forwarder;
+ shared_ptr<DummyLocalFace> face1 = make_shared<DummyLocalFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ shared_ptr<Face> face3 = make_shared<DummyLocalFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
+ Pit& pit = forwarder.getPit();
+
+ // local face, /localhost: OK
+ shared_ptr<Interest> interestA1 = makeInterest("/localhost/A1");
+ shared_ptr<pit::Entry> pitA1 = pit.insert(*interestA1).first;
+ pitA1->insertOrUpdateInRecord(face3, *interestA1);
+ face1->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pitA1, *face1);
+ BOOST_CHECK_EQUAL(face1->m_sentInterests.size(), 1);
+
+ // non-local face, /localhost: violate
+ shared_ptr<Interest> interestA2 = makeInterest("/localhost/A2");
+ shared_ptr<pit::Entry> pitA2 = pit.insert(*interestA2).first;
+ pitA2->insertOrUpdateInRecord(face3, *interestA2);
+ face2->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pitA2, *face2);
+ BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 0);
+
+ // local face, non-/localhost: OK
+ shared_ptr<Interest> interestA3 = makeInterest("/A3");
+ shared_ptr<pit::Entry> pitA3 = pit.insert(*interestA3).first;
+ pitA3->insertOrUpdateInRecord(face3, *interestA3);
+ face1->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pitA3, *face1);
+ BOOST_CHECK_EQUAL(face1->m_sentInterests.size(), 1);
+
+ // non-local face, non-/localhost: OK
+ shared_ptr<Interest> interestA4 = makeInterest("/A4");
+ shared_ptr<pit::Entry> pitA4 = pit.insert(*interestA4).first;
+ pitA4->insertOrUpdateInRecord(face3, *interestA4);
+ face2->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pitA4, *face2);
+ BOOST_CHECK_EQUAL(face2->m_sentInterests.size(), 1);
+
+ // local face, /localhost: OK
+ face1->m_sentDatas.clear();
+ forwarder.onOutgoingData(Data("/localhost/B1"), *face1);
+ BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1);
+
+ // non-local face, /localhost: OK
+ face2->m_sentDatas.clear();
+ forwarder.onOutgoingData(Data("/localhost/B2"), *face2);
+ BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 0);
+
+ // local face, non-/localhost: OK
+ face1->m_sentDatas.clear();
+ forwarder.onOutgoingData(Data("/B3"), *face1);
+ BOOST_CHECK_EQUAL(face1->m_sentDatas.size(), 1);
+
+ // non-local face, non-/localhost: OK
+ face2->m_sentDatas.clear();
+ forwarder.onOutgoingData(Data("/B4"), *face2);
+ BOOST_CHECK_EQUAL(face2->m_sentDatas.size(), 1);
+}
+
+BOOST_AUTO_TEST_CASE(ScopeLocalhopOutgoing)
+{
+ Forwarder forwarder;
+ shared_ptr<DummyLocalFace> face1 = make_shared<DummyLocalFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ shared_ptr<DummyLocalFace> face3 = make_shared<DummyLocalFace>();
+ shared_ptr<DummyFace> face4 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
+ forwarder.addFace(face4);
+ Pit& pit = forwarder.getPit();
+
+ // from local face, to local face: OK
+ shared_ptr<Interest> interest1 = makeInterest("/localhop/1");
+ shared_ptr<pit::Entry> pit1 = pit.insert(*interest1).first;
+ pit1->insertOrUpdateInRecord(face1, *interest1);
+ face3->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pit1, *face3);
+ BOOST_CHECK_EQUAL(face3->m_sentInterests.size(), 1);
+
+ // from non-local face, to local face: OK
+ shared_ptr<Interest> interest2 = makeInterest("/localhop/2");
+ shared_ptr<pit::Entry> pit2 = pit.insert(*interest2).first;
+ pit2->insertOrUpdateInRecord(face2, *interest2);
+ face3->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pit2, *face3);
+ BOOST_CHECK_EQUAL(face3->m_sentInterests.size(), 1);
+
+ // from local face, to non-local face: OK
+ shared_ptr<Interest> interest3 = makeInterest("/localhop/3");
+ shared_ptr<pit::Entry> pit3 = pit.insert(*interest3).first;
+ pit3->insertOrUpdateInRecord(face1, *interest3);
+ face4->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pit3, *face4);
+ BOOST_CHECK_EQUAL(face4->m_sentInterests.size(), 1);
+
+ // from non-local face, to non-local face: violate
+ shared_ptr<Interest> interest4 = makeInterest("/localhop/4");
+ shared_ptr<pit::Entry> pit4 = pit.insert(*interest4).first;
+ pit4->insertOrUpdateInRecord(face2, *interest4);
+ face4->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pit4, *face4);
+ BOOST_CHECK_EQUAL(face4->m_sentInterests.size(), 0);
+
+ // from local face and non-local face, to local face: OK
+ shared_ptr<Interest> interest5 = makeInterest("/localhop/5");
+ shared_ptr<pit::Entry> pit5 = pit.insert(*interest5).first;
+ pit5->insertOrUpdateInRecord(face1, *interest5);
+ pit5->insertOrUpdateInRecord(face2, *interest5);
+ face3->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pit5, *face3);
+ BOOST_CHECK_EQUAL(face3->m_sentInterests.size(), 1);
+
+ // from local face and non-local face, to non-local face: OK
+ shared_ptr<Interest> interest6 = makeInterest("/localhop/6");
+ shared_ptr<pit::Entry> pit6 = pit.insert(*interest6).first;
+ pit6->insertOrUpdateInRecord(face1, *interest6);
+ pit6->insertOrUpdateInRecord(face2, *interest6);
+ face4->m_sentInterests.clear();
+ forwarder.onOutgoingInterest(pit6, *face4);
+ BOOST_CHECK_EQUAL(face4->m_sentInterests.size(), 1);
+}
+
+BOOST_AUTO_TEST_CASE(StrategyDispatch)
+{
+ LimitedIo limitedIo;
+ Forwarder forwarder;
+ shared_ptr<Face> face1 = make_shared<DummyFace>();
+ shared_ptr<Face> face2 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+
+ StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
+ shared_ptr<DummyStrategy> strategyP = make_shared<DummyStrategy>(
+ boost::ref(forwarder), "ndn:/strategyP");
+ shared_ptr<DummyStrategy> strategyQ = make_shared<DummyStrategy>(
+ boost::ref(forwarder), "ndn:/strategyQ");
+ strategyChoice.install(strategyP);
+ strategyChoice.install(strategyQ);
+ strategyChoice.insert("ndn:/" , strategyP->getName());
+ strategyChoice.insert("ndn:/B", strategyQ->getName());
+
+ shared_ptr<Interest> interest1 = makeInterest("ndn:/A/1");
+ strategyP->m_afterReceiveInterest_count = 0;
+ strategyP->m_interestOutFace = face2;
+ forwarder.onInterest(*face1, *interest1);
+ BOOST_CHECK_EQUAL(strategyP->m_afterReceiveInterest_count, 1);
+
+ shared_ptr<Interest> interest2 = makeInterest("ndn:/B/2");
+ strategyQ->m_afterReceiveInterest_count = 0;
+ strategyQ->m_interestOutFace = face2;
+ forwarder.onInterest(*face1, *interest2);
+ BOOST_CHECK_EQUAL(strategyQ->m_afterReceiveInterest_count, 1);
+
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(5));
+
+ shared_ptr<Data> data1 = makeData("ndn:/A/1/a");
+ strategyP->m_beforeSatisfyPendingInterest_count = 0;
+ forwarder.onData(*face2, *data1);
+ BOOST_CHECK_EQUAL(strategyP->m_beforeSatisfyPendingInterest_count, 1);
+
+ shared_ptr<Data> data2 = makeData("ndn:/B/2/b");
+ strategyQ->m_beforeSatisfyPendingInterest_count = 0;
+ forwarder.onData(*face2, *data2);
+ BOOST_CHECK_EQUAL(strategyQ->m_beforeSatisfyPendingInterest_count, 1);
+
+ shared_ptr<Interest> interest3 = makeInterest("ndn:/A/3");
+ interest3->setInterestLifetime(time::milliseconds(30));
+ forwarder.onInterest(*face1, *interest3);
+ shared_ptr<Interest> interest4 = makeInterest("ndn:/B/4");
+ interest4->setInterestLifetime(time::milliseconds(5000));
+ forwarder.onInterest(*face1, *interest4);
+
+ strategyP->m_beforeExpirePendingInterest_count = 0;
+ strategyQ->m_beforeExpirePendingInterest_count = 0;
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(100));
+ BOOST_CHECK_EQUAL(strategyP->m_beforeExpirePendingInterest_count, 1);
+ BOOST_CHECK_EQUAL(strategyQ->m_beforeExpirePendingInterest_count, 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/fw/ncc-strategy.cpp b/tests/daemon/fw/ncc-strategy.cpp
new file mode 100644
index 0000000..29db3b3
--- /dev/null
+++ b/tests/daemon/fw/ncc-strategy.cpp
@@ -0,0 +1,110 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "fw/ncc-strategy.hpp"
+#include "strategy-tester.hpp"
+#include "tests/daemon/face/dummy-face.hpp"
+#include "tests/limited-io.hpp"
+
+#include "tests/test-common.hpp"
+
+namespace nfd {
+namespace tests {
+
+BOOST_FIXTURE_TEST_SUITE(FwNccStrategy, BaseFixture)
+
+// NccStrategy is fairly complex.
+// The most important property is:
+// it remembers which upstream is the fastest to return Data,
+// and favors this upstream in subsequent Interests.
+BOOST_AUTO_TEST_CASE(FavorRespondingUpstream)
+{
+ LimitedIo limitedIo;
+ Forwarder forwarder;
+ typedef StrategyTester<fw::NccStrategy> NccStrategyTester;
+ shared_ptr<NccStrategyTester> strategy = make_shared<NccStrategyTester>(boost::ref(forwarder));
+ strategy->onAction += bind(&LimitedIo::afterOp, &limitedIo);
+
+ shared_ptr<DummyFace> face1 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face2 = make_shared<DummyFace>();
+ shared_ptr<DummyFace> face3 = make_shared<DummyFace>();
+ forwarder.addFace(face1);
+ forwarder.addFace(face2);
+ forwarder.addFace(face3);
+
+ Fib& fib = forwarder.getFib();
+ shared_ptr<fib::Entry> fibEntry = fib.insert(Name()).first;
+ fibEntry->addNextHop(face1, 10);
+ fibEntry->addNextHop(face2, 20);
+
+ StrategyChoice& strategyChoice = forwarder.getStrategyChoice();
+ strategyChoice.install(strategy);
+ strategyChoice.insert(Name(), strategy->getName());
+
+ Pit& pit = forwarder.getPit();
+
+ // first Interest: strategy knows nothing and follows routing
+ shared_ptr<Interest> interest1p = makeInterest("ndn:/0Jm1ajrW/%00");
+ Interest& interest1 = *interest1p;
+ interest1.setInterestLifetime(time::milliseconds(8000));
+ shared_ptr<pit::Entry> pitEntry1 = pit.insert(interest1).first;
+
+ pitEntry1->insertOrUpdateInRecord(face3, interest1);
+ strategy->afterReceiveInterest(*face3, interest1, fibEntry, pitEntry1);
+
+ // forwards to face1 because routing says it's best
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(1));
+ BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 1);
+ BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[0].get<1>(), face1);
+
+ // forwards to face2 because face1 doesn't respond
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(500));
+ BOOST_REQUIRE_EQUAL(strategy->m_sendInterestHistory.size(), 2);
+ BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[1].get<1>(), face2);
+
+ // face2 responds
+ shared_ptr<Data> data1p = makeData("ndn:/0Jm1ajrW/%00");
+ Data& data1 = *data1p;
+ strategy->beforeSatisfyPendingInterest(pitEntry1, *face2, data1);
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(500));
+
+ // second Interest: strategy knows face2 is best
+ shared_ptr<Interest> interest2p = makeInterest("ndn:/0Jm1ajrW/%00%01");
+ Interest& interest2 = *interest2p;
+ interest2.setInterestLifetime(time::milliseconds(8000));
+ shared_ptr<pit::Entry> pitEntry2 = pit.insert(interest2).first;
+
+ pitEntry2->insertOrUpdateInRecord(face3, interest2);
+ strategy->afterReceiveInterest(*face3, interest2, fibEntry, pitEntry2);
+
+ // forwards to face2 because it responds previously
+ limitedIo.run(LimitedIo::UNLIMITED_OPS, time::milliseconds(1));
+ BOOST_REQUIRE_GE(strategy->m_sendInterestHistory.size(), 3);
+ BOOST_CHECK_EQUAL(strategy->m_sendInterestHistory[2].get<1>(), face2);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace tests
+} // namespace nfd
diff --git a/tests/daemon/fw/strategy-tester.hpp b/tests/daemon/fw/strategy-tester.hpp
new file mode 100644
index 0000000..e3debef
--- /dev/null
+++ b/tests/daemon/fw/strategy-tester.hpp
@@ -0,0 +1,89 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2014 Regents of the University of California,
+ * Arizona Board of Regents,
+ * Colorado State University,
+ * University Pierre & Marie Curie, Sorbonne University,
+ * Washington University in St. Louis,
+ * Beijing Institute of Technology
+ *
+ * This file is part of NFD (Named Data Networking Forwarding Daemon).
+ * See AUTHORS.md for complete list of NFD authors and contributors.
+ *
+ * NFD 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.
+ *
+ * NFD 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
+ * NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#ifndef NFD_TESTS_NFD_FW_STRATEGY_TESTER_HPP
+#define NFD_TESTS_NFD_FW_STRATEGY_TESTER_HPP
+
+#include <boost/tuple/tuple_comparison.hpp>
+#include "fw/strategy.hpp"
+
+namespace nfd {
+namespace tests {
+
+/** \class StrategyTester
+ * \brief extends strategy S for unit testing
+ *
+ * Actions invoked by S are recorded but not passed to forwarder
+ */
+template<typename S>
+class StrategyTester : public S
+{
+public:
+ explicit
+ StrategyTester(Forwarder& forwarder)
+ : S(forwarder, Name(S::STRATEGY_NAME).append("tester"))
+ {
+ }
+
+ /// fires after each Action
+ EventEmitter<> onAction;
+
+protected:
+ virtual void
+ sendInterest(shared_ptr<pit::Entry> pitEntry,shared_ptr<Face> outFace);
+
+ virtual void
+ rejectPendingInterest(shared_ptr<pit::Entry> pitEntry);
+
+public:
+ typedef boost::tuple<shared_ptr<pit::Entry>, shared_ptr<Face> > SendInterestArgs;
+ std::vector<SendInterestArgs> m_sendInterestHistory;
+
+ typedef boost::tuple<shared_ptr<pit::Entry> > RejectPendingInterestArgs;
+ std::vector<RejectPendingInterestArgs> m_rejectPendingInterestHistory;
+};
+
+
+template<typename S>
+inline void
+StrategyTester<S>::sendInterest(shared_ptr<pit::Entry> pitEntry,
+ shared_ptr<Face> outFace)
+{
+ m_sendInterestHistory.push_back(SendInterestArgs(pitEntry, outFace));
+ pitEntry->insertOrUpdateOutRecord(outFace, pitEntry->getInterest());
+ onAction();
+}
+
+template<typename S>
+inline void
+StrategyTester<S>::rejectPendingInterest(shared_ptr<pit::Entry> pitEntry)
+{
+ m_rejectPendingInterestHistory.push_back(RejectPendingInterestArgs(pitEntry));
+ onAction();
+}
+
+} // namespace tests
+} // namespace nfd
+
+#endif // NFD_TESTS_NFD_FW_STRATEGY_TESTER_HPP