Stop application through Schedule,it does work?

496 views
Skip to first unread message

hongyu deng

unread,
Apr 7, 2016, 8:20:40 AM4/7/16
to ns-3-users
Hi all,
I try to stop application through Simulator::Schedule() like this
void SetApplicationStopTime( Ptr<Application> app, ApplicationContainer c)
{
  app->SetStopTime(Simulator::Now());
  c.Stop(Seconds(Simulator::Now()));
}
BUT it does not work when the time arrive,it does not STOP send data.Why?
And it can STOP TX or RX data though that way
serverApps.Stop (Seconds(simtime-45));
clientApps.Stop (Seconds(simtime-45));
Meanwhile i found that even if i don't set application start time,the app also send data?

So my question is :Can i through Simulator::Schedule() to stop application in a time i need?
Or there exist another way to solve this problem?
Any answer is very appreciate.

BR,
Hongyu.
 

Tommaso Pecorella

unread,
Apr 7, 2016, 1:16:59 PM4/7/16
to ns-3-users
Hi,

please try to limit your use of bold / large fonts, thanks.

About the question, SetStopTime only has an effect *before* the application initialization, i.e., before Simulator::Run().
Actually I don't think there's a general way to stop an application if the simulation is already running. If you feel that this is a limitation, please fill an enhancement request in the ns-3 bugzilla.

Thanks,

T.

hongyu deng

unread,
Apr 7, 2016, 9:08:46 PM4/7/16
to ns-3-users
Hi Tommaso Sir,

Thanks for your answer,and i will attention my large fonts.

About the question, SetStopTime only has an effect *before* the application initialization, i.e., before Simulator::Run().
Actually,i Schedule the function before Simulator::Run(),but it doesn't work.

And it looks like that is not exist a way to stop  application through Simulator::Schedule() in simulation process,all right?
Thanks.

BR,
Hongyu.

Tommaso Pecorella

unread,
Apr 8, 2016, 4:51:36 AM4/8/16
to ns-3-users
Hi Hongyu,


On Friday, April 8, 2016 at 3:08:46 AM UTC+2, hongyu deng wrote:
Hi Tommaso Sir,

Thanks for your answer,and i will attention my large fonts.
About the question, SetStopTime only has an effect *before* the application initialization, i.e., before Simulator::Run().
Actually,i Schedule the function before Simulator::Run(),but it doesn't work.

Strange. It should work, but it's actually the specific application's responsibility to *react* to a Stop. I mean that the base class will have its function triggered, but if the child class doesn't react as well... well, that's a bug in the child class.
 
And it looks like that is not exist a way to stop  application through Simulator::Schedule() in simulation process,all right?

None that can be applied to a generic application. If a child class have these methods as public, then it could.

Cheers,

T.

hongyu deng

unread,
Apr 8, 2016, 10:42:24 AM4/8/16
to ns-3-users
Hi Tommaso Sir,

The application which i used is PacketSink application,and i found that in base class PacketSink which inherited from class Application 
has no public function for stopping/starting application .Only has two private virtual function inherits from class Application.
It seems that i can't stop application in simulation process.

Meanwhile i found that if i don't set the application start time,the application will auto TX data at 0 second.
if i do like this Apps.Start (Seconds(5.0)); it would TX data at 5 second.Why?

Thanks,
Hongyu.

Tommaso Pecorella

unread,
Apr 8, 2016, 12:22:43 PM4/8/16
to ns-3-users
Hi,

PacketSink is a Sink. Meaning that it doesn't send packets, it just receives them. Its goal is to collect statistics and to avoid that the receiving node will reply to each packet with an error message or, in case of TCP, that the connection isn't established.

Apps.Start (Seconds(5.0)); will tell the app to start its behaviour at second 5. If the application that is initiating the connection (i.e., the client) is still trying to connect with the sink, it will e able to open a connection only after second 5, leasing to your behaviour. Nevertheless, the sender was probably trying even before that.

T.

hongyu deng

unread,
Apr 9, 2016, 8:30:17 AM4/9/16
to ns-3-users
Hi Tommaso Sir,

Sorry so late to reply.Thanks very much.

For the first,it's my fault,i forget it only a Sink.I used UdpClient and PacketSink in my simulation script,I should stop the UdpClient app, not PacketSink app.
But it can't stop or start application through Simulator::Schedule(),i think.I try many times,it does not work. as you said,it was initialized when the application SETs UP. Am i understand right?

Thanks for the second explanation.

Havefun,
Hongyu.

Tommaso Pecorella

unread,
Apr 9, 2016, 4:01:53 PM4/9/16
to ns-3-users
Hi,

you're right. At the moment it is not possible to start or stop the UdpClient app through Simulator::Schedule().
Again, if you find that this is a limitation, please open a bugzilla ticket.

Cheers,

T.

hongyu deng

unread,
Apr 9, 2016, 9:52:19 PM4/9/16
to ns-3-users
Hi Sir,
Sorry i don't know how to write a bugzilla ticket.Or could you give me a hint?
Actually,i think this is a limitation,the application should can stop and restart in a time we need in the simulation script,through Simulator::Schedule().
It is very useful if ns-3 can do that in the future.

Thanks,
Hongyu.

Tommaso Pecorella

unread,
Apr 10, 2016, 6:39:05 AM4/10/16
to ns-3-users
Hi Hongyu,


Cheers,

T.

hongyu deng

unread,
Apr 10, 2016, 8:51:22 AM4/10/16
to ns-3-users
Hi Tommaso Sir,

Thanks for the bugzilla.
Hope it can be resolved in next ns-3 version. 

Thanks,
Hongyu.
Reply all
Reply to author
Forward
0 new messages