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
16
17namespace ns3
18{
19namespace lorawan
20{
21
22/**
23 * @ingroup lorawan
24 *
25 * Class representing the MAC layer of a Class A LoRaWAN device.
26 */
28{
29 public:
30 /**
31 * Register this type.
32 * @return The object TypeId.
33 */
34 static TypeId GetTypeId();
35
36 ClassAEndDeviceLorawanMac(); //!< Default constructor
37 ~ClassAEndDeviceLorawanMac() override; //!< Destructor
38
39 /////////////////////
40 // Sending methods //
41 /////////////////////
42
43 /**
44 * Add headers and send a packet with the sending function of the physical layer.
45 *
46 * @param packet The packet to send.
47 */
48 void SendToPhy(Ptr<Packet> packet) override;
49
50 //////////////////////////
51 // Receiving methods //
52 //////////////////////////
53
54 /**
55 * Receive a packet.
56 *
57 * This method is typically registered as a callback in the underlying PHY
58 * layer so that it's called when a packet is going up the stack.
59 *
60 * @param packet The received packet.
61 */
62 void Receive(Ptr<const Packet> packet) override;
63
64 /**
65 * Function called by lower layers to inform this layer that reception of a
66 * packet we were locked on failed.
67 *
68 * @param packet The packet we failed to receive.
69 */
70 void FailedReception(Ptr<const Packet> packet) override;
71
72 /**
73 * Perform the actions that are required after a packet send.
74 *
75 * This function handles opening of the first receive window.
76 *
77 * @param packet The packet that has just been transmitted.
78 */
79 void TxFinished(Ptr<const Packet> packet) override;
80
81 /**
82 * Perform operations needed to open the first receive window.
83 */
85
86 /**
87 * Perform operations needed to open the second receive window.
88 */
90
91 /**
92 * Perform operations needed to close the first receive window.
93 */
95
96 /**
97 * Perform operations needed to close the second receive window.
98 */
100
101 /////////////////////////
102 // Getters and Setters //
103 /////////////////////////
104
105 /**
106 * Find the minimum wait time before the next possible transmission based
107 * on end device's Class Type.
108 *
109 * @param waitTime The minimum wait time that has to be respected,
110 * irrespective of the class (e.g., because of duty cycle limitations).
111 * @return The Time value.
112 */
113 Time GetNextClassTransmissionDelay(Time waitTime) override;
114
115 /**
116 * Get the data rate that will be used in the first receive window.
117 *
118 * @return The data rate.
119 */
121
122 /**
123 * Set the data rate to be used in the second receive window.
124 *
125 * @param dataRate The data rate.
126 */
127 void SetSecondReceiveWindowDataRate(uint8_t dataRate);
128
129 /**
130 * Get the data rate that will be used in the second receive window.
131 *
132 * @return The data rate.
133 */
134 uint8_t GetSecondReceiveWindowDataRate() const;
135
136 /**
137 * Set the frequency that will be used for the second receive window.
138 *
139 * @param frequencyHz The Frequency.
140 */
142
143 /**
144 * Get the frequency that is used for the second receive window.
145 *
146 * @return The frequency, in Hz.
147 */
149
150 /////////////////////////
151 // MAC command methods //
152 /////////////////////////
153
154 void OnRxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequencyHz) override;
155
156 private:
157 Time m_receiveDelay1; //!< The interval between when a packet is done sending and when the first
158 //!< receive window is opened.
159
160 /**
161 * The interval between when a packet is done sending and when the second
162 * receive window is opened.
163 */
165
166 /**
167 * The event of the closing the first receive window.
168 *
169 * This Event will be canceled if there's a successful reception of a packet.
170 */
172
173 /**
174 * The event of the closing the second receive window.
175 *
176 * This Event will be canceled if there's a successful reception of a packet.
177 */
179
180 /**
181 * The event of the second receive window opening.
182 *
183 * This Event is used to cancel the second window in case the first one is
184 * successful.
185 */
187
188 /**
189 * The frequency [Hz] to listen on for the second receive window.
190 */
192
193 /**
194 * The data rate to listen for during the second downlink transmission.
195 */
197
198 /**
199 * The RX1DROffset parameter value.
200 */
202
203}; /* ClassAEndDeviceLorawanMac */
204} /* namespace lorawan */
205} /* namespace ns3 */
206#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.
Definition ptr.h:70
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
a unique identifier for an interface.
Definition type-id.h:50
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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.