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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Davide Magrin <magrinda@dei.unipd.it>
7 */
8
9#ifndef LORA_HELPER_H
10#define LORA_HELPER_H
11
12#include "lora-packet-tracker.h"
13#include "lora-phy-helper.h"
14#include "lorawan-mac-helper.h"
15
16#include "ns3/lora-net-device.h"
17#include "ns3/net-device-container.h"
18#include "ns3/net-device.h"
19#include "ns3/node-container.h"
20
21#include <ctime>
22
23namespace ns3
24{
25namespace lorawan
26{
27
28/**
29 * \ingroup lorawan
30 *
31 * Helps to create LoraNetDevice objects.
32 *
33 * This class can help create a large set of similar LoraNetDevice objects and
34 * configure a large set of their attributes during creation.
35 */
37{
38 public:
39 LoraHelper(); //!< Default constructor
40 virtual ~LoraHelper(); //!< Destructor
41
42 /**
43 * Install LoraNetDevices on a list of nodes.
44 *
45 * \param phyHelper The PHY helper to create PHY objects.
46 * \param macHelper The MAC helper to create MAC objects.
47 * \param c The set of nodes on which a lora device will be installed.
48 * \return A device container which contains all the devices created by this method.
49 */
50 virtual NetDeviceContainer Install(const LoraPhyHelper& phyHelper,
51 const LorawanMacHelper& macHelper,
52 NodeContainer c) const;
53
54 /**
55 * Install LoraNetDevice on a single node.
56 *
57 * \param phyHelper The PHY helper to create PHY objects.
58 * \param macHelper The MAC helper to create MAC objects.
59 * \param node The node on which a lora device will be installed.
60 * \return A device container which contains all the devices created by this method.
61 */
62 virtual NetDeviceContainer Install(const LoraPhyHelper& phyHelper,
63 const LorawanMacHelper& macHelper,
64 Ptr<Node> node) const;
65
66 /**
67 * Enable tracking of packets via trace sources.
68 *
69 * This method automatically connects to trace sources to computes relevant
70 * metrics.
71 */
73
74 /**
75 * Periodically prints the simulation time to the standard output.
76 *
77 * \param interval The time period of the interval.
78 */
80
81 /**
82 * Periodically prints the status of devices in the network to a file.
83 *
84 * For each input device print the current position, data rate and transmission power settings.
85 *
86 * \param endDevices The devices to track.
87 * \param gateways The gateways in the network (this is only a placeholder parameter).
88 * \param filename The output filename.
89 * \param interval The time interval for printing.
90 *
91 * \todo Remove unused parameter gateways.
92 */
94 NodeContainer gateways,
95 std::string filename,
96 Time interval);
97
98 /**
99 * Periodically prints PHY-level performance at every gateway in the container.
100 *
101 * For each input gateway print counters for totPacketsSent, receivedPackets, interferedPackets,
102 * noMoreGwPackets, underSensitivityPackets and lostBecauseTxPackets.
103 *
104 * \param gateways The gateways to track.
105 * \param filename The output filename.
106 * \param interval The time interval for printing.
107 */
109 std::string filename,
110 Time interval);
111
112 /**
113 * Print the PHY-level performance of every gateway in the container since the last
114 * performance update.
115 *
116 * For each input gateway print counters for totPacketsSent, receivedPackets, interferedPackets,
117 * noMoreGwPackets, underSensitivityPackets and lostBecauseTxPackets.
118 *
119 * \param gateways The gateways to track.
120 * \param filename The output filename.
121 */
122 void DoPrintPhyPerformance(NodeContainer gateways, std::string filename);
123
124 /**
125 * Periodically print global performance as the total number of send and received
126 * packets.
127 *
128 * \param filename The output filename.
129 * \param interval The time interval for printing.
130 */
131 void EnablePeriodicGlobalPerformancePrinting(std::string filename, Time interval);
132
133 /**
134 * Print global performance as the total number of send and received packets since last
135 * performance update.
136 *
137 * \param filename The output filename.
138 */
139 void DoPrintGlobalPerformance(std::string filename);
140
141 /**
142 * Get a reference to the Packet Tracker object.
143 *
144 * \return the reference to the Packet Tracker object.
145 */
147
148 LoraPacketTracker* m_packetTracker = nullptr; //!< Pointer to the Packet Tracker object
149 time_t m_oldtime; //!< Real time (i.e., physical) of the last simulation time print
150
151 /**
152 * Print a summary of the current status of input devices.
153 *
154 * For each input device print the current position, data rate and transmission power settings.
155 *
156 * \param endDevices The devices to track.
157 * \param gateways The gateways in the network (this is only a placeholder parameter).
158 * \param filename The output filename.
159 *
160 * \todo Remove unused parameter gateways.
161 */
162 void DoPrintDeviceStatus(NodeContainer endDevices,
163 NodeContainer gateways,
164 std::string filename);
165
166 private:
167 /**
168 * Actually print the simulation time and re-schedule execution of this
169 * function.
170 *
171 * \param interval The delay for next printing.
172 */
173 void DoPrintSimulationTime(Time interval);
174
175 Time m_lastPhyPerformanceUpdate; //!< Timestamp of the last PHY performance update
176 Time m_lastGlobalPerformanceUpdate; //!< Timestamp of the last global performance update
177};
178
179} // namespace lorawan
180
181} // namespace ns3
182#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.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Helps to create LoraNetDevice objects.
Definition lora-helper.h:37
void EnablePeriodicDeviceStatusPrinting(NodeContainer endDevices, NodeContainer gateways, std::string filename, Time interval)
Periodically prints the status of devices in the network to a file.
LoraHelper()
Default constructor.
void DoPrintSimulationTime(Time interval)
Actually print the simulation time and re-schedule execution of this function.
void DoPrintDeviceStatus(NodeContainer endDevices, NodeContainer gateways, std::string filename)
Print a summary of the current status of input devices.
time_t m_oldtime
Real time (i.e., physical) of the last simulation time print.
virtual ~LoraHelper()
Destructor.
Time m_lastGlobalPerformanceUpdate
Timestamp of the last global performance update.
void EnablePeriodicPhyPerformancePrinting(NodeContainer gateways, std::string filename, Time interval)
Periodically prints PHY-level performance at every gateway in the container.
void DoPrintPhyPerformance(NodeContainer gateways, std::string filename)
Print the PHY-level performance of every gateway in the container since the last performance update.
void DoPrintGlobalPerformance(std::string filename)
Print global performance as the total number of send and received packets since last performance upda...
LoraPacketTracker * m_packetTracker
Pointer to the Packet Tracker object.
void EnablePacketTracking()
Enable tracking of packets via trace sources.
void EnableSimulationTimePrinting(Time interval)
Periodically prints the simulation time to the standard output.
LoraPacketTracker & GetPacketTracker()
Get a reference to the Packet Tracker object.
Time m_lastPhyPerformanceUpdate
Timestamp of the last PHY performance update.
virtual NetDeviceContainer Install(const LoraPhyHelper &phyHelper, const LorawanMacHelper &macHelper, NodeContainer c) const
Install LoraNetDevices on a list of nodes.
void EnablePeriodicGlobalPerformancePrinting(std::string filename, Time interval)
Periodically print global performance as the total number of send and received packets.
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.