Making everything compile. Now everything seems to work, but more
checking is necessary
diff --git a/apps/ccnx-app.cc b/apps/ccnx-app.cc
index a23167e..7b9c2b9 100644
--- a/apps/ccnx-app.cc
+++ b/apps/ccnx-app.cc
@@ -20,9 +20,14 @@
 
 #include "ccnx-app.h"
 #include "ns3/log.h"
+#include "ns3/assert.h"
 #include "ns3/packet.h"
+
 #include "ns3/ccnx-interest-header.h"
 #include "ns3/ccnx-content-object-header.h"
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-fib.h"
+#include "ns3/ccnx-local-face.h"
 
 NS_LOG_COMPONENT_DEFINE ("CcnxApp");
 
@@ -32,7 +37,7 @@
 NS_OBJECT_ENSURE_REGISTERED (CcnxApp);
     
 TypeId
-CcnxConsumer::GetTypeId (void)
+CcnxApp::GetTypeId (void)
 {
   static TypeId tid = TypeId ("ns3::CcnxApp")
     .SetParent<Application> ()
@@ -43,7 +48,7 @@
     
 CcnxApp::CcnxApp ()
   : m_protocolHandler (0)
-  , m_active (true)
+  , m_active (false)
   , m_face (0)
 {
 }
@@ -54,12 +59,12 @@
 }
 
 void
-CcnxProducer::DoDispose (void)
+CcnxApp::DoDispose (void)
 {
   NS_LOG_FUNCTION_NOARGS ();
 
   StopApplication ();
-  CcnxApp::DoDispose ();
+  Application::DoDispose ();
 }
 
 void
@@ -96,16 +101,14 @@
   NS_ASSERT (m_active != true);
   m_active = true;
 
-  NS_ASSERT_MSG (GetObject<Ccnx> () != 0,
+  NS_ASSERT_MSG (GetNode ()->GetObject<Ccnx> () != 0,
                  "Ccnx stack should be installed on the node " << GetNode ());
-  NS_ASSERT_MSG (GetObject<CcnxFib> () != 0);
 
   // step 1. Create a face
   m_face = Create<CcnxLocalFace> (/*Ptr<CcnxApp> (this)*/this);
     
   // step 2. Add face to the CCNx stack
-  GetObject<CcnxFib> ()->Add (m_prefix, m_face, 0);
-  GetObject<Ccnx> ()->AddFace (m_face);
+  GetNode ()->GetObject<Ccnx> ()->AddFace (m_face);
 
   // step 3. Enable face
   m_face->SetUp (true);
@@ -118,8 +121,7 @@
 
   if (!m_active) return; //don't assert here, just return
  
-  NS_ASSERT (GetObject<Ccnx> () != 0);
-  NS_ASSERT (GetObject<CcnxFib> () != 0);
+  NS_ASSERT (GetNode ()->GetObject<Ccnx> () != 0);
 
   m_active = false;
 
@@ -127,14 +129,14 @@
   m_face->SetUp (false);
 
   // step 2. Remove face from CCNx stack
-  GetObject<Ccnx> ()->RemoveFace (m_face);
-  GetObject<CcnxFib> ()->Add (m_prefix, m_face, 0);
+  GetNode ()->GetObject<Ccnx> ()->RemoveFace (m_face);
+  GetNode ()->GetObject<CcnxFib> ()->RemoveFromAll (m_face);
 
   // step 3. Destroy face
   NS_ASSERT_MSG (m_face->GetReferenceCount ()==1,
-                 "At this point, nobody else should have referenced this face");
+                 "At this point, nobody else should have referenced this face, but we have "
+                 << m_face->GetReferenceCount () << " references");
   m_face = 0;
 }
 
-
 }
diff --git a/apps/ccnx-app.h b/apps/ccnx-app.h
index 4f2cb83..f94018f 100644
--- a/apps/ccnx-app.h
+++ b/apps/ccnx-app.h
@@ -31,6 +31,7 @@
 class Packet;
 class CcnxInterestHeader;
 class CcnxContentObjectHeader;
