[ndnSIM] Creating Custom Strategy that keeps state.

Junxiao Shi shijunxiao at email.arizona.edu
Sat Jun 24 11:30:03 PDT 2017

Hi Lixia

A strategy cannot keep states on its instance, because NFD can re-create
the instance anytime. Once the instance is re-created, any states on the
instance would be lost. This requirement is on the API docs since the
NFD started doing the re-creating since sometime in 2016, when
StrategyChoice table was refactored. Since then, every StrategyChoice entry
has its own Strategy instance, instead of pointing to a global instance.
Any changes in StrategyChoice table would cause the strategy in affected
namespaces to lose any instance states.

I know many experimenters are guilty of making a "stateful" strategy
(myself included, in AccessStrategy::m_fit as OP noticed), but this is
never supported in the API. AsfStrategy is a good example where all states
are properly stored in Measurements.

Yours, Junxiao

On Sat, Jun 24, 2017 at 07:02 Lixia Zhang <lixia at cs.ucla.edu> wrote:

> this is just for my own understanding: I wonder why a strategy instance is
> not allowed to keep state?
> to avoid the same measurement result replicated in multiple strategy
> instances?
> whatever the reason, I feel it might be helpful if your reply also
> mentions it, to make everyone understand.
> On Jun 23, 2017, at 2:49 PM, Junxiao Shi <shijunxiao at email.arizona.edu>
> wrote:
> Hi Johnson
> Strategy should not keep states on its own instance. All states must be
> stored as StrategyInfo in a PIT or Measurements entry. Violating this rule
> triggers undefined behavior. See NFD developer guide "strategy storage"
> section for more information.
> Yours, Junxiao
> On Fri, Jun 23, 2017 at 2:43 PM, Olumide Akinwande <
> jolumideakinwande at yahoo.com> wrote:
>> Hi ndnSim friends,
>> I am trying to create a custom strategy that keeps state and I need some
>> help.
>> Going through the access-strategy in the ndnSim package, I'm a bit
>> confused about how some of the data structures declared in the
>> access-strategy.hpp are initialized.
>> For example an unordered_map is defined called "m_fit" that maps FaceId
>> to FaceInfo (class defined in the .hpp file) but in the access-strategy.cpp
>> file, only access actions are performed on "m_fit" (which is performed
>> twice).
>> I'm confused on how this map was initialised or its values set.
>> I think understanding the process is important for my programming and I
>> will be glad for any help.
>> Thanks,
>> Johnson
> _______________________________________________
> 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/20170624/01e687f2/attachment-0001.html>

More information about the ndnSIM mailing list