Access custom application functions directly

31 views
Skip to first unread message

Muhammad Sabet

unread,
Jul 26, 2016, 1:37:21 AM7/26/16
to ns-3-users
Hi there,
I have defined some custom applications with some additional custom functions. I need to access those functions. It seems this cannot be achieved via Helpers. How can I call them from outside of the application(e.g. from another application)?
I have tried downcasting, didn't get what I wanted.

Thanks,
Sabet

Muhammad Sabet

unread,
Jul 26, 2016, 1:41:56 AM7/26/16
to ns-3-users
I should mention that I have installed the application using associated helper. And by functions, I mean public ones.

Tommaso Pecorella

unread,
Jul 26, 2016, 8:47:16 AM7/26/16
to ns-3-users
Hi,

how could we help you with your custom applications, helpers and functions ?
I could tell you what I'd do with a normal application and its helper, but it would be most probably a bad idea, since it could not work at all with your code.
As a matter of fact, how could I be sure that you followed the ns-3 coding scheme ?
Summarizing, only the developer can answer the questions about his/her custom code. In this case: yourself.

T.

Muhammad Sabet

unread,
Jul 26, 2016, 9:25:58 AM7/26/16
to ns-3-users
Tommaso,

Thanks.
I have simple application class inherited from Application class which has
static TypeId GetTypeId (void)
 with addition to some other functions like StartApplication, StopApplication, SendPacket and some others.
Normally I use helpers to set attribs and install application on a node. And now I need to call member functions of the application from outside e.g. from another application class or from scenario directly. As far as I've tried I cannot call for example SendPacket using app helper.
I don't know if my explanation suffices for you, but for the sake of simplicity take:
https://github.com/nsnam/ns-3-dev-git/blob/master/src/applications/model/bulk-send-application.h
for instance. How can I call GetSocket from outside of the class? If I have an instance of this application installed on a node by associated helper, how can I call the object's public member functions?

Thanks,
Sabet

Muhammad Hosain Abdollahi Sabet

unread,
Jul 26, 2016, 9:31:42 AM7/26/16
to ns-3-...@googlegroups.com
Or to put it -as plainly as I can- into words:
How can I have a pointer to an object of BulkSendApplication class, so to be able to call it's member functions?

خندان باشید
با تشکر

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/TiE4Eq69xZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

Konstantinos

unread,
Jul 26, 2016, 9:55:03 AM7/26/16
to ns-3-users
From the pointer to a node, you can get the pointer to the Application with "GetApplication()"

Then using down casting (DynamicCast method in ns-3) you can convert that "Application" to BulkSendApplication" or your custom.
See examples in /wireless/ht-wifi-network.cc (https://www.nsnam.org/docs/doxygen/ht-wifi-network_8cc_source.html) how the UdpServer application is accessed.

Regards
K. 

خندان باشید
با تشکر

To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

Muhammad Hosain Abdollahi Sabet

unread,
Jul 26, 2016, 10:07:14 AM7/26/16
to ns-3-...@googlegroups.com
Konstantinos,
Thank you so much. I will try it for sure.

I did see the example. Why did it use PacketSink for DynamicCast?

Thanks,
Sabet

خندان باشید
با تشکر

K. 

خندان باشید
با تشکر

To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/TiE4Eq69xZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

Konstantinos

unread,
Jul 26, 2016, 10:22:01 AM7/26/16
to ns-3-users
Study the example and you should be able to figure it out.

خندان باشید
با تشکر

K. 

خندان باشید
با تشکر

To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/TiE4Eq69xZ4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages