A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
logical-lora-channel-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 LOGICAL_LORA_CHANNEL_HELPER_H
10#define LOGICAL_LORA_CHANNEL_HELPER_H
11
13#include "sub-band.h"
14
15#include "ns3/nstime.h"
16#include "ns3/ptr.h"
17#include "ns3/simple-ref-count.h"
18
19#include <vector>
20
21namespace ns3
22{
23namespace lorawan
24{
25
26/**
27 * @ingroup lorawan
28 *
29 * This class supports LorawanMac instances by managing a list of the logical
30 * channels that the device is supposed to be using, and establishes their
31 * relationship with SubBands.
32 *
33 * This class also takes into account duty cycle limitations, by updating a list
34 * of SubBand objects and providing methods to query whether transmission on a
35 * set channel is admissible or not.
36 */
37class LogicalLoraChannelHelper : public SimpleRefCount<LogicalLoraChannelHelper>
38{
39 public:
40 /**
41 * Construct a LogicalLoraChannelHelper of a certain size.
42 *
43 * @param size The maximum number of transmission channels that can be installed on this device
44 * according to regional parameter specifications.
45 */
46 LogicalLoraChannelHelper(uint8_t size);
47
48 ~LogicalLoraChannelHelper(); //!< Destructor
49
50 /**
51 * Get the time it is necessary to wait for before transmitting on a given channel.
52 *
53 * @param channel A pointer to the channel we want to know the wait time for.
54 * @return A Time instance containing the wait time before transmission is allowed on the
55 * channel.
56 */
58
59 /**
60 * Get the time it is necessary to wait for before transmitting on a given channel.
61 *
62 * @param frequencyHz The channel frequency [Hz] we want to know the wait time of for.
63 * @return A Time instance containing the wait time before transmission is allowed on the
64 * channel.
65 */
66 Time GetWaitTime(uint32_t frequencyHz) const;
67
68 /**
69 * Register the transmission of a packet.
70 *
71 * @param duration The duration of the transmission event.
72 * @param channel The channel the transmission was made on.
73 */
74 void AddEvent(Time duration, Ptr<LogicalLoraChannel> channel);
75
76 /**
77 * Register the transmission of a packet.
78 *
79 * @param duration The duration of the transmission event.
80 * @param frequencyHz The carrier frequency [Hz] the transmission was on.
81 */
82 void AddEvent(Time duration, uint32_t frequencyHz);
83
84 /**
85 * Get the frequency channel storage array of this device.
86 *
87 * By specifications, devices are required to hold an indexed structure
88 * of a certain size (region-dependent) for storing transmission channels.
89 *
90 * @remark Empty index slots hold nullptr.
91 *
92 * @return An indexed vector of pointers to LogicalLoraChannels.
93 */
94 std::vector<Ptr<LogicalLoraChannel>> GetRawChannelArray() const;
95
96 /**
97 * Set a new channel at a fixed index.
98 *
99 * @param chIndex The index of the channel to substitute.
100 * @param channel A pointer to the channel to add to the list.
101 */
102 void SetChannel(uint8_t chIndex, Ptr<LogicalLoraChannel> channel);
103
104 /**
105 * Add a new SubBand.
106 *
107 * @param subBand A pointer to the SubBand that needs to be added.
108 */
109 void AddSubBand(Ptr<SubBand> subBand);
110
111 /**
112 * Returns the maximum transmission power [dBm] that is allowed on a channel.
113 *
114 * @param channel The channel in question.
115 * @return The power in dBm.
116 */
117 double GetTxPowerForChannel(Ptr<LogicalLoraChannel> channel) const;
118
119 /**
120 * Returns the maximum transmission power [dBm] that is allowed on a channel.
121 *
122 * @param frequencyHz The carrier frequency [Hz] of the channel in question.
123 * @return The power in dBm.
124 */
125 double GetTxPowerForChannel(uint32_t frequencyHz) const;
126
127 /**
128 * Check if a frequency is valid, that is, if it belongs to any of the sub-bands registered in
129 * this class.
130 *
131 * @param frequencyHz The frequency [Hz] to be evaluated.
132 * @return Whether the input frequency belongs to any of the registered sub-bands.
133 */
134 bool IsFrequencyValid(uint32_t frequencyHz) const;
135
136 private:
137 /**
138 * Get the SubBand a frequency belongs to, also used to test validity of a frequency.
139 *
140 * @param frequencyHz The frequency [Hz] we want to check.
141 * @return The SubBand the frequency belongs to, nullptr if none.
142 */
144
145 /**
146 * A vector of the SubBands that are currently registered within this helper.
147 */
148 std::vector<Ptr<SubBand>> m_subBandList;
149
150 /**
151 * A vector of the LogicalLoraChannels that are currently registered within
152 * this helper. This vector represents the node's channel mask. The first N
153 * channels are the default ones for a fixed region.
154 */
155 std::vector<Ptr<LogicalLoraChannel>> m_channelVec;
156};
157
158} // namespace lorawan
159} // namespace ns3
160
161#endif /* LOGICAL_LORA_CHANNEL_HELPER_H */
Smart pointer class similar to boost::intrusive_ptr.
A template-based reference counting class.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
This class supports LorawanMac instances by managing a list of the logical channels that the device i...
void SetChannel(uint8_t chIndex, Ptr< LogicalLoraChannel > channel)
Set a new channel at a fixed index.
double GetTxPowerForChannel(Ptr< LogicalLoraChannel > channel) const
Returns the maximum transmission power [dBm] that is allowed on a channel.
bool IsFrequencyValid(uint32_t frequencyHz) const
Check if a frequency is valid, that is, if it belongs to any of the sub-bands registered in this clas...
std::vector< Ptr< LogicalLoraChannel > > m_channelVec
A vector of the LogicalLoraChannels that are currently registered within this helper.
LogicalLoraChannelHelper(uint8_t size)
Construct a LogicalLoraChannelHelper of a certain size.
std::vector< Ptr< SubBand > > m_subBandList
A vector of the SubBands that are currently registered within this helper.
std::vector< Ptr< LogicalLoraChannel > > GetRawChannelArray() const
Get the frequency channel storage array of this device.
Ptr< SubBand > GetSubBandFromFrequency(uint32_t frequencyHz) const
Get the SubBand a frequency belongs to, also used to test validity of a frequency.
void AddEvent(Time duration, Ptr< LogicalLoraChannel > channel)
Register the transmission of a packet.
void AddSubBand(Ptr< SubBand > subBand)
Add a new SubBand.
Time GetWaitTime(Ptr< LogicalLoraChannel > channel) const
Get the time it is necessary to wait for before transmitting on a given channel.
Every class exported by the ns3 library is enclosed in the ns3 namespace.