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