[ndnSIM] Registering custom Consumers, Producers (or apps in general)?

Alex Afanasyev aa at CS.UCLA.EDU
Wed Nov 30 21:31:17 PST 2016

Hi John,

The magic comes from NS-3's object system (in addition to standard object system that C++ provides).  For the class to be found by the name, e.g., in the AppHelper constructor, it needs to be so called "registered".

It is just a matter of adding `NS_OBJECT_ENSURE_REGISTERED(YourClass);` and implementing YourClass::GetTypeId() method that defines name, constructor, and any parameters that you wish.

Check apps/ndn-consumer-cbr.cpp for example.  You'll find similar code in many other "ns3::Object"-derived classes.


> On Nov 30, 2016, at 9:27 PM, John Baugh <jpbaugh at umich.edu> wrote:
> ndnSIM friends,
> In one of the examples, there is a line:
> ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
> Where does it know to find ConsumerCbr?  Do I just have to put the namespace and scope resolution operators if I, for example, create a custom consumer, producer, or other app?
> Also, there appears to be an error in the documentation, 
> http://ndnsim.net/2.2/doxygen/classns3_1_1ndn_1_1AppHelper.html#a67d941c1628aceef4b8add5c564ed3df <http://ndnsim.net/2.2/doxygen/classns3_1_1ndn_1_1AppHelper.html#a67d941c1628aceef4b8add5c564ed3df>
> The parameter named in the constructor (the const string reference) is named prefix in the header, but the description names it app.
> Thanks,
> John
> _______________________________________________
> 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/20161130/2aed6f4b/attachment.html>

More information about the ndnSIM mailing list