[ndnSIM] bad_weak_ptr in delaying Interest sending

Hussein AlOmaisi alomaisi2004 at yahoo.com
Fri Dec 18 05:02:24 PST 2020

I am writing a forwarding strategy for vehicular networks. My proposed strategy involve inducing delay in sending Interest packets that are either locally generated or received ones. I am trying to impose delay in calling sendInterest() in myNewStrategy::afterReceiveInterest() as follow (in a simple form):

ns3::Time time = ns3::MilliSeconds (50);
ns3::EventId eId = ns3::Simulator::Schedule (time, &fw::myNewStrategy::sendInterest, this, pitEntry,FaceEndpoint(outFace,0), interest);

but I get the the bad weak pointer:
terminate called after throwing an instance of 'std::bad_weak_ptr'
  what():  bad_weak_ptr

However, when I call sendInterest() without scheduling, it work fines:
this->sendInterest(pitEntry,FaceEndpoint(outFace,0), interest);

What I can understnd from reading about the error. It is an exception that is thrown by shared pointer twhen a weak pointer refers to an already deleted object. In sendInterest()  declaration,  pitEntry paramtere that is only in form of shared pointer. I tried to use pitEnty in weak pointer form with checking its expirey but I got same error.Also, I am sure the delay time for sendInterest() is less than pitEnrty's expiry timer that invoke rejectPendingInterest() to erase the PIT entry.

I tried using debugging tool "gdb" to figure out what ipart of code is causing that, but it seems undefined behavior.

Could you help me in the following:

1. Did I do a mistake in calling sendInterest() and passing parameters to the scheduler function? if so, what is the correct way?
2. Why scheduling sendInterest() issues this kind of error? does that impact of parameters scope? Does it need to pass parameters as shared pointers, if so, does that will impose redeclare/define other methods such as onOutgoingInterest in forwarder.cpp to accept shared pointer paramteres?
3. I hope if anyone can share here a code snippet or links regarding this issue.
4. Is this error can be under this waring as I can read it in ndnSIM documentation:
The strategy must not retain shared_ptr<pit::Entry>, otherwise undefined behavior may occur. However, the strategy is allowed to store weak_ptr<pit::Entry>.  

Your assistance would be higly appreceiated.

 Best regards,
Hussein Al-OmaisiPh.D. StudentNetwork and Communication Technology Research Group (NCT LAB)Faculty of Information Science and Technology (FTSM)The National University of Malaysia (UKM) 43600 Bangi, SelangorMalaysia
Mobile +60172433904WhatsApp +967 771607828Email:            alomaisi2004 at yahoo.com
            p92824 at siswa.ukm.edu.my
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20201218/3b85a2b2/attachment.html>

More information about the ndnSIM mailing list