model: Another set of refactoring/renaming to make code compile (not tested yet)

Refs #1005 (http://redmine.named-data.net/)
diff --git a/model/cs/content-store-impl.h b/model/cs/content-store-impl.h
index 9cd934e..69fa00e 100644
--- a/model/cs/content-store-impl.h
+++ b/model/cs/content-store-impl.h
@@ -156,7 +156,7 @@
 }
 
 template<class Policy>
-Ptr<const ContentObject>
+Ptr<ContentObject>
 ContentStoreImpl<Policy>::Lookup (Ptr<const Interest> interest)
 {
   NS_LOG_FUNCTION (this << interest->GetName ());
@@ -168,7 +168,7 @@
     {
       this->m_cacheHitsTrace (interest, node->payload ()->GetData ());
 
-      Ptr<ContentObject> copy = Create<ContentObject> (node->payload ()->GetData ());
+      Ptr<ContentObject> copy = Create<ContentObject> (*node->payload ()->GetData ());
       ConstCast<Packet> (copy->GetPayload ())->RemoveAllPacketTags ();
       return copy;
     }
diff --git a/model/cs/content-store-with-freshness.h b/model/cs/content-store-with-freshness.h
index 3ba871c..22242b9 100644
--- a/model/cs/content-store-with-freshness.h
+++ b/model/cs/content-store-with-freshness.h
@@ -46,7 +46,7 @@
   Print (std::ostream &os) const;
 
   virtual inline bool
-  Add (Ptr<const ContentObject> header, Ptr<const Packet> packet);
+  Add (Ptr<const ContentObject> data);
 
 private:
   inline void
@@ -95,7 +95,7 @@
   bool ok = super::Add (data);
   if (!ok) return false;
 
-  NS_LOG_DEBUG (header->GetName () << " added to cache");
+  NS_LOG_DEBUG (data->GetName () << " added to cache");
   RescheduleCleaning ();
   return true;
 }
