[ndnSIM] Get node id in forwarding strategy
Klaus Schneider
klaus at cs.arizona.edu
Sat Jul 14 13:06:39 PDT 2018
Hey,
Sorry for the late reply, I just wanted to add another way of getting
the node id into the forwarding strategy:
You can just create a node pointer in the Forwarder class and pass it
via the constructor (the constructor is only called once in
ns3::ndn::L3Protocol::initialize() )
> Forwarder(ns3::Ptr<ns3::Node> node);
From there, it's easy to access from the strategy.
Best regards,
Klaus
On 14/06/18 05:44, Adhy Satya wrote:
> 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
> <mailto: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
> <mailto: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::Simulator::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 <mailto:ndnSIM at lists.cs.ucla.edu>
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
> <http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim>
>
>
>
>
>
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
>
More information about the ndnSIM
mailing list