[ndnSIM] Access outgoing data pipeline from strategy

Rakesh Ranjan Jha rakeshranjan.jha at gmail.com
Tue Jul 11 20:05:37 PDT 2017


Thanks a lot Spyros!

Hi Junxiao,
Will be very grateful for your input here.

Thanks,
Rakesh

On Tue, Jul 11, 2017 at 10:52 PM, Spyridon (Spyros) Mastorakis <
mastorakis at cs.ucla.edu> wrote:

> Hi Rakesh,
>
> I have cc’d Junxiao here. He is one of the main developers of NFD and he
> should be able to let us know what would be the most appropriate way to do
> that.
>
> Thanks,
>
> Spyridon (Spyros) Mastorakis
> Personal Website: http://cs.ucla.edu/~mastorakis/
> Internet Research Laboratory
> Computer Science Department
> UCLA
>
> On Jul 9, 2017, at 4:03 PM, Rakesh Ranjan Jha <rakeshranjan.jha at gmail.com>
> wrote:
>
> Hi Spyridon,
>
> Thanks for answering. Let me clarify my statements:
>
> m_forwarder currently in Strategy base class, Strategy.cpp is a private
> member and hence can't be accessed from derived class.
> class Strategy : public enable_shared_from_this<Strategy>, noncopyable
> {
> ...
> private:
>   Name m_name;
>
>   /** \brief reference to the forwarder
>    *
>    *  Triggers can access forwarder indirectly via actions.
>    */
>   Forwarder& m_forwarder;
> ...
> }
>
> Also currently forwarder class has only Strategy base class as friend.
>
> class Forwarder
> {
> ...
>   // allow Strategy (base class) to enter pipelines
>   friend class fw::Strategy;
> };
>
> So, as I mentioned earlier to work around these I made m_forwarder a
> protected member and also added my strategy class as friend to forwarder as
> well.
>
> With these changes now I can access the pipeline as well as access private
> members of m_fowarder but then I see the error when trying to access the
> content store and send the fetched data in the outgoing pipeline. What I
> wasn't sure is that similar call in forwarder passes but fails in my
> strategy class
>
> //fowarder.cpp - This passes
>     if (m_csFromNdnSim == nullptr) {
>       m_cs.find(interest,
>                 bind(&Forwarder::onContentStoreHit, this, ref(inFace),
> pitEntry, _1, _2),
>                 bind(&Forwarder::onContentStoreMiss, this, ref(inFace),
> pitEntry, _1));
>     }
>
> //myStrategy.cpp - This fails
>     if (m_forwarder.m_csFromNdnSim == nullptr) {
>         /* m_forwarder is a reference to forwarder */
> m_forwarder.m_cs.find(pe->getInterest(),
>                   bind(&Forwarder::onContentStoreHit, &m_forwarder,
> ref(face), pe, _1, _2),
>   bind(&Forwarder::onContentStoreMiss, &m_forwarder, ref(face), pe, _1));
>      }
>
>
> Also if there is a better way to access the CS and outgoing pipeline from
> strategy please let me know.
>
> Thanks again,
> Rakesh
>
>
> On Sun, Jul 9, 2017 at 6:47 PM, Spyridon (Spyros) Mastorakis <
> mastorakis at cs.ucla.edu> wrote:
>
>> Hi Rakesh,
>>
>> I would like to make 2 comments about your code:
>>
>> 1) m_forwarder is already a reference to an object of type Forwarder, so
>> you tried to get a reference out of a reference.
>>
>> 2) The m_cs attribute is declared as a private member of the Forwarder
>> class.
>>
>> Please let me know if you have any questions.
>>
>> Thank you,
>>
>> Spyridon (Spyros) Mastorakis
>> Personal Website: http://cs.ucla.edu/~mastorakis/
>> Internet Research Laboratory
>> Computer Science Department
>> UCLA
>>
>> On Jul 9, 2017, at 10:30 AM, Rakesh Ranjan Jha <
>> rakeshranjan.jha at gmail.com> wrote:
>>
>> Hi,
>>
>> I'm trying to spontaneously inject a cached data (based on a previously
>> unfulfilled interest present in PIT and so I have an interest handle to
>> fetch data) from content store.
>>
>> However, I'm facing some issues:
>>
>> 1) Derived strategy doesn't seem to have any handle to fowarder although
>> base strategy has a handle and is friend to forwarder to access pipelines.
>> In order to workaround this I added my strategy also as a friend and gave
>> it a reference to forwarder, similar to base strategy. Is there a better
>> way to access pipeline from strategy?
>>
>> 2) To access data from CS and feed it to outgoing data pipeline, I follow
>> similar mechanism as done on receiving valid interest from forwarder:
>> //fowarder.cpp
>>     if (m_csFromNdnSim == nullptr) {
>>       m_cs.find(interest,
>>                 bind(&Forwarder::onContentStoreHit, this, ref(inFace),
>> pitEntry, _1, _2),
>>                 bind(&Forwarder::onContentStoreMiss, this, ref(inFace),
>> pitEntry, _1));
>>     }
>>
>> //myStrategy.cpp
>>     if (m_forwarder.m_csFromNdnSim == nullptr) {
>>         /* m_forwarder is a reference to forwarder */
>> m_forwarder.m_cs.find(pe->getInterest(),
>>                   bind(&Forwarder::onContentStoreHit, &m_forwarder,
>> ref(face), pe, _1, _2),
>>  bind(&Forwarder::onContentStoreMiss, &m_forwarder, ref(face), pe, _1));
>>      }
>>
>> However this fails compilation and I get error as below:
>>
>> ../src/ndnSIM/NFD/daemon/fw/my_strategy.cpp: In member function ‘virtual
>> void nfd::fw::MyStrategy::beforeSatisfyInterest(std::shared_ptr<nfd::pit::Entry>,
>> const nfd::Face&, const ndn::Data&)’:
>> ../src/ndnSIM/NFD/daemon/fw/my_strategy.cpp:243:75: error: no matching
>> function for call to ‘nfd::cs::Cs::find(const ndn::Interest&,
>> std::_Bind_helper<false, void (nfd::Forwarder::*)(const nfd::Face&,
>> std::shared_ptr<nfd::pit::Entry>, const ndn::Interest&, const
>> ndn::Data&), nfd::Forwarder*, std::reference_wrapper<int>,
>> std::shared_ptr<nfd::pit::Entry>&, const std::_Placeholder<1>&, const
>> std::_Placeholder<2>&>::type, std::_Bind_helper<false, void
>> (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::Entry>,
>> const ndn::Interest&), nfd::Forwarder*, std::reference_wrapper<int>,
>> std::shared_ptr<nfd::pit::Entry>&, const std::_Placeholder<1>&>::type)’
>>       bind(&Forwarder::onContentStoreMiss, &m_forwarder, ref(face), pe,
>> _1));
>>
>>  ^
>> In file included from ../src/ndnSIM/NFD/daemon/fw/forwarder.hpp:35:0,
>>                  from ../src/ndnSIM/NFD/daemon/fw/strategy.hpp:29,
>>                  from ../src/ndnSIM/NFD/daemon/fw/my_strategy.hpp:24,
>>                  from ../src/ndnSIM/NFD/daemon/fw/my_strategy.cpp:21:
>> ../src/ndnSIM/NFD/daemon/fw/../table/cs.hpp:88:3: note: candidate: void
>> nfd::cs::Cs::find(const ndn::Interest&, const HitCallback&, const
>> MissCallback&) const
>>    find(const Interest& interest,
>>    ^
>> ../src/ndnSIM/NFD/daemon/fw/../table/cs.hpp:88:3: note:   no known
>> conversion for argument 2 from ‘std::_Bind_helper<false, void
>> (nfd::Forwarder::*)(const nfd::Face&, std::shared_ptr<nfd::pit::Entry>,
>> const ndn::Interest&, const ndn::Data&), nfd::Forwarder*,
>> std::reference_wrapper<int>, std::shared_ptr<nfd::pit::Entry>&, const
>> std::_Placeholder<1>&, const std::_Placeholder<2>&>::type {aka
>> std::_Bind<std::_Mem_fn<void (nfd::Forwarder::*)(const nfd::Face&,
>> std::shared_ptr<nfd::pit::Entry>, const ndn::Interest&, const
>> ndn::Data&)>(nfd::Forwarder*, std::reference_wrapper<int>,
>> std::shared_ptr<nfd::pit::Entry>, std::_Placeholder<1>,
>> std::_Placeholder<2>)>}’ to ‘const HitCallback& {aka const
>> std::function<void(const ndn::Interest&, const ndn::Data&)>&}’
>>
>> Can somebody help me figure out why this fails when similar invocation
>> from forwarder passes?
>>
>> Thanks in advance,
>> Rakesh
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20170711/72fdaa3e/attachment.html>


More information about the ndnSIM mailing list