diff --git a/model/cs/custom-policies/freshness-policy.h b/model/cs/custom-policies/freshness-policy.h
index 5fa2a34..b85635e 100644
--- a/model/cs/custom-policies/freshness-policy.h
+++ b/model/cs/custom-policies/freshness-policy.h
@@ -103,7 +103,7 @@
       insert (typename parent_trie::iterator item)
       {
         // get_time (item) = Simulator::Now ();
-        Time freshness = item->payload ()->GetHeader ()->GetFreshness ();
+        Time freshness = item->payload ()->GetData ()->GetFreshness ();
         if (!freshness.IsZero ())
           {
             get_freshness (item) = Simulator::Now () + freshness;
@@ -125,7 +125,7 @@
       inline void
       erase (typename parent_trie::iterator item)
       {
-        if (!item->payload ()->GetHeader ()->GetFreshness ().IsZero ())
+        if (!item->payload ()->GetData ()->GetFreshness ().IsZero ())
           {
             // erase only if freshness is non zero (otherwise an item is not in the policy
             policy_container::erase (policy_container::s_iterator_to (*item));
diff --git a/model/cs/ndn-content-store.cc b/model/cs/ndn-content-store.cc
index cfe362e..f1c25b7 100644
--- a/model/cs/ndn-content-store.cc
+++ b/model/cs/ndn-content-store.cc
@@ -69,7 +69,7 @@
 const Name&
 Entry::GetName () const
 {
-  return m_header->GetName ();
+  return m_data->GetName ();
 }
 
 Ptr<const ContentObject>
diff --git a/model/fw/nacks.cc b/model/fw/nacks.cc
index 357427c..bda2582 100644
--- a/model/fw/nacks.cc
+++ b/model/fw/nacks.cc
@@ -78,7 +78,7 @@
                    Ptr<Interest> interest)
 {
   if (interest->GetNack () > 0)
-    OnNack (inFace, header);
+    OnNack (inFace, interest);
   else
     super::OnInterest (inFace, interest);
 }
@@ -87,10 +87,10 @@
 Nacks::OnNack (Ptr<Face> inFace,
                Ptr<Interest> nack)
 {
-  // NS_LOG_FUNCTION (inFace << header->GetName ());
+  // NS_LOG_FUNCTION (inFace << nack->GetName ());
   m_inNacks (nack, inFace);
 
-  Ptr<pit::Entry> pitEntry = m_pit->Lookup (*header);
+  Ptr<pit::Entry> pitEntry = m_pit->Lookup (*nack);
   if (pitEntry == 0)
     {
       // somebody is doing something bad
@@ -98,7 +98,7 @@
       return;
     }
 
-  DidReceiveValidNack (inFace, header->GetNack (), nack, pitEntry);
+  DidReceiveValidNack (inFace, nack->GetNack (), nack, pitEntry);
 }
 
 void
@@ -136,7 +136,7 @@
 {
   if (m_nacksEnabled)
     {
-      Ptr<Interest> nack = Create<Interest> (*header);
+      Ptr<Interest> nack = Create<Interest> (*interest);
       nack->SetNack (Interest::NACK_GIVEUP_PIT);
 
       FwHopCountTag hopCountTag;
@@ -159,7 +159,7 @@
       pitEntry->ClearOutgoing (); // to force erasure of the record
     }
 
-  super::DidExhaustForwardingOptions (inFace, header, origPacket, pitEntry);
+  super::DidExhaustForwardingOptions (inFace, interest, pitEntry);
 }
 
 void
diff --git a/model/fw/ndn-forwarding-strategy.cc b/model/fw/ndn-forwarding-strategy.cc
index ef61593..df417dd 100644
--- a/model/fw/ndn-forwarding-strategy.cc
+++ b/model/fw/ndn-forwarding-strategy.cc
@@ -261,10 +261,10 @@
       WillSatisfyPendingInterest (inFace, pitEntry);
 
       // Actually satisfy pending interest
-      SatisfyPendingInterest (inFace, header, payload, pitEntry);
+      SatisfyPendingInterest (inFace, data, pitEntry);
 
       // Lookup another PIT entry
-      pitEntry = m_pit->Lookup (*header);
+      pitEntry = m_pit->Lookup (*data);
     }
 }
 
diff --git a/model/ndn-app-face.cc b/model/ndn-app-face.cc
index 23712f2..b66fa92 100644
--- a/model/ndn-app-face.cc
+++ b/model/ndn-app-face.cc
@@ -76,15 +76,16 @@
 {
 }
 
-AppFace& AppFace::operator= (const AppFace &)
+AppFace&
+AppFace::operator= (const AppFace &)
 {
   return *((AppFace*)0);
 }
 
 bool
-Face::SendInterest (Ptr<const Interest> interest, Ptr<const Packet> packet)
+AppFace::SendInterest (Ptr<const Interest> interest)
 {
-  NS_LOG_FUNCTION (this << interest << packet);
+  NS_LOG_FUNCTION (this << interest);
 
   if (!IsUp ())
     {
@@ -92,24 +93,24 @@
     }
 
   if (interest->GetNack () > 0)
-    m_app->OnNack (interest, packet);
+    m_app->OnNack (interest);
   else
-    m_app->OnInterest (interest, packet);
+    m_app->OnInterest (interest);
   
   return true;
 }
 
 bool
-Face::SendData (Ptr<const ContentObject> data, Ptr<const Packet> packet)
+AppFace::SendData (Ptr<const ContentObject> data)
 {
-  NS_LOG_FUNCTION (this << data << packet);
+  NS_LOG_FUNCTION (this << data);
 
   if (!IsUp ())
     {
       return false;
     }
 
-  m_app->OnContentObject (data, packet);
+  m_app->OnContentObject (data);
   return true;
 }
 
diff --git a/model/ndn-app-face.h b/model/ndn-app-face.h
index 4b47fda..5c88b4e 100644
--- a/model/ndn-app-face.h
+++ b/model/ndn-app-face.h
@@ -64,10 +64,10 @@
   ////////////////////////////////////////////////////////////////////
   // methods overloaded from Face
   virtual bool
-  SendInterest (Ptr<const Interest> interest, Ptr<const Packet> packet);
+  SendInterest (Ptr<const Interest> interest);
 
   virtual bool
-  SendData (Ptr<const ContentObject> data, Ptr<const Packet> packet);
+  SendData (Ptr<const ContentObject> data);
 
 public:
   virtual std::ostream&
diff --git a/model/ndn-content-object.cc b/model/ndn-content-object.cc
index d287ca7..7fcb459 100644
--- a/model/ndn-content-object.cc
+++ b/model/ndn-content-object.cc
@@ -30,20 +30,19 @@
 namespace ns3 {
 namespace ndn {
 
-NS_OBJECT_ENSURE_REGISTERED (ContentObject);
-NS_OBJECT_ENSURE_REGISTERED (ContentObjectTail);
-
-ContentObject::ContentObject ()
+ContentObject::ContentObject (Ptr<Packet> payload/* = Create<Packet> ()*/)
   : m_signature (0)
+  , m_payload (payload)
+  , m_wire (0)
 {
 }
 
 ContentObject::ContentObject (const ContentObject &other)
   : m_name (Create<Name> (other.GetName ()))
-  , m_freshness (other->GetFreshness ())
-  , m_timestamp (other->GetTimestamp ())
-  , m_signature (other->GetSignature ())
-  , m_payload (other->GetPayload ()->Copy ())
+  , m_freshness (other.GetFreshness ())
+  , m_timestamp (other.GetTimestamp ())
+  , m_signature (other.GetSignature ())
+  , m_payload (other.GetPayload ()->Copy ())
   , m_wire (0)
 {
 }
@@ -117,5 +116,17 @@
   // os << "<ContentObject><Name>" << GetName () << "</Name><Content>";
 }
 
+void
+ContentObject::SetPayload (Ptr<Packet> payload)
+{
+  m_payload = payload;
+}
+
+Ptr<const Packet>
+ContentObject::GetPayload () const
+{
+  return m_payload;
+}
+
 } // namespace ndn
 } // namespace ns3