+class CcnxFace;
 
 /**
  * @ingroup ccnx
@@ -41,7 +42,7 @@
 class CcnxApp: public Application
 {
 public:
-  typedef Callback<bool, const Ptr<CcnxFace>&> ProtocolHandler;
+  typedef Callback<bool, const Ptr<const Packet>&> ProtocolHandler;
   
   static TypeId GetTypeId ();
 
@@ -94,8 +95,6 @@
 protected:
   ProtocolHandler m_protocolHandler;
   bool m_active; 
-
-private:
   Ptr<CcnxFace> m_face; // local face that is created 
 };
 
diff --git a/apps/ccnx-consumer.cc b/apps/ccnx-consumer.cc
index 01a5b1d..5d2ce7c 100644
--- a/apps/ccnx-consumer.cc
+++ b/apps/ccnx-consumer.cc
@@ -20,12 +20,21 @@
 
 #include "ccnx-consumer.h"
 #include "ns3/ptr.h"
-#include "ns3/ccnx-local-face.h"
-#include "ns3/ccnx.h"
+#include "ns3/log.h"
+#include "ns3/simulator.h"
+#include "ns3/packet.h"
 #include "ns3/callback.h"
 #include "ns3/string.h"
+#include "ns3/boolean.h"
+#include "ns3/uinteger.h"
+
+#include "ns3/ccnx.h"
+#include "ns3/ccnx-local-face.h"
+#include "ns3/ccnx-interest-header.h"
 #include "ns3/ccnx-content-object-header.h"
 
+#include <boost/ref.hpp>
+
 NS_LOG_COMPONENT_DEFINE ("CcnxConsumer");
 
 namespace ns3
@@ -67,14 +76,14 @@
                    CcnxNameComponentsValue (),
                    MakeCcnxNameComponentsAccessor (&CcnxConsumer::m_exclude),
                    MakeCcnxNameComponentsChecker ())
-    .AddAttribute ("Initial Nonce", "If 0 then nonce is not used",
-                   UintegerValue(1),
-                   MakeUintegerAccessor(&CcnxConsumer::m_initialNonce),
-                   MakeUintegerChecker<uint32_t>())
-    .AddTraceSource ("InterestTrace", "Interests that were sent",
-                     MakeTraceSourceAccessor (&CcnxConsumer::m_interestsTrace))
-    .AddTraceSource ("ContentObjectTrace", "ContentObjects that were received",
-                     MakeTraceSourceAccessor (&CcnxConsumer::m_contentObjectsTrace))
+    // .AddAttribute ("Initial Nonce", "If 0 then nonce is not used",
+    //                UintegerValue(1),
+    //                MakeUintegerAccessor(&CcnxConsumer::m_initialNonce),
+    //                MakeUintegerChecker<uint32_t>())
+    // .AddTraceSource ("InterestTrace", "Interests that were sent",
+    //                  MakeTraceSourceAccessor (&CcnxConsumer::m_interestsTrace))
+    // .AddTraceSource ("ContentObjectTrace", "ContentObjects that were received",
+    //                  MakeTraceSourceAccessor (&CcnxConsumer::m_contentObjectsTrace))
     ;
 
   return tid;
@@ -87,19 +96,6 @@
   NS_LOG_FUNCTION_NOARGS ();
 }
     
-CcnxConsumer::~CcnxConsumer()
-{
-  NS_LOG_FUNCTION_NOARGS ();
-}
-    
-void
-CcnxConsumer::DoDispose (void)
-{
-  NS_LOG_FUNCTION_NOARGS ();
-        
-  Application::DoDispose ();
-}
-    
 // Application Methods
 void 
 CcnxConsumer::StartApplication () // Called at time specified by Start
@@ -129,11 +125,10 @@
 CcnxConsumer::SendPacket ()
 {
   NS_LOG_FUNCTION_NOARGS ();
-  NS_LOG_INFO ("Sending Interest at " << Simulator::Now ());
     
   //
   Ptr<CcnxNameComponents> nameWithSequence = Create<CcnxNameComponents> (m_interestName);
-  (*name) (m_seq++);
+  (*nameWithSequence) (m_seq++);
   //
 
   CcnxInterestHeader interestHeader;
@@ -145,7 +140,7 @@
   interestHeader.SetMaxSuffixComponents (m_maxSuffixComponents);
   interestHeader.SetMinSuffixComponents (m_minSuffixComponents);
         
-  NS_LOG_INFO ("Interest: \n" << interestHeader);
+  NS_LOG_INFO ("Requesting Interest: \n" << interestHeader);
 
   Ptr<Packet> packet = Create<Packet> ();
   packet->AddHeader (interestHeader);
@@ -161,7 +156,7 @@
 {
   NS_LOG_FUNCTION (this << contentObject << payload);
 
-  NS_LOG_INFO ("Received content object: " << cref(*contentObject));
+  NS_LOG_INFO ("Received content object: " << boost::cref(*contentObject));
 }
 
 } // namespace ns3
diff --git a/apps/ccnx-consumer.h b/apps/ccnx-consumer.h
index b2c115b..792c829 100644
--- a/apps/ccnx-consumer.h
+++ b/apps/ccnx-consumer.h
@@ -22,6 +22,8 @@
 #define CCNX_CONSUMER_H
 
 #include "ccnx-app.h"
+#include "ns3/random-variable.h"
+#include "ns3/ccnx-name-components.h"
 
 namespace ns3 
 {
diff --git a/apps/ccnx-interest-sender.cc b/apps/ccnx-interest-sender.cc
index bcf3d76..d110978 100644
--- a/apps/ccnx-interest-sender.cc
+++ b/apps/ccnx-interest-sender.cc
@@ -1,161 +1,160 @@
-/* -*-  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: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
+// /* -*-  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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+//  */
 
