model+helper+tests: Create an ndnSIM-specific transport for the NFD face system

This commit replaces the previous hack of implementing NS-3's inter-node
communication using the LinkService abstraction of the NFD face system.
The new implementation has higher memory overhead, but allows simulation
of any LinkService versions, including GenericLinkService that
implements NDNLPv2 protocol (i.e., fragmentation, network NACKs, etc.).

Change-Id: I3d16bcf29f4858049d1040a3e421e1c7151b3ba2
Refs: #3871, #3873
diff --git a/helper/ndn-global-routing-helper.cpp b/helper/ndn-global-routing-helper.cpp
index 6d13d6b..282f784 100644
--- a/helper/ndn-global-routing-helper.cpp
+++ b/helper/ndn-global-routing-helper.cpp
@@ -27,7 +27,7 @@
 
 #include "model/ndn-l3-protocol.hpp"
 #include "helper/ndn-fib-helper.hpp"
-#include "model/ndn-net-device-link-service.hpp"
+#include "model/ndn-net-device-transport.hpp"
 #include "model/ndn-global-router.hpp"
 
 #include "daemon/table/fib.hpp"
@@ -81,15 +81,15 @@
   node->AggregateObject(gr);
 
   for (auto& face : ndn->getForwarder()->getFaceTable()) {
-    auto linkService = dynamic_cast<NetDeviceLinkService*>(face.getLinkService());
-    if (linkService == nullptr) {
-      NS_LOG_DEBUG("Skipping non-netdevice face");
+    auto transport = dynamic_cast<NetDeviceTransport*>(face.getTransport());
+    if (transport == nullptr) {
+      NS_LOG_DEBUG("Skipping non ndnSIM-specific transport face");
       continue;
     }
 
-    Ptr<NetDevice> nd = linkService->GetNetDevice();
+    Ptr<NetDevice> nd = transport->GetNetDevice();
     if (nd == 0) {
-      NS_LOG_DEBUG("Not a NetDevice associated with NetDeviceFace");
+      NS_LOG_DEBUG("Not a NetDevice associated with an ndnSIM-specific transport instance");
       continue;
     }
 
@@ -326,9 +326,9 @@
     for (auto& faceId : faceIds) {
       auto* face = l3->getForwarder()->getFaceTable().get(faceId);
       NS_ASSERT(face != nullptr);
-      auto linkService = dynamic_cast<NetDeviceLinkService*>(face->getLinkService());
-      if (linkService == nullptr) {
-        NS_LOG_DEBUG("Skipping non-netdevice face");
+      auto transport = dynamic_cast<NetDeviceTransport*>(face->getTransport());
+      if (transport == nullptr) {
+        NS_LOG_DEBUG("Skipping non ndnSIM-specific transport face");
         continue;
       }
 
diff --git a/helper/ndn-link-control-helper.cpp b/helper/ndn-link-control-helper.cpp
index 26a2a2c..2b46946 100644
--- a/helper/ndn-link-control-helper.cpp
+++ b/helper/ndn-link-control-helper.cpp
@@ -32,7 +32,7 @@
 #include "ns3/pointer.h"
 
 #include "model/ndn-l3-protocol.hpp"
-#include "model/ndn-net-device-link-service.hpp"
+#include "model/ndn-net-device-transport.hpp"
 #include "NFD/daemon/face/face.hpp"
 
 #include "fw/forwarder.hpp"
@@ -57,11 +57,11 @@
 
   // iterate over all faces to find the right one
   for (const auto& face : ndn1->getForwarder()->getFaceTable()) {
-    auto linkService = dynamic_cast<NetDeviceLinkService*>(face.getLinkService());
-    if (linkService == nullptr)
+    auto transport = dynamic_cast<NetDeviceTransport*>(face.getTransport());
+    if (transport == nullptr)
       continue;
 
-    Ptr<PointToPointNetDevice> nd1 = linkService->GetNetDevice()->GetObject<PointToPointNetDevice>();
+    Ptr<PointToPointNetDevice> nd1 = transport->GetNetDevice()->GetObject<PointToPointNetDevice>();
     if (nd1 == nullptr)
       continue;
 
diff --git a/helper/ndn-stack-helper.cpp b/helper/ndn-stack-helper.cpp
index 4b9cd90..98bb186 100644
--- a/helper/ndn-stack-helper.cpp
+++ b/helper/ndn-stack-helper.cpp
@@ -26,8 +26,7 @@
 #include "ns3/point-to-point-channel.h"
 
 #include "model/ndn-l3-protocol.hpp"
-#include "model/ndn-net-device-link-service.hpp"
-#include "model/null-transport.hpp"
+#include "model/ndn-net-device-transport.hpp"
 #include "utils/ndn-time.hpp"
 #include "utils/dummy-keychain.hpp"
 #include "model/cs/ndn-content-store.hpp"
@@ -36,6 +35,7 @@
 #include <map>
 #include <boost/lexical_cast.hpp>
 
+#include "ns3/ndnSIM/NFD/daemon/face/generic-link-service.hpp"
 #include "ns3/ndnSIM/NFD/daemon/table/cs-policy-priority-fifo.hpp"
 #include "ns3/ndnSIM/NFD/daemon/table/cs-policy-lru.hpp"
 
@@ -270,9 +270,18 @@
 {
   NS_LOG_DEBUG("Creating default Face on node " << node->GetId());
 
-  auto netDeviceLink = make_unique<NetDeviceLinkService>(node, netDevice);
-  auto transport = make_unique<NullTransport>(constructFaceUri(netDevice), "netdev://[ff:ff:ff:ff:ff:ff]");
-  auto face = std::make_shared<Face>(std::move(netDeviceLink), std::move(transport));
+  // Create an ndnSIM-specific transport instance
+  ::nfd::face::GenericLinkService::Options opts;
+  opts.allowFragmentation = true;
+  opts.allowReassembly = true;
+
+  auto linkService = make_unique<::nfd::face::GenericLinkService>(opts);
+
+  auto transport = make_unique<NetDeviceTransport>(node, netDevice,
+                                                   constructFaceUri(netDevice),
+                                                   "netdev://[ff:ff:ff:ff:ff:ff]");
+
+  auto face = std::make_shared<Face>(std::move(linkService), std::move(transport));
   face->setMetric(1);
 
   ndn->addFace(face);
@@ -299,10 +308,18 @@
   if (remoteNetDevice->GetNode() == node)
     remoteNetDevice = channel->GetDevice(1);
 
-  auto netDeviceLink = make_unique<NetDeviceLinkService>(node, netDevice);
+  // Create an ndnSIM-specific transport instance
+  ::nfd::face::GenericLinkService::Options opts;
+  opts.allowFragmentation = true;
+  opts.allowReassembly = true;
 
-  auto transport = make_unique<NullTransport>(constructFaceUri(netDevice), constructFaceUri(remoteNetDevice));
-  auto face = std::make_shared<Face>(std::move(netDeviceLink), std::move(transport));
+  auto linkService = make_unique<::nfd::face::GenericLinkService>(opts);
+
+  auto transport = make_unique<NetDeviceTransport>(node, netDevice,
+                                                   constructFaceUri(netDevice),
+                                                   constructFaceUri(remoteNetDevice));
+
+  auto face = std::make_shared<Face>(std::move(linkService), std::move(transport));
   face->setMetric(1);
 
   ndn->addFace(face);