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 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Davide Magrin <magrinda@dei.unipd.it>
18 */
19
20#ifndef PERIODIC_SENDER_H
21#define PERIODIC_SENDER_H
22
23#include "lorawan-mac.h"
24
25#include "ns3/application.h"
26#include "ns3/attribute.h"
27#include "ns3/nstime.h"
28
29namespace ns3
30{
31namespace lorawan
32{
33
34/**
35 * \ingroup lorawan
36 *
37 * Implements a sender application generating packets following a periodic point process.
38 */
40{
41 public:
42 PeriodicSender(); //!< Default constructor
43 ~PeriodicSender() override; //!< Destructor
44
45 /**
46 * Register this type.
47 * \return The object TypeId.
48 */
49 static TypeId GetTypeId();
50
51 /**
52 * Set the sending interval.
53 *
54 * \param interval The interval between two packet send instances.
55 */
56 void SetInterval(Time interval);
57
58 /**
59 * Get the sending interval.
60 *
61 * \return The interval between two packet sends.
62 */
63 Time GetInterval() const;
64
65 /**
66 * Set the initial delay of this application.
67 *
68 * \param delay The initial delay value.
69 */
70 void SetInitialDelay(Time delay);
71
72 /**
73 * Set packet size.
74 *
75 * \param size The base packet size value in bytes.
76 */
77 void SetPacketSize(uint8_t size);
78
79 /**
80 * Set to add randomness to the base packet size.
81 *
82 * On each call to SendPacket(), an integer number is picked from a random variable. That
83 * integer number is then added to the base packet size to create the new packet.
84 *
85 * \param rv The random variable used to extract the additional number of packet bytes.
86 * Extracted values can be negative, but if they are lower than the base packet size they
87 * produce a runtime error. This check is left to the caller during definition of the random
88 * variable.
89 */
91
92 /**
93 * Send a packet using the LoraNetDevice's Send method.
94 */
95 void SendPacket();
96
97 /**
98 * Start the application by scheduling the first SendPacket event.
99 */
100 void StartApplication() override;
101
102 /**
103 * Stop the application.
104 */
105 void StopApplication() override;
106
107 private:
108 Time m_interval; //!< The interval between to consecutive send events.
109 Time m_initialDelay; //!< The initial delay of this application.
110 EventId m_sendEvent; //!< The sending event scheduled as next.
111 Ptr<LorawanMac> m_mac; //!< The MAC layer of this node.
112 uint8_t m_basePktSize; //!< The packet size.
114 m_pktSizeRV; //!< The random variable that adds bytes to the packet size.
115};
116
117} // namespace lorawan
118
119} // namespace ns3
120#endif /* SENDER_APPLICATION */
The base class for all ns3 applications.
Definition: application.h:62
An identifier for simulation events.
Definition: event-id.h:56
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
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.