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 "ns3/application.h"
13#include "ns3/random-variable-stream.h"
14
15namespace ns3
16{
17namespace lorawan
18{
19
20class LorawanMac;
21
22/**
23 * @ingroup lorawan
24 *
25 * Implements a sender application generating packets following a periodic point process.
26 */
28{
29 public:
30 PeriodicSender(); //!< Default constructor
31 ~PeriodicSender() override; //!< Destructor
32
33 /**
34 * Register this type.
35 * @return The object TypeId.
36 */
37 static TypeId GetTypeId();
38
39 /**
40 * Set the sending interval.
41 *
42 * @param interval The interval between two packet send instances.
43 */
44 void SetInterval(Time interval);
45
46 /**
47 * Get the sending interval.
48 *
49 * @return The interval between two packet sends.
50 */
51 Time GetInterval() const;
52
53 /**
54 * Set the initial delay of this application.
55 *
56 * @param delay The initial delay value.
57 */
58 void SetInitialDelay(Time delay);
59
60 /**
61 * Set packet size.
62 *
63 * @param size The base packet size value in bytes.
64 */
65 void SetPacketSize(uint8_t size);
66
67 /**
68 * Set to add randomness to the base packet size.
69 *
70 * On each call to SendPacket(), an integer number is picked from a random variable. That
71 * integer number is then added to the base packet size to create the new packet.
72 *
73 * @param rv The random variable used to extract the additional number of packet bytes.
74 * Extracted values can be negative, but if they are lower than the base packet size they
75 * produce a runtime error. This check is left to the caller during definition of the random
76 * variable.
77 */
79
80 /**
81 * Send a packet using the LoraNetDevice's Send method.
82 */
83 void SendPacket();
84
85 /**
86 * Start the application by scheduling the first SendPacket event.
87 */
88 void StartApplication() override;
89
90 /**
91 * Stop the application.
92 */
93 void StopApplication() override;
94
95 private:
96 Time m_interval; //!< The interval between to consecutive send events.
97 Time m_initialDelay; //!< The initial delay of this application.
98 EventId m_sendEvent; //!< The sending event scheduled as next.
99 Ptr<LorawanMac> m_mac; //!< The MAC layer of this node.
100 uint8_t m_basePktSize; //!< The packet size.
102 m_pktSizeRV; //!< The random variable that adds bytes to the packet size.
103};
104
105} // namespace lorawan
106} // namespace ns3
107
108#endif /* SENDER_APPLICATION */
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
Class representing the LoRaWAN MAC layer.
Definition lorawan-mac.h:36
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.