A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tutorial-app.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: GPL-2.0-only
3 */
4
5#ifndef TUTORIAL_APP_H
6#define TUTORIAL_APP_H
7
8#include "ns3/core-module.h"
9#include "ns3/internet-module.h"
10#include "ns3/network-module.h"
11
12namespace ns3
13{
14
15class Application;
16
17/**
18 * Tutorial - a simple Application sending packets.
19 */
21{
22 public:
24 ~TutorialApp() override;
25
26 /**
27 * Register this type.
28 * \return The TypeId.
29 */
30 static TypeId GetTypeId();
31
32 /**
33 * Setup the socket.
34 * \param socket The socket.
35 * \param address The destination address.
36 * \param packetSize The packet size to transmit.
37 * \param nPackets The number of packets to transmit.
38 * \param dataRate the data rate to use.
39 */
40 void Setup(Ptr<Socket> socket,
41 Address address,
43 uint32_t nPackets,
44 DataRate dataRate);
45
46 private:
47 void StartApplication() override;
48 void StopApplication() override;
49
50 /// Schedule a new transmission.
51 void ScheduleTx();
52 /// Send a packet.
53 void SendPacket();
54
55 Ptr<Socket> m_socket; //!< The transmission socket.
56 Address m_peer; //!< The destination address.
57 uint32_t m_packetSize; //!< The packet size.
58 uint32_t m_nPackets; //!< The number of packets to send.
59 DataRate m_dataRate; //!< The data rate to use.
60 EventId m_sendEvent; //!< Send event.
61 bool m_running; //!< True if the application is running.
62 uint32_t m_packetsSent; //!< The number of packets sent.
63};
64
65} // namespace ns3
66
67#endif /* TUTORIAL_APP_H */
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
Class for representing data rates.
Definition data-rate.h:78
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Tutorial - a simple Application sending packets.
void StopApplication() override
Application specific shutdown code.
void ScheduleTx()
Schedule a new transmission.
static TypeId GetTypeId()
Register this type.
~TutorialApp() override
EventId m_sendEvent
Send event.
Ptr< Socket > m_socket
The transmission socket.
uint32_t m_packetsSent
The number of packets sent.
void SendPacket()
Send a packet.
Address m_peer
The destination address.
uint32_t m_packetSize
The packet size.
void Setup(Ptr< Socket > socket, Address address, uint32_t packetSize, uint32_t nPackets, DataRate dataRate)
Setup the socket.
void StartApplication() override
Application specific startup code.
DataRate m_dataRate
The data rate to use.
uint32_t m_nPackets
The number of packets to send.
bool m_running
True if the application is running.
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static const uint32_t packetSize
Packet size generated at the AP.