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 * Get the data rate that will be used in the first receive window.
41 *
42 * @return The data rate.
43 */
45
46 /**
47 * Set the data rate to be used in the second receive window.
48 *
49 * @param dataRate The data rate.
50 */
51 void SetSecondReceiveWindowDataRate(uint8_t dataRate);
52
53 /**
54 * Get the data rate that will be used in the second receive window.
55 *
56 * @return The data rate.
57 */
58 uint8_t GetSecondReceiveWindowDataRate() const;
59
60 /**
61 * Set the frequency that will be used for the second receive window.
62 *
63 * @param frequencyHz The Frequency.
64 */
66
67 /**
68 * Get the frequency that is used for the second receive window.
69 *
70 * @return The frequency, in Hz.
71 */
73
74 private:
75 /**
76 * Set of possible outcomes of a reception window
77 */
79 {
80 ACK, //!< Correctly received a network acknowledgement
81 RECV, //!< Correctly received a downlink packet (no ACK)
82 FAIL, //!< Reception initiated but failed
83 NONE //!< Reception window timed out
84 };
85
86 Time GetNextClassTransmissionDelay() const override;
87 void SendToPhy(Ptr<Packet> packet) override;
88 void TxFinished(Ptr<const Packet> packet) override;
89
90 /**
91 * Perform operations needed to open the first receive window.
92 */
94
95 /**
96 * Perform operations needed to open the second receive window.
97 */
99
100 /**
101 * Perform operations needed to close the first receive window.
102 */
104
105 /**
106 * Perform operations needed to close the second receive window.
107 */
109
110 /**
111 * Decide whether we can retransmit based on reception outcome.
112 *
113 * @param outcome Outcome of the reception.
114 */
115 void ManageRetransmissions(RxOutcome outcome);
116
117 void Receive(Ptr<const Packet> packet) override;
118 void FailedReception(Ptr<const Packet> packet) override;
119 void OnRxParamSetupReq(uint8_t rx1DrOffset, uint8_t rx2DataRate, double frequencyHz) override;
120
121 EventId m_secondReceiveWindow; //!< The event of the second receive window opening, used
122 //!< to cancel the second window in case the first one is
123 //!< successful.
124
125 // Reception window parameters
126
127 Time m_receiveDelay1; //!< The interval between when a packet is done sending and when the first
128 //!< receive window is opened.
129 uint32_t m_firstReceiveWindowFrequencyHz; //!< The frequency [Hz] to listen on for the first
130 //!< receive window. This value is set dynamically to
131 //!< the last uplink transmission frequency.
132 uint8_t m_rx1DrOffset; //!< The RX1DROffset parameter value.
133
134 Time m_receiveDelay2; //!< The interval between when a packet is done sending and when the
135 //!< second receive window is opened.
136 uint32_t m_secondReceiveWindowFrequencyHz; //!< The frequency [Hz] to listen on for the second
137 //!< receive window.
138 uint8_t m_secondReceiveWindowDataRate; //!< The data rate to listen for during the second
139 //!< downlink transmission.
140
141 // Rescheduling purposes
142
143 bool m_busy; //!< Whether the MAC layer is currently busy with in the LoRaWAN Class A process of
144 //!< transmitting an uplink packet and then opening two reception windows.
145};
146
147} /* namespace lorawan */
148} /* namespace ns3 */
149
150#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.
uint32_t m_firstReceiveWindowFrequencyHz
The frequency [Hz] to listen on for the first receive window.
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
Inform this layer that reception of a packet we were locked on failed.
uint32_t GetSecondReceiveWindowFrequency() const
Get the frequency that is used for the second receive window.
RxOutcome
Set of possible outcomes of a reception window.
@ ACK
Correctly received a network acknowledgement.
@ RECV
Correctly received a downlink packet (no ACK).
Time GetNextClassTransmissionDelay() const override
Find the minimum wait time before the next possible transmission based on end device's Class Type sch...
void SetSecondReceiveWindowFrequency(uint32_t frequencyHz)
Set the frequency that will be used for the second receive window.
bool m_busy
Whether the MAC layer is currently busy with in the LoRaWAN Class A process of transmitting an uplink...
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.
void CloseFirstReceiveWindow()
Perform operations needed to close the first receive window.
void SendToPhy(Ptr< Packet > packet) override
Gather PHY transmission parameters and send a packet through the LoRa 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 actions after sending a packet.
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.
void ManageRetransmissions(RxOutcome outcome)
Decide whether we can retransmit based on reception outcome.
EventId m_secondReceiveWindow
The event of the second receive window opening, used to cancel the second window in case the first on...
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 from the lower layer.
void OpenFirstReceiveWindow()
Perform operations needed to open the first receive window.
Every class exported by the ns3 library is enclosed in the ns3 namespace.