[ndnSIM] ndnSIM Digest, Vol 6, Issue 35 How to get instant link load

Alex Afanasyev alexander.afanasyev at ucla.edu
Tue Jun 4 10:28:18 PDT 2013

Hi Andriana,

If you're using stackHelper, it is possible to specify which exactly version of content store you want to initialize during "Install" phase and optionally it's parameters. For example:
helper.SetContentStore ("ns3::ndn::cs::Lfu", "MaxSize", "100000");

If you want to have different content stores installed on different nodes, you can select content stores, then install stack on some nodes, then change selection and install NDN stack on other nodes.  I just made an example of that in `examples/ndn-simple-with-cs-lfu.cc'.

While I would still recommend implementing "custom" content stores using policies (so you would not need to reimplement data structure for storage, correct lookup process, which takes care of finding cached item using potentially shorter name from the interest, does some "standard" logging so you can use cache tracer, etc.), it is possible to implement a completely different content store just by inheriting from ns3::ndn::ContentStore class, exactly as you described.  In fact, you probably have seen my message that I just sent to mailing list about Nocache "content store".  In this implementation I did exactly this (made a new class inherited from ContentStore and implemented pure virtual methods), since there is no need for special data structures or complex lookups.


> Hello,
> I just wonna stick to the last sentence of the below message regards to
> where should a new caching policy be implemented. I searched through some
> related classes and figured out an option of how to do so and just want to
> verify here or to let me know if someone has a better idea. I figured that
> when using the stackHelper to create your nodes the constructor
> automatically initiates the content store to use LRU policy and caching
> every object along the way. The main reason for it is the implementation
> class used, named as ndn-content-store-impl. That class inherits the main
> functions from the ndn-content-store class which has just virtual
> functions in it for the main operations that a content store has, e.g.
> lookup, add of an object, print -as far as i remember. So, would it be ok
> to implement a class that inherits the ndn-content-store class but
> identify the add function differently - doing caching only under some
> certain circumstances. If anyone has an opinion on this please let me
> know.
> Thanks in advance for your time!
> Kind regards,
> Andriana.
>> Message: 5
>> Date: Tue, 28 May 2013 23:21:53 -0700
>> From: Alex Afanasyev <alexander.afanasyev at ucla.edu>
>> To: ??? <blindeafer at 163.com>
>> Cc: ndnsim at lists.cs.ucla.edu
>> Subject: Re: [ndnSIM] How to get instant link load
>> Message-ID: <513C38AB-85DB-4DB7-8F7B-A7234B1842FE at ucla.edu>
>> Content-Type: text/plain; charset="utf-8"
>> Hi!
>> Can you define "instant" load more specifically?  You can't have "instant"
>> load, since it would be either 100% (packet "on the line") or 0% (nothing
>> is on the line).
>> In any case, to implement this, you could extend forwarding strategy to
>> keep track of amount of sent/received data on each face.  Here is some
>> example (though not exactly what you're looking for)
>> https://github.com/cawka/ndnSIM-ddos-interest-flooding/blob/master/extensions/stats.h
>> how it can be implemented.  In the example, the forwarding strategy
>> extension keeps track of number of forwarded interests and number of
>> unsatisfied.  You can overload different methods (InInterest, InData,
>> DidSendOutInterest, DidSendOutData) and get amount of sent/received data
>> instead.
>> After you have this module implemented, you can create a policy to control
>> how DATA packets are cached.  Currently, there are a number of policies
>> available, including LRU, LFU, Random, Persistent, and some other.  It is
>> not the case with all policies that all passing by DATA packets will be
>> cached.  For example, with Random policy, there is always a chance that
>> new item will be rejected.  In your case, you would need to write a
>> policy, that on every insert consults "stats" module and applies
>> probabilistic decision whether to cache item or not.
>> Here is just a little bit background that could be useful to understand
>> content store (I made this example before for FIB, but it is good for
>> Content Store as well):
>> -----------------
>> Content Store (as well as FIB and PIT) is organized using the underlying
>> data structure that is a complex tree.  Each node of the tree corresponds
>> to a name component, and connection to child nodes is implemented as a
>> hash array.   If you want, you can check more details by looking into the
>> source code in
>> https://github.com/NDN-Routing/ndnSIM/blob/master/utils/trie/trie.h.
>> An example
>> Let say, Content Store has cached DATA packets with the following names:
>> /a
>> /a/b
>> /a/d
>> /b/a
>> /b/b
>> The structure that will be created would look like
>> (root) --- a (*) ----- b (*)
>> \          \
>>  \           \------ d (*)
>>   \
>>    \----- b ----- a (*)
>>             \
>>              \---- b (*)
>> The nodes with (*) mean that at this level there is a payload (valid CS
>> entry), which can be returned during the lookup process.
>> Children on each level are stored in a hash-based container.
>> In addition to this trie structure, each inserted item is also subject to
>> a policy:  every time an item is inserted, looked up, modified, or
>> deleted, a policy is getting notified and can do some action, e.g., remove
>> item, promote item, or do something else.  Here are links to existing
>> policy implementations:
>> LRU:
>> https://github.com/NDN-Routing/ndnSIM/blob/master/utils/trie/lru-policy.h
>> LFU:
>> https://github.com/NDN-Routing/ndnSIM/blob/master/utils/trie/lfu-policy.h
>> Random:
>> https://github.com/NDN-Routing/ndnSIM/blob/master/utils/trie/random-policy.h
>> Persistent:
>> https://github.com/NDN-Routing/ndnSIM/blob/master/utils/trie/persistent-policy.h
>> -----------------
>> ---
>> Alex
>> On May 28, 2013, at 6:49 PM, ??? <blindeafer at 163.com> wrote:
>>> Hi all,
>>> I have an idea about cache scheme.In this scheme,I want to get the
>>> instant incoming link load everytime a contentobject come into a node
>>> and the outgoing link load(s) according to PIT entry if the
>>> contentobject is matched in PIT.What function I could modify and how can
>>> I write function to realize this idea?
>>> BTW,I wonder if a node will cache every contentobject when it comes
>>> in?What class and member function a node implement to cache a
>>> contentobject?
>>> Best regards.

More information about the ndnSIM mailing list