How to stop simulator

32 views
Skip to first unread message

Aleksandr Okhrimenko

unread,
Dec 7, 2017, 4:56:06 PM12/7/17
to ns-3-users
Hi all!

I took tutorial's example fifth.cc for the basis
and I want to stop simulator after the delivery of a specified amount of data by the TCP protocol, for example 1MB.
What I need to do?

Method
void ns3::Simulator::Stop ( void 
)
should be called, but where to calculate the guaranteed amount of delivered data?

Thanks

Rediet

unread,
Dec 8, 2017, 4:07:52 AM12/8/17
to ns-3-users
Hi,

You can simply add the call to Simulator::Stop in MyApp::SendPacket, when there are no more packets to send.

Rediet

Aleksandr Okhrimenko

unread,
Dec 9, 2017, 4:17:15 AM12/9/17
to ns-3-users
Hi, Rediet

Thanks for your assistance.
Corrected the code MyApp::SendPacket according to your recommendations:

void
MyApp::SendPacket(void)
{
 
Ptr<Packet> packet = Create<Packet>(m_packetSize);
  m_socket
->Send(packet);

 
if (++m_packetsSent < m_nPackets) {
   
ScheduleTx();
 
} else {
    NS_LOG_INFO
("Total sended packets: " + std::to_string(m_packetsSent));
   
Simulator::Stop();
 
}


}

T
est passed. Thanks

8-12-2017, 11:07:52 UTC+2 user Rediet написал:
Reply all
Reply to author
Forward
0 new messages