A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
periodic-sender.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Davide Magrin <magrinda@dei.unipd.it>
7 */
8
9#ifndef PERIODIC_SENDER_H
10#define PERIODIC_SENDER_H
11
12#include "lorawan-mac.h"
13
14#include "ns3/application.h"
15#include "ns3/attribute.h"
16#include "ns3/nstime.h"
17
18namespace ns3
19{
20namespace lorawan
21{
22
23/**
24 * \ingroup lorawan
25 *
26 * Implements a sender application generating packets following a periodic point process.
27 */
29{
30 public:
31 PeriodicSender(); //!< Default constructor
32 ~PeriodicSender() override; //!< Destructor
33
34 /**
35 * Register this type.
36 * \return The object TypeId.
37 */
38 static TypeId GetTypeId();
39
40 /**
41 * Set the sending interval.
42 *
43 * \param interval The interval between two packet send instances.
44 */
45 void SetInterval(Time interval);
46
47 /**
48 * Get the sending interval.
49 *
50 * \return The interval between two packet sends.
51 */
52 Time GetInterval() const;
53
54 /**
55 * Set the initial delay of this application.
56 *
57 * \param delay The initial delay value.
58 */
59 void SetInitialDelay(Time delay);
60
61 /**
62 * Set packet size.
63 *
64 * \param size The base packet size value in bytes.
65 */
66 void SetPacketSize(uint8_t size);
67
68 /**
69 * Set to add randomness to the base packet size.
70 *
71 * On each call to SendPacket(), an integer number is picked from a random variable. That
72 * integer number is then added to the base packet size to create the new packet.
73 *
74 * \param rv The random variable used to extract the additional number of packet bytes.
75 * Extracted values can be negative, but if they are lower than the base packet size they
76 * produce a runtime error. This check is left to the caller during definition of the random
77 * variable.
78 */
80
81 /**
82 * Send a packet using the LoraNetDevice's Send method.
83 */
84 void SendPacket();
85
86 /**
87 * Start the application by scheduling the first SendPacket event.
88 */
89 void StartApplication() override;
90
91 /**
92 * Stop the application.
93 */
94 void StopApplication() override;
95
96 private:
97 Time m_interval; //!< The interval between to consecutive send events.
98 Time m_initialDelay; //!< The initial delay of this application.
99 EventId m_sendEvent; //!< The sending event scheduled as next.
100 Ptr<LorawanMac> m_mac; //!< The MAC layer of this node.
101 uint8_t m_basePktSize; //!< The packet size.
103 m_pktSizeRV; //!< The random variable that adds bytes to the packet size.
104};
105
106} // namespace lorawan
107
108} // namespace ns3
109#endif /* SENDER_APPLICATION */
The base class for all ns3 applications.
Definition application.h:51
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Implements a sender application generating packets following a periodic point process.
Ptr< RandomVariableStream > m_pktSizeRV
The random variable that adds bytes to the packet size.
Time m_interval
The interval between to consecutive send events.
~PeriodicSender() override
Destructor.
Time GetInterval() const
Get the sending interval.
Ptr< LorawanMac > m_mac
The MAC layer of this node.
void SetInterval(Time interval)
Set the sending interval.
void SetPacketSize(uint8_t size)
Set packet size.
void StartApplication() override
Start the application by scheduling the first SendPacket event.
void SetInitialDelay(Time delay)
Set the initial delay of this application.
void SetPacketSizeRandomVariable(Ptr< RandomVariableStream > rv)
Set to add randomness to the base packet size.
Time m_initialDelay
The initial delay of this application.
static TypeId GetTypeId()
Register this type.
void SendPacket()
Send a packet using the LoraNetDevice's Send method.
EventId m_sendEvent
The sending event scheduled as next.
PeriodicSender()
Default constructor.
void StopApplication() override
Stop the application.
uint8_t m_basePktSize
The packet size.
Every class exported by the ns3 library is enclosed in the ns3 namespace.