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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Davide Magrin <magrinda@dei.unipd.it>
7 * Martina Capuzzo <capuzzom@dei.unipd.it>
8 *
9 * Modified by: Peggy Anderson <peggy.anderson@usask.ca>
10 */
11
12#ifndef CLASS_A_END_DEVICE_LORAWAN_MAC_H
13#define CLASS_A_END_DEVICE_LORAWAN_MAC_H
14
15#include "end-device-lorawan-mac.h" // EndDeviceLorawanMac
16#include "lora-frame-header.h" // RxParamSetupReq
17#include "lorawan-mac.h" // Packet
18// #include "ns3/random-variable-stream.h"
19#include "lora-device-address.h"
20
21// #include "ns3/traced-value.h"
22
23namespace ns3
24{
25namespace lorawan
26{
27
28/**
29 * @ingroup lorawan
30 *
31 * Class representing the MAC layer of a Class A LoRaWAN device.
32 */
34{
35 public:
36 /**
37 * Register this type.
38 * @return The object TypeId.
39 */
40 static TypeId GetTypeId();
41
42 ClassAEndDeviceLorawanMac(); //!< Default constructor
43 ~ClassAEndDeviceLorawanMac() override; //!< Destructor
44
45 /////////////////////
46 // Sending methods //
47 /////////////////////
48
49 /**
50 * Add headers and send a packet with the sending function of the physical layer.
51 *
52 * @param packet The packet to send.
53 */
54 void SendToPhy(Ptr<Packet> packet) override;
55
56 //////////////////////////
57 // Receiving methods //
58 //////////////////////////
59
60 /**
61 * Receive a packet.
62 *
63 * This method is typically registered as a callback in the underlying PHY
64 * layer so that it's called when a packet is going up the stack.
65 *
66 * @param packet The received packet.
67 */
68 void Receive(Ptr<const Packet> packet) override;
69
70 /**
71 * Function called by lower layers to inform this layer that reception of a
72 * packet we were locked on failed.
73 *
74 * @param packet The packet we failed to receive.
75 */
76 void FailedReception(Ptr<const Packet> packet) override;
77
78 /**
79 * Perform the actions that are required after a packet send.
80 *
81 * This function handles opening of the first receive window.
82 *
83 * @param packet The packet that has just been transmitted.
84 */
85 void TxFinished(Ptr<const Packet> packet) override;
86
87 /**
88 * Perform operations needed to open the first receive window.
89 */
91
92 /**
93 * Perform operations needed to open the second receive window.
94 */
96
97 /**
98 * Perform operations needed to close the first receive window.
99 */
101
102 /**
103 * Perform operations needed to close the second receive window.
104 */
106
107 /////////////////////////
108 // Getters and Setters //
109 /////////////////////////
110
111 /**
112 * Find the minimum wait time before the next possible transmission based
113 * on end device's Class Type.
114 *
115 * @param waitTime The minimum wait time that has to be respected,
116 * irrespective of the class (e.g., because of duty cycle limitations).
117 * @return The Time value.
118 */
119 Time GetNextClassTransmissionDelay(Time waitTime) override;
120
121 /**
122 * Get the data rate that will be used in the first receive window.
123 *
124 * @return The data rate.
125 */
127
128 /**
129 * Set the data rate to be used in the second receive window.
130 *
131 * @param dataRate The data rate.
132 */
133 void SetSecondReceiveWindowDataRate(uint8_t dataRate);
134
135 /**
136 * Get the data rate that will be used in the second receive window.
137 *
138 * @return The data rate.
139 */
140 uint8_t GetSecondReceiveWindowDataRate() const;
141
142 /**
143 * Set the frequency that will be used for the second receive window.
144 *
145 * @param frequencyHz The Frequency.
146 */
148
149 /**
150 * Get the frequency that is used for the second receive window.
151 *
152 * @return The frequency, in Hz.
153 */
155
156 /////////////////////////
157 // MAC command methods //
158 /////////////////////////
159
160 void OnRxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequencyHz) override;
161
162 private:
163 Time m_receiveDelay1; //!< The interval between when a packet is done sending and when the first
164 //!< receive window is opened.
165
166 /**
167 * The interval between when a packet is done sending and when the second
168 * receive window is opened.
169 */
171
172 /**
173 * The event of the closing the first receive window.
174 *
175 * This Event will be canceled if there's a successful reception of a packet.
176 */
178
179 /**
180 * The event of the closing the second 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 second receive window opening.
188 *
189 * This Event is used to cancel the second window in case the first one is
190 * successful.
191 */
193
194 /**
195 * The frequency [Hz] to listen on for the second receive window.
196 */
198
199 /**
200 * The data rate to listen for during the second downlink transmission.
201 */
203
204 /**
205 * The RX1DROffset parameter value.
206 */
208
209}; /* ClassAEndDeviceLorawanMac */
210} /* namespace lorawan */
211} /* namespace ns3 */
212#endif /* CLASS_A_END_DEVICE_LORAWAN_MAC_H */
An identifier for simulation events.
Definition event-id.h:45
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
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...
uint32_t GetSecondReceiveWindowFrequency() const
Get the frequency that is used for the second receive window.
EventId m_closeFirstWindow
The event of the closing the first receive window.
void SetSecondReceiveWindowFrequency(uint32_t frequencyHz)
Set the frequency that will be used for the second 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 waitTime) override
Find the minimum wait time before the next possible transmission based on end device's Class Type.
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.
uint32_t m_secondReceiveWindowFrequencyHz
The frequency [Hz] to listen on for the second receive window.
void TxFinished(Ptr< const Packet > packet) override
Perform the actions that are required after a packet send.
void CloseSecondReceiveWindow()
Perform operations needed to close the second receive window.
void OnRxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequencyHz) override
Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Devic...
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 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.