model+apps: Replace AppFace with AppFaceModel and relevant changes in ndn::App
Change-Id: I59faedaadf9d054ae22d813a4ce41f1f30b9321c
Refs: #3560
diff --git a/model/ndn-app-face.cpp b/model/ndn-app-link-service.cpp
similarity index 67%
rename from model/ndn-app-face.cpp
rename to model/ndn-app-link-service.cpp
index 61c3c21..6b89b42 100644
--- a/model/ndn-app-face.cpp
+++ b/model/ndn-app-link-service.cpp
@@ -17,7 +17,7 @@
* ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
-#include "ndn-app-face.hpp"
+#include "ndn-app-link-service.hpp"
#include "ns3/log.h"
#include "ns3/packet.h"
@@ -27,14 +27,13 @@
#include "apps/ndn-app.hpp"
-NS_LOG_COMPONENT_DEFINE("ndn.AppFace");
+NS_LOG_COMPONENT_DEFINE("ndn.AppLinkService");
namespace ns3 {
namespace ndn {
-AppFace::AppFace(Ptr<App> app)
- : LocalFace(FaceUri("appFace://"), FaceUri("appFace://"))
- , m_node(app->GetNode())
+AppLinkService::AppLinkService(Ptr<App> app)
+ : m_node(app->GetNode())
, m_app(app)
{
NS_LOG_FUNCTION(this << app);
@@ -42,49 +41,56 @@
NS_ASSERT(m_app != 0);
}
-AppFace::~AppFace()
+AppLinkService::~AppLinkService()
{
NS_LOG_FUNCTION_NOARGS();
}
void
-AppFace::close()
-{
- this->fail("Close connection");
-}
-
-void
-AppFace::sendInterest(const Interest& interest)
+AppLinkService::doSendInterest(const Interest& interest)
{
NS_LOG_FUNCTION(this << &interest);
- this->emitSignal(onSendInterest, interest);
-
// to decouple callbacks
Simulator::ScheduleNow(&App::OnInterest, m_app, interest.shared_from_this());
}
void
-AppFace::sendData(const Data& data)
+AppLinkService::doSendData(const Data& data)
{
NS_LOG_FUNCTION(this << &data);
- this->emitSignal(onSendData, data);
-
// to decouple callbacks
Simulator::ScheduleNow(&App::OnData, m_app, data.shared_from_this());
}
void
-AppFace::onReceiveInterest(const Interest& interest)
+AppLinkService::doSendNack(const lp::Nack& nack)
{
- this->emitSignal(onReceiveInterest, interest);
+ NS_LOG_FUNCTION(this << &nack);
+
+ // to decouple callbacks
+ // Simulator::ScheduleNow(&App::OnNack, m_app, nack.shared_from_this());
+}
+
+//
+
+void
+AppLinkService::onReceiveInterest(const Interest& interest)
+{
+ this->receiveInterest(interest);
}
void
-AppFace::onReceiveData(const Data& data)
+AppLinkService::onReceiveData(const Data& data)
{
- this->emitSignal(onReceiveData, data);
+ this->receiveData(data);
+}
+
+void
+AppLinkService::onReceiveNack(const lp::Nack& nack)
+{
+ this->receiveNack(nack);
}
} // namespace ndn
diff --git a/model/ndn-app-face.hpp b/model/ndn-app-link-service.hpp
similarity index 62%
rename from model/ndn-app-face.hpp
rename to model/ndn-app-link-service.hpp
index ab3de90..798ac1a 100644
--- a/model/ndn-app-face.hpp
+++ b/model/ndn-app-link-service.hpp
@@ -17,12 +17,11 @@
* ndnSIM, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
**/
-#ifndef NDN_APP_FACE_H
-#define NDN_APP_FACE_H
+#ifndef NDN_APP_LINK_SERVICE_HPP
+#define NDN_APP_LINK_SERVICE_HPP
#include "ns3/ndnSIM/model/ndn-common.hpp"
-#include "ns3/ndnSIM/NFD/daemon/face/local-face.hpp"
-#include "ns3/ndnSIM/model/ndn-face.hpp"
+#include "ns3/ndnSIM/NFD/daemon/face/link-service.hpp"
namespace ns3 {
@@ -35,50 +34,46 @@
/**
* \ingroup ndn-face
- * \brief Implementation of application Ndn face
+ * \brief Implementation of LinkService for ndnSIM application
*
- * This class defines basic functionality of Ndn face. Face is core
- * component responsible for actual delivery of data packet to and
- * from Ndn stack
- *
- * \see AppFace, NdnNetDeviceFace
+ * \see NetDeviceLinkService
*/
-class AppFace : public nfd::LocalFace {
+class AppLinkService : public nfd::face::LinkService
+{
public:
/**
* \brief Default constructor
*/
- AppFace(Ptr<App> app);
+ AppLinkService(Ptr<App> app);
- virtual ~AppFace();
+ virtual ~AppLinkService();
-public: // from nfd::Face
- /**
- * @brief Send Interest towards application
- */
- virtual void
- sendInterest(const Interest& interest);
-
- /**
- * @brief Send Data towards application
- */
- virtual void
- sendData(const Data& data);
-
- /**
- * @brief Send Interest towards NFD
- */
+public:
void
onReceiveInterest(const Interest& interest);
- /**
- * @brief Send Data towards NFD
- */
void
onReceiveData(const Data& data);
+ void
+ onReceiveNack(const lp::Nack& nack);
+
+private:
virtual void
- close();
+ doSendInterest(const Interest& interest) override;
+
+ virtual void
+ doSendData(const Data& data) override;
+
+ virtual void
+ doSendNack(const lp::Nack& nack) override;
+
+ virtual void
+ doReceivePacket(nfd::face::Transport::Packet&& packet) override
+ {
+ // does nothing (all operations for now handled by LinkService)
+ BOOST_ASSERT(false);
+ }
private:
Ptr<Node> m_node;
@@ -88,4 +83,4 @@
} // namespace ndn
} // namespace ns3
-#endif // NDN_APP_FACE_H
+#endif // NDN_APP_LINK_SERVICE_HPP