-#include "ccnx-interest-sender.h"
+// #include "ccnx-interest-sender.h"
 
-NS_LOG_COMPONENT_DEFINE ("CcnxInterestSender");
+// NS_LOG_COMPONENT_DEFINE ("CcnxInterestSender");
 
-namespace ns3
-{    
+// namespace ns3
+// {    
 
-NS_OBJECT_ENSURE_REGISTERED (CcnxInterestSender);
+// NS_OBJECT_ENSURE_REGISTERED (CcnxInterestSender);
 
-TypeId
-CcnxInterestSender::GetTypeId (void)
-{
-    static TypeId tid = TypeId ("ns3::CcnxInterestSender")
-    .SetParent<Application> ()
-    .AddConstructor<CcnxInterestSender> ()
-    .AddAttribute ("OffTime", "Time interval between packets",
-                   TimeValue (Seconds (0.1)),
-                   MakeTimeAccessor (&CcnxInterestSender::m_offTime),
-                   MakeTimeChecker ())
-    // Alex: this is incorrect. SetNode call is not called if face is created using this accessor
-    // .AddAttribute ("Face","Local face to be used",
-    //                PointerValue (CreateObject<CcnxLocalFace> ()),
-    //                MakePointerAccessor (&CcnxInterestSender::m_face),
-    //                MakePointerChecker<CcnxLocalFace> ())
-    .AddAttribute ("NameComponents","CcnxName of the Interest (use CcnxNameComponents)",
-                   CcnxNameComponentsValue (CcnxNameComponents (/* root */)),
-                   MakeCcnxNameComponentsAccessor (&CcnxInterestSender::m_interestName),
-                   MakeCcnxNameComponentsChecker ())
-    .AddAttribute ("LifeTime", "LifeTime fo interest packet",
-                   TimeValue (Seconds (4.0)),
-                   MakeTimeAccessor (&CcnxInterestSender::m_interestLifeTime),
-                   MakeTimeChecker ())
-    .AddAttribute ("MinSuffixComponents", "MinSuffixComponents",
-                   IntegerValue(-1),
-                   MakeIntegerAccessor(&CcnxInterestSender::m_minSuffixComponents),
-                   MakeIntegerChecker<int32_t>())
-    .AddAttribute ("MaxSuffixComponents", "MaxSuffixComponents",
-                   IntegerValue(-1),
-                   MakeIntegerAccessor(&CcnxInterestSender::m_maxSuffixComponents),
-                   MakeIntegerChecker<int32_t>())
-    .AddAttribute ("ChildSelector", "ChildSelector",
-                   BooleanValue(false),
-                   MakeBooleanAccessor(&CcnxInterestSender::m_childSelector),
-                   MakeBooleanChecker())
-    .AddAttribute ("Exclude","only simple name matching is supported (use CcnxNameComponents)",
-                   CcnxNameComponentsValue (CcnxNameComponents(/* root */)),
-                   MakeCcnxNameComponentsAccessor (&CcnxInterestSender::m_exclude),
-                   MakeCcnxNameComponentsChecker ())
-    .AddAttribute ("Initial Nonce", "If 0 then nonce is not used",
-                   UintegerValue(1),
-                   MakeUintegerAccessor(&CcnxInterestSender::m_initialNonce),
-                   MakeUintegerChecker<uint32_t>())
-    ;
-    /*
-    .AddAttribute ("NoiseModel",
-                   "A pointer to the model of the channel ambient noise.",
-                   PointerValue (CreateObject<UanNoiseModelDefault> ()),
-                   MakePointerAccessor (&UanChannel::m_noise),
-                   MakePointerChecker<UanNoiseModel> ())*/
-    return tid;
-}
+// TypeId
+// CcnxInterestSender::GetTypeId (void)
+// {
+//   static TypeId tid = TypeId ("ns3::CcnxInterestSender")
+//     .SetParent<Application> ()
+//     .AddConstructor<CcnxInterestSender> ()
+//     .AddAttribute ("OffTime", "Time interval between packets",
+//                    TimeValue (Seconds (0.1)),
+//                    MakeTimeAccessor (&CcnxInterestSender::m_offTime),
+//                    MakeTimeChecker ())
+//     // Alex: this is incorrect. SetNode call is not called if face is created using this accessor
+//     // .AddAttribute ("Face","Local face to be used",
+//     //                PointerValue (CreateObject<CcnxLocalFace> ()),
+//     //                MakePointerAccessor (&CcnxInterestSender::m_face),
+//     //                MakePointerChecker<CcnxLocalFace> ())
+//     .AddAttribute ("NameComponents","CcnxName of the Interest (use CcnxNameComponents)",
+//                    CcnxNameComponentsValue (CcnxNameComponents (/* root */)),
+//                    MakeCcnxNameComponentsAccessor (&CcnxInterestSender::m_interestName),
+//                    MakeCcnxNameComponentsChecker ())
+//     .AddAttribute ("LifeTime", "LifeTime fo interest packet",
+//                    TimeValue (Seconds (4.0)),
+//                    MakeTimeAccessor (&CcnxInterestSender::m_interestLifeTime),
+//                    MakeTimeChecker ())
+//     .AddAttribute ("MinSuffixComponents", "MinSuffixComponents",
+//                    IntegerValue(-1),
+//                    MakeIntegerAccessor(&CcnxInterestSender::m_minSuffixComponents),
+//                    MakeIntegerChecker<int32_t>())
+//     .AddAttribute ("MaxSuffixComponents", "MaxSuffixComponents",
+//                    IntegerValue(-1),
+//                    MakeIntegerAccessor(&CcnxInterestSender::m_maxSuffixComponents),
+//                    MakeIntegerChecker<int32_t>())
+//     .AddAttribute ("ChildSelector", "ChildSelector",
+//                    BooleanValue(false),
+//                    MakeBooleanAccessor(&CcnxInterestSender::m_childSelector),
+//                    MakeBooleanChecker())
+//     .AddAttribute ("Exclude","only simple name matching is supported (use CcnxNameComponents)",
+//                    CcnxNameComponentsValue (CcnxNameComponents(/* root */)),
+//                    MakeCcnxNameComponentsAccessor (&CcnxInterestSender::m_exclude),
+//                    MakeCcnxNameComponentsChecker ())
+//     .AddAttribute ("Initial Nonce", "If 0 then nonce is not used",
+//                    UintegerValue(1),
+//                    MakeUintegerAccessor(&CcnxInterestSender::m_initialNonce),
+//                    MakeUintegerChecker<uint32_t>())
+//     ;
+//   /*
+//     .AddAttribute ("NoiseModel",
+//     "A pointer to the model of the channel ambient noise.",
+//     PointerValue (CreateObject<UanNoiseModelDefault> ()),
+//     MakePointerAccessor (&UanChannel::m_noise),
+//     MakePointerChecker<UanNoiseModel> ())*/
+//   return tid;
+// }
     
-CcnxInterestSender::CcnxInterestSender ()
-{
-    NS_LOG_FUNCTION_NOARGS ();
-}
+// CcnxInterestSender::CcnxInterestSender ()
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
+// }
     
-CcnxInterestSender::~CcnxInterestSender()
-{
-    NS_LOG_FUNCTION_NOARGS ();
-}
+// CcnxInterestSender::~CcnxInterestSender()
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
+// }
     
-void
-CcnxInterestSender::DoDispose (void)
-{
-    NS_LOG_FUNCTION_NOARGS ();
+// void
+// CcnxInterestSender::DoDispose (void)
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
         
-    Application::DoDispose ();
-}
+//   Application::DoDispose ();
+// }
     
-// Application Methods
-void 
-CcnxInterestSender::StartApplication () // Called at time specified by Start
-{
-    NS_LOG_FUNCTION_NOARGS ();
-    ScheduleNextTx();
-}
+// // Application Methods
+// void 
+// CcnxInterestSender::StartApplication () // Called at time specified by Start
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
+//   ScheduleNextTx();
+// }
     
-void 
-CcnxInterestSender::StopApplication () // Called at time specified by Stop
-{
-    NS_LOG_FUNCTION_NOARGS ();
+// void 
+// CcnxInterestSender::StopApplication () // Called at time specified by Stop
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
     
-    CancelEvents ();
-}
+//   CancelEvents ();
+// }
     
-void 
-CcnxInterestSender::CancelEvents ()
-{
-    NS_LOG_FUNCTION_NOARGS ();
+// void 
+// CcnxInterestSender::CancelEvents ()
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
         
-    Simulator::Cancel (m_sendEvent);
-}
+//   Simulator::Cancel (m_sendEvent);
+// }
 
-void 
-CcnxInterestSender::ScheduleNextTx ()
-{
-    NS_LOG_FUNCTION_NOARGS ();
+// void 
+// CcnxInterestSender::ScheduleNextTx ()
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
         
-    Time nextTime = Seconds(m_offTime);
-    m_sendEvent = Simulator::Schedule (nextTime, &CcnxInterestSender::SendPacket, this);
-}
+//   Time nextTime = Seconds(m_offTime);
+//   m_sendEvent = Simulator::Schedule (nextTime, &CcnxInterestSender::SendPacket, this);
+// }
     
-void
-CcnxInterestSender::SendPacket ()
-{
-    NS_LOG_FUNCTION_NOARGS ();
-    // NS_LOG_INFO ("Sending Interest at " << Simulator::Now ());
+// void
+// CcnxInterestSender::SendPacket ()
+// {
+//   NS_LOG_FUNCTION_NOARGS ();
+//   // NS_LOG_INFO ("Sending Interest at " << Simulator::Now ());
     
-    uint32_t randomNonce = UniformVariable().GetInteger(1, std::numeric_limits<uint32_t>::max ());
-    CcnxInterestHeader interestHeader;
-    interestHeader.SetNonce(randomNonce);
-    //const Ptr<CcnxNameComponents> name = Create<CcnxNameComponents>(m_interestName);
-    interestHeader.SetName(Create<CcnxNameComponents> (m_interestName)); //making a copy of name
-    interestHeader.SetInterestLifetime(m_interestLifeTime);
-    interestHeader.SetChildSelector(m_childSelector);
-    //const Ptr<CcnxNameComponents> exclude = Create<CcnxNameComponents>(m_exclude);
-    interestHeader.SetExclude(Create<CcnxNameComponents> (m_exclude));
-    interestHeader.SetMaxSuffixComponents(m_maxSuffixComponents);
-    interestHeader.SetMinSuffixComponents(m_minSuffixComponents);
+//   uint32_t randomNonce = UniformVariable().GetInteger(1, std::numeric_limits<uint32_t>::max ());
+//   CcnxInterestHeader interestHeader;
+//   interestHeader.SetNonce(randomNonce);
+//   //const Ptr<CcnxNameComponents> name = Create<CcnxNameComponents>(m_interestName);
+//   interestHeader.SetName(Create<CcnxNameComponents> (m_interestName)); //making a copy of name
+//   interestHeader.SetInterestLifetime(m_interestLifeTime);
+//   interestHeader.SetChildSelector(m_childSelector);
+//   //const Ptr<CcnxNameComponents> exclude = Create<CcnxNameComponents>(m_exclude);
+//   interestHeader.SetExclude(Create<CcnxNameComponents> (m_exclude));
+//   interestHeader.SetMaxSuffixComponents(m_maxSuffixComponents);
+//   interestHeader.SetMinSuffixComponents(m_minSuffixComponents);
     
-    Ptr<Packet> packet = Create<Packet> ();
-    packet->AddHeader (interestHeader);
+//   Ptr<Packet> packet = Create<Packet> ();
+//   packet->AddHeader (interestHeader);
     
-    m_face->Send(packet);
+//   m_face->Send(packet);
     
-    ScheduleNextTx();
-}
-
+//   ScheduleNextTx();
+// }
     
-}
+// }
diff --git a/apps/ccnx-interest-sender.h b/apps/ccnx-interest-sender.h
index ad8de28..cbb54ad 100644
--- a/apps/ccnx-interest-sender.h
+++ b/apps/ccnx-interest-sender.h
@@ -1,106 +1,106 @@
-/* -*-  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: Ilya Moiseenko <iliamo@cs.ucla.edu>
- */
+// /* -*-  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: Ilya Moiseenko <iliamo@cs.ucla.edu>
+//  */
 
