ndnSIM-v2: Initial implementation

- Name, name::Components, Interest, Data now use ndn-cxx
- Ptr is replaced with shared_ptr for ndn-cxx structures

Credits for the change also to Mickey Sweat, Wentao Shang, and Alex Afanasyev
diff --git a/model/cs/content-store-impl.hpp b/model/cs/content-store-impl.hpp
index b35fdb4..4692486 100644
--- a/model/cs/content-store-impl.hpp
+++ b/model/cs/content-store-impl.hpp
@@ -21,11 +21,11 @@
 #ifndef NDN_CONTENT_STORE_IMPL_H_
 #define NDN_CONTENT_STORE_IMPL_H_
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ndn-content-store.hpp"
 
 #include "ns3/packet.h"
-#include "ns3/ndn-interest.h"
-#include "ns3/ndn-data.h"
 #include <boost/foreach.hpp>
 
 #include "ns3/log.h"
@@ -48,7 +48,7 @@
   typedef Entry base_type;
 
 public:
-  EntryImpl(Ptr<ContentStore> cs, Ptr<const Data> data)
+  EntryImpl(Ptr<ContentStore> cs, shared_ptr<const Data> data)
     : Entry(cs, data)
     , item_(0)
   {
@@ -103,14 +103,14 @@
 
   // from ContentStore
 
-  virtual inline Ptr<Data>
-  Lookup(Ptr<const Interest> interest);
+  virtual inline shared_ptr<Data>
+  Lookup(shared_ptr<const Interest> interest);
 
   virtual inline bool
-  Add(Ptr<const Data> data);
+  Add(shared_ptr<const Data> data);
 
   // virtual bool
-  // Remove (Ptr<Interest> header);
+  // Remove (shared_ptr<Interest> header);
 
   virtual inline void
   Print(std::ostream& os) const;
@@ -200,8 +200,8 @@
 };
 
 template<class Policy>
