GetPrefix was added to Producer app
diff --git a/apps/ccnx-producer.h b/apps/ccnx-producer.h
index 55049dd..840400b 100644
--- a/apps/ccnx-producer.h
+++ b/apps/ccnx-producer.h
@@ -45,10 +45,73 @@
#include "ns3/header.h"
#include "ns3/ccnx.h"
#include "ns3/ccnx-content-object-header.h"
+#include "ns3/ccnx-name-components.h"
+#include "ns3/ccnx-fib.h"
+
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/tag.hpp>
+#include <boost/multi_index/ordered_index.hpp>
+#include <boost/multi_index/sequenced_index.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#include <boost/multi_index/mem_fun.hpp>
namespace ns3
{
+ class DataStoreEntry
+ {
+ public:
+ /**
+ * \brief Construct data store entry
+ *
+ * \param header Parsed CcnxContentObject header
+ * \param packet Original CCNx packet
+ *
+ * The constructor will make a copy of the supplied packet and calls
+ * RemoveHeader and RemoveTail on the copy.
+ */
+ DataStoreEntry (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet);
+
+ /**
+ * \brief Get prefix of the stored entry
+ * \returns prefix of the stored entry
+ */
+ inline const CcnxNameComponents&
+ GetName () const;
+
+ /**
+ * \brief Get CcnxContentObjectHeader of the stored entry
+ * \returns CcnxContentObjectHeader of the stored entry
+ */
+ inline Ptr<const CcnxContentObjectHeader>
+ GetHeader () const;
+
+ /**
+ * \brief Get content of the stored entry
+ * \returns content of the stored entry
+ */
+ inline Ptr<const Packet>
+ GetPacket () const;
+
+ /**
+ * \brief Convenience method to create a fully formed CCNx packet from stored header and content
+ * \returns A read-write copy of the packet with CcnxContentObjectHeader and CcxnContentObjectTail
+ */
+ Ptr<Packet>
+ GetFullyFormedCcnxPacket () const;
+
+ // Copy constructor is required by the container. Though, we're
+ // storing only two pointers, so shouldn't be a problem
+ // private:
+ // CcnxContentStoreEntry (const CcnxContentStoreEntry &); ///< disabled copy constructor
+ // CcnxContentStoreEntry& operator= (const CcnxContentStoreEntry&); ///< disabled copy operator
+
+ private:
+ //Ptr<CcnxContentObjectHeader> m_header; ///< \brief non-modifiable CcnxContentObjectHeader
+ //Ptr<Packet> m_packet; ///< \brief non-modifiable content of the ContentObject packet
+ };
+
+
class CcnxProducer: public Application
{
public:
@@ -58,9 +121,26 @@
virtual ~CcnxProducer ();
- void HandlePacket (const Ptr<CcnxFace> &face, const Ptr<const Packet> &packet);
- uint32_t GetStoreCapacity();
- void AddContentStoreEntry (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet);
+ //void HandlePacket (const Ptr<CcnxFace> &face, const Ptr<const Packet> &packet);
+ //uint32_t GetStoreCapacity();
+ //void SetStoreCapacity(uint32_t capacity);
+ //void AddContentStoreEntry (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet);
+
+ void OnInterest(const Ptr<const CcnxInterestHeader> &interest);
+
+ CcnxNameComponents GetPrefix() const;
+ /**
+ * \brief Add a new content to the data store.
+ *
+ * \param header Fully parsed CcnxContentObjectHeader
+ * \param packet Fully formed CCNx packet to add to content store
+ * (will be copied and stripped down of headers)
+ *
+ * If entry with the same prefix exists, the old entry will be
+ * promoted to the top of the MRU hash
+ */
+ //void
+ //Add (Ptr<CcnxContentObjectHeader> header, Ptr<const Packet> packet);
protected:
virtual void DoDispose (void);
@@ -69,48 +149,59 @@
virtual void StartApplication (void); // Called at time specified by Start
virtual void StopApplication (void); // Called at time specified by Stop
+ /**
+ * \brief Find corresponding CS entry for the given interest
+ *
+ * \param interest Interest for which matching content store entry
+ * will be searched
+ *
+ * If an entry is found, it is promoted to the top of most recent
+ * used entries index, \see m_contentStore
+ */
+ //Ptr<Packet>
+ //Lookup (Ptr<const CcnxInterestHeader> interest);
+
+
Ptr<Ccnx> m_ccnx;
Time m_offTime;
- //Ptr<CcnxNameComponents> m_interestName;
- //Time m_interestLifeTime;
- //int32_t m_minSuffixComponents;
- //int32_t m_maxSuffixComponents;
- //bool m_childSelector;
- //Ptr<CcnxNameComponents> m_exclude;
- //uint32_t m_initialNonce;
-
+
//EventId m_sendEvent; // Eventid of pending "send packet" event
TypeId m_tid;
Ptr<CcnxLocalFace> m_face;
- uint32_t m_storeCapacity;
-
+ /*struct DataStoreContainer
+ {
+ typedef
+ boost::multi_index::multi_index_container<
+ DataStoreEntry,
+ boost::multi_index::indexed_by<
+ boost::multi_index::hashed_unique<
+ boost::multi_index::tag<__ccnx_private::i_prefix>,
+ boost::multi_index::const_mem_fun<DataStoreEntry,
+ const CcnxNameComponents&,
+ &DataStoreEntry::GetName>,
+ CcnxPrefixHash>,
+ boost::multi_index::sequenced<boost::multi_index::tag<__ccnx_private::i_mru> >
+#ifdef _DEBUG
+ ,
+ boost::multi_index::ordered_unique<
+ boost::multi_index::tag<__ccnx_private::i_ordered>,
+ boost::multi_index::const_mem_fun<DataStoreEntry,
+ const CcnxNameComponents&,
+ &CcnxContentStoreEntry::GetName>
+ >
+#endif
+ >
+ > type;
+ };*/
+
//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
- );
-
- // Event handlers
- void StartSending ();
- void StopSending ();
- void SendPacket ();
- //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler;
-
-private:
- void ScheduleNextTx ();
- //typedef Callback<void,const Ptr<CcnxFace>&,const Ptr<const Packet>& > ProtocolHandler;
-
+
+ //DataStoreContainer::type m_availableData;
+ //uint32_t m_storeCapacity;
+ uint32_t m_virtualPayloadSize;
+ CcnxNameComponents m_prefix;
TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_interestsTrace;
TracedCallback<const Ptr<CcnxFace>&,const Ptr<const Packet>& > m_contentObjectsTrace;
};