-#include "ns3/application.h"
-#include "ns3/log.h"
-#include "ns3/random-variable.h"
-#include "ns3/nstime.h"
-#include "ns3/event-id.h"
-#include "ns3/ptr.h"
-#include "ns3/simulator.h"
-#include "ns3/ccnx-interest-header.h"
-#include "ns3/ccnx-local-face.h"
-#include "ns3/ccnx-name-components.h"
-#include "ns3/packet.h"
-#include "ns3/boolean.h"
-#include "ns3/integer.h"
-#include "ns3/uinteger.h"
-#include "ns3/random-variable.h"
-#include <limits> 
-#include "ns3/pointer.h"
+// #include "ns3/application.h"
+// #include "ns3/log.h"
+// #include "ns3/random-variable.h"
+// #include "ns3/nstime.h"
+// #include "ns3/event-id.h"
+// #include "ns3/ptr.h"
+// #include "ns3/simulator.h"
+// #include "ns3/ccnx-interest-header.h"
+// #include "ns3/ccnx-local-face.h"
+// #include "ns3/ccnx-name-components.h"
+// #include "ns3/packet.h"
+// #include "ns3/boolean.h"
+// #include "ns3/integer.h"
+// #include "ns3/uinteger.h"
+// #include "ns3/random-variable.h"
+// #include <limits> 
+// #include "ns3/pointer.h"
 
