A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lora-helper.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 LORA_HELPER_H
21#define LORA_HELPER_H
22
23#include "lora-packet-tracker.h"
24#include "lora-phy-helper.h"
25#include "lorawan-mac-helper.h"
26
27#include "ns3/lora-net-device.h"
28#include "ns3/net-device-container.h"
29#include "ns3/net-device.h"
30#include "ns3/node-container.h"
31
32#include <ctime>
33
34namespace ns3
35{
36namespace lorawan
37{
38
39/**
40 * \ingroup lorawan
41 *
42 * Helps to create LoraNetDevice objects.
43 *
44 * This class can help create a large set of similar LoraNetDevice objects and
45 * configure a large set of their attributes during creation.
46 */
48{
49 public:
50 LoraHelper(); //!< Default constructor
51 virtual ~LoraHelper(); //!< Destructor
52
53 /**
54 * Install LoraNetDevices on a list of nodes.
55 *
56 * \param phyHelper The PHY helper to create PHY objects.
57 * \param macHelper The MAC helper to create MAC objects.
58 * \param c The set of nodes on which a lora device will be installed.
59 * \return A device container which contains all the devices created by this method.
60 */
61 virtual NetDeviceContainer Install(const LoraPhyHelper& phyHelper,
62 const LorawanMacHelper& macHelper,
63 NodeContainer c) const;
64
65 /**
66 * Install LoraNetDevice on a single node.
67 *
68 * \param phyHelper The PHY helper to create PHY objects.
69 * \param macHelper The MAC helper to create MAC objects.
70 * \param node The node on which a lora device will be installed.
71 * \return A device container which contains all the devices created by this method.
72 */
73 virtual NetDeviceContainer Install(const LoraPhyHelper& phyHelper,
74 const LorawanMacHelper& macHelper,
75 Ptr<Node> node) const;
76
77 /**
78 * Enable tracking of packets via trace sources.
79 *
80 * This method automatically connects to trace sources to computes relevant
81 * metrics.
82 */
84
85 /**
86 * Periodically prints the simulation time to the standard output.
87 *
88 * \param interval The time period of the interval.
89 */
91
92 /**
93 * Periodically prints the status of devices in the network to a file.
94 *
95 * For each input device print the current position, data rate and transmission power settings.
96 *
97 * \param endDevices The devices to track.
98 * \param gateways The gateways in the network (this is only a placeholder parameter).
99 * \param filename The output filename.
100 * \param interval The time interval for printing.
101 *
102 * \todo Remove unused parameter gateways.
103 */
105 NodeContainer gateways,
106 std::string filename,
107 Time interval);
108
109 /**
110 * Periodically prints PHY-level performance at every gateway in the container.
111 *
112 * For each input gateway print counters for totPacketsSent, receivedPackets, interferedPackets,
113 * noMoreGwPackets, underSensitivityPackets and lostBecauseTxPackets.
114 *
115 * \param gateways The gateways to track.
116 * \param filename The output filename.
117 * \param interval The time interval for printing.
118 */
120 std::string filename,
121 Time interval);
122
123 /**
124 * Print the PHY-level performance of every gateway in the container since the last
125 * performance update.
126 *
127 * For each input gateway print counters for totPacketsSent, receivedPackets, interferedPackets,
128 * noMoreGwPackets, underSensitivityPackets and lostBecauseTxPackets.
129 *
130 * \param gateways The gateways to track.
131 * \param filename The output filename.
132 */
133 void DoPrintPhyPerformance(NodeContainer gateways, std::string filename);
134
135 /**
136 * Periodically print global performance as the total number of send and received
137 * packets.
138 *
139 * \param filename The output filename.
140 * \param interval The time interval for printing.
141 */
142 void EnablePeriodicGlobalPerformancePrinting(std::string filename, Time interval);
143
144 /**
145 * Print global performance as the total number of send and received packets since last
146 * performance update.
147 *
148 * \param filename The output filename.
149 */
150 void DoPrintGlobalPerformance(std::string filename);
151
152 /**
153 * Get a reference to the Packet Tracker object.
154 *
155 * \return the reference to the Packet Tracker object.
156 */
158
159 LoraPacketTracker* m_packetTracker = nullptr; //!< Pointer to the Packet Tracker object
160 time_t m_oldtime; //!< Real time (i.e., physical) of the last simulation time print
161
162 /**
163 * Print a summary of the current status of input devices.
164 *
165 * For each input device print the current position, data rate and transmission power settings.
166 *
167 * \param endDevices The devices to track.
168 * \param gateways The gateways in the network (this is only a placeholder parameter).
169 * \param filename The output filename.
170 *
171 * \todo Remove unused parameter gateways.
172 */
173 void DoPrintDeviceStatus(NodeContainer endDevices,
174 NodeContainer gateways,
175 std::string filename);
176
177 private:
178 /**
179 * Actually print the simulation time and re-schedule execution of this
180 * function.
181 *
182 * \param interval The delay for next printing.
183 */
184 void DoPrintSimulationTime(Time interval);
185
186 Time m_lastPhyPerformanceUpdate; //!< Timestamp of the last PHY performance update
187 Time m_lastGlobalPerformanceUpdate; //!< Timestamp of the last global performance update
188};
189
190} // namespace lorawan
191
192} // namespace ns3
193#endif /* LORA_HELPER_H */
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Helps to create LoraNetDevice objects.
Definition: lora-helper.h:48
void EnablePeriodicDeviceStatusPrinting(NodeContainer endDevices, NodeContainer gateways, std::string filename, Time interval)
Periodically prints the status of devices in the network to a file.
Definition: lora-helper.cc:169
LoraHelper()
Default constructor.
Definition: lora-helper.cc:33
void DoPrintSimulationTime(Time interval)
Actually print the simulation time and re-schedule execution of this function.
Definition: lora-helper.cc:328
void DoPrintDeviceStatus(NodeContainer endDevices, NodeContainer gateways, std::string filename)
Print a summary of the current status of input devices.
Definition: lora-helper.cc:189
time_t m_oldtime
Real time (i.e., physical) of the last simulation time print.
Definition: lora-helper.h:160
virtual ~LoraHelper()
Destructor.
Definition: lora-helper.cc:39
Time m_lastGlobalPerformanceUpdate
Timestamp of the last global performance update.
Definition: lora-helper.h:187
void EnablePeriodicPhyPerformancePrinting(NodeContainer gateways, std::string filename, Time interval)
Periodically prints PHY-level performance at every gateway in the container.
Definition: lora-helper.cc:236
void DoPrintPhyPerformance(NodeContainer gateways, std::string filename)
Print the PHY-level performance of every gateway in the container since the last performance update.
Definition: lora-helper.cc:253
void DoPrintGlobalPerformance(std::string filename)
Print global performance as the total number of send and received packets since last performance upda...
Definition: lora-helper.cc:300
LoraPacketTracker * m_packetTracker
Pointer to the Packet Tracker object.
Definition: lora-helper.h:159
void EnablePacketTracking()
Enable tracking of packets via trace sources.
Definition: lora-helper.cc:145
void EnableSimulationTimePrinting(Time interval)
Periodically prints the simulation time to the standard output.
Definition: lora-helper.cc:162
LoraPacketTracker & GetPacketTracker()
Get a reference to the Packet Tracker object.
Definition: lora-helper.cc:154
Time m_lastPhyPerformanceUpdate
Timestamp of the last PHY performance update.
Definition: lora-helper.h:186
virtual NetDeviceContainer Install(const LoraPhyHelper &phyHelper, const LorawanMacHelper &macHelper, NodeContainer c) const
Install LoraNetDevices on a list of nodes.
Definition: lora-helper.cc:44
void EnablePeriodicGlobalPerformancePrinting(std::string filename, Time interval)
Periodically print global performance as the total number of send and received packets.
Definition: lora-helper.cc:286
Tracks and stores packets sent in the simulation and provides aggregation functionality.
Helper to install LoraPhy instances on multiple Nodes.
Helper class for configuring and installing the LorawanMac class on devices and gateways.
Every class exported by the ns3 library is enclosed in the ns3 namespace.