[ndnSIM] (no subject)

SUBODH MISHRA 1911602 at iiitdmj.ac.in
Fri Jan 7 04:53:36 PST 2022


Dear all
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
the callback function named Client as well as global variable r to count
the number of packets.

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/ndnSIM-module.h"

namespace ns3 {

int r;
void Client(Ptr<const ndn::Data> d, Ptr<const ndn::App> app, Ptr<const
ndn::Face> f)
{
std::cout<<"Total data packets recieved"<<r++<<endl;
}





int main(int argc, char* argv[]) {


     Config::SetDefault("ns3::PointToPointNetDevice::DataRate",
StringValue("1Mbps"));
     Config::SetDefault("ns3::PointToPointChannel::Delay",
StringValue("10ms"));
     Config::SetDefault("ns3::QueueBase::MaxSize", StringValue("20p"));

     // Read optional command-line parameters (e.g., enable visualizer with
./waf --run=<> --visualize
     CommandLine cmd;
     cmd.Parse(argc, argv);

     // Creating nodes
     NodeContainer nodes;
     nodes.Create(3);

     // Connecting nodes using two links
     PointToPointHelper p2p;
     p2p.Install(nodes.Get(0), nodes.Get(1));
     p2p.Install(nodes.Get(1), nodes.Get(2));

     // Install NDN stack on all nodes
     ndn::StackHelper ndnHelper;
     ndnHelper.SetDefaultRoutes(true);
     ndnHelper.InstallAll();

     // Choosing forwarding strategy
     ndn::StrategyChoiceHelper::InstallAll("/prefix",
"/localhost/nfd/strategy/multicast");

     // Installing applications

     // Consumer
     ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
     // Consumer will request /prefix/0, /prefix/1, ...
     consumerHelper.SetPrefix("/prefix");
     consumerHelper.SetAttribute("Frequency", StringValue("10")); // 10
interests a second
     auto apps = consumerHelper.Install(nodes.Get(0));
   // first node
     apps.Stop(Seconds(10.0)); // stop the consumer app at 10 seconds mark

     // Producer
     ndn::AppHelper producerHelper("ns3::ndn::Producer");
     // Producer will reply to all requests starting with /prefix
     producerHelper.SetPrefix("/prefix");
     producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
     producerHelper.Install(nodes.Get(2)); // last node
     Config::Connect("/NodeList/0/ApplicationList/*/ReceivedDatas",
MakeCallback(&Client));
     Simulator::Stop(Seconds(20.0));

     Simulator::Run();
     Simulator::Destroy();

     return 0;
   }

  // setting default parameters for PointToPoint links and channels

}

 // namespace ns3

int
main(int argc, char* argv[])
{


return ns3::main(argc, argv);


}
I am recieving the following error:-


In file included from ./ns3/attribute.h:25,
                 from ./ns3/attribute-accessor-helper.h:23,
                 from ./ns3/core-module.h:12,
                 from ../scratch/ndn-simple.cc:22:
./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = const
ndn::Data]’:
./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]’
./ns3/callback.h:481:5:   required from here
./ns3/ptr.h:758:14: error: ‘const class ndn::Data’ has no member named
‘Unref’
  758 |       m_ptr->Unref ();
      |       ~~~~~~~^~~~~
./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = const
ns3::ndn::App]’:
./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]’
./ns3/callback.h:481:5:   required from here
./ns3/ptr.h:758:14: error: invalid use of incomplete type ‘const class
ns3::ndn::App’
In file included from ./ns3/ndn-all.hpp:34,
                 from ./ns3/ndnSIM-module.h:10,
                 from ../scratch/ndn-simple.cc:25:
./ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.hpp:41:7: note: forward
declaration of ‘class ns3::ndn::App’
   41 | class App;
      |       ^~~
In file included from ./ns3/attribute.h:25,
                 from ./ns3/attribute-accessor-helper.h:23,
                 from ./ns3/core-module.h:12,
                 from ../scratch/ndn-simple.cc:22:
./ns3/ptr.h: In instantiation of ‘ns3::Ptr<T>::~Ptr() [with T = const
nfd::face::Face]’:
./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]’
./ns3/callback.h:481:5:   required from here
./ns3/ptr.h:758:14: error: ‘const class nfd::face::Face’ has no member
named ‘Unref’
  758 |       m_ptr->Unref ();
      |       ~~~~~~~^~~~~
./ns3/ptr.h: In instantiation of ‘void ns3::Ptr<T>::Acquire() const [with T
= const ndn::Data]’:
./ns3/ptr.h:743:3:   required from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&)
[with T = const ndn::Data]’
./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]’
./ns3/callback.h:481:5:   required from here
./ns3/ptr.h:712:14: error: ‘const class ndn::Data’ has no member named ‘Ref’
  712 |       m_ptr->Ref ();
      |       ~~~~~~~^~~
./ns3/ptr.h: In instantiation of ‘void ns3::Ptr<T>::Acquire() const [with T
= const ns3::ndn::App]’:
./ns3/ptr.h:743:3:   required from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&)
[with T = const ns3::ndn::App]’
./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]’
./ns3/callback.h:481:5:   required from here
./ns3/ptr.h:712:14: error: invalid use of incomplete type ‘const class
ns3::ndn::App’
In file included from ./ns3/ndn-all.hpp:34,
                 from ./ns3/ndnSIM-module.h:10,
                 from ../scratch/ndn-simple.cc:25:
./ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.hpp:41:7: note: forward
declaration of ‘class ns3::ndn::App’
   41 | class App;
      |       ^~~
In file included from ./ns3/attribute.h:25,
                 from ./ns3/attribute-accessor-helper.h:23,
                 from ./ns3/core-module.h:12,
                 from ../scratch/ndn-simple.cc:22:
./ns3/ptr.h: In instantiation of ‘void ns3::Ptr<T>::Acquire() const [with T
= const nfd::face::Face]’:
./ns3/ptr.h:743:3:   required from ‘ns3::Ptr<T>::Ptr(const ns3::Ptr<T>&)
[with T = const nfd::face::Face]’
./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]’
./ns3/callback.h:481:5:   required from here
./ns3/ptr.h:712:14: error: ‘const class nfd::face::Face’ has no member
named ‘Ref’
  712 |       m_ptr->Ref ();
      |       ~~~~~~~^~~

Waf: Leaving directory `/home/sub/eclipse-workspace/ndnSIM/ns-3/build'
Build failed
 -> task in 'ndn-simple' failed with exit status 1 (run with -v to display
more information)

Please help me to trace the total data packets received ...
Thanks in advance

Thanks & Regards
Subodh Mishra

Research Scholar (Ph.D),
Department of Computer Science and Engineering,
PDPM-Indian Institute of Information Technology,
Design and Manufacturing, Jabalpur

Email: 1911602 [at] iiitdmj [dot] ac [dot] in ,
           subodhkmishra [at] gmail [dot] com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20220107/3422496d/attachment-0001.html>


More information about the ndnSIM mailing list