A Discrete-Event Network Simulator
API
tutorial-app.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License version 2 as
4  * published by the Free Software Foundation;
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  */
15 
16 #ifndef TUTORIAL_APP_H
17 #define TUTORIAL_APP_H
18 
19 #include "ns3/core-module.h"
20 #include "ns3/internet-module.h"
21 #include "ns3/network-module.h"
22 
23 namespace ns3
24 {
25 
26 class Application;
27 
31 class TutorialApp : public Application
32 {
33  public:
34  TutorialApp();
35  ~TutorialApp() override;
36 
41  static TypeId GetTypeId();
42 
51  void Setup(Ptr<Socket> socket,
53  uint32_t packetSize,
54  uint32_t nPackets,
55  DataRate dataRate);
56 
57  private:
58  void StartApplication() override;
59  void StopApplication() override;
60 
62  void ScheduleTx();
64  void SendPacket();
65 
68  uint32_t m_packetSize;
69  uint32_t m_nPackets;
72  bool m_running;
73  uint32_t m_packetsSent;
74 };
75 
76 } // namespace ns3
77 
78 #endif /* TUTORIAL_APP_H */
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
Class for representing data rates.
Definition: data-rate.h:89
An identifier for simulation events.
Definition: event-id.h:55
Tutorial - a simple Application sending packets.
Definition: tutorial-app.h:32
void StopApplication() override
Application specific shutdown code.
Definition: tutorial-app.cc:75
void ScheduleTx()
Schedule a new transmission.
static TypeId GetTypeId()
Register this type.
Definition: tutorial-app.cc:41
~TutorialApp() override
Definition: tutorial-app.cc:34
EventId m_sendEvent
Send event.
Definition: tutorial-app.h:71
Ptr< Socket > m_socket
The transmission socket.
Definition: tutorial-app.h:66
uint32_t m_packetsSent
The number of packets sent.
Definition: tutorial-app.h:73
void SendPacket()
Send a packet.
Definition: tutorial-app.cc:91
Address m_peer
The destination address.
Definition: tutorial-app.h:67
uint32_t m_packetSize
The packet size.
Definition: tutorial-app.h:68
void Setup(Ptr< Socket > socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
Setup the socket.
Definition: tutorial-app.cc:51
void StartApplication() override
Application specific startup code.
Definition: tutorial-app.cc:65
DataRate m_dataRate
The data rate to use.
Definition: tutorial-app.h:70
uint32_t m_nPackets
The number of packets to send.
Definition: tutorial-app.h:69
bool m_running
True if the application is running.
Definition: tutorial-app.h:72
a unique identifier for an interface.
Definition: type-id.h:59
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint32_t packetSize
Packet size generated at the AP.