model+helper+ndn-cxx: Adjust ndn::L3Protocol and ndn::StackHelper for NFD 0.4+ model
This commit also restores ndn-cxx Face emulation, which is now necessary
for all NFD's management operations.
Change-Id: Id04cf69a2b0c81972248b6d80055e7c743fa869d
Refs: #3560
diff --git a/helper/ndn-face-container.hpp b/helper/ndn-face-container.hpp
index e55cc2a..545ff4d 100644
--- a/helper/ndn-face-container.hpp
+++ b/helper/ndn-face-container.hpp
@@ -27,7 +27,6 @@
#include "ns3/ptr.h"
#include "ns3/simple-ref-count.h"
-#include "ns3/ndnSIM/model/ndn-face.hpp"
namespace ns3 {
namespace ndn {
diff --git a/helper/ndn-fib-helper.hpp b/helper/ndn-fib-helper.hpp
index 76695f6..c231be9 100644
--- a/helper/ndn-fib-helper.hpp
+++ b/helper/ndn-fib-helper.hpp
@@ -21,7 +21,6 @@
#define NDN_FIB_HELPER_H
#include "ns3/ndnSIM/model/ndn-common.hpp"
-#include "ns3/ndnSIM/model/ndn-face.hpp"
#include "ns3/node.h"
#include "ns3/object-vector.h"
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index 7211639..06dd368 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -25,7 +25,8 @@
#include "ns3/point-to-point-net-device.h"
#include "model/ndn-l3-protocol.hpp"
-#include "model/ndn-net-device-face.hpp"
+#include "model/ndn-net-device-link-service.hpp"
+#include "model/null-transport.hpp"
#include "utils/ndn-time.hpp"
#include "utils/dummy-keychain.hpp"
#include "model/cs/ndn-content-store.hpp"
@@ -40,12 +41,12 @@
namespace ndn {
StackHelper::StackHelper()
- : m_needSetDefaultRoutes(false)
- , m_maxCsSize(100)
- , m_isRibManagerDisabled(false)
- , m_isFaceManagerDisabled(false)
- , m_isStatusServerDisabled(false)
+ : m_isRibManagerDisabled(false)
+ // , m_isFaceManagerDisabled(false)
+ , m_isForwarderStatusManagerDisabled(false)
, m_isStrategyChoiceManagerDisabled(false)
+ , m_needSetDefaultRoutes(false)
+ , m_maxCsSize(100)
{
setCustomNdnCxxClocks();
@@ -158,12 +159,12 @@
ndn->getConfig().put("ndnSIM.disable_rib_manager", true);
}
- if (m_isFaceManagerDisabled) {
- ndn->getConfig().put("ndnSIM.disable_face_manager", true);
- }
+ // if (m_isFaceManagerDisabled) {
+ // ndn->getConfig().put("ndnSIM.disable_face_manager", true);
+ // }
- if (m_isStatusServerDisabled) {
- ndn->getConfig().put("ndnSIM.disable_status_server", true);
+ if (m_isForwarderStatusManagerDisabled) {
+ ndn->getConfig().put("ndnSIM.disable_forwarder_status_manager", true);
}
if (m_isStrategyChoiceManagerDisabled) {
@@ -194,15 +195,15 @@
}
void
-StackHelper::AddNetDeviceFaceCreateCallback(TypeId netDeviceType,
- StackHelper::NetDeviceFaceCreateCallback callback)
+StackHelper::AddFaceCreateCallback(TypeId netDeviceType,
+ StackHelper::FaceCreateCallback callback)
{
m_netDeviceCallbacks.push_back(std::make_pair(netDeviceType, callback));
}
void
-StackHelper::UpdateNetDeviceFaceCreateCallback(TypeId netDeviceType,
- NetDeviceFaceCreateCallback callback)
+StackHelper::UpdateFaceCreateCallback(TypeId netDeviceType,
+ FaceCreateCallback callback)
{
for (auto& i : m_netDeviceCallbacks) {
if (i.first == netDeviceType) {
@@ -213,39 +214,49 @@
}
void
-StackHelper::RemoveNetDeviceFaceCreateCallback(TypeId netDeviceType,
- NetDeviceFaceCreateCallback callback)
+StackHelper::RemoveFaceCreateCallback(TypeId netDeviceType,
+ FaceCreateCallback callback)
{
- m_netDeviceCallbacks.remove_if([&] (const std::pair<TypeId, NetDeviceFaceCreateCallback>& i) {
+ m_netDeviceCallbacks.remove_if([&] (const std::pair<TypeId, FaceCreateCallback>& i) {
return (i.first == netDeviceType);
});
}
-shared_ptr<NetDeviceFace>
+shared_ptr<Face>
StackHelper::DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
Ptr<NetDevice> netDevice) const
{
- NS_LOG_DEBUG("Creating default NetDeviceFace on node " << node->GetId());
+ NS_LOG_DEBUG("Creating default Face on node " << node->GetId());
- shared_ptr<NetDeviceFace> face = std::make_shared<NetDeviceFace>(node, netDevice);
+ auto netDeviceLink = make_unique<NetDeviceLinkService>(node, netDevice);
+ auto transport = make_unique<NullTransport>("netDevice://", "netDevice://");
+ auto face = std::make_shared<Face>(std::move(netDeviceLink), std::move(transport));
+ face->setMetric(1);
+
+ // @TODO add netDevice ID
ndn->addFace(face);
- NS_LOG_LOGIC("Node " << node->GetId() << ": added NetDeviceFace as face #"
+ NS_LOG_LOGIC("Node " << node->GetId() << ": added Face as face #"
<< face->getLocalUri());
return face;
}
-shared_ptr<NetDeviceFace>
+shared_ptr<Face>
StackHelper::PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
Ptr<NetDevice> device) const
{
- NS_LOG_DEBUG("Creating point-to-point NetDeviceFace on node " << node->GetId());
+ NS_LOG_DEBUG("Creating point-to-point Face on node " << node->GetId());
- shared_ptr<NetDeviceFace> face = std::make_shared<NetDeviceFace>(node, device);
+ auto netDeviceLink = make_unique<NetDeviceLinkService>(node, device);
+ auto transport = make_unique<NullTransport>("netDevice://", "netDevice://");
+ auto face = std::make_shared<Face>(std::move(netDeviceLink), std::move(transport));
+ face->setMetric(1);
+
+ // @TODO add netDevice ID
ndn->addFace(face);
- NS_LOG_LOGIC("Node " << node->GetId() << ": added NetDeviceFace as face #"
+ NS_LOG_LOGIC("Node " << node->GetId() << ": added Face as face #"
<< face->getLocalUri());
return face;
@@ -299,10 +310,10 @@
Update(NodeContainer::GetGlobal());
}
-shared_ptr<NetDeviceFace>
+shared_ptr<Face>
StackHelper::createAndRegisterFace(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> device) const
{
- shared_ptr<NetDeviceFace> face;
+ shared_ptr<Face> face;
for (const auto& item : m_netDeviceCallbacks) {
if (device->GetInstanceTypeId() == item.first ||
@@ -319,7 +330,9 @@
if (m_needSetDefaultRoutes) {
// default route with lowest priority possible
- FibHelper::AddRoute(node, "/", face, std::numeric_limits<int32_t>::max());
+
+ // TODO: Restore when FibHelper is available
+ // FibHelper::AddRoute(node, "/", face, std::numeric_limits<int32_t>::max());
}
return face;
}
@@ -330,11 +343,11 @@
m_isRibManagerDisabled = true;
}
-void
-StackHelper::disableFaceManager()
-{
- m_isFaceManagerDisabled = true;
-}
+// void
+// StackHelper::disableFaceManager()
+// {
+// m_isFaceManagerDisabled = true;
+// }
void
StackHelper::disableStrategyChoiceManager()
@@ -343,9 +356,9 @@
}
void
-StackHelper::disableStatusServer()
+StackHelper::disableForwarderStatusManager()
{
- m_isStatusServerDisabled = true;
+ m_isForwarderStatusManagerDisabled = true;
}
} // namespace ndn
diff --git a/helper/ndn-stack-helper.hpp b/helper/ndn-stack-helper.hpp
index 4b6f38b..0cb3413 100644
--- a/helper/ndn-stack-helper.hpp
+++ b/helper/ndn-stack-helper.hpp
@@ -17,8 +17,8 @@
* ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
-#ifndef NDN_STACK_HELPER_H
-#define NDN_STACK_HELPER_H
+#ifndef NDNSIM_HELPER_NDN_STACK_HELPER_HPP
+#define NDNSIM_HELPER_NDN_STACK_HELPER_HPP
#include "ns3/ndnSIM/model/ndn-common.hpp"
@@ -37,7 +37,6 @@
namespace ndn {
-class NetDeviceFace;
class L3Protocol;
/**
@@ -88,8 +87,8 @@
const std::string& value3 = "", const std::string& attr4 = "",
const std::string& value4 = "");
- typedef Callback<shared_ptr<NetDeviceFace>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
- NetDeviceFaceCreateCallback;
+ typedef Callback<shared_ptr<Face>, Ptr<Node>, Ptr<L3Protocol>, Ptr<NetDevice>>
+ FaceCreateCallback;
/**
* @brief Add callback to create and configure instance of the face, based on supplied Ptr<Node>
@@ -101,7 +100,7 @@
*(DefaultNetDeviceCallback)
*/
void
- AddNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+ AddFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
/**
* @brief Update callback to create and configure instance of the face, based on supplied
@@ -112,14 +111,14 @@
* Using this method, it is possible to override Face creation for PointToPointNetDevices
*/
void
- UpdateNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+ UpdateFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
/**
* @brief Remove callback to create and configure instance of the face, based on supplied
* Ptr<Node> and Ptr<NetDevice>
*/
void
- RemoveNetDeviceFaceCreateCallback(TypeId netDeviceType, NetDeviceFaceCreateCallback callback);
+ RemoveFaceCreateCallback(TypeId netDeviceType, FaceCreateCallback callback);
/**
* \brief Install Ndn stack on the node
@@ -218,11 +217,12 @@
void
disableRibManager();
- /**
- * \brief Disable Face Manager
- */
- void
- disableFaceManager();
+ // Cannot be disabled for now
+ // /**
+ // * \brief Disable Face Manager
+ // */
+ // void
+ // disableFaceManager();
/**
* \brief Disable Strategy Choice Manager
@@ -231,24 +231,24 @@
disableStrategyChoiceManager();
/**
- * \brief Disable Status Server
+ * \brief Disable Forwarder Status Manager
*/
void
- disableStatusServer();
+ disableForwarderStatusManager();
private:
- shared_ptr<NetDeviceFace>
+ shared_ptr<Face>
DefaultNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> netDevice) const;
- shared_ptr<NetDeviceFace>
+ shared_ptr<Face>
PointToPointNetDeviceCallback(Ptr<Node> node, Ptr<L3Protocol> ndn,
Ptr<NetDevice> netDevice) const;
- shared_ptr<NetDeviceFace>
+ shared_ptr<Face>
createAndRegisterFace(Ptr<Node> node, Ptr<L3Protocol> ndn, Ptr<NetDevice> device) const;
bool m_isRibManagerDisabled;
- bool m_isFaceManagerDisabled;
- bool m_isStatusServerDisabled;
+ // bool m_isFaceManagerDisabled;
+ bool m_isForwarderStatusManagerDisabled;
bool m_isStrategyChoiceManagerDisabled;
public:
@@ -262,11 +262,11 @@
bool m_needSetDefaultRoutes;
size_t m_maxCsSize;
- typedef std::list<std::pair<TypeId, NetDeviceFaceCreateCallback>> NetDeviceCallbackList;
+ typedef std::list<std::pair<TypeId, FaceCreateCallback>> NetDeviceCallbackList;
NetDeviceCallbackList m_netDeviceCallbacks;
};
} // namespace ndn
} // namespace ns3
-#endif /* NDN_STACK_HELPER_H */
+#endif // NDNSIM_HELPER_NDN_STACK_HELPER_HPP