-namespace ns3 
-{
+// namespace ns3 
+// {
     
-class Socket;
+// class Socket;
     
-class CcnxInterestSender: public Application
-{
-public: 
-  static TypeId GetTypeId (void);
+// class CcnxInterestSender: public Application
+// {
+// public: 
+//   static TypeId GetTypeId (void);
         
-  CcnxInterestSender ();
+//   CcnxInterestSender ();
         
-  virtual ~CcnxInterestSender ();
+//   virtual ~CcnxInterestSender ();
         
-protected:
-  virtual void DoDispose (void);
-private:
-  // inherited from Application base class.
-  virtual void StartApplication (void);    // Called at time specified by Start
-  virtual void StopApplication (void);     // Called at time specified by Stop
+// protected:
+//   virtual void DoDispose (void);
+// private:
+//   // inherited from Application base class.
+//   virtual void StartApplication (void);    // Called at time specified by Start
+//   virtual void StopApplication (void);     // Called at time specified by Stop
         
-  //Time m_onTime;
-  Time m_offTime;
-  CcnxNameComponents m_interestName;
+//   //Time m_onTime;
+//   Time m_offTime;
+//   CcnxNameComponents m_interestName;
   
-  Time m_interestLifeTime;
-  int32_t m_minSuffixComponents;
-  int32_t m_maxSuffixComponents;
-  bool m_childSelector;
-  CcnxNameComponents m_exclude;
-  uint32_t m_initialNonce;
+//   Time m_interestLifeTime;
+//   int32_t m_minSuffixComponents;
+//   int32_t m_maxSuffixComponents;
+//   bool m_childSelector;
+//   CcnxNameComponents m_exclude;
+//   uint32_t m_initialNonce;
     
-  //EventId         m_startStopEvent;     // Event id for next start or stop event
-  EventId         m_sendEvent;    // Eventid of pending "send packet" event
-  TypeId          m_tid;
-  Ptr<CcnxLocalFace> m_face;
+//   //EventId         m_startStopEvent;     // Event id for next start or stop event
+//   EventId         m_sendEvent;    // Eventid of pending "send packet" event
+//   TypeId          m_tid;
+//   Ptr<CcnxLocalFace> m_face;
         
-  //helpers
-  void CancelEvents ();
+//   //helpers
+//   void CancelEvents ();
         
-  void Construct (Ptr<Node> n,
-                  std::string tid,
-                  const Time& offtime,
-                  Ptr<CcnxLocalFace> face,
-                  Ptr<CcnxNameComponents> nameComponents,
-                  const Time& lifetime,
-                  const int32_t& minSuffixComponents,
-                  const int32_t& maxSuffixComponents,
-                  const bool childSelector,
-                  Ptr<CcnxNameComponents> exclude,
-                  const uint32_t& initialNonce
-                  );
+//   void Construct (Ptr<Node> n,
+//                   std::string tid,
+//                   const Time& offtime,
+//                   Ptr<CcnxLocalFace> face,
+//                   Ptr<CcnxNameComponents> nameComponents,
+//                   const Time& lifetime,
+//                   const int32_t& minSuffixComponents,
+//                   const int32_t& maxSuffixComponents,
+//                   const bool childSelector,
+//                   Ptr<CcnxNameComponents> exclude,
+//                   const uint32_t& initialNonce
+//                   );
     
-  // Event handlers
-  void StartSending ();
-  void StopSending ();
-  void SendPacket ();
+//   // Event handlers
+//   void StartSending ();
+//   void StopSending ();
+//   void SendPacket ();
         
-private:
-  void ScheduleNextTx ();
-  //void ScheduleStartEvent ();
-  //void ScheduleStopEvent ();
-  void ConnectionSucceeded (Ptr<Socket>);
-  void ConnectionFailed (Ptr<Socket>);
-  void Ignore (Ptr<Socket>);
+// private:
+//   void ScheduleNextTx ();
+//   //void ScheduleStartEvent ();
+//   //void ScheduleStopEvent ();
+//   void ConnectionSucceeded (Ptr<Socket>);
+//   void ConnectionFailed (Ptr<Socket>);
+//   void Ignore (Ptr<Socket>);
         
-};
-}
+// };
+// }
diff --git a/apps/ccnx-producer.cc b/apps/ccnx-producer.cc
index 1cec691..0a82d0c 100644
--- a/apps/ccnx-producer.cc
+++ b/apps/ccnx-producer.cc
@@ -20,11 +20,17 @@
  */
 
 #include "ccnx-producer.h"
