[ndnSIM] How to get Node Id?
Alex Afanasyev
aa at cs.fiu.edu
Thu Mar 15 10:10:23 PDT 2018
> On Mar 15, 2018, at 1:06 PM, Mudasir Qazi <mudasirqazi00 at gmail.com <mailto:mudasirqazi00 at gmail.com>> wrote:
>
> Hi,
>
> I am looking for the ID of a node in the network. I want to know which node has sent interest or data etc.
>
> I have found following way to get it in ndn-app-link-service.cpp class, and it works fine because this class has m_node private member.
>
> uint32_t nodeId = m_node->GetId(); //works fine in ndn-app-link-service.cpp
>
> But, the problem is, I also need to get Node ID in forwarder.cpp as well as on several other places in whole ndnSIM. I have tried following method to get it in forwarder.cpp but it does not work.
>
> //does not work in forwarder.cpp
> ns3::Ptr<ns3::Application> app = ns3::Ptr<ns3::Application>();
the above is pointless-- you're creating nullptr and then trying to dereference.
> ns3::Ptr<ns3::Node> node = app->GetNode();
> uint32_t nodeId = node->GetId();
You can use simulator context to get access to the node (same as in ndn-cxx/src/face.cpp on line 98):
ns3::Ptr<ns3::Node> node = ns3::NodeList::GetNode(ns3::Simulator::GetContext());
--
Alex
>
> Please guide me how can I get it in forwarder.cpp as well as give me a general method to get it wherever it is needed in whole ndnSIM for future purposes.
>
>
> --
> Regards,
> Mudasir Qazi
> _______________________________________________
> 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
______________
Alex Afanasyev
Assistant Professor, SCIS, Florida International University
11200 SW 8th Street, ECS Room 261B, Miami, FL 33199
phone: +1.305.348.4960 (office); email: aa at cs.fiu.edu <mailto:aa at cs.fiu.edu>
web: https://users.cs.fiu.edu/~afanasyev/ <https://users.cs.fiu.edu/~afanasyev/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20180315/e849e762/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 873 bytes
Desc: Message signed with OpenPGP
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20180315/e849e762/attachment.sig>
More information about the ndnSIM
mailing list