[ndnSIM] Conversion from ns3::Application to specific application type.

Anil Jangam anilj.mailing at gmail.com
Sat Dec 19 18:12:30 PST 2015


Thanks Junxiao,

I did not understand how Application object is installed using
AddApplication() in the Install() method of AppHelper and yet it can be
retrieved by node->GetObject<ConsumerCbr>(). This API is not symmetric but
it working!

->GetObject<ConsumerCbr>(), I think is typically used when the object is
added to the node by aggregate() function, isn't it?

Since the install uses AddApplication() I think we can use GetApplication()
to get reference to installed application. My type casting is failing at
compile time.

error: invalid conversion from ‘ns3::Application*’ to ‘ns3::ndn::NlsrApp*’
[-fpermissive]

The corresponding line is. So what kind of type casting required here?
 Ptr<ndn::NlsrApp> nlsrApp = (Ptr<ndn::NlsrApp>) (*i)->GetApplication(0);

AFA setting attributes is concerned, I do not know how it works. I want to
set the config object into the application used inside the application's
logic. To give an analogy, I am trying to set the configuration object
inside the app::RealApp.
I have exact same implementation as given here:
http://ndnsim.net/2.1/guide-to-simulate-real-apps.html (Read from : How to
simulate real applications...)

/anil.



On Sat, Dec 19, 2015 at 3:00 PM, Junxiao Shi <shijunxiao at email.arizona.edu>
wrote:

> Hi Anil
>
> To get Ptr<ConsumerCbr> from Ptr<Application>, you may use type-casting or
> ->GetObject<ConsumerCbr>().
>
> The proper way to set a parameter onto an application object is through
> ns-3 attributes.
>
> See ns-3 Manual <
> https://www.nsnam.org/docs/release/3.24/manual/html/index.html> "Object
> Model" and "Configuration and Attributes" section for more information.
>
> Yours, Junxiao
> On Dec 19, 2015 3:45 PM, "Anil Jangam" <anilj.mailing at gmail.com> wrote:
>
>> Hi,
>>
>> In a scenario where an application instance is installed on the nodes,
>> what is the way to retrieve that application instance from the node?
>>
>> In my requirement, I want to set some parameters into my application
>> object, which is not possible at the time it is installed on the node.
>> Perhaps they all do not use the parametrized constructor (I am talking
>> about the classes in ns-3/src/ndnSIM/apps path).
>>
>> In an example below:
>>  80   ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
>>  83   consumerHelper.Install(consumerNodes);
>>
>> I want to retrieve back the instance of "ns3::ndn::ConsumerCbr" from the
>> consumerNodes object.
>>
>> I checked the API in bit details, the ndn-app-helper has this code:
>> 119   Ptr<Application> app = m_factory.Create<Application>();
>> 120   node->AddApplication(app);
>>
>> The node interface also provides an API GetApplication, but it returns
>> Application instance:
>> 160 Ptr<Application>
>> 161 Node::GetApplication (uint32_t index) const
>>
>> How to convert it from ns3::Application to ns3::ndn::ConsumerCbr? Perhaps
>> this is simple type casting operation, but just want to confirm it.
>>
>> Any other suggestion to achieve the same (i.e. updating the application
>> instance installed on the node) is also fine with me.
>>
>> /anil.
>>
>>
>>
>> _______________________________________________
>> 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/20151219/e200a527/attachment.html>


More information about the ndnSIM mailing list