Files

68 lines
1.6 KiB
C
Raw Permalink Normal View History

2022-01-30 11:14:47 -06:00
/*
2024-06-17 16:17:10 +02:00
* SPDX-License-Identifier: GPL-2.0-only
2022-01-30 11:14:47 -06:00
*/
#ifndef TUTORIAL_APP_H
#define TUTORIAL_APP_H
#include "ns3/core-module.h"
#include "ns3/internet-module.h"
2022-10-07 20:08:35 +00:00
#include "ns3/network-module.h"
2022-01-30 11:14:47 -06:00
2022-10-07 20:08:35 +00:00
namespace ns3
{
2022-01-30 11:14:47 -06:00
class Application;
/**
* Tutorial - a simple Application sending packets.
*/
class TutorialApp : public Application
{
2022-10-07 20:08:35 +00:00
public:
TutorialApp();
~TutorialApp() override;
2022-01-30 11:14:47 -06:00
2022-10-07 20:08:35 +00:00
/**
* Register this type.
2024-11-08 18:05:46 +00:00
* @return The TypeId.
2022-10-07 20:08:35 +00:00
*/
static TypeId GetTypeId();
2022-01-30 11:14:47 -06:00
2022-10-07 20:08:35 +00:00
/**
* Setup the socket.
2024-11-08 18:05:46 +00:00
* @param socket The socket.
* @param address The destination address.
* @param packetSize The packet size to transmit.
* @param nPackets The number of packets to transmit.
* @param dataRate the data rate to use.
2022-10-07 20:08:35 +00:00
*/
void Setup(Ptr<Socket> socket,
Address address,
uint32_t packetSize,
uint32_t nPackets,
DataRate dataRate);
2022-01-30 11:14:47 -06:00
2022-10-07 20:08:35 +00:00
private:
void StartApplication() override;
void StopApplication() override;
2022-01-30 11:14:47 -06:00
2022-10-07 20:08:35 +00:00
/// Schedule a new transmission.
void ScheduleTx();
/// Send a packet.
void SendPacket();
2022-01-30 11:14:47 -06:00
2023-02-05 10:09:18 -08:00
Ptr<Socket> m_socket; //!< The transmission socket.
2022-10-07 20:08:35 +00:00
Address m_peer; //!< The destination address.
uint32_t m_packetSize; //!< The packet size.
2023-02-05 10:09:18 -08:00
uint32_t m_nPackets; //!< The number of packets to send.
DataRate m_dataRate; //!< The data rate to use.
2022-10-07 20:08:35 +00:00
EventId m_sendEvent; //!< Send event.
bool m_running; //!< True if the application is running.
2023-02-05 10:09:18 -08:00
uint32_t m_packetsSent; //!< The number of packets sent.
2022-01-30 11:14:47 -06:00
};
} // namespace ns3
#endif /* TUTORIAL_APP_H */