model+NFD/rib: Enable full-featured RIB manager
Change-Id: I033b29ed3cbcc1a98b7eae759792c832668253ee
Refs: #2370
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index a9dbfe7..b0f138c 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -149,12 +149,8 @@
}
Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol>();
-
ndn->getConfig().put("tables.cs_max_packets", (m_maxCsSize == 0) ? 1 : m_maxCsSize);
- // NFD initialization
- ndn->initialize();
-
// Create and aggregate content store if NFD's contest store has been disabled
if (m_maxCsSize == 0) {
ndn->AggregateObject(m_contentStoreFactory.Create<ContentStore>());
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index 3cbda38..f8c037a 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -43,6 +43,7 @@
#include "ns3/ndnSIM/NFD/daemon/mgmt/face-manager.hpp"
#include "ns3/ndnSIM/NFD/daemon/mgmt/strategy-choice-manager.hpp"
#include "ns3/ndnSIM/NFD/daemon/mgmt/status-server.hpp"
+#include "ns3/ndnSIM/NFD/rib/rib-manager.hpp"
#include "ns3/ndnSIM/NFD/daemon/face/null-face.hpp"
#include "ns3/ndnSIM/NFD/core/config-file.hpp"
@@ -160,6 +161,8 @@
shared_ptr<nfd::FaceManager> m_faceManager;
shared_ptr<nfd::StrategyChoiceManager> m_strategyChoiceManager;
shared_ptr<nfd::StatusServer> m_statusServer;
+ shared_ptr<nfd::rib::RibManager> m_ribManager;
+ shared_ptr< ::ndn::Face> m_face;
nfd::ConfigSection m_config;
@@ -183,6 +186,7 @@
m_impl->m_forwarder = make_shared<nfd::Forwarder>();
initializeManagement();
+ Simulator::ScheduleWithContext(m_node->GetId(), Seconds(0), &L3Protocol::initializeRibManager, this);
m_impl->m_forwarder->getFaceTable().addReserved(make_shared<nfd::NullFace>(), nfd::FACEID_NULL);
@@ -262,6 +266,38 @@
entry->addNextHop(m_impl->m_internalFace, 0);
}
+void
+L3Protocol::initializeRibManager()
+{
+ using namespace nfd;
+
+ m_impl->m_face = make_shared< ::ndn::Face>();
+ m_impl->m_ribManager = make_shared<rib::RibManager>(*(m_impl->m_face),
+ StackHelper::getKeyChain());
+
+ ConfigFile config([] (const std::string& filename, const std::string& sectionName,
+ const ConfigSection& section, bool isDryRun) {
+ // Ignore "log" and sections belonging to NFD,
+ // but raise an error if we're missing a handler for a "rib" section.
+ if (sectionName != "rib" || sectionName == "log") {
+ // do nothing
+ }
+ else {
+ // missing NRD section
+ ConfigFile::throwErrorOnUnknownSection(filename, sectionName, section, isDryRun);
+ }
+ });
+
+ m_impl->m_ribManager->setConfigFile(config);
+
+ // apply config
+ config.parse(m_impl->m_config, false, "ndnSIM.conf");
+
+ m_impl->m_ribManager->registerWithNfd();
+
+ m_impl->m_ribManager->enableLocalControlHeader();
+}
+
shared_ptr<nfd::Forwarder>
L3Protocol::getForwarder()
{
@@ -296,6 +332,8 @@
if (m_node == nullptr) {
m_node = GetObject<Node>();
if (m_node != nullptr) {
+ initialize();
+
NS_ASSERT(m_impl->m_forwarder != nullptr);
m_impl->m_csFromNdnSim = GetObject<ContentStore>();
if (m_impl->m_csFromNdnSim != nullptr) {
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index ea0052b..88b522e 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -90,13 +90,8 @@
* \brief Default constructor. Creates an empty stack without forwarding strategy set
*/
L3Protocol();
- virtual ~L3Protocol();
- /**
- * \brief Initialize NFD instance
- */
- void
- initialize();
+ virtual ~L3Protocol();
/**
* \brief Get smart pointer to nfd::Forwarder installed on the node
@@ -179,8 +174,14 @@
private:
void
+ initialize();
+
+ void
initializeManagement();
+ void
+ initializeRibManager();
+
private:
class Impl;
std::unique_ptr<Impl> m_impl;
diff --git a/tests/unit-tests/ndn-cxx/face.t.cpp b/tests/unit-tests/ndn-cxx/face.t.cpp
index d50f8a9..c78c8df 100644
--- a/tests/unit-tests/ndn-cxx/face.t.cpp
+++ b/tests/unit-tests/ndn-cxx/face.t.cpp
@@ -78,7 +78,6 @@
}
};
-BOOST_AUTO_TEST_CASE_EXPECTED_FAILURES(SetInterestFilter, 2);
BOOST_AUTO_TEST_CASE(SetInterestFilter)
{
FactoryCallbackApp::Install(getNode("B"), [this] () -> shared_ptr<void> {
diff --git a/wscript b/wscript
index 494cd43..71f2c9a 100644
--- a/wscript
+++ b/wscript
@@ -109,7 +109,7 @@
excl=['ndn-cxx/src/**/*-osx.cpp',
'ndn-cxx/src/util/dummy-client-face.cpp'])
- nfdSrc = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in ['NFD/core', 'NFD/daemon']],
+ nfdSrc = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in ['NFD/core', 'NFD/daemon', 'NFD/rib']],
excl=['NFD/core/network-interface.cpp',
'NFD/daemon/main.cpp',
'NFD/daemon/nfd.cpp',
@@ -118,14 +118,15 @@
'NFD/daemon/face/tcp*',
'NFD/daemon/face/udp*',
'NFD/daemon/face/unix-stream*',
- 'NFD/daemon/face/websocket*'])
+ 'NFD/daemon/face/websocket*',
+ 'NFD/rib/nrd.cpp'])
module = bld.create_ns3_module('ndnSIM', deps)
module.module = 'ndnSIM'
module.features += ' ns3fullmoduleheaders ndncxxheaders'
module.use += ['version-ndn-cxx', 'version-NFD', 'BOOST', 'CRYPTOPP', 'SQLITE3', 'RT', 'PTHREAD']
- module.includes = ['../..', '../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', '../../ns3/ndnSIM', '../../ns3/ndnSIM/ndn-cxx']
- module.export_includes = ['../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', '../../ns3/ndnSIM']
+ module.includes = ['../..', '../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM', '../../ns3/ndnSIM/ndn-cxx']
+ module.export_includes = ['../../ns3/ndnSIM/NFD', './NFD/core', './NFD/daemon', './NFD/rib', '../../ns3/ndnSIM']
headers = bld(features='ns3header')
headers.module = 'ndnSIM'
@@ -139,7 +140,7 @@
module.source = bld.path.ant_glob(['%s/**/*.cpp' % dir for dir in module_dirs],
excl=['model/ip-faces/*']) + ndnCxxSrc + nfdSrc
- module_dirs = ['NFD/core', 'NFD/daemon', 'apps', 'helper', 'model', 'utils']
+ module_dirs = ['NFD/core', 'NFD/daemon', 'NFD/rib', 'apps', 'helper', 'model', 'utils']
module.full_headers = bld.path.ant_glob(['%s/**/*.hpp' % dir for dir in module_dirs])
module.full_headers += bld.path.ant_glob('NFD/common.hpp')