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