[ndnSIM] Custom Strategy for Interest data collection - not working?

John Baugh jpbaugh at umich.edu
Fri Jan 6 19:14:44 PST 2017


Alex,

When you say that the strategies aren't intended to be overridden, do you
mean those such as MulticastStrategy?

I assume Strategy will still be overridable.

My entire purpose for this code isn't to actually modify the strategy, but
to be able to use an existing strategy, with some logging / data collection
occurring.

I'm ultimately going to use the data collected about interests in the
Policy.  So the classes will have to interact.

Also, from your description, I now assume STRATEGY_NAME must have that
exact name, and is used elsewhere besides just setting the default
parameter?  Is this behavior / requirement documented anywhere?

Thanks,

John


On Jan 6, 2017 7:40 PM, "Alex Afanasyev" <aa at cs.ucla.edu> wrote:

Here is a quick patch to "fix" the issue.  It is a requirement to have
STRATEGY_NAME **as a static variable** in the strategy class.  Otherwise,
strategy is simply not being registered properly.

Also, while possible right now, the strategies are not designed to be
overridden.  In the upcoming release, it would result in compilation error.

--
Alex

================= begin patch =====================
diff --git a/extensions/PopularityStrategy.cpp b/extensions/
PopularityStrategy.cpp
index ecae694..36cc08a 100644
--- a/extensions/PopularityStrategy.cpp
+++ b/extensions/PopularityStrategy.cpp
@@ -5,11 +5,12 @@ using namespace std;
 namespace nfd {
 namespace fw {

-//const ndn::Name PopularityStrategy::STRATEGY_NAME =
"ndn:/localhost/nfd/strategy/popularity-strategy";
+const ndn::Name PopularityStrategy::STRATEGY_NAME =
"ndn:/localhost/nfd/strategy/popularity-strategy";

 NFD_REGISTER_STRATEGY(PopularityStrategy);

-PopularityStrategy::PopularityStrategy(Forwarder& forwarder, const Name&
name) : MulticastStrategy(forwarder, name)
+PopularityStrategy::PopularityStrategy(Forwarder& forwarder, const Name&
name)
+  : MulticastStrategy(forwarder, name)
 {
    cout<<"Inside ctor for PopularityStrategy"<<endl;
 }//end ctor
@@ -20,7 +21,7 @@ PopularityStrategy::afterReceiveInterest(const Face&
inFace,
                                const shared_ptr<pit::Entry>& pitEntry)
 {
   //behave just like the multicast strategy
-  MulticastStrategy::afterReceiveInterest(inFace, interest, pitEntry);
+  // MulticastStrategy::afterReceiveInterest(inFace, interest, pitEntry);

   //also, maintain popularity eventually
   cout<<"In afterReceiveInterest, with interest:
"<<interest.getName().toUri()<<endl;
diff --git a/extensions/PopularityStrategy.hpp b/extensions/
PopularityStrategy.hpp
index 4a0e6b4..447be49 100644
--- a/extensions/PopularityStrategy.hpp
+++ b/extensions/PopularityStrategy.hpp
@@ -9,8 +9,6 @@
 namespace nfd {
 namespace fw {

-const ndn::Name STRATEGY_NAME("ndn:/localhost/nfd/strategy/popularity-
strategy");
-
 class PopularityStrategy : public MulticastStrategy {

 public:
@@ -20,7 +18,7 @@ public:
   afterReceiveInterest(const Face& inFace, const Interest& interest,
                        const shared_ptr<pit::Entry>& pitEntry);

-  //static const ndn::Name STRATEGY_NAME("ndn:/localhost/
nfd/strategy/popularity-strategy")
+  static const ndn::Name STRATEGY_NAME;

================== end patch =======================

On Jan 6, 2017, at 1:37 PM, John Baugh <jpbaugh at umich.edu> wrote:

Alex and ndnSIM friends,

Anyone get a chance to look at this?  I am truly at a loss.

On Jan 5, 2017 10:00 PM, "John Baugh" <jpbaugh at umich.edu> wrote:

> Alex,
>
> I think I've got this right.  Let me know if you have any problems
> downloading the necessary files:
>
> https://github.com/profjpbaugh/ndnSIM-strategy1
>
> Thanks,
>
> John
>
> On Thu, Jan 5, 2017 at 8:54 PM, Alex Afanasyev <aa at cs.ucla.edu> wrote:
>
>> If you can share you scenario repo on github, it would be much easier.
>> As I will be able to compile and try to run the code.
>>
>> --
>> Alex
>>
>> On Jan 5, 2017, at 5:34 PM, John Baugh <jpbaugh at umich.edu> wrote:
>>
>> Alex and others,
>>
>> I have updated the code:
>> https://drive.google.com/open?id=0By9ufeKqmJYYY3Rzem5EN0ZyREE
>>
>> I even included the PolicyToFile class that does successfully print
>> content store related things to the file.
>>
>> But even after adding GlobalRoutingHelper functions, I cannot get this to
>> work.  I'll assume it's not a problem related to me subclassing
>> MulticastStrategy rather than Strategy, is it?
>>
>> But, I'm doing everything that is in the example on ndnSIM's website.  I
>> used the RandomLoadBalancer as my example.  It still isn't working.
>>
>> I'm not even at the point where I'm doing much with the actual
>> interests...  I just want to print out information when an interest is
>> received, and when the object is created initially (i.e., when the ctor is
>> called.)
>>
>> Any help would be greatly appreciated, as always.  If anyone could run
>> the code and see if you can figure out what's going on, I'd be very
>> appeciative (make a umd subdirectory for the Policy class .hpp and .cpp, or
>> change around the includes - doesn't matter, of course)
>>
>> Thanks,
>>
>> John
>>
>> On Thu, Jan 5, 2017 at 2:47 AM, Alex Afanasyev <aa at cs.ucla.edu> wrote:
>>
>>> I think you forgot to configure FIBs, e.g., using GlobalRoutingHelper.
>>>
>>> ---
>>> Alex
>>>
>>> On Jan 4, 2017, at 11:42 PM, John Baugh <jpbaugh at umich.edu> wrote:
>>>
>>> ndnSIM friends,
>>>
>>> I am continuing a previous attempt at creating a Custom Strategy, for
>>> the primary purpose of recording information on Interests as they arrive at
>>> a router.
>>>
>>> The three involved files, linked in my Google Drive are:
>>>
>>> 1. *The scenario file:*   (jpb-strategy1-test.cpp)
>>>      https://drive.google.com/open?id=0By9ufeKqmJYYWXNpbEFYSEI2VWc
>>>
>>> 2. *The PopularityStrategy.hpp file* with my custom strategy
>>> specification
>>>      https://drive.google.com/open?id=0By9ufeKqmJYYQm5BQVRSQzNjSnc
>>>
>>> 3.  *The PopularityStrategy.cpp file* with the implementation of the
>>> custom strategy class
>>>       https://drive.google.com/open?id=0By9ufeKqmJYYcTFXc1ZUcnpfQTA
>>>
>>>
>>> Notes:
>>> - I have the scenario file in the *scenarios* directory (I'm using the
>>> template from GitHub)
>>> - I have the PopularityStrategy.[hpp,cpp] files in the *extensions *
>>> directory
>>> - I subclassed MulticastStrategy to create the PopularityStrategy
>>> - I did call NFD_REGISTER_STRATEGY at the top of the
>>> PopularityStrategy.cpp file
>>>
>>> Everything compiles just fine, but I get *no printout from the
>>> PopularityStrategy *class.  I have cout<< inside both the constructor
>>> and the afterReceiveInterest function.
>>>
>>> It's as if it's not being used at all.
>>>
>>> I am very much at a loss, and would greatly appreciate assistance on
>>> this.  It's close.  I can feel it.  :)
>>>
>>> Thanks,
>>>
>>> John
>>>
>>>
>>> _______________________________________________
>>> 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/20170106/876e6eb4/attachment.html>


More information about the ndnSIM mailing list