+#include "ns3/log.h"
 #include "ns3/ccnx-interest-header.h"
+#include "ns3/ccnx-content-object-header.h"
 #include "ns3/string.h"
-#include "ns3/integer.h"
+#include "ns3/uinteger.h"
+#include "ns3/packet.h"
 
 #include "ns3/ccnx-local-face.h"
+#include "ns3/ccnx-fib.h"
+
+#include <boost/ref.hpp>
 
 NS_LOG_COMPONENT_DEFINE ("CcnxProducer");
 
@@ -60,7 +66,29 @@
 {
   // NS_LOG_FUNCTION_NOARGS ();
 }
-       
+
+// inherited from Application base class.
+void
+CcnxProducer::StartApplication ()
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  NS_ASSERT (GetNode ()->GetObject<CcnxFib> () != 0);
+
+  CcnxApp::StartApplication ();
+
+  GetNode ()->GetObject<CcnxFib> ()->Add (m_prefix, m_face, 0);
+}
+
+void
+CcnxProducer::StopApplication ()
+{
+  NS_LOG_FUNCTION_NOARGS ();
+  NS_ASSERT (GetNode ()->GetObject<CcnxFib> () != 0);
+
+  CcnxApp::StopApplication ();
+}
+
+
 void
 CcnxProducer::OnInterest (const Ptr<const CcnxInterestHeader> &interest)
 {
@@ -71,12 +99,14 @@
   static CcnxContentObjectTail tail;
   Ptr<CcnxContentObjectHeader> header = Create<CcnxContentObjectHeader> ();
   header->SetName (Create<CcnxNameComponents> (interest->GetName ()));
+
+  NS_LOG_INFO ("Respodning with ContentObject:\n" << boost::cref(*header));
   
   Ptr<Packet> packet = Create<Packet> (m_virtualPayloadSize);
-  outgoingPacket->AddHeader (*header);
-  outgoingPacket->AddTrailer (tail);
+  packet->AddHeader (*header);
+  packet->AddTrailer (tail);
 
-  m_protocolHandler (outgoingPacket);
+  m_protocolHandler (packet);
 }
 
 } // namespace ns3
diff --git a/apps/ccnx-producer.h b/apps/ccnx-producer.h
index 289c22e..ac9a492 100644
--- a/apps/ccnx-producer.h
+++ b/apps/ccnx-producer.h
@@ -41,6 +41,14 @@
   // inherited from CcnxApp
   void OnInterest (const Ptr<const CcnxInterestHeader> &interest);
 
+protected:
+  // inherited from Application base class.
+  virtual void
+  StartApplication ();    // Called at time specified by Start
+
+  virtual void
+  StopApplication ();     // Called at time specified by Stop
+
 private:
   CcnxNameComponents m_prefix;
   uint32_t m_virtualPayloadSize;