[ndnSIM] [2] ContentStore order

Alex Afanasyev alexander.afanasyev at ucla.edu
Sun Nov 17 11:58:08 PST 2013


Hi Wassim,

Cache is organized as a hash-based container, so it is expected that entries are not in any particular order.  To get access to policy-based ordering (FIFO in your case), you would need a little bit more complex code.  Here is a basic example:

#include "ns3/ndnSIM/model/cs/content-store-impl.h"
#include "ns3/ndnSIM/utils/trie/fifo-policy.h"
#include "ns3/ndnSIM/utils/trie/random-policy.h"

...


  // typedef ns3::ndn::ndnSIM::random_policy_traits policy;
  typedef ns3::ndn::ndnSIM::fifo_policy_traits policy;
  
  typedef ns3::ndn::cs::ContentStoreImpl<policy> CS;
  typedef CS::super::policy_container Policy;

  Ptr<CS> cs = DynamicCast<CS> (NodeList::GetNode(1)->GetObject<ndn::ContentStore> ());
  if (!cs)
    {
      std::cerr << "Please select the right CS policy" << std::endl;
      exit (1);
    }

  for (Policy::iterator it = cs->GetPolicy().begin ();
       it != cs->GetPolicy().end();
       it++)
    {
      std::cout << it->payload()->GetName() << std::endl;
    }

---
Alex

On Nov 17, 2013, at 3:37 AM, Wassim Drira <drirawassim+ndnsim at gmail.com> wrote:

> Hi all,
> 
> I am using ContentStore to store some msgs in reception order. I am using the fifo variant. The issue is when printing the content of the cache, it looks not ordered as you can see below (sequence number in the end of the name).
> 
> Do you have an idea about the cause and may be a solution to this issue...
> 
> %%%%%%%% ----- Code ----- %%%%%%%
> ObjectFactory m_contentStoreFactory;
> m_contentStoreFactory.SetTypeId ("ns3::ndn::cs::Stats::Fifo");
> m_contentStoreFactory.Set("MaxSize", StringValue ("50"));
> m_pubCS = m_contentStoreFactory.Create<ContentStore> ();
> ......
> Ptr<ns3::ndn::cs::Entry> entry = m_pubCS->Begin();
> while(entry){
>         NS_LOG_DEBUG("Cache Entry:"<< entry->GetData()->GetName());
>         entry = m_pubCS->Next(entry);
> }
> %%%%%%%% ----- OutPut ----- %%%%%%%
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%02
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%01
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%04
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%03
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%06
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%05
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%08
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%07
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%0A
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%09
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%0C
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%0B
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%0E
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%0D
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%10
> 18.0186s 1 ndn.ANode:OnMsg(): [DEBUG] Cache Entry:/news/2/%00%0F
> 
> 
> Best regards
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20131117/b410649d/attachment.html>


More information about the ndnSIM mailing list