diff --git a/model/ndn-content-object.h b/model/ndn-content-object.h
index 387fee1..f586c15 100644
--- a/model/ndn-content-object.h
+++ b/model/ndn-content-object.h
@@ -27,6 +27,7 @@
 #include "ns3/simple-ref-count.h"
 #include "ns3/trailer.h"
 #include "ns3/nstime.h"
+#include "ns3/packet.h"
 
 #include <string>
 #include <vector>
@@ -73,7 +74,7 @@
  *      +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *
  */
-class ContentObject : public SimpleRefCount<ContentObject,Header>
+class ContentObject : public SimpleRefCount<ContentObject>
 {
 public:
   /**
@@ -81,7 +82,7 @@
    *
    * Creates a null header
    **/
-  ContentObject ();
+  ContentObject (Ptr<Packet> payload = Create<Packet> ());
 
   /**
    * @brief Copy constructor
@@ -173,7 +174,7 @@
    *
    * This payload can also carry packet tags
    */
-  Ptr<const Payload>
+  Ptr<const Packet>
   GetPayload () const;
   
   /**
@@ -190,6 +191,12 @@
   inline void
   SetWire (Ptr<const Packet> packet) const;
 
+  /**
+   * @brief Print Interest in plain-text to the specified output stream
+   */
+  void
+  Print (std::ostream &os) const;
+  
 private:
   // NO_ASSIGN
   ContentObject &
@@ -211,6 +218,19 @@
  */
 class ContentObjectException {};
 
+inline Ptr<const Packet>
+ContentObject::GetWire () const
+{
+  return m_wire;
+}
+
+inline void
+ContentObject::SetWire (Ptr<const Packet> packet) const
+{
+  m_wire = packet;
+}
+
+
 } // namespace ndn
 } // namespace ns3
 
diff --git a/model/ndn-face.cc b/model/ndn-face.cc
index 5b72044..5f8d75c 100644
--- a/model/ndn-face.cc
+++ b/model/ndn-face.cc
@@ -32,6 +32,7 @@
 #include "ns3/random-variable.h"
 #include "ns3/pointer.h"
 
