[ndnSIM] Help Needed: Getting Node Name in Forwarder.cpp for Output Logging
Mohammad R. Shakournia
shakournia at ut.ac.ir
Fri Mar 7 03:35:15 PST 2025
I created a function to retrieve the node name by mapping an nfd::Forwarderto the corresponding ns-3 node. First, I iterate through all nodes in ns3::NodeList, find the node that is running this forwarder, and then retrieve its name. The key part of the function looks like this:
ns3::Ptr<ns3::ndn::L3Protocol> l3proto = node->GetObject<ns3::ndn::L3Protocol>();
if (l3proto) { nfd::Forwarder* fwd = l3proto->getForwarder().get();
if (fwd == thisFwd) { std::string name = ns3::Names::FindName(node); }}
I also made another change in the forwarder. The original function signature used FaceEndpoint ingress, which takes all faces as input. I modified it to nfd::face::Face& to allow handling individual faces of nodes.
By the way, thanks for your help! Everything is working well now.
March 4, 2025 at 8:18 AM, "DJEMAA Adel" <a_djemaa at esi.dz mailto:a_djemaa at esi.dz?to=%22DJEMAA%20Adel%22%20%3Ca_djemaa%40esi.dz%3E > wrote:
>
> Dear Mohammad,
> Try this code to retrieve node names in Forwader.cpp file:
> auto node = ns3::NodeList::GetNode(ns3::Simulator::GetContext());
> std::cout<<" ************ Node ID :****************"<< node->GetId() <<std::endl;
> You need to include these:
> #include <ns3/node-list.h>
> #include <ns3/node.h>
> Let us know if this answers your question.
> kind regards;
>
> Le lun. 3 mars 2025 à 16:49, Mohammad R. Shakournia via ndnSIM <ndnsim at lists.cs.ucla.edu mailto:ndnsim at lists.cs.ucla.edu > a écrit :
>
> >
> > Dear ndnSIM community,
> >
> > I am currently working on measuring CS and PIT lookup times in **Forwarder.cpp** by using a clock in the **onIncomingInterest** function. I log these measurements to separate output files for each node. However, I am facing an issue:
> >
> > 1. The node names are **not appearing** in my output files.
> >
> > 2. When using tracers like **L3Tracer**, multiple faces are assigned to each node, making it difficult to map **faceId** to the corresponding **node name**, even with explicit mapping.
> >
> > I tried retrieving node names using ns3::Names::FindName(node), but it does not always return the expected results. Could you please guide me on how to correctly obtain the **node name** in **Forwarder.cpp** and include it in my output logs?
> >
> > Any insights or suggestions would be greatly appreciated.
> >
> > Best regards,
> >
> > Mohammad Reza Shakournia
> >
> > _______________________________________________
> > ndnSIM mailing list
> > ndnSIM at lists.cs.ucla.edu mailto:ndnSIM at lists.cs.ucla.edu
> > https://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
> >
>
> --
> Mr DJAMA Adel
> Phd
> Ecole Militaire Polytechnique
> Algiers 16046, ALGERIA
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20250307/a077a3df/attachment.htm>
More information about the ndnSIM
mailing list