[ndnSIM] Compilng error during the usage of "name.toUri()"

John Baugh jpbaugh at umich.edu
Sun Nov 20 22:25:45 PST 2016


Try checking if name is nullptr:

ns3::ndn::Name name = entry-> GetPrefix();

if(name != nullptr)
  name.toUri();
else
  cout<<"ooops!"<<endl;

On Nov 21, 2016 1:18 AM, "Alex Afanasyev" <aa at cs.ucla.edu> wrote:

>
> > On Nov 20, 2016, at 10:15 PM, ZHANG, Lu <lu.zhang at fuji.waseda.jp> wrote:
> >
> > Hi all,
> >
> > I would like to print out the prefix name in PIT on to screen by using
> the toUri() function in Name class. The topology is simple as below:
> >
> >
> >  *      +----------+     10Mbps      +--------+     10Mbps
> +----------+
> >  *      | consumer | <------------> | router | <------------> | producer
> |
> >  *      +----------+         10ms      +--------+          10ms
>  +----------+
> >  *
> >
> >
> > Part of my program is like below:
> >
> >   Ptr<ndn::Pit> pit = nodes.Get(1)->GetObject<ndn::Pit> ();
> >   Ptr<ndn::pit::Entry> entry = pit->Find(ns3::ndn::Name("/prefix"));
> >   ns3::ndn::Name name = entry-> GetPrefix();
> >   name.toUri();
> >
> > When executing compile command ./waf --run 1 --vis I got below output:
> >
> > Command ['/home/11/ndnSIM/ns-3/build/scratch/1', '--
> SimulatorImplementationType=ns3::VisualSimulatorImpl'] terminated with
> signal SIGSEGV. Run it under a debugger to get more information (./waf
> --run <program> --command-template="gdb --args %s <args>").
> >
> > Any one have clue on why this happens or how should I use the toUri()
> function?
>
> You can check to run the scenario in the debugger using the suggested
> command, but I would suspect that you're simply getting a segfault because
> there is no "/prefix" entry in the PIT (Find returns NULL and then you're
> dereferencing NULL).
>
> ---
> Alex
>
>
> _______________________________________________
> ndnSIM mailing list
> ndnSIM at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20161121/e68b2b1a/attachment.html>


More information about the ndnSIM mailing list