tests+ci: Add and enable a partial unit test coverage

Change-Id: I6dbc5cf4d68679bd6f943322f572313884c8aef7
Refs: #2369
diff --git a/tests/unit-tests/helper/ndn-face-container.t.cpp b/tests/unit-tests/helper/ndn-face-container.t.cpp
new file mode 100644
index 0000000..59df4b9
--- /dev/null
+++ b/tests/unit-tests/helper/ndn-face-container.t.cpp
@@ -0,0 +1,61 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "helper/ndn-face-container.hpp"
+
+#include "ns3/node-container.h"
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/node.h"
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/ndnSIM-module.h"
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(HelperNdnFaceContainer, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(AddAll)
+{
+ NodeContainer nodes;
+ nodes.Create(4);
+
+ PointToPointHelper p2p;
+ p2p.Install(nodes.Get(0), nodes.Get(1));
+ p2p.Install(nodes.Get(0), nodes.Get(2));
+ p2p.Install(nodes.Get(0), nodes.Get(3));
+
+ StackHelper ndnHelper;
+ ndnHelper.SetDefaultRoutes(true);
+
+ Ptr<FaceContainer> a = ndnHelper.InstallAll();
+ FaceContainer b;
+ b.AddAll(a);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(a->Begin(), a->Begin() + a->GetN(),
+                               b.Begin(), b.End());
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/helper/ndn-fib-helper.t.cpp b/tests/unit-tests/helper/ndn-fib-helper.t.cpp
new file mode 100644
index 0000000..6d4ab1a
--- /dev/null
+++ b/tests/unit-tests/helper/ndn-fib-helper.t.cpp
@@ -0,0 +1,77 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "helper/ndn-fib-helper.hpp"
+#include "model/ndn-net-device-face.hpp"
+
+#include "ns3/node-container.h"
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/node.h"
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/ndnSIM-module.h"
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(HelperNdnFibHelper, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(AddRoute)
+{
+ NodeContainer nodes;
+ nodes.Create(2);
+
+ PointToPointHelper p2p;
+ p2p.Install(nodes.Get(0), nodes.Get(1));
+
+ StackHelper ndnHelper;
+ Ptr<FaceContainer> node0_faceContainer = ndnHelper.InstallAll();
+
+ ndn::FibHelper::AddRoute(nodes.Get(0), "/prefix/1", nodes.Get(1), 1);
+ // Installing applications
+ ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
+ consumerHelper.SetAttribute("Frequency", StringValue("10")); // 10 interests a second
+
+ ndn::AppHelper producerHelper("ns3::ndn::Producer");
+ producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
+
+ consumerHelper.SetPrefix("/prefix/1");
+ consumerHelper.Install(nodes.Get(0));
+
+ producerHelper.SetPrefix("/prefix/1");
+ producerHelper.Install(nodes.Get(1));
+
+ FaceContainer::Iterator node1Face_iterator = node0_faceContainer->Begin() + 1;
+
+ auto node1_netDeviceFace = std::dynamic_pointer_cast<NetDeviceFace>(node0_faceContainer->Get(node1Face_iterator));
+
+ Simulator::Stop(Seconds(20.0));
+ Simulator::Run();
+
+ ::ndn::nfd::FaceStatus faceStatus = node1_netDeviceFace->getFaceStatus();
+ BOOST_CHECK_EQUAL(faceStatus.getNInInterests(), 200);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/helper/ndn-global-routing-helper.t.cpp b/tests/unit-tests/helper/ndn-global-routing-helper.t.cpp
new file mode 100644
index 0000000..318c824
--- /dev/null
+++ b/tests/unit-tests/helper/ndn-global-routing-helper.t.cpp
@@ -0,0 +1,140 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "helper/ndn-global-routing-helper.hpp"
+
+#include "model/ndn-global-router.hpp"
+#include "model/ndn-l3-protocol.hpp"
+#include "model/ndn-face.hpp"
+#include "model/ndn-net-device-face.hpp"
+
+#include "ns3/channel.h"
+#include "ns3/net-device.h"
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/ndnSIM-module.h"
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/point-to-point-layout-module.h"
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(HelperGlobalRoutingHelper, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(CalculateRouteCase1)
+{
+  ofstream file1("/tmp/topo1.txt");
+  file1 << "router\n\n"
+        << "#node city  y x mpi-partition\n"
+        << "A1  NA  1 1 1\n"
+        << "B1  NA  80  -40 1\n"
+        << "C1  NA  80  40  1\n\n"
+        << "link\n\n"
+        << "# from  to  capacity  metric  delay queue\n"
+        << "A1      B1  10Mbps    100 1ms 100\n"
+        << "A1      C1  10Mbps    50  1ms 100\n"
+        << "B1      C1  10Mbps    1 1ms 100\n";
+  file1.close();
+
+  AnnotatedTopologyReader topologyReader("");
+  topologyReader.SetFileName("/tmp/topo1.txt");
+  topologyReader.Read();
+
+  // Install NDN stack on all nodes
+  ndn::StackHelper ndnHelper;
+  ndnHelper.InstallAll();
+
+  topologyReader.ApplyOspfMetric();
+
+  ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
+  BOOST_CHECK_NO_THROW(ndnGlobalRoutingHelper.InstallAll());
+
+  ndnGlobalRoutingHelper.AddOrigins("/test/prefix", Names::Find<Node>("C1"));
+  BOOST_CHECK_NO_THROW(ndn::GlobalRoutingHelper::CalculateRoutes());
+
+  auto ndn = Names::Find<Node>("A1")->GetObject<ndn::L3Protocol>();
+  for (const auto& entry : ndn->getForwarder()->getFib()) {
+    bool isFirst = true;
+    for (auto& nextHop : entry.getNextHops()) {
+      auto face = dynamic_pointer_cast<ndn::NetDeviceFace>(nextHop.getFace());
+      if (face == nullptr)
+        continue;
+      BOOST_CHECK_EQUAL(Names::FindName(face->GetNetDevice()->GetChannel()->GetDevice(1)->GetNode()), "C1");
+      isFirst = false;
+    }
+  }
+
+  Simulator::Stop(Seconds(20.0));
+  Simulator::Run();
+}
+
+BOOST_AUTO_TEST_CASE(CalculateRouteCase2)
+{
+  ofstream file1("/tmp/topo2.txt");
+  file1 << "router\n\n"
+        << "#node city  y x mpi-partition\n"
+        << "A2  NA  1 1 1\n"
+        << "B2  NA  80  -40 1\n"
+        << "C2  NA  80  40  1\n\n"
+        << "link\n\n"
+        << "# from  to  capacity  metric  delay queue\n"
+        << "A2      B2  10Mbps    100 1ms 100\n"
+        << "A2      C2  10Mbps    500  1ms 100\n"
+        << "B2      C2  10Mbps    1 1ms 100\n";
+  file1.close();
+
+  AnnotatedTopologyReader topologyReader("");
+  topologyReader.SetFileName("/tmp/topo2.txt");
+  topologyReader.Read();
+
+  // Install NDN stack on all nodes
+  ndn::StackHelper ndnHelper;
+  ndnHelper.InstallAll();
+
+  topologyReader.ApplyOspfMetric();
+
+  ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
+  ndnGlobalRoutingHelper.InstallAll();
+
+  ndnGlobalRoutingHelper.AddOrigins("/prefix", Names::Find<Node>("C2"));
+  ndn::GlobalRoutingHelper::CalculateRoutes();
+
+  auto ndn = Names::Find<Node>("A2")->GetObject<ndn::L3Protocol>();
+  for (const auto& entry : ndn->getForwarder()->getFib()) {
+    bool isFirst = true;
+    for (auto& nextHop : entry.getNextHops()) {
+      auto face = dynamic_pointer_cast<ndn::NetDeviceFace>(nextHop.getFace());
+      if (face == nullptr)
+        continue;
+      BOOST_CHECK_EQUAL(Names::FindName(face->GetNetDevice()->GetChannel()->GetDevice(1)->GetNode()), "B2");
+      isFirst = false;
+    }
+  }
+
+  Simulator::Stop(Seconds(20.0));
+  Simulator::Run();
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/helper/ndn-link-control-helper.t.cpp b/tests/unit-tests/helper/ndn-link-control-helper.t.cpp
new file mode 100644
index 0000000..31ac2f2
--- /dev/null
+++ b/tests/unit-tests/helper/ndn-link-control-helper.t.cpp
@@ -0,0 +1,94 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "helper/ndn-link-control-helper.hpp"
+#include "model/ndn-l3-protocol.hpp"
+#include "model/ndn-net-device-face.hpp"
+#include "model/ndn-app-face.hpp"
+#include "NFD/daemon/fw/forwarder.hpp"
+
+#include <ndn-cxx/management/nfd-face-status.hpp>
+
+#include "ns3/assert.h"
+#include "ns3/names.h"
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/point-to-point-channel.h"
+#include "ns3/channel.h"
+#include "ns3/log.h"
+#include "ns3/error-model.h"
+#include "ns3/string.h"
+#include "ns3/boolean.h"
+#include "ns3/double.h"
+#include "ns3/pointer.h"
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/ndnSIM-module.h"
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(HelperNdnLinkControlHelper, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(FailLink)
+{
+  NodeContainer nodes;
+  nodes.Create(2);
+
+  PointToPointHelper p2p;
+  p2p.Install(nodes.Get(0), nodes.Get(1));
+
+  StackHelper ndnHelper;
+  ndnHelper.SetDefaultRoutes(true);
+
+  Ptr<FaceContainer> node0_faceContainer = ndnHelper.InstallAll();
+
+  AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
+
+  consumerHelper.SetPrefix("/prefix");
+  consumerHelper.SetAttribute("Frequency", StringValue("1"));
+  ApplicationContainer consumerAppContainer = consumerHelper.Install(nodes.Get(0));
+
+  AppHelper producerHelper("ns3::ndn::Producer");
+
+  producerHelper.SetPrefix("/prefix");
+  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
+  ApplicationContainer producerAppContainer = producerHelper.Install(nodes.Get(1));
+
+  FaceContainer::Iterator node2Face_it = node0_faceContainer->Begin() + 1;
+
+  auto node1_netDeviceFace = std::dynamic_pointer_cast<NetDeviceFace>(node0_faceContainer->Get(node2Face_it));
+
+  Simulator::Schedule(Seconds(0.0), ndn::LinkControlHelper::FailLink, nodes.Get(0), nodes.Get(1));
+  Simulator::Schedule(Seconds(5.0), ndn::LinkControlHelper::UpLink, nodes.Get(0), nodes.Get(1));
+  Simulator::Stop(Seconds(10.0));
+
+  Simulator::Run();
+
+  ::ndn::nfd::FaceStatus faceStatus = node1_netDeviceFace->getFaceStatus();
+  BOOST_CHECK_EQUAL(faceStatus.getNInInterests(), 5);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/helper/ndn-strategy-choice-helper.t.cpp b/tests/unit-tests/helper/ndn-strategy-choice-helper.t.cpp
new file mode 100644
index 0000000..c4f1ebc
--- /dev/null
+++ b/tests/unit-tests/helper/ndn-strategy-choice-helper.t.cpp
@@ -0,0 +1,136 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "helper/ndn-strategy-choice-helper.hpp"
+#include "helper/ndn-face-container.hpp"
+#include "model/ndn-net-device-face.hpp"
+
+#include "ns3/node-container.h"
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/point-to-point-grid.h"
+#include "ns3/node.h"
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/ndnSIM-module.h"
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(TestStrategyChoiceHelper, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(GridScenario)
+{
+  ofstream file("/tmp/topo3.txt");
+  file  << "router\n\n"
+        << "#node city  y x mpi-partition\n"
+        << "A3  NA  10 10 1\n"
+        << "B3  NA  20 10 1\n"
+        << "C3  NA  10 20 1\n"
+        << "D3  NA  20 20 1\n\n"
+        << "link\n\n"
+        << "# from  to  capacity  metric  delay queue\n"
+        << "A3      B3  10Mbps    100 1ms 500\n"
+        << "A3      C3  10Mbps    200 1ms 500\n"
+        << "B3      D3  10Mbps    100 1ms 500\n"
+        << "C3      D3  10Mbps    200 1ms 500\n";
+  file.close();
+
+  AnnotatedTopologyReader topologyReader("");
+  topologyReader.SetFileName("/tmp/topo3.txt");
+  topologyReader.Read();
+
+  // Install NDN stack on all nodes
+  ndn::StackHelper ndnHelper;
+  Ptr<FaceContainer> node_faceContainer = ndnHelper.InstallAll();
+  GlobalRoutingHelper ndnGlobalRoutingHelper;
+  ndnGlobalRoutingHelper.InstallAll();
+
+  // Install different forwarding strategies
+  StrategyChoiceHelper::Install(Names::Find<Node>("A3"), "/prefix",
+                                "/localhost/nfd/strategy/broadcast");
+  StrategyChoiceHelper::Install(Names::Find<Node>("B3"), "/prefix",
+                                "/localhost/nfd/strategy/best-route");
+  StrategyChoiceHelper::Install(Names::Find<Node>("C3"), "/prefix",
+                                "/localhost/nfd/strategy/broadcast");
+  StrategyChoiceHelper::Install(Names::Find<Node>("D3"), "/prefix",
+                                "/localhost/nfd/strategy/best-route");
+
+  AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
+  consumerHelper.SetPrefix("/prefix");
+  consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second
+  consumerHelper.Install(Names::Find<Node>("A3"));
+
+  AppHelper producerHelper("ns3::ndn::Producer");
+  producerHelper.SetPrefix("/prefix");
+  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
+  producerHelper.Install(Names::Find<Node>("D3"));
+
+  // Add /prefix origins to ndn::GlobalRouter
+  ndnGlobalRoutingHelper.AddOrigins("/prefix", Names::Find<Node>("D3"));
+
+  // Calculate and install FIBs
+  GlobalRoutingHelper::CalculateRoutes();
+
+  // Node0 is consumer which is connected to intermediate Node1 and Node2
+
+  FaceContainer::Iterator IntermediateNode1Face1Iterator = node_faceContainer->Begin() + 2; // Node1 with strategy broadcast
+  FaceContainer::Iterator IntermediateNode1Face2Iterator = node_faceContainer->Begin() + 3;
+
+  FaceContainer::Iterator IntermediateNode2Face1Iterator = node_faceContainer->Begin() + 4; // Node2 with strategy best route
+  FaceContainer::Iterator IntermediateNode2Face2Iterator = node_faceContainer->Begin() + 5;
+
+  FaceContainer::Iterator ProducerFaceIterator1 = node_faceContainer->Begin() + 6;
+  FaceContainer::Iterator ProducerFaceIterator2 = node_faceContainer->Begin() + 7;
+
+  auto Producer_netDeviceFace1 = std::dynamic_pointer_cast<NetDeviceFace>(node_faceContainer->Get(ProducerFaceIterator1));
+  auto Producer_netDeviceFace2 = std::dynamic_pointer_cast<NetDeviceFace>(node_faceContainer->Get(ProducerFaceIterator2));
+
+  auto IntermediateNode1_netDeviceFace1 = std::dynamic_pointer_cast<NetDeviceFace>(node_faceContainer->Get(IntermediateNode1Face1Iterator));
+  auto IntermediateNode1_netDeviceFace2 = std::dynamic_pointer_cast<NetDeviceFace>(node_faceContainer->Get(IntermediateNode1Face2Iterator));
+
+  auto IntermediateNode2_netDeviceFace1 = std::dynamic_pointer_cast<NetDeviceFace>(node_faceContainer->Get(IntermediateNode2Face1Iterator));
+  auto IntermediateNode2_netDeviceFace2 = std::dynamic_pointer_cast<NetDeviceFace>(node_faceContainer->Get(IntermediateNode2Face2Iterator));
+
+  Simulator::Stop(Seconds(5.0));
+  Simulator::Run();
+
+  ::ndn::nfd::FaceStatus producerFace1Status = Producer_netDeviceFace1->getFaceStatus();
+  ::ndn::nfd::FaceStatus producerFace2Status = Producer_netDeviceFace2->getFaceStatus();
+
+  ::ndn::nfd::FaceStatus IntermediateNode1Face1Status = IntermediateNode1_netDeviceFace1->getFaceStatus();
+  ::ndn::nfd::FaceStatus IntermediateNode1Face2Status = IntermediateNode1_netDeviceFace2->getFaceStatus();
+
+  ::ndn::nfd::FaceStatus IntermediateNode2Face1Status = IntermediateNode2_netDeviceFace1->getFaceStatus();
+  ::ndn::nfd::FaceStatus IntermediateNode2Face2Status = IntermediateNode2_netDeviceFace2->getFaceStatus();
+
+  BOOST_CHECK_EQUAL(producerFace1Status.getNInInterests(), 500);
+  BOOST_CHECK_EQUAL(producerFace2Status.getNInInterests(), 0);
+  BOOST_CHECK_EQUAL(IntermediateNode1Face1Status.getNInInterests(), 500);
+  BOOST_CHECK_EQUAL(IntermediateNode1Face2Status.getNInInterests(), 0);
+  BOOST_CHECK_EQUAL(IntermediateNode2Face1Status.getNInInterests(), 0);
+  BOOST_CHECK_EQUAL(IntermediateNode2Face2Status.getNInInterests(), 0);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/model/ndn-header.t.cpp b/tests/unit-tests/model/ndn-header.t.cpp
new file mode 100644
index 0000000..3776c8a
--- /dev/null
+++ b/tests/unit-tests/model/ndn-header.t.cpp
@@ -0,0 +1,53 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "model/ndn-header.hpp"
+#include "model/ndn-ns3.hpp"
+#include "helper/ndn-stack-helper.hpp"
+
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/data.hpp>
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(ModelNdnHeader, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(TypeId)
+{
+ auto interest = make_shared<ndn::Interest>("/prefix");
+ PacketHeader<Interest> interestPktHeader(*interest);
+ BOOST_CHECK_EQUAL(interestPktHeader.GetTypeId().GetName().c_str(), "ns3::ndn::Interest");
+
+ auto data = make_shared<ndn::Data>();
+ data->setFreshnessPeriod(ndn::time::milliseconds(1000));
+ data->setContent(std::make_shared< ::ndn::Buffer>(1024));
+ ndn::StackHelper::getKeyChain().sign(*data);
+ PacketHeader<Data> dataPktHeader(*data);
+
+ BOOST_CHECK_EQUAL(dataPktHeader.GetTypeId().GetName().c_str(), "ns3::ndn::Data");
+ BOOST_CHECK_EQUAL(dataPktHeader.GetSerializedSize(), 1354); // 328 + 1024
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/model/ndn-net-device-face.t.cpp b/tests/unit-tests/model/ndn-net-device-face.t.cpp
new file mode 100644
index 0000000..23a6406
--- /dev/null
+++ b/tests/unit-tests/model/ndn-net-device-face.t.cpp
@@ -0,0 +1,138 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+
+#include "model/ndn-net-device-face.hpp"
+#include "model/ndn-l3-protocol.hpp"
+#include "model/ndn-ns3.hpp"
+#include "NFD/daemon/face/face-counters.hpp"
+
+#include <ndn-cxx/management/nfd-face-status.hpp>
+
+#include "ns3/net-device.h"
+#include "ns3/log.h"
+#include "ns3/packet.h"
+#include "ns3/node.h"
+#include "ns3/pointer.h"
+#include "ns3/point-to-point-net-device.h"
+#include "ns3/channel.h"
+#include "ndn-face-container.hpp"
+#include "ns3/node-container.h"
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/point-to-point-module.h"
+#include "ns3/ndnSIM-module.h"
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(ModelNdnNetDeviceFace, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(SendInterest)
+{
+  NodeContainer nodes;
+  nodes.Create(2);
+  PointToPointHelper p2p;
+  p2p.Install(nodes.Get(0), nodes.Get(1));
+
+  StackHelper ndnHelper;
+  ndnHelper.SetDefaultRoutes(true);
+
+  Ptr<FaceContainer> node0_faceContainer = ndnHelper.InstallAll();
+
+  ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
+  consumerHelper.SetPrefix("/prefix");
+  consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second
+  consumerHelper.Install(nodes.Get(0));
+
+  ndn::AppHelper producerHelper("ns3::ndn::Producer");
+  producerHelper.SetPrefix("/prefix");
+  producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
+  producerHelper.Install(nodes.Get(1));
+
+  FaceContainer::Iterator node1Face_iterator = node0_faceContainer->Begin() + 1;
+
+  auto node1_netDeviceFace = std::dynamic_pointer_cast<NetDeviceFace>(node0_faceContainer->Get(node1Face_iterator));
+
+  Simulator::Stop(Seconds(20.0));
+  Simulator::Run();
+
+  ::ndn::nfd::FaceStatus faceStatus = node1_netDeviceFace->getFaceStatus();
+  BOOST_CHECK_EQUAL(faceStatus.getNInInterests(), 2000);
+  Simulator::Destroy();
+}
+
+BOOST_AUTO_TEST_CASE(SendData)
+{
+
+ NodeContainer nodes;
+ nodes.Create(2);
+ PointToPointHelper p2p;
+ p2p.Install(nodes.Get(0), nodes.Get(1));
+
+
+ StackHelper ndnHelper;
+ ndnHelper.SetDefaultRoutes(true);
+
+ Ptr<FaceContainer> node0_faceContainer = ndnHelper.InstallAll();
+
+ ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
+ consumerHelper.SetPrefix("/prefix");
+ consumerHelper.SetAttribute("Frequency", StringValue("10"));
+ consumerHelper.Install(nodes.Get(0));
+
+ ndn::AppHelper producerHelper("ns3::ndn::Producer");
+ producerHelper.SetPrefix("/prefix");
+ producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
+ producerHelper.Install(nodes.Get(1));
+
+ FaceContainer::Iterator node0Face_iterator = node0_faceContainer->Begin();
+ FaceContainer::Iterator node1Face_iterator = node0_faceContainer->Begin() + 1;
+
+ auto node0_netDeviceFace = std::dynamic_pointer_cast<NetDeviceFace>(node0_faceContainer->Get(node0Face_iterator));
+ auto node1_netDeviceFace = std::dynamic_pointer_cast<NetDeviceFace>(node0_faceContainer->Get(node1Face_iterator));
+
+ auto interest = std::make_shared<ndn::Interest>("/prefix");
+ UniformVariable rand(0, std::numeric_limits<uint32_t>::max());
+ interest->setNonce(rand.GetValue());
+ interest->setInterestLifetime(ndn::time::seconds(1));
+
+ auto data = std::make_shared<ndn::Data>(interest->getName());
+ data->setFreshnessPeriod(ndn::time::milliseconds(1000));
+ data->setContent(std::make_shared< ::ndn::Buffer>(1024));
+ ndn::StackHelper::getKeyChain().sign(*data);
+
+ node1_netDeviceFace->sendData(*data);
+
+ Simulator::Stop(Seconds(20.0));
+ Simulator::Run();
+
+ ::ndn::nfd::FaceStatus node0faceStatus = node0_netDeviceFace->getFaceStatus();
+ ::ndn::nfd::FaceStatus node1faceStatus = node1_netDeviceFace->getFaceStatus();
+ BOOST_CHECK_EQUAL(node1faceStatus.getNOutDatas(), 201);
+ Simulator::Destroy();
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/model/ndn-ns3.t.cpp b/tests/unit-tests/model/ndn-ns3.t.cpp
new file mode 100644
index 0000000..bd94360
--- /dev/null
+++ b/tests/unit-tests/model/ndn-ns3.t.cpp
@@ -0,0 +1,60 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#include "model/ndn-ns3.hpp"
+#include "helper/ndn-stack-helper.hpp"
+#include "model/ndn-header.hpp"
+#include "utils/ndn-ns3-packet-tag.hpp"
+
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/name.hpp>
+
+#include "../tests-common.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+BOOST_FIXTURE_TEST_SUITE(ModelNdnNs3, CleanupFixture)
+
+BOOST_AUTO_TEST_CASE(ToPacket)
+{
+  auto interest = make_shared<ndn::Interest>("/prefix");
+  Ptr<Packet> interestPacket = Convert::ToPacket(*interest);
+  uint32_t type1;
+  type1 = Convert::getPacketType(interestPacket);
+
+  BOOST_CHECK_EQUAL(type1, ::ndn::tlv::Interest);
+
+  auto data = std::make_shared<ndn::Data>(interest->getName());
+  data->setFreshnessPeriod(ndn::time::milliseconds(1000));
+  data->setContent(std::make_shared< ::ndn::Buffer>(1024));
+  ndn::StackHelper::getKeyChain().sign(*data);
+  Ptr<Packet> DataPacket = Convert::ToPacket(*data);
+  uint32_t type2;
+  type2 = Convert::getPacketType(DataPacket);
+
+  BOOST_CHECK_EQUAL(type2, ::ndn::tlv::Data);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+} // namespace ndn
+} // namespace ns3
diff --git a/tests/unit-tests/tests-common.hpp b/tests/unit-tests/tests-common.hpp
new file mode 100644
index 0000000..1c51eae
--- /dev/null
+++ b/tests/unit-tests/tests-common.hpp
@@ -0,0 +1,44 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2015  Regents of the University of California.
+ *
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
+ *
+ * ndnSIM is free software: you can redistribute it and/or modify it under the terms
+ * of the GNU General Public License as published by the Free Software Foundation,
+ * either version 3 of the License, or (at your option) any later version.
+ *
+ * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+ * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE.  See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * ndnSIM, e.g., in COPYING.md file.  If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+#ifndef NDNSIM_TESTS_UNIT_TESTS_TESTS_COMMON_HPP
+#define NDNSIM_TESTS_UNIT_TESTS_TESTS_COMMON_HPP
+
+#include "ns3/core-module.h"
+#include "boost-test.hpp"
+#include "model/ndn-global-router.hpp"
+
+namespace ns3 {
+namespace ndn {
+
+class CleanupFixture
+{
+public:
+  ~CleanupFixture()
+  {
+    Simulator::Destroy();
+    Names::Clear();
+    GlobalRouter::clear();
+  }
+};
+
+} // namespace ndn
+} // namespace ns3
+
+#endif // NDNSIM_TESTS_UNIT_TESTS_TESTS_COMMON_HPP