model: New content store variations: support for content freshness

The following content store realizations now fully support freshness set
in ContentObjects:
- ns3::ndn::cs::Freshness::Lru
- ns3::ndn::cs::Freshness::Random
- ns3::ndn::cs::Freshness::Fifo

Example ndn-simple-with-content-freshness demonstrates basics of new
content stores.
diff --git a/examples/custom-apps/custom-app.cc b/examples/custom-apps/custom-app.cc
index 06ec139..14c564e 100644
--- a/examples/custom-apps/custom-app.cc
+++ b/examples/custom-apps/custom-app.cc
@@ -33,7 +33,6 @@
 #include "ns3/ndn-fib.h"
 #include "ns3/random-variable.h"
 
-
 NS_LOG_COMPONENT_DEFINE ("CustomApp");
 
 namespace ns3 {
diff --git a/examples/custom-apps/dumb-requester.cc b/examples/custom-apps/dumb-requester.cc
new file mode 100644
index 0000000..1d068c4
--- /dev/null
+++ b/examples/custom-apps/dumb-requester.cc
@@ -0,0 +1,122 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011-2012 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>
+ */
+
+// dumb-requester.cc
+
+#include "dumb-requester.h"
+#include "ns3/ptr.h"
+#include "ns3/log.h"
+#include "ns3/simulator.h"
+#include "ns3/packet.h"
+#include "ns3/random-variable.h"
+#include "ns3/string.h"
+
+#include "ns3/ndn-app-face.h"
+#include "ns3/ndn-interest.h"
+#include "ns3/ndn-content-object.h"
+
+NS_LOG_COMPONENT_DEFINE ("DumbRequester");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (DumbRequester);
+
+// register NS-3 type
+TypeId
+DumbRequester::GetTypeId ()
+{
+  static TypeId tid = TypeId ("DumbRequester")
+    .SetParent<ndn::App> ()
+    .AddConstructor<DumbRequester> ()
+
+    .AddAttribute ("Prefix", "Requested name",
+                   StringValue ("/dumb-interest"),
+                   ndn::MakeNameComponentsAccessor (&DumbRequester::m_name),
+                   ndn::MakeNameComponentsChecker ())
+    ;
+  return tid;
+}
+
+DumbRequester::DumbRequester ()
+  : m_isRunning (false)
+{
+}
+
+// Processing upon start of the application
+void
+DumbRequester::StartApplication ()
+{
+  // initialize ndn::App
+  ndn::App::StartApplication ();
+
+  m_isRunning = true;
+  Simulator::ScheduleNow (&DumbRequester::SendInterest, this);
+}
+
+// Processing when application is stopped
+void
+DumbRequester::StopApplication ()
+{
+  m_isRunning = false;
+  // cleanup ndn::App
+  ndn::App::StopApplication ();
+}
+
+void
+DumbRequester::SendInterest ()
+{
+  if (!m_isRunning) return;
+  
+  /////////////////////////////////////
+  // Sending one Interest packet out //
+  /////////////////////////////////////
+  
+  Ptr<ndn::NameComponents> prefix = Create<ndn::NameComponents> (m_name); // another way to create name
+
+  // Create and configure ndn::InterestHeader
+  ndn::InterestHeader interestHeader;
+  UniformVariable rand (0,std::numeric_limits<uint32_t>::max ());
+  interestHeader.SetNonce            (rand.GetValue ());
+  interestHeader.SetName             (prefix);
+  interestHeader.SetInterestLifetime (Seconds (1.0));
+
+  // Create packet and add ndn::InterestHeader
+  Ptr<Packet> packet = Create<Packet> ();
+  packet->AddHeader (interestHeader);
+
+  NS_LOG_DEBUG ("Sending Interest packet for " << *prefix);
+  
+  // Forward packet to lower (network) layer
+  m_protocolHandler (packet);
+
+  // Call trace (for logging purposes)
+  m_transmittedInterests (&interestHeader, this, m_face);
+  Simulator::Schedule (Seconds (1.0), &DumbRequester::SendInterest, this);
+}
+
+void
+DumbRequester::OnContentObject (const Ptr<const ndn::ContentObjectHeader> &contentObject,
+                                Ptr<Packet> payload)
+{
+  NS_LOG_DEBUG ("Receiving ContentObject packet for " << contentObject->GetName ());
+}
+
+
+} // namespace ns3
diff --git a/examples/custom-apps/dumb-requester.h b/examples/custom-apps/dumb-requester.h
new file mode 100644
index 0000000..050630d
--- /dev/null
+++ b/examples/custom-apps/dumb-requester.h
@@ -0,0 +1,69 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011-2012 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>
+ */
+
+// dumb-requester.h
+
+#ifndef DUMB_REQUESTER_H_
+#define DUMB_REQUESTER_H_
+
+#include "ns3/ndn-app.h"
+#include "ns3/ndn-name-components.h"
+
+namespace ns3 {
+
+/**
+ * @brief A dumb requester application
+ *
+ * This app keeps requesting every second the same content object 
+ */
+class DumbRequester : public ndn::App
+{
+public:
+  // register NS-3 type "DumbRequester"
+  static TypeId
+  GetTypeId ();
+
+  DumbRequester ();
+  
+  // (overridden from ndn::App) Processing upon start of the application
+  virtual void
+  StartApplication ();
+
+  // (overridden from ndn::App) Processing when application is stopped
+  virtual void
+  StopApplication ();
+
+  // (overridden from ndn::App) Callback that will be called when Data arrives
+  virtual void
+  OnContentObject (const Ptr<const ndn::ContentObjectHeader> &contentObject,
+                   Ptr<Packet> payload);
+  
+private:
+  void
+  SendInterest ();
+
+private:
+  bool m_isRunning;
+  ndn::NameComponents m_name;
+};
+
+} // namespace ns3
+
+#endif // DUMB_REQUESTER_H_
diff --git a/examples/custom-apps/hijacker.cc b/examples/custom-apps/hijacker.cc
new file mode 100644
index 0000000..252cf92
--- /dev/null
+++ b/examples/custom-apps/hijacker.cc
@@ -0,0 +1,74 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011-2012 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>
+ */
+
+// hijacker.cc
+
+#include "hijacker.h"
+
+NS_LOG_COMPONENT_DEFINE ("Hijacker");
+
+namespace ns3 {
+
+// Necessary if you are planning to use ndn::AppHelper
+NS_OBJECT_ENSURE_REGISTERED (Hijacker);
+
+TypeId
+Hijacker::GetTypeId ()
+{
+  static TypeId tid = TypeId ("Hijacker")
+    .SetParent<ndn::App> ()
+    .AddConstructor<Hijacker> ()
+    ;
+
+  return tid;
+}
+
+Hijacker::Hijacker ()
+{
+}
+
+void
+Hijacker::OnInterest (const Ptr<const ndn::InterestHeader> &interest, Ptr<Packet> packet)
+{
+  ndn::App::OnInterest (interest, packet); // forward call to perform app-level tracing
+  // do nothing else (hijack interest)
+
+  NS_LOG_DEBUG ("Do nothing for incoming interest for" << interest->GetName ());
+}
+
+void
+Hijacker::StartApplication ()
+{
+  App::StartApplication ();
+
+  // equivalent to setting interest filter for "/" prefix
+  Ptr<ndn::Fib> fib = GetNode ()->GetObject<ndn::Fib> ();
+  Ptr<ndn::fib::Entry> fibEntry = fib->Add ("/", m_face, 0);
+  fibEntry->UpdateStatus (m_face, ndn::fib::FaceMetric::NDN_FIB_GREEN);
+}
+
+void
+Hijacker::StopApplication ()
+{
+  App::StopApplication ();
+}
+
+} // namespace ns3
+
diff --git a/examples/custom-apps/hijacker.h b/examples/custom-apps/hijacker.h
new file mode 100644
index 0000000..84d9070
--- /dev/null
+++ b/examples/custom-apps/hijacker.h
@@ -0,0 +1,55 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2011-2012 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>
+ */
+
+// hijacker.h
+
+#ifndef HIJACKER_H_
+#define HIJACKER_H_
+
+#include "ns3/core-module.h"
+#include "ns3/network-module.h"
+#include "ns3/ndnSIM-module.h"
+
+namespace ns3 {
+
+class Hijacker : public ndn::App
+{
+public:
+  static TypeId
+  GetTypeId ();
+
+  Hijacker ();
+
+  // Receive all Interests but do nothing in response
+  void
+  OnInterest (const Ptr<const ndn::InterestHeader> &interest, Ptr<Packet> packet);
+
+protected:
+  // inherited from Application base class.
+  virtual void
+  StartApplication ();
+
+  virtual void
+  StopApplication ();
+};
+
+} // namespace ns3
+
+#endif // HIJACKER_H_