How to get socket form onoffapplication helper?

113 views
Skip to first unread message

yitao xing

unread,
Apr 17, 2020, 12:57:46 PM4/17/20
to ns-3-users
I notice that there is  a GetSocket() in OnOffApplicatioin class, but there is not something like this in OnOffApplicationHelper.

I am trying to trace the cwnd in the socket that the helper create and install, so after

ApplicationContainer serverApp = server.Install (staWifiNode);//I have actually run a simulation with this script, so the application should be good.


I use
Ptr<OnOffApplication> app = serverApp.Get(0);

but get error info: error: invalid conversion from ‘ns3::Application*’ to ‘ns3::OnOffApplication*’ [-fpermissive]

But when I successfully get applicatioin ptr like Ptr<Application> app = serverApp.Get(0);
I dont know how to get to the GetSocket() function availiable in OnOffApplication.

HELP ANYONE HELP PLZ:(

Vishaka Basnayake

unread,
Apr 17, 2020, 2:34:05 PM4/17/20
to ns-3-...@googlegroups.com

Hello,

Would the following work for you?

Ptr
<OnOffApplication> app = serverApp.Get(0);

Ptr<Socket> socketA = app->GetSocket();

Thanks 
Vishaka

--
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/6b58b61b-f8cb-42dc-ac8e-566da3eb82b8%40googlegroups.com.

yitao xing

unread,
Apr 17, 2020, 9:58:18 PM4/17/20
to ns-3-users
Hi,

NO. I got this messege:

error: invalid conversion from ns3::Application*’ to ns3::OnOffApplication*’



在 2020年4月18日星期六 UTC+8上午2:34:05,Vishaka Basnayake写道:

Hello,

Would the following work for you?

Ptr
<OnOffApplication> app = serverApp.Get(0);

Ptr<Socket> socketA = app->GetSocket();

Thanks 
Vishaka

On Fri, Apr 17, 2020 at 6:58 PM yitao xing <ytxi...@gmail.com> wrote:
I notice that there is  a GetSocket() in OnOffApplicatioin class, but there is not something like this in OnOffApplicationHelper.

I am trying to trace the cwnd in the socket that the helper create and install, so after

ApplicationContainer serverApp = server.Install (staWifiNode);//I have actually run a simulation with this script, so the application should be good.


I use
Ptr<OnOffApplication> app = serverApp.Get(0);

but get error info: error: invalid conversion from ‘ns3::Application*’ to ‘ns3::OnOffApplication*’ [-fpermissive]

But when I successfully get applicatioin ptr like Ptr<Application> app = serverApp.Get(0);
I dont know how to get to the GetSocket() function availiable in OnOffApplication.

HELP ANYONE HELP PLZ:(

--
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 the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-...@googlegroups.com.

yitao xing

unread,
Apr 17, 2020, 11:15:19 PM4/17/20
to ns-3-users
// We want to look at changes in the ns-3 TCP congestion window.  We need
// to crank up a flow and hook the CongestionWindow attribute on the socket
// of the sender.  Normally one would use an on-off application to generate a
// flow, but this has a couple of problems.  First, the socket of the on-off
// application is not created until Application Start time, so we wouldn't be
// able to hook the socket (now) at configuration time.  Second, even if we
// could arrange a call after start time, the socket is not public so we
// couldn't get at it.

Here is it. One should create his own application if he wants to trace the socket.
在 2020年4月18日星期六 UTC+8上午12:57:46,yitao xing写道:

Gopal Rawat

unread,
Apr 18, 2020, 8:42:02 AM4/18/20
to ns-3-users
Hi ,

You can try something like this :

// Use Downcasting for your purpose
Ptr<OnOffApplication> app = DynamicCast <OnOffApplication> (serverApp.Get(0));

// Then access the socket
Ptr<Socket> socket = app->GetSocket();

Regards,
G.
Reply all
Reply to author
Forward
0 new messages