[ndnSIM] Get node id in forwarding strategy

Adhy Satya adhysatya820 at gmail.com
Thu Jun 14 05:44:47 PDT 2018


Hi Alex. Hi John,

Thanks for the answers.

@Alex, I'm not sure if I understood your solution correctly. The line
"*ns3::Ptr<ns3::Node>
node = ns3::NodeList::GetNode(ns3::Simulator::GetContext());*" is causing
the crash because in some cases the call to Simulator::GetContext() was
returning an invalid number. What should I use instead?

@John, this solution seems to work for me :) Thanks.


Best,
Adhy


On Thu, Jun 14, 2018 at 6:30 AM, John Baugh <jpbaugh at umich.edu> wrote:

> I think using the Simulator::ScheduleWithContext would be the best, as
> Alex just suggested.
>
> However, what is the behavior if you tried something like:
>
> void
> BroadcastStrategy::afterReceiveInterest(const Face& inFace, const
> Interest& interest,const shared_ptr<pit::Entry>& pitEntry)
> {
>   const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
>   const fib::NextHopList& nexthops = fibEntry.getNextHops();
>
>  *int contextVal = ns3::Simulator::GetContext();*
>
> * if(contextVal != -1) *
> * {*
> *    ns3::Ptr<ns3::Node> node = ns3::NodeList::GetNode(contextVal);  *
>     ns3::Ptr<ns3::NetDevice> netDevice;
>     ns3::Ptr<ns3::ndn::L3Protocol> ndnl3;
>     ndnl3 = node->GetObject<ns3::ndn::L3Protocol>();
>  }
>
>
> //...........
>
> Thoughts?
>
> John
>
> On Wed, Jun 13, 2018 at 8:33 PM, Adhy Satya <adhysatya820 at gmail.com>
> wrote:
>
>> Hi,
>>
>> I wrote a custom fw-strategy where I get the node ID like so:
>>
>> void
>> BroadcastStrategy::afterReceiveInterest(const Face& inFace, const
>> Interest& interest,const shared_ptr<pit::Entry>& pitEntry)
>> {
>>   const fib::Entry& fibEntry = this->lookupFib(*pitEntry);
>>   const fib::NextHopList& nexthops = fibEntry.getNextHops();
>>
>>
>>   ns3::Ptr<ns3::Node> node = ns3::NodeList::GetNode(ns3::Si
>> mulator::GetContext());
>>   ns3::Ptr<ns3::NetDevice> netDevice;
>>   ns3::Ptr<ns3::ndn::L3Protocol> ndnl3;
>>   ndnl3 = node->GetObject<ns3::ndn::L3Protocol>();
>>
>>
>> The issue is that I'm getting the exact same error as this post from Oct
>> 2017
>> <http://www.lists.cs.ucla.edu/pipermail/ndnsim/2017-October/004175.html>.
>> There are several other posts with the same issue, some want to get the
>> node id in the lru-cache, etc. However, all these posts seem to be
>> scheduling an event, then getting with Simulator::GetContext().
>>
>> I can't apply the solution from this posts in my case, since I don't call
>> Simulator::ScheduleWithContext(). I just want to get the id of the node
>> that is processing the Interest.
>>
>> Is there another option to this?
>>
>> I'm using ndnSIM 2.5
>>
>> Thank you!
>> Adhy
>>
>>
>> _______________________________________________
>> 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/20180614/e7576d88/attachment-0001.html>


More information about the ndnSIM mailing list