A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
23namespace ns3
24{
25
26class Application;
27
28/**
29 * Tutorial - a simple Application sending packets.
30 */
32{
33 public:
35 ~TutorialApp() override;
36
37 /**
38 * Register this type.
39 * \return The TypeId.
40 */
41 static TypeId GetTypeId();
42
43 /**
44 * Setup the socket.
45 * \param socket The socket.
46 * \param address The destination address.
47 * \param packetSize The packet size to transmit.
48 * \param nPackets The number of packets to transmit.
49 * \param dataRate the data rate to use.
50 */
51 void Setup(Ptr<Socket> socket,
52 Address address,
54 uint32_t nPackets,
55 DataRate dataRate);
56
57 private:
58 void StartApplication() override;
59 void StopApplication() override;
60
61 /// Schedule a new transmission.
62 void ScheduleTx();
63 /// Send a packet.
64 void SendPacket();
65
66 Ptr<Socket> m_socket; //!< The transmission socket.
67 Address m_peer; //!< The destination address.
68 uint32_t m_packetSize; //!< The packet size.
69 uint32_t m_nPackets; //!< The number of packets to send.
70 DataRate m_dataRate; //!< The data rate to use.
71 EventId m_sendEvent; //!< Send event.
72 bool m_running; //!< True if the application is running.
73 uint32_t m_packetsSent; //!< The number of packets sent.
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
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint32_t packetSize
Packet size generated at the AP.