model+helper+examples: Enable configurability of NFD parameters using StackHelper
Refs: #2353, #2220
diff --git a/helper/ndn-fib-helper.cpp b/helper/ndn-fib-helper.cpp
index 6218aeb..dddcc8a 100644
--- a/helper/ndn-fib-helper.cpp
+++ b/helper/ndn-fib-helper.cpp
@@ -59,7 +59,7 @@
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- StackHelper::getKeyChain().signWithSha256(*command);
+ StackHelper::getKeyChain().sign(*command);
Ptr<L3Protocol> l3protocol = node->GetObject<L3Protocol>();
shared_ptr<nfd::FibManager> fibManager = l3protocol->getFibManager();
@@ -77,7 +77,7 @@
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- StackHelper::getKeyChain().signWithSha256(*command);
+ StackHelper::getKeyChain().sign(*command);
Ptr<L3Protocol> L3protocol = node->GetObject<L3Protocol>();
shared_ptr<nfd::FibManager> fibManager = L3protocol->getFibManager();
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index 5e2038c..6e45281 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -41,7 +41,7 @@
StackHelper::StackHelper()
: m_needSetDefaultRoutes(false)
- , m_shouldUseNfdCs(true)
+ , m_maxCsSize(100)
{
setCustomNdnCxxClocks();
@@ -96,14 +96,13 @@
}
void
-StackHelper::SetContentStore(const std::string& contentStore, const std::string& attr1,
- const std::string& value1, const std::string& attr2,
- const std::string& value2, const std::string& attr3,
- const std::string& value3, const std::string& attr4,
- const std::string& value4)
+StackHelper::SetOldContentStore(const std::string& contentStore, const std::string& attr1,
+ const std::string& value1, const std::string& attr2,
+ const std::string& value2, const std::string& attr3,
+ const std::string& value3, const std::string& attr4,
+ const std::string& value4)
{
- NS_ASSERT_MSG(m_shouldUseNfdCs == false,
- "First choose not to use NFD's CS and then select the replacement policy");
+ m_maxCsSize = 0;
m_contentStoreFactory.SetTypeId(contentStore);
if (attr1 != "")
@@ -117,15 +116,9 @@
}
void
-StackHelper::SetContentStoreChoice(bool shouldUseNfdCs)
+StackHelper::setCsSize(size_t maxSize)
{
- m_shouldUseNfdCs = shouldUseNfdCs;
-}
-
-bool
-StackHelper::shouldUseNfdCs() const
-{
- return m_shouldUseNfdCs;
+ m_maxCsSize = maxSize;
}
Ptr<FaceContainer>
@@ -157,12 +150,15 @@
Ptr<L3Protocol> ndn = m_ndnFactory.Create<L3Protocol>();
+ ndn->getConfig().put("tables.cs_max_packets", (m_maxCsSize == 0) ? 1 : m_maxCsSize);
+
// NFD initialization
- ndn->initialize(m_shouldUseNfdCs);
+ ndn->initialize();
// Create and aggregate content store if NFD's contest store has been disabled
- if (!m_shouldUseNfdCs)
+ if (m_maxCsSize == 0) {
ndn->AggregateObject(m_contentStoreFactory.Create<ContentStore>());
+ }
// Aggregate L3Protocol on node (must be after setting ndnSIM CS)
node->AggregateObject(ndn);
diff --git a/helper/ndn-stack-helper.hpp b/helper/ndn-stack-helper.hpp
index 63cc564..836a6b4 100644
--- a/helper/ndn-stack-helper.hpp
+++ b/helper/ndn-stack-helper.hpp
@@ -61,7 +61,7 @@
* attribute or a set of functionality that may be of interest to many other
* classes.
*/
-class StackHelper {
+class StackHelper : boost::noncopyable {
public:
/**
* \brief Create a new NdnStackHelper with a default NDN_FLOODING forwarding stategy
@@ -87,25 +87,14 @@
* @param contentStoreClass string, representing class of the content store
*/
void
- SetContentStore(const std::string& contentStoreClass, const std::string& attr1 = "",
+ SetOldContentStore(const std::string& contentStoreClass, const std::string& attr1 = "",
const std::string& value1 = "", const std::string& attr2 = "",
const std::string& value2 = "", const std::string& attr3 = "",
const std::string& value3 = "", const std::string& attr4 = "",
const std::string& value4 = "");
- /**
- * @brief Set to use native NFD's content store or ndnSIM provided CS implementations
- *
- * @note ndnSIM CS implementations have limited support for NDN selectors
- */
void
- SetContentStoreChoice(const bool shouldUseNfdCs);
-
- /**
- * @brief Check if stack is using native NFD content store implementation
- */
- bool
- shouldUseNfdCs() const;
+ setCsSize(size_t maxSize);
typedef Callback<shared_ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
NetDeviceFaceCreateCallback;
@@ -214,16 +203,11 @@
setCustomNdnCxxClocks();
private:
- StackHelper(const StackHelper&);
- StackHelper&
- operator=(const StackHelper& o);
-
-private:
ObjectFactory m_ndnFactory;
ObjectFactory m_contentStoreFactory;
bool m_needSetDefaultRoutes;
- bool m_shouldUseNfdCs;
+ size_t m_maxCsSize;
typedef std::list<std::pair<TypeId, NetDeviceFaceCreateCallback>> NetDeviceCallbackList;
NetDeviceCallbackList m_netDeviceCallbacks;
diff --git a/helper/ndn-strategy-choice-helper.cpp b/helper/ndn-strategy-choice-helper.cpp
index 53e0209..53ba544 100644
--- a/helper/ndn-strategy-choice-helper.cpp
+++ b/helper/ndn-strategy-choice-helper.cpp
@@ -39,7 +39,7 @@
commandName.append(encodedParameters);
shared_ptr<Interest> command(make_shared<Interest>(commandName));
- StackHelper::getKeyChain().signWithSha256(*command);
+ StackHelper::getKeyChain().sign(*command);
Ptr<L3Protocol> L3protocol = node->GetObject<L3Protocol>();
auto strategyChoiceManager = L3protocol->getStrategyChoiceManager();
strategyChoiceManager->onStrategyChoiceRequest(*command);