<div dir="ltr">Dear all <div>I just want to calculate the total number of received data packet on the consumer in the ndn-simple.cpp. I used the following code in which i used </div><div>the callback function named Client as well as global variable r to count the number of packets.</div><div><br></div><div>#include "ns3/core-module.h"<br>#include "ns3/network-module.h"<br>#include "ns3/point-to-point-module.h"<br>#include "ns3/ndnSIM-module.h"<br><br>namespace ns3 {<br></div><div><br></div><div>int r;<br>void Client(Ptr<const ndn::Data> d, Ptr<const ndn::App> app, Ptr<const ndn::Face> f)<br>{<br>std::cout<<"Total data packets recieved"<<r++<<endl;<br>}<br><br><br><br><br><br>int main(int argc, char* argv[]) {<br><br><br>     Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps"));<br>     Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms"));<br>     Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("20p"));<br><br>     // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize<br>     CommandLine cmd;<br>     cmd.Parse(argc, argv);<br><br>     // Creating nodes<br>     NodeContainer nodes;<br>     nodes.Create(3);<br><br>     // Connecting nodes using two links<br>     PointToPointHelper p2p;<br>     p2p.Install(nodes.Get(0), nodes.Get(1));<br>     p2p.Install(nodes.Get(1), nodes.Get(2));<br><br>     // Install NDN stack on all nodes<br>     ndn::StackHelper ndnHelper;<br>     ndnHelper.SetDefaultRoutes(true);<br>     ndnHelper.InstallAll();<br><br>     // Choosing forwarding strategy<br>     ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/multicast");<br><br>     // Installing applications<br><br>     // Consumer<br>     ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");<br>     // Consumer will request /prefix/0, /prefix/1, ...<br>     consumerHelper.SetPrefix("/prefix");<br>     consumerHelper.SetAttribute("Frequency", StringValue("10")); // 10 interests a second<br>     auto apps = consumerHelper.Install(nodes.Get(0));                        // first node<br>     apps.Stop(Seconds(10.0)); // stop the consumer app at 10 seconds mark<br><br>     // Producer<br>     ndn::AppHelper producerHelper("ns3::ndn::Producer");<br>     // Producer will reply to all requests starting with /prefix<br>     producerHelper.SetPrefix("/prefix");<br>     producerHelper.SetAttribute("PayloadSize", StringValue("1024"));<br>     producerHelper.Install(nodes.Get(2)); // last node<br>     Config::Connect("/NodeList/0/ApplicationList/*/ReceivedDatas", MakeCallback(&Client));<br>     Simulator::Stop(Seconds(20.0));<br><br>     Simulator::Run();<br>     Simulator::Destroy();<br><br>     return 0;<br>   }<br><br>  // setting default parameters for PointToPoint links and channels<br><br>}<br><br> // namespace ns3<br><br>int<br>main(int argc, char* argv[])<br>{<br><br><br>return ns3::main(argc, argv);<br><br><br>}<br><div>I am receiving the following error message:-</div><div><br></div><div><br></div><div>In file included from ./ns3/attribute.h:25,<br>                 from ./ns3/attribute-accessor-helper.h:23,<br>                 from ./ns3/core-module.h:12,<br>                 from ../scratch/ndn-simple.cc:22:<br>./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = const ndn::Data]’:<br>./ns3/callback.h:482:31:   required from ‘R ns3::FunctorCallbackImpl<T, R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::operator()(T1, T2, T3) [with T = void (*)(ns3::Ptr<const ndn::Data>, ns3::Ptr<const ns3::ndn::App>, ns3::Ptr<const nfd::face::Face>); R = void; T1 = ns3::Ptr<const ndn::Data>; T2 = ns3::Ptr<const ns3::ndn::App>; T3 = ns3::Ptr<const nfd::face::Face>; T4 = ns3::empty; T5 = ns3::empty; T6 = ns3::empty; T7 = ns3::empty; T8 = ns3::empty; T9 = ns3::empty]’<br>./ns3/callback.h:481:5:   required from here<br>./ns3/ptr.h:758:14: error: ‘const class ndn::Data’ has no member named ‘Unref’<br>  758 |       m_ptr->Unref ();<br>      |       ~~~~~~~^~~~~<br>./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = const ns3::ndn::App]’:<br>./ns3/callback.h:482:31:   required from ‘R ns3::FunctorCallbackImpl<T, R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::operator()(T1, T2, T3) [with T = void (*)(ns3::Ptr<const ndn::Data>, ns3::Ptr<const ns3::ndn::App>, ns3::Ptr<const nfd::face::Face>); R = void; T1 = ns3::Ptr<const ndn::Data>; T2 = ns3::Ptr<const ns3::ndn::App>; T3 = ns3::Ptr<const nfd::face::Face>; T4 = ns3::empty; T5 = ns3::empty; T6 = ns3::empty; T7 = ns3::empty; T8 = ns3::empty; T9 = ns3::empty]’<br>./ns3/callback.h:481:5:   required from here<br>./ns3/ptr.h:758:14: error: invalid use of incomplete type ‘const class ns3::ndn::App’<br>In file included from ./ns3/ndn-all.hpp:34,<br>                 from ./ns3/ndnSIM-module.h:10,<br>                 from ../scratch/ndn-simple.cc:25:<br>./ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.hpp:41:7: note: forward declaration of ‘class ns3::ndn::App’<br>   41 | class App;<br>      |       ^~~<br>In file included from ./ns3/attribute.h:25,<br>                 from ./ns3/attribute-accessor-helper.h:23,<br>                 from ./ns3/core-module.h:12,<br>                 from ../scratch/ndn-simple.cc:22:<br>./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = const nfd::face::Face]’:<br>./ns3/callback.h:482:31:   required from ‘R ns3::FunctorCallbackImpl<T, R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::operator()(T1, T2, T3) [with T = void (*)(ns3::Ptr<const ndn::Data>, ns3::Ptr<const ns3::ndn::App>, ns3::Ptr<const nfd::face::Face>); R = void; T1 = ns3::Ptr<const ndn::Data>; T2 = ns3::Ptr<const ns3::ndn::App>; T3 = ns3::Ptr<const nfd::face::Face>; T4 = ns3::empty; T5 = ns3::empty; T6 = ns3::empty; T7 = ns3::empty; T8 = ns3::empty; T9 = ns3::empty]’<br>./ns3/callback.h:481:5:   required from here<br>./ns3/ptr.h:758:14: error: ‘const class nfd::face::Face’ has no member named ‘Unref’<br>  758 |       m_ptr->Unref ();<br>      |       ~~~~~~~^~~~~<br>./ns3/ptr.h: In instantiation of ‘void ns3::Ptr<T>::Acquire() const [with T = const ndn::Data]’:<br>./ns3/ptr.h:743:3:   required from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&) [with T = const ndn::Data]’<br>./ns3/callback.h:482:31:   required from ‘R ns3::FunctorCallbackImpl<T, R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::operator()(T1, T2, T3) [with T = void (*)(ns3::Ptr<const ndn::Data>, ns3::Ptr<const ns3::ndn::App>, ns3::Ptr<const nfd::face::Face>); R = void; T1 = ns3::Ptr<const ndn::Data>; T2 = ns3::Ptr<const ns3::ndn::App>; T3 = ns3::Ptr<const nfd::face::Face>; T4 = ns3::empty; T5 = ns3::empty; T6 = ns3::empty; T7 = ns3::empty; T8 = ns3::empty; T9 = ns3::empty]’<br>./ns3/callback.h:481:5:   required from here<br>./ns3/ptr.h:712:14: error: ‘const class ndn::Data’ has no member named ‘Ref’<br>  712 |       m_ptr->Ref ();<br>      |       ~~~~~~~^~~<br>./ns3/ptr.h: In instantiation of ‘void ns3::Ptr<T>::Acquire() const [with T = const ns3::ndn::App]’:<br>./ns3/ptr.h:743:3:   required from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&) [with T = const ns3::ndn::App]’<br>./ns3/callback.h:482:31:   required from ‘R ns3::FunctorCallbackImpl<T, R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::operator()(T1, T2, T3) [with T = void (*)(ns3::Ptr<const ndn::Data>, ns3::Ptr<const ns3::ndn::App>, ns3::Ptr<const nfd::face::Face>); R = void; T1 = ns3::Ptr<const ndn::Data>; T2 = ns3::Ptr<const ns3::ndn::App>; T3 = ns3::Ptr<const nfd::face::Face>; T4 = ns3::empty; T5 = ns3::empty; T6 = ns3::empty; T7 = ns3::empty; T8 = ns3::empty; T9 = ns3::empty]’<br>./ns3/callback.h:481:5:   required from here<br>./ns3/ptr.h:712:14: error: invalid use of incomplete type ‘const class ns3::ndn::App’<br>In file included from ./ns3/ndn-all.hpp:34,<br>                 from ./ns3/ndnSIM-module.h:10,<br>                 from ../scratch/ndn-simple.cc:25:<br>./ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.hpp:41:7: note: forward declaration of ‘class ns3::ndn::App’<br>   41 | class App;<br>      |       ^~~<br>In file included from ./ns3/attribute.h:25,<br>                 from ./ns3/attribute-accessor-helper.h:23,<br>                 from ./ns3/core-module.h:12,<br>                 from ../scratch/ndn-simple.cc:22:<br>./ns3/ptr.h: In instantiation of ‘void ns3::Ptr<T>::Acquire() const [with T = const nfd::face::Face]’:<br>./ns3/ptr.h:743:3:   required from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&) [with T = const nfd::face::Face]’<br>./ns3/callback.h:482:31:   required from ‘R ns3::FunctorCallbackImpl<T, R, T1, T2, T3, T4, T5, T6, T7, T8, T9>::operator()(T1, T2, T3) [with T = void (*)(ns3::Ptr<const ndn::Data>, ns3::Ptr<const ns3::ndn::App>, ns3::Ptr<const nfd::face::Face>); R = void; T1 = ns3::Ptr<const ndn::Data>; T2 = ns3::Ptr<const ns3::ndn::App>; T3 = ns3::Ptr<const nfd::face::Face>; T4 = ns3::empty; T5 = ns3::empty; T6 = ns3::empty; T7 = ns3::empty; T8 = ns3::empty; T9 = ns3::empty]’<br>./ns3/callback.h:481:5:   required from here<br>./ns3/ptr.h:712:14: error: ‘const class nfd::face::Face’ has no member named ‘Ref’<br>  712 |       m_ptr->Ref ();<br>      |       ~~~~~~~^~~<br><br>Waf: Leaving directory `/home/sub/eclipse-workspace/ndnSIM/ns-3/build'<br>Build failed<br> -> task in 'ndn-simple' failed with exit status 1 (run with -v to display more information)<br></div><div><br></div>Please help me to trace the total data packets received ...</div><div>Thanks in advance</div><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div style="color:rgb(34,34,34)">Thanks & Regards<br></div><div><font color="#444444" face="georgia, serif" size="4">Subodh Mishra</font></div><div style="color:rgb(34,34,34)"><br></div><div style="color:rgb(34,34,34)"><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font color="#000000" face="times new roman, serif"><span style="font-size:small">Research Scholar (Ph.D),</span><br></font></div><div style="color:rgb(136,136,136);font-size:12.8px"><font size="2" color="#000000" face="times new roman, serif">Department of Computer Science and Engineering,</font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font size="2" color="#000000" face="times new roman, serif">PDPM-Indian Institute of Information Technology, </font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><font size="2" color="#000000" face="times new roman, serif">Design and Manufacturing, Jabalpur</font></div><div dir="ltr" style="color:rgb(136,136,136);font-size:12.8px"><br></div></div><div style="color:rgb(34,34,34);font-size:12.8px"><font color="#000000">Email: 1911602 [at] iiitdmj [dot] ac [dot] in ,</font></div><div style="color:rgb(34,34,34);font-size:12.8px"><font color="#000000">           subodhkmishra [at] gmail [dot] com</font></div></div></div></div>