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 void FailedReception(Ptr<const Packet> packet) override;
71
72 void TxFinished(Ptr<const Packet> packet) override;
73
74 /**
75 * Perform operations needed to open the first receive window.
76 */
78
79 /**
80 * Perform operations needed to open the second receive window.
81 */
83
84 /**
85 * Perform operations needed to close the first receive window.
86 */
88
89 /**
90 * Perform operations needed to close the second receive window.
91 */
93
94 /////////////////////////
95 // Getters and Setters //
96 /////////////////////////
97
98 /**
99 * Find the minimum waiting time before the next possible transmission based
100 * on end device's Class Type.
101 *
102 * \param waitingTime The minimum waiting time that has to be respected,
103 * irrespective of the class (e.g., because of duty cycle limitations).
104 * \return The Time value.
105 */
106 Time GetNextClassTransmissionDelay(Time waitingTime) override;
107
108 /**
109 * Get the data rate that will be used in the first receive window.
110 *
111 * \return The data rate.
112 */
114
115 /**
116 * Set the data rate to be used in the second receive window.
117 *
118 * \param dataRate The data rate.
119 */
120 void SetSecondReceiveWindowDataRate(uint8_t dataRate);
121
122 /**
123 * Get the data rate that will be used in the second receive window.
124 *
125 * \return The data rate.
126 */
127 uint8_t GetSecondReceiveWindowDataRate() const;
128
129 /**
130 * Set the frequency that will be used for the second receive window.
131 *
132 * \param frequencyMHz The Frequency.
133 */
134 void SetSecondReceiveWindowFrequency(double frequencyMHz);
135
136 /**
137 * Get the frequency that is used for the second receive window.
138 *
139 * \return The frequency, in MHz.
140 */
141 double GetSecondReceiveWindowFrequency() const;
142
143 /////////////////////////
144 // MAC command methods //
145 /////////////////////////
146
147 /**
148 * Perform the actions that need to be taken when receiving a RxParamSetupReq
149 * command based on the Device's Class Type.
150 *
151 * \param rxParamSetupReq The Parameter Setup Request, which contains:
152 * - The offset to set.
153 * - The data rate to use for the second receive window.
154 * - The frequency to use for the second receive window.
155 */
156 void OnRxClassParamSetupReq(Ptr<RxParamSetupReq> rxParamSetupReq) override;
157
158 private:
159 Time m_receiveDelay1; //!< The interval between when a packet is done sending and when the first
160 //!< receive window is opened.
161
162 /**
163 * The interval between when a packet is done sending and when the second
164 * receive window is opened.
165 */
167
168 /**
169 * The event of the closing the first receive window.
170 *
171 * This Event will be canceled if there's a successful reception of a packet.
172 */
174
175 /**
176 * The event of the closing the second receive window.
177 *
178 * This Event will be canceled if there's a successful reception of a packet.
179 */
181
182 /**
183 * The event of the second receive window opening.
184 *
185 * This Event is used to cancel the second window in case the first one is
186 * successful.
187 */
189
190 /**
191 * The frequency to listen on for the second receive window.
192 */
194
195 /**
196 * The data rate to listen for during the second downlink transmission.
197 */
199
200 /**
201 * The RX1DROffset parameter value.
202 */
204
205}; /* ClassAEndDeviceLorawanMac */
206} /* namespace lorawan */
207} /* namespace ns3 */
208#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:48
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.