A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
class-a-end-device-lorawan-mac.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 * Martina Capuzzo <capuzzom@dei.unipd.it>
19 *
20 * Modified by: Peggy Anderson <peggy.anderson@usask.ca>
21 */
22
23#ifndef CLASS_A_END_DEVICE_LORAWAN_MAC_H
24#define CLASS_A_END_DEVICE_LORAWAN_MAC_H
25
26#include "end-device-lorawan-mac.h" // EndDeviceLorawanMac
27#include "lora-frame-header.h" // RxParamSetupReq
28#include "lorawan-mac.h" // Packet
29// #include "ns3/random-variable-stream.h"
30#include "lora-device-address.h"
31
32// #include "ns3/traced-value.h"
33
34namespace ns3
35{
36namespace lorawan
37{
38
39/**
40 * \ingroup lorawan
41 *
42 * Class representing the MAC layer of a Class A LoRaWAN device.
43 */
45{
46 public:
47 /**
48 * Register this type.
49 * \return The object TypeId.
50 */
51 static TypeId GetTypeId();
52
53 ClassAEndDeviceLorawanMac(); //!< Default constructor
54 ~ClassAEndDeviceLorawanMac() override; //!< Destructor
55
56 /////////////////////
57 // Sending methods //
58 /////////////////////
59
60 /**
61 * Add headers and send a packet with the sending function of the physical layer.
62 *
63 * \param packet The packet to send.
64 */
65 void SendToPhy(Ptr<Packet> packet) override;
66
67 //////////////////////////
68 // Receiving methods //
69 //////////////////////////
70
71 /**
72 * Receive a packet.
73 *
74 * This method is typically registered as a callback in the underlying PHY
75 * layer so that it's called when a packet is going up the stack.
76 *
77 * \param packet The received packet.
78 */
79 void Receive(Ptr<const Packet> packet) override;
80
81 void FailedReception(Ptr<const Packet> packet) override;
82
83 void TxFinished(Ptr<const Packet> packet) override;
84
85 /**
86 * Perform operations needed to open the first receive window.
87 */
89
90 /**
91 * Perform operations needed to open the second receive window.
92 */
94
95 /**
96 * Perform operations needed to close the first receive window.
97 */
99
100 /**
101 * Perform operations needed to close the second receive window.
102 */
104
105 /////////////////////////
106 // Getters and Setters //
107 /////////////////////////
108
109 /**
110 * Find the minimum waiting time before the next possible transmission based
111 * on end device's Class Type.
112 *
113 * \param waitingTime The minimum waiting time that has to be respected,
114 * irrespective of the class (e.g., because of duty cycle limitations).
115 * \return The Time value.
116 */
117 Time GetNextClassTransmissionDelay(Time waitingTime) override;
118
119 /**
120 * Get the data rate that will be used in the first receive window.
121 *
122 * \return The data rate.
123 */
125
126 /**
127 * Set the data rate to be used in the second receive window.
128 *
129 * \param dataRate The data rate.
130 */
131 void SetSecondReceiveWindowDataRate(uint8_t dataRate);
132
133 /**
134 * Get the data rate that will be used in the second receive window.
135 *
136 * \return The data rate.
137 */
138 uint8_t GetSecondReceiveWindowDataRate() const;
139
140 /**
141 * Set the frequency that will be used for the second receive window.
142 *
143 * \param frequencyMHz The Frequency.
144 */
145 void SetSecondReceiveWindowFrequency(double frequencyMHz);
146
147 /**
148 * Get the frequency that is used for the second receive window.
149 *
150 * \return The frequency, in MHz.
151 */
152 double GetSecondReceiveWindowFrequency() const;
153
154 /////////////////////////
155 // MAC command methods //
156 /////////////////////////
157
158 /**
159 * Perform the actions that need to be taken when receiving a RxParamSetupReq
160 * command based on the Device's Class Type.
161 *
162 * \param rxParamSetupReq The Parameter Setup Request, which contains:
163 * - The offset to set.
164 * - The data rate to use for the second receive window.
165 * - The frequency to use for the second receive window.
166 */
167 void OnRxClassParamSetupReq(Ptr<RxParamSetupReq> rxParamSetupReq) override;
168
169 private:
170 Time m_receiveDelay1; //!< The interval between when a packet is done sending and when the first
171 //!< receive window is opened.
172
173 /**
174 * The interval between when a packet is done sending and when the second
175 * receive window is opened.
176 */
178
179 /**
180 * The event of the closing the first receive window.
181 *
182 * This Event will be canceled if there's a successful reception of a packet.
183 */
185
186 /**
187 * The event of the closing the second receive window.
188 *
189 * This Event will be canceled if there's a successful reception of a packet.
190 */
192
193 /**
194 * The event of the second receive window opening.
195 *
196 * This Event is used to cancel the second window in case the first one is
197 * successful.
198 */
200
201 /**
202 * The frequency to listen on for the second receive window.
203 */
205
206 /**
207 * The data rate to listen for during the second downlink transmission.
208 */
210
211 /**
212 * The RX1DROffset parameter value.
213 */
215
216}; /* ClassAEndDeviceLorawanMac */
217} /* namespace lorawan */
218} /* namespace ns3 */
219#endif /* CLASS_A_END_DEVICE_LORAWAN_MAC_H */
An identifier for simulation events.
Definition: event-id.h:56
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Class representing the MAC layer of a Class A LoRaWAN device.
uint8_t m_rx1DrOffset
The RX1DROffset parameter value.
void OpenSecondReceiveWindow()
Perform operations needed to open the second receive window.
uint8_t GetSecondReceiveWindowDataRate() const
Get the data rate that will be used in the second receive window.
Time m_receiveDelay2
The interval between when a packet is done sending and when the second receive window is opened.
void FailedReception(Ptr< const Packet > packet) override
Function called by lower layers to inform this layer that reception of a packet we were locked on fai...
double GetSecondReceiveWindowFrequency() const
Get the frequency that is used for the second receive window.
double m_secondReceiveWindowFrequency
The frequency to listen on for the second receive window.
EventId m_closeFirstWindow
The event of the closing the first receive window.
uint8_t m_secondReceiveWindowDataRate
The data rate to listen for during the second downlink transmission.
Time m_receiveDelay1
The interval between when a packet is done sending and when the first receive window is opened.
Time GetNextClassTransmissionDelay(Time waitingTime) override
Find the minimum waiting time before the next possible transmission based on end device's Class Type.
void OnRxClassParamSetupReq(Ptr< RxParamSetupReq > rxParamSetupReq) override
Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Devic...
void CloseFirstReceiveWindow()
Perform operations needed to close the first receive window.
void SendToPhy(Ptr< Packet > packet) override
Add headers and send a packet with the sending function of the physical layer.
void TxFinished(Ptr< const Packet > packet) override
Perform actions after sending a packet.
void CloseSecondReceiveWindow()
Perform operations needed to close the second receive window.
uint8_t GetFirstReceiveWindowDataRate()
Get the data rate that will be used in the first receive window.
EventId m_closeSecondWindow
The event of the closing the second receive window.
EventId m_secondReceiveWindow
The event of the second receive window opening.
void SetSecondReceiveWindowDataRate(uint8_t dataRate)
Set the data rate to be used in the second receive window.
void Receive(Ptr< const Packet > packet) override
Receive a packet.
void SetSecondReceiveWindowFrequency(double frequencyMHz)
Set the frequency that will be used for the second receive window.
void OpenFirstReceiveWindow()
Perform operations needed to open the first receive window.
Class representing the MAC layer of a LoRaWAN device.
Every class exported by the ns3 library is enclosed in the ns3 namespace.