-Ptr<Data>
-ContentStoreImpl<Policy>::Lookup(Ptr<const Interest> interest)
+shared_ptr<Data>
+ContentStoreImpl<Policy>::Lookup(shared_ptr<const Interest> interest)
 {
   NS_LOG_FUNCTION(this << interest->GetName());
 
@@ -217,7 +217,7 @@
   if (node != this->end()) {
     this->m_cacheHitsTrace(interest, node->payload()->GetData());
 
-    Ptr<Data> copy = Create<Data>(*node->payload()->GetData());
+    shared_ptr<Data> copy = make_shared<Data>(*node->payload()->GetData());
     ConstCast<Packet>(copy->GetPayload())->RemoveAllPacketTags();
     return copy;
   }
@@ -229,7 +229,7 @@
 
 template<class Policy>
 bool
-ContentStoreImpl<Policy>::Add(Ptr<const Data> data)
+ContentStoreImpl<Policy>::Add(shared_ptr<const Data> data)
 {
   NS_LOG_FUNCTION(this << data->GetName());
 
diff --git a/model/cs/content-store-nocache.cpp b/model/cs/content-store-nocache.cpp
index 85505d1..9aef87b 100644
--- a/model/cs/content-store-nocache.cpp
+++ b/model/cs/content-store-nocache.cpp
@@ -52,15 +52,15 @@
 {
 }
 
-Ptr<Data>
-Nocache::Lookup(Ptr<const Interest> interest)
+shared_ptr<Data>
+Nocache::Lookup(shared_ptr<const Interest> interest)
 {
   this->m_cacheMissesTrace(interest);
   return 0;
 }
 
 bool
-Nocache::Add(Ptr<const Data> data)
+Nocache::Add(shared_ptr<const Data> data)
 {
   return false;
 }
diff --git a/model/cs/content-store-nocache.hpp b/model/cs/content-store-nocache.hpp
index 5745821..bf271cb 100644
--- a/model/cs/content-store-nocache.hpp
+++ b/model/cs/content-store-nocache.hpp
@@ -22,6 +22,8 @@
 #ifndef NDN_CONTENT_STORE_NOCACHE_H
 #define NDN_CONTENT_STORE_NOCACHE_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/ndnSIM/model/cs/ndn-content-store.hpp"
 
 namespace ns3 {
@@ -52,11 +54,11 @@
    */
   virtual ~Nocache();
 
-  virtual Ptr<Data>
-  Lookup(Ptr<const Interest> interest);
+  virtual shared_ptr<Data>
+  Lookup(shared_ptr<const Interest> interest);
 
   virtual bool
-  Add(Ptr<const Data> data);
+  Add(shared_ptr<const Data> data);
 
   virtual void
   Print(std::ostream& os) const;
diff --git a/model/cs/content-store-with-freshness.hpp b/model/cs/content-store-with-freshness.hpp
index 07aa56f..836a94f 100644
--- a/model/cs/content-store-with-freshness.hpp
+++ b/model/cs/content-store-with-freshness.hpp
@@ -21,7 +21,7 @@
 #ifndef NDN_CONTENT_STORE_WITH_FRESHNESS_H_
 #define NDN_CONTENT_STORE_WITH_FRESHNESS_H_
 
-#include "content-store-impl.h"
+#include "ns3/ndnSIM/model/ndn-common.hpp"
 
 #include "content-store-impl.hpp"
 
@@ -57,7 +57,7 @@
   Print(std::ostream& os) const;
 
   virtual inline bool
-  Add(Ptr<const Data> data);
+  Add(shared_ptr<const Data> data);
 
 private:
   inline void
@@ -98,7 +98,7 @@
 
 template<class Policy>
 inline bool
-ContentStoreWithFreshness<Policy>::Add(Ptr<const Data> data)
+ContentStoreWithFreshness<Policy>::Add(shared_ptr<const Data> data)
 {
   bool ok = super::Add(data);
   if (!ok)
diff --git a/model/cs/content-store-with-probability.hpp b/model/cs/content-store-with-probability.hpp
index cca50c1..b442e4a 100644
--- a/model/cs/content-store-with-probability.hpp
+++ b/model/cs/content-store-with-probability.hpp
@@ -21,7 +21,7 @@
 #ifndef NDN_CONTENT_STORE_WITH_PROBABILITY_H_
 #define NDN_CONTENT_STORE_WITH_PROBABILITY_H_
 
-#include "content-store-impl.h"
+#include "ns3/ndnSIM/model/ndn-common.hpp"
 
 #include "content-store-impl.hpp"
 
diff --git a/model/cs/content-store-with-stats.hpp b/model/cs/content-store-with-stats.hpp
index b5f7540..f1ba5b2 100644
--- a/model/cs/content-store-with-stats.hpp
+++ b/model/cs/content-store-with-stats.hpp
@@ -21,7 +21,7 @@
 #ifndef NDN_CONTENT_STORE_WITH_STATS_H_
 #define NDN_CONTENT_STORE_WITH_STATS_H_
 
-#include "content-store-impl.h"
+#include "ns3/ndnSIM/model/ndn-common.hpp"
 
 #include "content-store-impl.hpp"
 
diff --git a/model/cs/custom-policies/freshness-policy.hpp b/model/cs/custom-policies/freshness-policy.hpp
index 999c61d..9d66c66 100644
--- a/model/cs/custom-policies/freshness-policy.hpp
+++ b/model/cs/custom-policies/freshness-policy.hpp
@@ -21,6 +21,8 @@
 #ifndef FRESHNESS_POLICY_H_
 #define FRESHNESS_POLICY_H_
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include <boost/intrusive/options.hpp>
 #include <boost/intrusive/list.hpp>
 
diff --git a/model/cs/custom-policies/lifetime-stats-policy.hpp b/model/cs/custom-policies/lifetime-stats-policy.hpp
index 1102ef1..1abf39d 100644
--- a/model/cs/custom-policies/lifetime-stats-policy.hpp
+++ b/model/cs/custom-policies/lifetime-stats-policy.hpp
@@ -21,6 +21,8 @@
 #ifndef LIFETIME_STATS_POLICY_H_
 #define LIFETIME_STATS_POLICY_H_
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include <boost/intrusive/options.hpp>
 #include <boost/intrusive/list.hpp>
 
diff --git a/model/cs/custom-policies/probability-policy.hpp b/model/cs/custom-policies/probability-policy.hpp
index 57d6835..8638c0a 100644
--- a/model/cs/custom-policies/probability-policy.hpp
+++ b/model/cs/custom-policies/probability-policy.hpp
@@ -21,6 +21,8 @@
 #ifndef PROBABILITY_POLICY_H_
 #define PROBABILITY_POLICY_H_
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include <boost/intrusive/options.hpp>
 #include <boost/intrusive/list.hpp>
 
diff --git a/model/cs/ndn-content-store.cpp b/model/cs/ndn-content-store.cpp
index 3588eb9..8df04c6 100644
--- a/model/cs/ndn-content-store.cpp
+++ b/model/cs/ndn-content-store.cpp
@@ -57,7 +57,7 @@
 
 //////////////////////////////////////////////////////////////////////
 
-Entry::Entry(Ptr<ContentStore> cs, Ptr<const Data> data)
+Entry::Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data)
   : m_cs(cs)
   , m_data(data)
 {
@@ -69,7 +69,7 @@
   return m_data->GetName();
 }
 
-Ptr<const Data>
+shared_ptr<const Data>
 Entry::GetData() const
 {
   return m_data;
diff --git a/model/cs/ndn-content-store.hpp b/model/cs/ndn-content-store.hpp
index 23266c4..e28eea0 100644
--- a/model/cs/ndn-content-store.hpp
+++ b/model/cs/ndn-content-store.hpp
@@ -22,6 +22,8 @@
 #ifndef NDN_CONTENT_STORE_H
 #define NDN_CONTENT_STORE_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/object.h"
 #include "ns3/ptr.h"
 #include "ns3/traced-callback.h"
@@ -65,7 +67,7 @@
    * The constructor will make a copy of the supplied packet and calls
    * RemoveHeader and RemoveTail on the copy.
    */
-  Entry(Ptr<ContentStore> cs, Ptr<const Data> data);
+  Entry(Ptr<ContentStore> cs, shared_ptr<const Data> data);
 
   /**
    * \brief Get prefix of the stored entry
@@ -78,7 +80,7 @@
    * \brief Get Data of the stored entry
    * \returns Data of the stored entry
    */
-  Ptr<const Data>
+  shared_ptr<const Data>
   GetData() const;
 
   /**
@@ -89,7 +91,7 @@
 
 private:
   Ptr<ContentStore> m_cs; ///< \brief content store to which entry is added
-  Ptr<const Data> m_data; ///< \brief non-modifiable Data
+  shared_ptr<const Data> m_data; ///< \brief non-modifiable Data
 };
 
 } // namespace cs
@@ -124,8 +126,8 @@
    * If an entry is found, it is promoted to the top of most recent
    * used entries index, \see m_contentStore
    */
-  virtual Ptr<Data>
-  Lookup(Ptr<const Interest> interest) = 0;
+  virtual shared_ptr<Data>
+  Lookup(shared_ptr<const Interest> interest) = 0;
 
   /**
    * \brief Add a new content to the content store.
@@ -136,7 +138,7 @@
    * @returns true if an existing entry was updated, false otherwise
    */
   virtual bool
-  Add(Ptr<const Data> data) = 0;
+  Add(shared_ptr<const Data> data) = 0;
 
   // /*
   //  * \brief Add a new content to the content store.
@@ -145,7 +147,7 @@
   //  * @returns true if an existing entry was removed, false otherwise
   //  */
   // virtual bool
-  // Remove (Ptr<Interest> header) = 0;
+  // Remove (shared_ptr<Interest> header) = 0;
 
   /**
    * \brief Print out content store entries
@@ -187,10 +189,10 @@
   GetContentStore(Ptr<Object> node);
 
 protected:
-  TracedCallback<Ptr<const Interest>,
-                 Ptr<const Data>> m_cacheHitsTrace; ///< @brief trace of cache hits
+  TracedCallback<shared_ptr<const Interest>,
+                 shared_ptr<const Data>> m_cacheHitsTrace; ///< @brief trace of cache hits
 
-  TracedCallback<Ptr<const Interest>> m_cacheMissesTrace; ///< @brief trace of cache misses
+  TracedCallback<shared_ptr<const Interest>> m_cacheMissesTrace; ///< @brief trace of cache misses
 };
 
 inline std::ostream&
diff --git a/model/ip-faces/ndn-ip-face-stack.hpp b/model/ip-faces/ndn-ip-face-stack.hpp
index a9322c6..577ad5a 100644
--- a/model/ip-faces/ndn-ip-face-stack.hpp
+++ b/model/ip-faces/ndn-ip-face-stack.hpp
@@ -22,11 +22,12 @@
 #ifndef NDN_IP_FACE_STACK_H
 #define NDN_IP_FACE_STACK_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/application.h"
 #include "ns3/socket.h"
 #include "ns3/inet-socket-address.h"
 #include "ns3/ptr.h"
-#include "ns3/ndn-name.hpp"
 
 #include <map>
 
diff --git a/model/ip-faces/ndn-ip-faces-helper.hpp b/model/ip-faces/ndn-ip-faces-helper.hpp
index 928a766..b167437 100644
--- a/model/ip-faces/ndn-ip-faces-helper.hpp
+++ b/model/ip-faces/ndn-ip-faces-helper.hpp
@@ -22,6 +22,8 @@
 #ifndef NDN_IP_FACES_HELPER_H
 #define NDN_IP_FACES_HELPER_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/ptr.h"
 #include "ns3/nstime.h"
 #include "ns3/ipv4-address.h"
diff --git a/model/ip-faces/ndn-tcp-face.cpp b/model/ip-faces/ndn-tcp-face.cpp
index 701ad64..9f24986 100644
--- a/model/ip-faces/ndn-tcp-face.cpp
+++ b/model/ip-faces/ndn-tcp-face.cpp
@@ -30,8 +30,6 @@
 #include "ns3/pointer.h"
 #include "ns3/tcp-socket-factory.h"
 
-#include "ns3/ndn-name.hpp"
-
 using namespace std;
 
 NS_LOG_COMPONENT_DEFINE("ndn.TcpFace");
diff --git a/model/ip-faces/ndn-tcp-face.hpp b/model/ip-faces/ndn-tcp-face.hpp
index 0543bd5..9f1ad88 100644
--- a/model/ip-faces/ndn-tcp-face.hpp
+++ b/model/ip-faces/ndn-tcp-face.hpp
@@ -21,6 +21,8 @@
 #ifndef NDN_TCP_FACE_H
 #define NDN_TCP_FACE_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/ndn-face.hpp"
 #include "ns3/socket.h"
 #include "ns3/ptr.h"
diff --git a/model/ip-faces/ndn-udp-face.cpp b/model/ip-faces/ndn-udp-face.cpp
index fed972c..414ccd8 100644
--- a/model/ip-faces/ndn-udp-face.cpp
+++ b/model/ip-faces/ndn-udp-face.cpp
@@ -28,8 +28,6 @@
 #include "ns3/pointer.h"
 #include "ns3/udp-socket-factory.h"
 
-#include "ns3/ndn-name.hpp"
-
 using namespace std;
 
 NS_LOG_COMPONENT_DEFINE("ndn.UdpFace");
diff --git a/model/ip-faces/ndn-udp-face.hpp b/model/ip-faces/ndn-udp-face.hpp
index f0c3293..ec97c99 100644
--- a/model/ip-faces/ndn-udp-face.hpp
+++ b/model/ip-faces/ndn-udp-face.hpp
@@ -21,6 +21,8 @@
 #ifndef NDN_UDP_FACE_H
 #define NDN_UDP_FACE_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/ndn-face.hpp"
 #include "ns3/socket.h"
 #include "ns3/ptr.h"
diff --git a/model/ndn-app-face.cpp b/model/ndn-app-face.cpp
index d267f6b..bc788e9 100644
--- a/model/ndn-app-face.cpp
+++ b/model/ndn-app-face.cpp
@@ -31,9 +31,6 @@
 #include "ns3/ndn-header-helper.hpp"
 #include "ns3/ndn-app.hpp"
 
-#include "ndn-interest.hpp"
-#include "ndn-data.hpp"
-
 NS_LOG_COMPONENT_DEFINE("ndn.AppFace");
 
 namespace ns3 {
@@ -80,7 +77,7 @@
 }
 
 bool
-AppFace::SendInterest(Ptr<const Interest> interest)
+AppFace::SendInterest(shared_ptr<const Interest> interest)
 {
   NS_LOG_FUNCTION(this << interest);
 
@@ -88,16 +85,13 @@
     return false;
   }
 
-  if (interest->GetNack() > 0)
-    m_app->OnNack(interest);
-  else
-    m_app->OnInterest(interest);
+  m_app->OnInterest(interest);
 
   return true;
 }
 
 bool
-AppFace::SendData(Ptr<const Data> data)
+AppFace::SendData(shared_ptr<const Data> data)
 {
   NS_LOG_FUNCTION(this << data);
 
diff --git a/model/ndn-app-face.hpp b/model/ndn-app-face.hpp
index 6d8be19..3e06597 100644
--- a/model/ndn-app-face.hpp
+++ b/model/ndn-app-face.hpp
@@ -22,6 +22,8 @@
 #ifndef NDN_APP_FACE_H
 #define NDN_APP_FACE_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ndn-face.hpp"
 #include "ns3/traced-callback.h"
 
@@ -31,12 +33,6 @@
 
 namespace ndn {
 
-class Interest;
-class Data;
-
-typedef Interest InterestHeader;
-typedef Data DataHeader;
-
 class App;
 
 /**
@@ -63,10 +59,10 @@
   ////////////////////////////////////////////////////////////////////
   // methods overloaded from Face
   virtual bool
-  SendInterest(Ptr<const Interest> interest);
+  SendInterest(shared_ptr<const Interest> interest);
 
   virtual bool
-  SendData(Ptr<const Data> data);
+  SendData(shared_ptr<const Data> data);
 
 public:
   virtual std::ostream&
@@ -76,6 +72,7 @@
 private:
   AppFace();
   AppFace(const AppFace&); ///< \brief Disabled copy constructor
+
   AppFace&
   operator=(const AppFace&); ///< \brief Disabled copy operator
 
diff --git a/model/ndn-common.hpp b/model/ndn-common.hpp
index f5da38b..32fd44f 100644
--- a/model/ndn-common.hpp
+++ b/model/ndn-common.hpp
@@ -1,12 +1,21 @@
-/** -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2013, Regents of the University of California
- *                     Alexander Afanasyev
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2014  Regents of the University of California.
  *
- * BSD license, See the doc/LICENSE file for more information
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
  *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
+ * 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 NDN_COMMON_H
 #define NDN_COMMON_H
@@ -14,40 +23,34 @@
 #include "ns3/nstime.h"
 #include "ns3/simulator.h"
 
-#define NDNSIM_MODE 1
+#include "ndn-ns3.hpp"
 
-#define NDN_NAMESPACE_BEGIN                                                                        \
-  namespace ns3 {                                                                                  \
-  namespace ndn {
-#define NDN_NAMESPACE_END                                                                          \
-  } /*ndn*/                                                                                        \
-  } /*ns3*/
+#include <ndn-cxx/interest.hpp>
+#include <ndn-cxx/encoding/block.hpp>
+#include <ndn-cxx/signature.hpp>
+#include <ndn-cxx/signature-info.hpp>
+#include <ndn-cxx/name.hpp>
+#include <ndn-cxx/data.hpp>
+#include <ndn-cxx/security/key-chain.hpp>
 
-/**
- * @brief NS-3 namespace
- */
 namespace ns3 {
-
-/**
- * @brief ndnSIM namespace
- */
 namespace ndn {
-}
-}
 
-NDN_NAMESPACE_BEGIN
+using ::ndn::Name;
+namespace name = ::ndn::name;
 
-typedef Time TimeInterval;
+using std::shared_ptr;
+using std::make_shared;
 
-namespace time {
+using ::ndn::Interest;
+using ::ndn::Data;
+using ::ndn::KeyLocator;
+using ::ndn::Signature;
+using ::ndn::SignatureInfo;
+using ::ndn::Block;
+using ::ndn::KeyChain;
 
-inline Time
-NowUnixTimestamp()
-{
-  return Simulator::Now();
-}
-}
-
-NDN_NAMESPACE_END
+} // namespace ndn
+} // namespace ns3
 
 #endif // NDN_COMMON_H
diff --git a/model/ndn-face.cpp b/model/ndn-face.cpp
deleted file mode 100644
index 505c2b4..0000000
--- a/model/ndn-face.cpp
+++ /dev/null
@@ -1,276 +0,0 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- *
- */
-
-#include "ndn-face.hpp"
-
-#include "ns3/packet.h"
-#include "ns3/log.h"
-#include "ns3/node.h"
-#include "ns3/assert.h"
-#include "ns3/uinteger.h"
-#include "ns3/double.h"
-#include "ns3/boolean.h"
-#include "ns3/simulator.h"
-#include "ns3/random-variable.h"
-#include "ns3/pointer.h"
-
-#include "ns3/ndn-header-helper.hpp"
-#include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.hpp"
-
-#include "ns3/ndn-wire.h"
-
-#include <boost/ref.hpp>
-
-NS_LOG_COMPONENT_DEFINE("ndn.Face");
-
-namespace ns3 {
-namespace ndn {
-
-NS_OBJECT_ENSURE_REGISTERED(Face);
-
-TypeId
-Face::GetTypeId()
-{
-  static TypeId tid =
-    TypeId("ns3::ndn::Face")
-      .SetParent<Object>()
-      .SetGroupName("Ndn")
-      .AddAttribute("Id", "Face id (unique integer for the Ndn stack on this node)",
-                    TypeId::ATTR_GET, // allow only getting it.
-                    UintegerValue(0), MakeUintegerAccessor(&Face::m_id),
-                    MakeUintegerChecker<uint32_t>());
-  return tid;
-}
-
-/**
- * By default, Ndn face are created in the "down" state
- *  with no IP addresses.  Before becoming useable, the user must
- * invoke SetUp on them once an Ndn address and mask have been set.
- */
-Face::Face(Ptr<Node> node)
-  : m_node(node)
-  , m_upstreamInterestHandler(MakeNullCallback<void, Ptr<Face>, Ptr<Interest>>())
-  , m_upstreamDataHandler(MakeNullCallback<void, Ptr<Face>, Ptr<Data>>())
-  , m_ifup(false)
-  , m_id((uint32_t)-1)
-  , m_metric(0)
-  , m_flags(0)
-{
-  NS_LOG_FUNCTION(this << node);
-
-  NS_ASSERT_MSG(node != 0, "node cannot be NULL. Check the code");
-}
-
-Face::~Face()
-{
-  NS_LOG_FUNCTION_NOARGS();
-}
-
-Face::Face(const Face&)
-{
-}
-
-Face& Face::operator= (const Face &)
-{
-  return *this;
-}
-
-Ptr<Node>
-Face::GetNode() const
-{
-  return m_node;
-}
-
-void
-Face::RegisterProtocolHandlers(const InterestHandler& interestHandler,
-                               const DataHandler& dataHandler)
-{
-  NS_LOG_FUNCTION_NOARGS();
-
-  m_upstreamInterestHandler = interestHandler;
-  m_upstreamDataHandler = dataHandler;
-}
-
-void
-Face::UnRegisterProtocolHandlers()
-{
-  NS_LOG_FUNCTION_NOARGS();
-
-  m_upstreamInterestHandler = MakeNullCallback<void, Ptr<Face>, Ptr<Interest>>();
-  m_upstreamDataHandler = MakeNullCallback<void, Ptr<Face>, Ptr<Data>>();
-}
-
-bool
-Face::SendInterest(Ptr<const Interest> interest)
-{
-  NS_LOG_FUNCTION(this << boost::cref(*this) << interest->GetName());
-
-  if (!IsUp()) {
-    return false;
-  }
-
-  return Send(Wire::FromInterest(interest));
-}
-
-bool
-Face::SendData(Ptr<const Data> data)
-{
-  NS_LOG_FUNCTION(this << data);
-
-  if (!IsUp()) {
-    return false;
-  }
-
-  return Send(Wire::FromData(data));
-}
-
-bool
-Face::Send(Ptr<Packet> packet)
-{
-  FwHopCountTag hopCount;
-  bool tagExists = packet->RemovePacketTag(hopCount);
-  if (tagExists) {
-    hopCount.Increment();
-    packet->AddPacketTag(hopCount);
-  }
-
-  return true;
-}
-
-bool
-Face::Receive(Ptr<const Packet> p)
-{
-  NS_LOG_FUNCTION(this << p << p->GetSize());
-
-  if (!IsUp()) {
-    // no tracing here. If we were off while receiving, we shouldn't even know that something was
-    // there
-    return false;
-  }
-
-  Ptr<Packet> packet = p->Copy(); // give upper layers a rw copy of the packet
-  try {
-    HeaderHelper::Type type = HeaderHelper::GetNdnHeaderType(packet);
-    switch (type) {
-    case HeaderHelper::INTEREST_NDNSIM:
-      return ReceiveInterest(Wire::ToInterest(packet, Wire::WIRE_FORMAT_NDNSIM));
-    case HeaderHelper::INTEREST_CCNB:
-      return ReceiveInterest(Wire::ToInterest(packet, Wire::WIRE_FORMAT_CCNB));
-    case HeaderHelper::CONTENT_OBJECT_NDNSIM:
-      return ReceiveData(Wire::ToData(packet, Wire::WIRE_FORMAT_NDNSIM));
-    case HeaderHelper::CONTENT_OBJECT_CCNB:
-      return ReceiveData(Wire::ToData(packet, Wire::WIRE_FORMAT_CCNB));
-    default:
-      NS_FATAL_ERROR("Not supported NDN header");
-      return false;
-    }
-
-    // exception will be thrown if packet is not recognized
-  }
-  catch (UnknownHeaderException) {
-    NS_FATAL_ERROR("Unknown NDN header. Should not happen");
-    return false;
-  }
-
-  return false;
-}
-
-bool
-Face::ReceiveInterest(Ptr<Interest> interest)
-{
-  if (!IsUp()) {
-    // no tracing here. If we were off while receiving, we shouldn't even know that something was
-    // there
-    return false;
-  }
-
-  m_upstreamInterestHandler(this, interest);
-  return true;
-}
-
-bool
-Face::ReceiveData(Ptr<Data> data)
-{
-  if (!IsUp()) {
-    // no tracing here. If we were off while receiving, we shouldn't even know that something was
-    // there
-    return false;
-  }
-
-  m_upstreamDataHandler(this, data);
-  return true;
-}
-
-void
-Face::SetMetric(uint16_t metric)
-{
-  NS_LOG_FUNCTION(metric);
-  m_metric = metric;
-}
-
-uint16_t
-Face::GetMetric(void) const
-{
-  return m_metric;
-}
-
-void
-Face::SetFlags(uint32_t flags)
-{
-  m_flags = flags;
-}
-
-bool
-Face::operator== (const Face &face) const
-{
-  NS_ASSERT_MSG(m_node->GetId() == face.m_node->GetId(),
-                "Faces of different nodes should not be compared to each other: " << *this << " == "
-                                                                                  << face);
-
-  return (m_id == face.m_id);
-}
-
-bool
-Face::operator< (const Face &face) const
-{
-  NS_ASSERT_MSG(m_node->GetId() == face.m_node->GetId(),
-                "Faces of different nodes should not be compared to each other: " << *this << " == "
-                                                                                  << face);
-
-  return (m_id < face.m_id);
-}
-
-std::ostream&
-Face::Print(std::ostream& os) const
-{
-  os << "id=" << GetId();
-  return os;
-}
-
-std::ostream&
-operator<<(std::ostream& os, const Face& face)
-{
-  face.Print(os);
-  return os;
-}
-
-} // namespace ndn
-} // namespace ns3
diff --git a/model/ndn-face.hpp b/model/ndn-face.hpp
index b8cd098..2eeb969 100644
--- a/model/ndn-face.hpp
+++ b/model/ndn-face.hpp
@@ -1,327 +1,32 @@
-/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
-/*
- * Copyright (c) 2011 University of California, Los Angeles
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/**
+ * Copyright (c) 2011-2014  Regents of the University of California.
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation;
+ * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and
+ * contributors.
  *
- * This program 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.
+ * 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.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * 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.
  *
- * Authors: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
- */
+ * 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 NDN_FACE_H
-#define NDN_FACE_H
-
-#include <ostream>
-#include <algorithm>
-
-#include "ns3/ptr.h"
-#include "ns3/object.h"
-#include "ns3/nstime.h"
-#include "ns3/type-id.h"
-#include "ns3/traced-callback.h"
-#include "ns3/ndn-name.hpp"
+#ifndef NDNSIM_NDN_FACE_HPP
+#define NDNSIM_NDN_FACE_HPP
 
 namespace ns3 {
-
-class Packet;
-class Node;
-
 namespace ndn {
 
-class Interest;
-class Data;
-
-/**
- * \ingroup ndn
- * \defgroup ndn-face Faces
- */
-/**
- * \ingroup ndn-face
- * \brief Virtual class defining NDN face
- *
- * 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 ndn::AppFace, ndn::NetDeviceFace
- */
-class Face : public Object {
-public:
-  static TypeId
-  GetTypeId();
-
-  /**
-   * \brief NDN protocol handlers
-   *
-   * \param face Face from which packet has been received
-   * \param packet Original packet
-   */
-  typedef Callback<void, Ptr<Face>, Ptr<Interest>> InterestHandler;
-  typedef Callback<void, Ptr<Face>, Ptr<Data>> DataHandler;
-
-  /**
-   * \brief Default constructor
-   */
-  Face(Ptr<Node> node);
-  virtual ~Face();
-
-  /**
-   * @brief Get node to which this face is associated
-   */
-  Ptr<Node>
-  GetNode() const;
-
-  ////////////////////////////////////////////////////////////////////
-
-  /**
-   * \brief Register callback to call when new packet arrives on the face
-   *
-   * This method should call protocol-dependent registration function
-   */
-  virtual void
-  RegisterProtocolHandlers(const InterestHandler& interestHandler, const DataHandler& dataHandler);
-
-  /**
-   * \brief Un-Register callback to call when new packet arrives on the face
-   *
-   * This method should call protocol-dependent registration function
-   */
-  virtual void
-  UnRegisterProtocolHandlers();
-
-  /**
-   * @brief Send out interest through the face
-   * @param interest Interest to send out
-   * @param packet "payload" that is attached to the interest (can carry some packet tags)
-   *
-   * @returns true if interest is considered to be send out (enqueued)
-   */
-  virtual bool
-  SendInterest(Ptr<const Interest> interest);
-
-  /**
-   * @brief Send out Dat packet through the face
-   * @param data Data packet to send out
-   * @param packet Data packet payload, can also carry packet tags
-   *
-   * @returns true if Data packet is considered to be send out (enqueued)
-   */
-  virtual bool
-  SendData(Ptr<const Data> data);
-
-  /**
-   * \brief Receive interest from application or another node and forward it up to the NDN stack
-   *
-   * By default it is called from inside Receive method, but can be used directly, if appropriate
-   */
-  virtual bool
-  ReceiveInterest(Ptr<Interest> interest);
-
-  /**
-   * \brief Receive Data packet from application or another node and forward it up to the NDN stack
-   *
-   * By default it is called from inside Receive method, but can be used directly, if appropriate
-   */
-  virtual bool
-  ReceiveData(Ptr<Data> data);
-  ////////////////////////////////////////////////////////////////////
-
-  /**
-   * \brief Assign routing/forwarding metric with face
-   *
-   * \param metric configured routing metric (cost) of this face
-   */
-  virtual void
-  SetMetric(uint16_t metric);
-
-  /**
-   * \brief Get routing/forwarding metric assigned to the face
-   *
-   * \returns configured routing/forwarding metric (cost) of this face
-   */
-  virtual uint16_t
-  GetMetric(void) const;
-
-  /**
-   * These are face states and may be distinct from actual lower-layer
-   * device states, such as found in real implementations (where the
-   * device may be down but ndn face state is still up).
-   */
-
-  /**
-   * \brief Enable or disable this face
-   */
-  inline void
-  SetUp(bool up = true);
-
-  /**
-   * \brief Returns true if this face is enabled, false otherwise.
-   */
-  inline bool
-  IsUp() const;
-
-  /**
-   * @brief Get face flags
-   *
-   * Face flags may indicate various properties of the face.  For example, if the face is an
-   *application face,
-   * than the returned flags have Face::APPLICATION bit set.
-   *
-   * @see ndn::Face::Flags for the list of currently defined face flags
-   */
-  inline uint32_t
-  GetFlags() const;
-
-  /**
-   * @brief List of currently defined face flags
-   */
-  enum Flags {
-    APPLICATION = 1 ///< @brief An application face
-  };
-
-  /**
-   * @brief Print information about the face into the stream
-   * @param os stream to write information to
-   */
-  virtual std::ostream&
-  Print(std::ostream& os) const;
-
-  /**
-   * \brief Set face Id
-   *
-   * Id is purely informative and should not be used for any other purpose
-   *
-   * \param id id to set
-   */
-  inline void
-  SetId(uint32_t id);
-
-  /**
-   * \brief Get face Id
-   *
-   * Id is purely informative and should not be used for any other purpose
-   *
-   * \returns id id to set
-   */
-  inline uint32_t
-  GetId() const;
-
-  /**
-   * \brief Compare two faces. Only two faces on the same node could be compared.
-   *
-   * Internal index is used for comparison.
-   */
-  bool
-  operator==(const Face& face) const;
-
-  /**
-   * \brief Compare two faces. Only two faces on the same node could be compared.
-   *
-   * Internal index is used for comparison.
-   */
-  inline bool
-  operator!=(const Face& face) const;
-
-  /**
-   * \brief Compare two faces. Only two faces on the same node could be compared.
-   *
-   * Internal index is used for comparison.
-   */
-  bool
-  operator<(const Face& face) const;
-
-protected:
-  /**
-   * @brief Send packet down to the stack (towards app or network)
-   */
-  virtual bool
-  Send(Ptr<Packet> packet);
-
-  /**
-   * @brief Send packet up to the stack (towards forwarding strategy)
-   */
-  virtual bool
-  Receive(Ptr<const Packet> p);
-
-  /**
-   * @brief Set face flags
-   */
-  void
-  SetFlags(uint32_t flags);
-
-private:
-  Face(const Face&); ///< \brief Disabled copy constructor
-  Face&
-  operator=(const Face&); ///< \brief Disabled copy operator
-
-protected:
-  Ptr<Node> m_node; ///< \brief Smart pointer to Node
-
-private:
-  InterestHandler m_upstreamInterestHandler;
-  DataHandler m_upstreamDataHandler;
-  bool m_ifup;
-  uint32_t m_id;     ///< \brief id of the interface in NDN stack (per-node uniqueness)
-  uint16_t m_metric; ///< \brief metric of the face
-  uint32_t m_flags;  ///< @brief faces flags (e.g., APPLICATION)
+class Face {
 };
 
-std::ostream&
-operator<<(std::ostream& os, const Face& face);
-
-inline bool
-Face::IsUp(void) const
-{
-  return m_ifup;
-}
-
-inline void
-Face::SetUp(bool up /* = true*/)
-{
-  m_ifup = up;
-}
-
-inline uint32_t
-Face::GetFlags() const
-{
-  return m_flags;
-}
-
-inline bool
-operator<(const Ptr<Face>& lhs, const Ptr<Face>& rhs)
-{
-  return *lhs < *rhs;
-}
-
-void
-Face::SetId(uint32_t id)
-{
-  m_id = id;
-}
-
-uint32_t
-Face::GetId() const
-{
-  return m_id;
-}
-
-inline bool
-Face::operator!= (const Face &face) const
-{
-  return !(*this == face);
-}
-
 } // namespace ndn
 } // namespace ns3
 
-#endif // NDN_FACE_H
+#endif // NDNSIM_NDN_FACE_HPP
diff --git a/model/ndn-global-router.cpp b/model/ndn-global-router.cpp
index f44a088..19d5654 100644
--- a/model/ndn-global-router.cpp
+++ b/model/ndn-global-router.cpp
@@ -22,12 +22,9 @@
 
 #include "ns3/ndn-l3-protocol.hpp"
 #include "ns3/ndn-face.hpp"
-#include "ns3/ndn-name.hpp"
 
 #include "ns3/channel.h"
 
-using namespace boost;
-
 namespace ns3 {
 namespace ndn {
 
@@ -70,7 +67,7 @@
 }
 
 void
-GlobalRouter::AddLocalPrefix(Ptr<Name> prefix)
+GlobalRouter::AddLocalPrefix(shared_ptr<Name> prefix)
 {
   m_localPrefixes.push_back(prefix);
 }
@@ -78,7 +75,7 @@
 void
 GlobalRouter::AddIncidency(Ptr<Face> face, Ptr<GlobalRouter> gr)
 {
-  m_incidencies.push_back(make_tuple(this, face, gr));
+  m_incidencies.push_back(boost::make_tuple(this, face, gr));
 }
 
 GlobalRouter::IncidencyList&
diff --git a/model/ndn-global-router.hpp b/model/ndn-global-router.hpp
index f680db7..f742656 100644
--- a/model/ndn-global-router.hpp
+++ b/model/ndn-global-router.hpp
@@ -21,6 +21,8 @@
 #ifndef NDN_GLOBAL_ROUTER_H
 #define NDN_GLOBAL_ROUTER_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ns3/object.h"
 #include "ns3/ptr.h"
 
@@ -35,9 +37,6 @@
 
 class L3Protocol;
 class Face;
-class Name;
-
-typedef Name NameComponents;
 
 /**
  * @ingroup ndn
@@ -56,7 +55,7 @@
   /**
    * @brief List of locally exported prefixes
    */
-  typedef std::list<Ptr<Name>> LocalPrefixList;
+  typedef std::list<shared_ptr<Name>> LocalPrefixList;
 
   /**
    * \brief Interface ID
@@ -88,7 +87,7 @@
    * @param prefix Prefix
    */
   void
-  AddLocalPrefix(Ptr<Name> prefix);
+  AddLocalPrefix(shared_ptr<Name> prefix);
 
   /**
    * @brief Add edge to the node
diff --git a/model/ndn-l3-protocol.cpp b/model/ndn-l3-protocol.cpp
index d7505e7..07d38f3 100644
--- a/model/ndn-l3-protocol.cpp
+++ b/model/ndn-l3-protocol.cpp
@@ -33,8 +33,6 @@
 #include "ns3/random-variable.h"
 
 #include "ns3/ndn-pit.hpp"
-#include "ns3/ndn-interest.hpp"
-#include "ns3/ndn-data.hpp"
 
 #include "ns3/ndn-face.hpp"
 #include "ns3/ndn-forwarding-strategy.hpp"
diff --git a/model/ndn-l3-protocol.hpp b/model/ndn-l3-protocol.hpp
index 5b71e3a..cf3d19a 100644
--- a/model/ndn-l3-protocol.hpp
+++ b/model/ndn-l3-protocol.hpp
@@ -21,6 +21,8 @@
 #ifndef NDN_L3_PROTOCOL_H
 #define NDN_L3_PROTOCOL_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include <list>
 #include <vector>
 
diff --git a/model/ndn-net-device-face.cpp b/model/ndn-net-device-face.cpp
index 31d57fc..71c23ce 100644
--- a/model/ndn-net-device-face.cpp
+++ b/model/ndn-net-device-face.cpp
@@ -31,7 +31,6 @@
 // #include "ns3/address.h"
 #include "ns3/point-to-point-net-device.h"
 #include "ns3/channel.h"
-#include "ns3/ndn-name.hpp"
 
 NS_LOG_COMPONENT_DEFINE("ndn.NetDeviceFace");
 
diff --git a/model/ndn-net-device-face.hpp b/model/ndn-net-device-face.hpp
index 5bc8e3a..05acb60 100644
--- a/model/ndn-net-device-face.hpp
+++ b/model/ndn-net-device-face.hpp
@@ -21,6 +21,8 @@
 #ifndef NDN_NET_DEVICE_FACE_H
 #define NDN_NET_DEVICE_FACE_H
 
+#include "ns3/ndnSIM/model/ndn-common.hpp"
+
 #include "ndn-face.hpp"
 #include "ns3/net-device.h"