[ndnSIM] do statistics about the lifetime of a content store entry in ndnSIM

Alex Afanasyev alexander.afanasyev at ucla.edu
Mon Dec 10 00:28:55 PST 2012


Hi Xiaoyan,

Replacement and removal of content store entries in ndnSIM is controlled by so called policies. These policies are not really related specifically to the content store, but to the general data structure (trie-with-policy: utils/trie/trie-with-policy.h).  There are currently three policies that are used in content stores: lru-policy.h, random-policy.h, and fifo-policy.h (code in utils/trie/ folder).  If you create a new policy, a "new" content store can be created by adding a couple of lines (at least in the current code) into model/cs/content-store-impl.cc file:

---

// (1) A little bit cheating to trick NS-3 object system

template<>
TypeId
ContentStoreImpl< YOUR_POLICY >::GetTypeId ()
{
  static TypeId tid = TypeId ("CONTENT_STORE_NAME")  // e.g., to use in ndnStackHelper.SetContentStore ("CONTENT_STORE_NAME")
    .SetGroupName ("Ndn")
    .SetParent<ContentStore> ()
    .AddConstructor< ContentStoreImpl< YOUR_POLICY > > ()
    .AddAttribute ("MaxSize",
                   "Set maximum number of entries in ContentStore. If 0, limit is not enforced",
                   StringValue ("100"),
                   MakeUintegerAccessor (&ContentStoreImpl< YOUR_POLICY >::GetMaxSize,
                                         &ContentStoreImpl< YOUR_POLICY >::SetMaxSize),
                   MakeUintegerChecker<uint32_t> ())
    ;

  return tid;
}

// (2) specialize content store implementation:

template class ContentStoreImpl<lru_policy_traits>;

---

Now regarding the policy itself. 
For CS statistic generation I would recommend (at least for now) creating a custom "replacement" policy based on the existing one.  That is, if you want stats for LRU policy, just copy lru-policy.h to lru-policy-stat.h and do necessary modifications.  There is also multi-policy.h, which potentially could be a better fit (e.g., you would not need to "reimplement" stats for every replacement policy), but I haven't thoroughly tested this implementation.

The code should be semi-self explanatory, though may be a little bit obscured.  Looking forward to hear about your progress and/or problems :)

Sincerely,
Alex

On Dec 10, 2012, at 12:08 AM, Xiao yan Hu <xhbreezehu at gmail.com> wrote:

> Hi all,
> 
> Really happy to join the ndnSIM mailing list.
> Thank Alex very much for the development of ndnSIM which enables the simulation for NDN features. 
> Hope everyone have fun with ndnSIM.
> I am doing some research on the NDN caching stuff and trying to simulate it with ndnSIM.
> I want to do statistics about the average time that an content object stays in the content store of a NDN node which is based on the lifetime of content store entries that have been replaced. Would you guys pls tell me where is the exact source code location of ndnSIM when an content store entry is replaced/erased?
> Look forward to hearing from your guys :) Thanks in advance!
> 
> Best regards,
> Xiaoyan





More information about the ndnSIM mailing list