+#include "ns3/ndn-header-helper.h"
 #include "ns3/ndnSIM/utils/ndn-fw-hop-count-tag.h"
 #include "ns3/ndnSIM/model/wire/ndnsim.h"
 
@@ -66,7 +67,8 @@
  */
 Face::Face (Ptr<Node> node)
   : m_node (node)
-  , m_protocolHandler (MakeNullCallback<void,const Ptr<Face>&,const Ptr<const Packet>&> ())
+  , m_upstreamInterestHandler (MakeNullCallback< void, Ptr<Face>, Ptr<Interest> > ())
+  , m_upstreamDataHandler (MakeNullCallback< void, Ptr<Face>, Ptr<ContentObject> > ())
   , m_ifup (false)
   , m_id ((uint32_t)-1)
   , m_metric (0)
@@ -111,15 +113,15 @@
 {
   NS_LOG_FUNCTION_NOARGS ();
 
-  m_upstreamInterestHandler = MakeNullCallback< void, const Ptr<Face>&, Ptr<Interest>, Ptr<Packet> > ();
-  m_upstreamDataHandler = MakeNullCallback< void, const Ptr<Face>&, Ptr<ContentObject>, Ptr<Packet> > ();
+  m_upstreamInterestHandler = MakeNullCallback< void, Ptr<Face>, Ptr<Interest> > ();
+  m_upstreamDataHandler = MakeNullCallback< void, Ptr<Face>, Ptr<ContentObject> > ();
 }
 
 
 bool
 Face::SendInterest (Ptr<const Interest> interest)
 {
-  NS_LOG_FUNCTION (this << interest << packet);
+  NS_LOG_FUNCTION (this << interest);
 
   if (!IsUp ())
     {
@@ -133,7 +135,7 @@
 bool
 Face::SendData (Ptr<const ContentObject> data)
 {
-  NS_LOG_FUNCTION (this << data << packet);
+  NS_LOG_FUNCTION (this << data);
 
   if (!IsUp ())
     {
@@ -161,7 +163,7 @@
 bool
 Face::Receive (Ptr<const Packet> p)
 {
-  NS_LOG_FUNCTION (this << packet << packet->GetSize ());
+  NS_LOG_FUNCTION (this << p << p->GetSize ());
 
   if (!IsUp ())
     {
diff --git a/model/ndn-interest.cc b/model/ndn-interest.cc
index 195c4f9..bd8784e 100644
--- a/model/ndn-interest.cc
+++ b/model/ndn-interest.cc
@@ -29,27 +29,25 @@
 namespace ns3 {
 namespace ndn {
 
-NS_OBJECT_ENSURE_REGISTERED (Interest);
-
-Interest::Interest ()
+Interest::Interest (Ptr<Packet> payload/* = Create<Packet> ()*/)
   : m_name ()
   , m_scope (0xFF)
   , m_interestLifetime (Seconds (0))
   , m_nonce (0)
   , m_nackType (NORMAL_INTEREST)
-  , m_payload (0)
+  , m_payload (payload)
   , m_wire (0)
 {
 }
 
 Interest::Interest (const Interest &interest)
-  : m_name                (Create<Name> (interest.GetName ()))
-  , m_scope               (interest.m_scope)
-  , m_interestLifetime    (interest.m_interestLifetime)
-  , m_nonce               (interest.m_nonce)
-  , m_nackType            (interest.m_nackType)
-  , m_payload (interest.GetPayload ()->Copy ())
-  , m_wire (0)
+  : m_name             (Create<Name> (interest.GetName ()))
+  , m_scope            (interest.m_scope)
+  , m_interestLifetime (interest.m_interestLifetime)
+  , m_nonce            (interest.m_nonce)
+  , m_nackType         (interest.m_nackType)
+  , m_payload          (interest.GetPayload ()->Copy ())
+  , m_wire             (0)
 {
 }
 
@@ -138,7 +136,7 @@
   m_payload = payload;
 }
 
-Ptr<const Payload>
+Ptr<const Packet>
 Interest::GetPayload () const
 {
   return m_payload;
diff --git a/model/ndn-interest.h b/model/ndn-interest.h
index c1fb277..32dfcd8 100644
--- a/model/ndn-interest.h
+++ b/model/ndn-interest.h
@@ -26,6 +26,7 @@
 #include "ns3/header.h"
 #include "ns3/simple-ref-count.h"
 #include "ns3/nstime.h"
+#include "ns3/packet.h"
 
 #include <string>
 #include <vector>
@@ -40,7 +41,7 @@
 namespace ndn {
 
 /**
- * @brief NDN Interest (wire formats are defined in wire/*)
+ * @brief NDN Interest (wire formats are defined in wire)
  *
  **/
 class Interest : public SimpleRefCount<Interest>
@@ -51,7 +52,7 @@
    *
    * Creates a null header
    **/
-  Interest ();
+  Interest (Ptr<Packet> payload = Create<Packet> ());
 
   /**
    * @brief Copy constructor
@@ -194,7 +195,7 @@
    *
    * This payload can carry packet tags
    */
-  Ptr<const Payload>
+  Ptr<const Packet>
   GetPayload () const;
   
   /**
@@ -211,6 +212,12 @@
   inline void
   SetWire (Ptr<const Packet> packet) const;
 
+  /**
+   * @brief Print Interest in plain-text to the specified output stream
+   */
+  void
+  Print (std::ostream &os) const;
+  
 private:
   // NO_ASSIGN
   Interest &
@@ -233,9 +240,6 @@
   return m_wire;
 }
 
-/**
- * @brief Set (cache) wire formatted packet
- */
 inline void
 Interest::SetWire (Ptr<const Packet> packet) const
 {
diff --git a/model/ndn-l3-protocol.cc b/model/ndn-l3-protocol.cc
index 59993ac..f0c660d 100644
--- a/model/ndn-l3-protocol.cc
+++ b/model/ndn-l3-protocol.cc
@@ -32,7 +32,6 @@
 #include "ns3/simulator.h"
 #include "ns3/random-variable.h"
 
-#include "ns3/ndn-header-helper.h"
 #include "ns3/ndn-pit.h"
 #include "ns3/ndn-interest.h"
 #include "ns3/ndn-content-object.h"
@@ -51,23 +50,8 @@
 
 const uint16_t L3Protocol::ETHERNET_FRAME_TYPE = 0x7777;
 
-uint64_t L3Protocol::s_interestCounter = 0;
-uint64_t L3Protocol::s_dataCounter = 0;
-
 NS_OBJECT_ENSURE_REGISTERED (L3Protocol);
 
-uint64_t
-L3Protocol::GetInterestCounter ()
-{
-  return s_interestCounter;
-}
-
-uint64_t
-L3Protocol::GetDataCounter ()
-{
-  return s_dataCounter;
-}
-
 TypeId
 L3Protocol::GetTypeId (void)
 {
diff --git a/model/ndn-net-device-face.cc b/model/ndn-net-device-face.cc
index 03a9cca..eb2b357 100644
--- a/model/ndn-net-device-face.cc
+++ b/model/ndn-net-device-face.cc
@@ -95,14 +95,14 @@
 void
 NetDeviceFace:: UnRegisterProtocolHandlers ()
 {
-  m_node->UnRegisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this));
+  m_node->UnregisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, this));
   Face::UnRegisterProtocolHandlers ();
 }
 
 bool
 NetDeviceFace::Send (Ptr<Packet> packet)
 {
-  if (!Face::Send ())
+  if (!Face::Send (packet))
     {
       return false;
     }
diff --git a/model/pit/custom-policies/serialized-size-policy.h b/model/pit/custom-policies/serialized-size-policy.h
index 7cfb506..61f6306 100644
--- a/model/pit/custom-policies/serialized-size-policy.h
+++ b/model/pit/custom-policies/serialized-size-policy.h
@@ -96,7 +96,14 @@
         current_space_used_ -= get_size (item);
         policy_container::erase (*item);
 
-        get_order (item) = item->payload ()->GetInterest ()->GetSerializedSize ();
+        if (item->payload ()->GetInterest ()->GetWire ())
+          {
+            get_order (item) = item->payload ()->GetInterest ()->GetWire ()->GetSize ();
+          }
+        else
+          {
+            get_order (item) = 0;
+          }
         current_space_used_ += get_size (item); // this operation can violate policy constraint, so in some case
                                                 // it may be necessary to remove some other element
         policy_container::insert (*item);
@@ -105,7 +112,11 @@
       inline bool
       insert (typename parent_trie::iterator item)
       {
-        uint32_t interestSize = item->payload ()->GetInterest ()->GetSerializedSize ();
+        uint32_t interestSize = 0;
+        if (item->payload ()->GetInterest ()->GetWire ())
+          {
+            interestSize = item->payload ()->GetInterest ()->GetWire ()->GetSize ();
+          }
 
         // can't use logging here
         NS_LOG_DEBUG ("Number of entries: " << policy_container::size ()
diff --git a/model/pit/ndn-pit-entry.cc b/model/pit/ndn-pit-entry.cc
index 906fcdd..1908dd0 100644
--- a/model/pit/ndn-pit-entry.cc
+++ b/model/pit/ndn-pit-entry.cc
@@ -25,6 +25,7 @@
 #include "ns3/ndn-name.h"
 #include "ns3/ndn-interest.h"
 
+#include "ns3/packet.h"
 #include "ns3/simulator.h"
 #include "ns3/log.h"
 
diff --git a/model/pit/ndn-pit.cc b/model/pit/ndn-pit.cc
index ea84496..079cf3f 100644
--- a/model/pit/ndn-pit.cc
+++ b/model/pit/ndn-pit.cc
@@ -27,6 +27,7 @@
 #include "ns3/nstime.h"
 #include "ns3/uinteger.h"
 #include "ns3/simulator.h"
+#include "ns3/packet.h"
 
 #include <boost/lambda/bind.hpp>
 #include <boost/lambda/lambda.hpp>
diff --git a/model/wire/ndnsim.cc b/model/wire/ndnsim.cc
index 747d264..2152d99 100644
--- a/model/wire/ndnsim.cc
+++ b/model/wire/ndnsim.cc
@@ -10,11 +10,22 @@
 
 #include "ndnsim.h"
 
+using namespace std;
+
+#include <ns3/header.h>
+#include <ns3/packet.h>
+#include <ns3/log.h>
+
+NS_LOG_COMPONENT_DEFINE ("ndn.wire.ndnSIM");
+
 NDN_NAMESPACE_BEGIN
 
 namespace wire {
 namespace ndnSIM {
 
+NS_OBJECT_ENSURE_REGISTERED (Interest);
+NS_OBJECT_ENSURE_REGISTERED (Data);
+
 
 class Name
 {
@@ -29,7 +40,7 @@
   {
   }
 
-  Ptr<Name>
+  Ptr<ndn::Name>
   GetName ()
   {
     return m_name;
@@ -56,7 +67,7 @@
   {
     Buffer::Iterator i = start;
 
-    i.WriteU16 (static_cast<uint16_t> (m_name->GetSerializedSize ()-2));
+    i.WriteU16 (static_cast<uint16_t> (GetSerializedSize ()-2));
 
     for (std::list<std::string>::const_iterator item = m_name->begin ();
          item != m_name->end ();
@@ -119,7 +130,7 @@
 {
   static TypeId tid = TypeId ("ns3::ndn::Interest::ndnSIM")
     .SetGroupName ("Ndn")
-    .AddParent<Header> ()
+    .SetParent<Header> ()
     .AddConstructor<Interest> ()
     ;
   return tid;
@@ -137,10 +148,12 @@
   Ptr<const Packet> p = interest->GetWire ();
   if (!p)
     {
-      p = Create<Packet> (*interest->GetPayload ());
-      Interest wireEncoding (interest);
-      p->AddHeader (wireEncoding);
-      interest->SetWire (p);
+      Ptr<Packet> packet = Create<Packet> (*interest->GetPayload ());
+      Interest wireEncoding (ConstCast<ndn::Interest> (interest));
+      packet->AddHeader (wireEncoding);
+      interest->SetWire (packet);
+
+      p = packet;
     }
   
   return p->Copy ();
@@ -150,7 +163,7 @@
 Interest::FromWire (Ptr<Packet> packet)
 {
   Ptr<ndn::Interest> interest = Create<ndn::Interest> ();
-  // interest->SetWire (packet->Copy ()); /* not sure if this is needed */
+  interest->SetWire (packet->Copy ());
 
   Interest wireEncoding (interest);
   packet->RemoveHeader (wireEncoding);
@@ -166,7 +179,7 @@
   size_t size =
     1/*version*/ + 1 /*type*/ + 2/*length*/ +
     (4/*nonce*/ + 1/*scope*/ + 1/*nack type*/ + 2/*timestamp*/ +
-     (Name (ConstCast<ns3::Name> (m_interest->GetNamePtr ())).GetSerializedSize ()) +
+     (Name (ConstCast<ndn::Name> (m_interest->GetNamePtr ())).GetSerializedSize ()) +
      (2 + 0)/* selectors */ +
      (2 + 0)/* options */);
   
@@ -182,17 +195,17 @@
 
   start.WriteU16 (GetSerializedSize () - 4);
 
-  start.WriteU32 (m_nonce);
-  start.WriteU8 (m_scope);
-  start.WriteU8 (m_nackType);
+  start.WriteU32 (m_interest->GetNonce ());
+  start.WriteU8 (m_interest->GetScope ());
+  start.WriteU8 (m_interest->GetNack ());
 
-  NS_ASSERT_MSG (0 <= m_interest->GetInterestLifetime.ToInteger (Time::S) && m_interest->GetInterestLifetime.ToInteger (Time::S) < 65535,
+  NS_ASSERT_MSG (0 <= m_interest->GetInterestLifetime ().ToInteger (Time::S) && m_interest->GetInterestLifetime ().ToInteger (Time::S) < 65535,
                  "Incorrect InterestLifetime (should not be smaller than 0 and larger than 65535");
   
   // rounding timestamp value to seconds
-  start.WriteU16 (static_cast<uint16_t> (m_interest->GetInterestLifetime.ToInteger (Time::S)));
+  start.WriteU16 (static_cast<uint16_t> (m_interest->GetInterestLifetime ().ToInteger (Time::S)));
 
-  uint32_t offset = Name (ConstCast<ns3::Name> (m_interest->GetNamePtr ())).Serialize (start);
+  uint32_t offset = Name (ConstCast<ndn::Name> (m_interest->GetNamePtr ())).Serialize (start);
   start.Next (offset);
   
   start.WriteU16 (0); // no selectors
@@ -214,13 +227,13 @@
   
   m_interest->SetNonce (i.ReadU32 ());
   m_interest->SetScope (i.ReadU8 ());
-  m_interest->SetNackType (i.ReadU8 ());
+  m_interest->SetNack (i.ReadU8 ());
 
   m_interest->SetInterestLifetime (Seconds (i.ReadU16 ()));
 
   Name name;
   uint32_t offset = name.Deserialize (i);
-  m_interest->SetName (name->GetName ());
+  m_interest->SetName (name.GetName ());
   i.Next (offset);
   
   i.ReadU16 ();
@@ -231,6 +244,12 @@
   return i.GetDistanceFrom (start);
 }
 
+void
+Interest::Print (std::ostream &os) const
+{
+  m_interest->Print (os);
+}
+
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -265,7 +284,7 @@
 }
 
 Ptr<ndn::ContentObject>
-GetData ()
+Data::GetData ()
 {
   return m_data;
 }
@@ -276,10 +295,12 @@
   Ptr<const Packet> p = data->GetWire ();
   if (!p)
     {
-      p = Create<Packet> (*data->GetPayload ());
-      Data wireEncoding (data);
-      p->AddHeader (wireEncoding);
-      data->SetWire (p);
+      Ptr<Packet> packet = Create<Packet> (*data->GetPayload ());
+      Data wireEncoding (ConstCast<ndn::ContentObject> (data));
+      packet->AddHeader (wireEncoding);
+      data->SetWire (packet);
+
+      p = packet;
     }
   
   return p->Copy ();
@@ -289,7 +310,7 @@
 Data::FromWire (Ptr<Packet> packet)
 {
   Ptr<ndn::ContentObject> data = Create<ndn::ContentObject> ();
-  // data->SetWire (packet->Copy ()); /* not sure if this is needed */
+  data->SetWire (packet->Copy ());
 
   Data wireEncoding (data);
   packet->RemoveHeader (wireEncoding);
@@ -303,7 +324,7 @@
 Data::GetSerializedSize () const
 {
   uint32_t size = 1 + 1 + 2 +
-    ((2 + 2) + (Name (ConstCast<ns3::Name> (m_data->GetNamePtr ())).GetSerializedSize ()) + (2 + 2 + 4 + 2 + 2 + (2 + 0)));
+    ((2 + 2) + (Name (ConstCast<ndn::Name> (m_data->GetNamePtr ())).GetSerializedSize ()) + (2 + 2 + 4 + 2 + 2 + (2 + 0)));
   if (m_data->GetSignature () != 0)
     size += 4;
   
@@ -331,15 +352,15 @@
     }
 
   // name
-  uint32_t offset = Name (ConstCast<ns3::Name> (m_data->GetNamePtr ())).Serialize (start);
+  uint32_t offset = Name (ConstCast<ndn::Name> (m_data->GetNamePtr ())).Serialize (start);
   start.Next (offset);
 
   // content
   // for now assume that contentdata length is zero
   start.WriteU16 (2 + 4 + 2 + 2 + (2 + 0));
   start.WriteU16 (4 + 2 + 2 + (2 + 0));
-  start.WriteU32 (static_cast<uint32_t> (m_data->GetTimestamp.ToInteger (Time::S)));
-  start.WriteU16 (static_cast<uint16_t> (m_data->GetFreshness.ToInteger (Time::S)));
+  start.WriteU32 (static_cast<uint32_t> (m_data->GetTimestamp ().ToInteger (Time::S)));
+  start.WriteU16 (static_cast<uint16_t> (m_data->GetFreshness ().ToInteger (Time::S)));
   start.WriteU16 (0); // reserved 
   start.WriteU16 (0); // Length (ContentInfoOptions)
 
@@ -364,20 +385,20 @@
     {
       if (i.ReadU16 () != 0xFF00) // signature type
         throw new ContentObjectException ();
-      m_data.SetSignature (i.ReadU32 ());
+      m_data->SetSignature (i.ReadU32 ());
     }
   else if (signatureLength == 2)
     {
       if (i.ReadU16 () != 0) // signature type
         throw new ContentObjectException ();
-      m_data.SetSignature (0);
+      m_data->SetSignature (0);
     }
   else
     throw new ContentObjectException ();
 
   Name name;
   uint32_t offset = name.Deserialize (i);
-  m_data->SetName (name->GetName ());
+  m_data->SetName (name.GetName ());
   i.Next (offset);
 
   if (i.ReadU16 () != (2 + 4 + 2 + 2 + (2 + 0))) // content length
@@ -400,7 +421,13 @@
   return i.GetDistanceFrom (start);
 }
 
+void
+Data::Print (std::ostream &os) const
+{
+  m_data->Print (os);
 }
-}
+
+} // ndnSIM
+} // wire
 
 NDN_NAMESPACE_END
diff --git a/model/wire/ndnsim.h b/model/wire/ndnsim.h
index bc711dc..c42e532 100644
--- a/model/wire/ndnsim.h
+++ b/model/wire/ndnsim.h
@@ -11,7 +11,7 @@
 #ifndef NDN_WIRE_NDNSIM_H
 #define NDN_WIRE_NDNSIM_H
 
-#include "ns3/ndn-common.h"
+#include "../ndn-common.h"
 #include "ns3/ndn-interest.h"
 #include "ns3/ndn-content-object.h"
 
@@ -91,7 +91,7 @@
   Ptr<ndn::Interest> m_interest;
 };
 
-class Data : Header
+class Data : public Header
 {
 public:
   Data ();