lorawan-mac-end-device-class-a.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2017 University of Padova
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Davide Magrin <magrinda@dei.unipd.it>
19  * Martina Capuzzo <capuzzom@dei.unipd.it>
20  *
21  * Modified by: Peggy Anderson <peggy.anderson@usask.ca>
22  * Bastien Tauran <bastien.tauran@viveris.fr>
23  */
24 
25 #ifndef LORAWAN_MAC_END_DEVICE_CLASS_A_H
26 #define LORAWAN_MAC_END_DEVICE_CLASS_A_H
27 
28 #include <ns3/lora-device-address.h>
29 #include <ns3/lora-frame-header.h> // RxParamSetupReq
30 #include <ns3/lorawan-mac-end-device.h> // LorawanMacEndDevice
31 #include <ns3/lorawan-mac.h> // Packet
32 
33 namespace ns3
34 {
35 
40 {
41  public:
42  static TypeId GetTypeId(void);
43 
45  LorawanMacEndDeviceClassA(uint32_t satId, uint32_t beamId, Ptr<SatSuperframeSeq> seq);
47 
49  // Sending methods //
51 
57  virtual void SendToPhy(Ptr<Packet> packet);
58 
60  // Receiving methods //
62 
71  virtual void Receive(Ptr<Packet> packet);
72 
73  virtual void FailedReception(Ptr<const Packet> packet);
74 
80  virtual void TxFinished();
81 
87  void SetRaModel(SatEnums::RandomAccessModel_t randomAccessModel);
88 
92  void OpenFirstReceiveWindow(void);
93 
97  void OpenSecondReceiveWindow(void);
98 
102  void CloseFirstReceiveWindow(void);
103 
107  void CloseSecondReceiveWindow(void);
108 
110  // Getters and Setters //
112 
120  virtual Time GetNextClassTransmissionDelay(Time waitingTime);
121 
127  uint8_t GetFirstReceiveWindowDataRate(void);
128 
134  void SetSecondReceiveWindowDataRate(uint8_t dataRate);
135 
141  uint8_t GetSecondReceiveWindowDataRate(void);
142 
148  void SetSecondReceiveWindowFrequency(double frequencyMHz);
149 
155  double GetSecondReceiveWindowFrequency(void);
156 
158  // MAC command methods //
160 
170  virtual void OnRxClassParamSetupReq(Ptr<RxParamSetupReq> rxParamSetupReq);
171 
172  private:
176  Ptr<SatSuperframeSeq> m_superframeSeq;
177 
182 
187 
192 
197 
202 
209 
216 
224 
229 
234 
238  uint8_t m_rx1DrOffset;
239 
240 }; /* LorawanMacEndDeviceClassA */
241 } /* namespace ns3 */
242 #endif /* LORAWAN_MAC_END_DEVICE_CLASS_A_H */
Class representing the MAC layer of a Class A LoRaWAN device.
EventId m_secondReceiveWindow
The event of the second receive window opening.
uint8_t GetFirstReceiveWindowDataRate(void)
Get the Data Rate that will be used in the first receive window.
Time m_secondWindowDelay
Time to wait between end of message transmission and opening of second reception window.
virtual void TxFinished()
Perform the actions that are required after a packet send.
SatEnums::PacketType_t m_packetType
Packet type used on RTN channel.
virtual void OnRxClassParamSetupReq(Ptr< RxParamSetupReq > rxParamSetupReq)
Perform the actions that need to be taken when receiving a RxParamSetupReq command based on the Devic...
virtual void SendToPhy(Ptr< Packet > packet)
Add headers and send a packet with the sending function of the physical layer.
Time m_secondWindowDuration
Duration of second reception window.
virtual Time GetNextClassTransmissionDelay(Time waitingTime)
Find the minimum waiting time before the next possible transmission based on End Device's Class Type.
Time m_firstWindowDuration
Duration of first reception window.
double GetSecondReceiveWindowFrequency(void)
Get the frequency that is used for the second receive window.
Ptr< SatSuperframeSeq > m_superframeSeq
Used superframe sequence for the return link.
EventId m_closeSecondWindow
The event of the closing the second receive window.
void CloseFirstReceiveWindow(void)
Perform operations needed to close the first receive window.
void OpenFirstReceiveWindow(void)
Perform operations needed to open the first receive window.
void OpenSecondReceiveWindow(void)
Perform operations needed to open the second receive window.
void SetSecondReceiveWindowDataRate(uint8_t dataRate)
Set the Data Rate to be used in the second receive window.
virtual void FailedReception(Ptr< const Packet > packet)
Function called by lower layers to inform this layer that reception of a packet we were locked on fai...
void SetSecondReceiveWindowFrequency(double frequencyMHz)
Set the frequency that will be used for the second receive window.
void CloseSecondReceiveWindow(void)
Perform operations needed to close the second receive window.
uint8_t m_rx1DrOffset
The RX1DROffset parameter value.
double m_secondReceiveWindowFrequency
The frequency to listen on for the second receive window.
virtual void Receive(Ptr< Packet > packet)
Receive a packet.
Time m_firstWindowDelay
Time to wait between end of message transmission and opening of first reception window.
EventId m_closeFirstWindow
The event of the closing the first receive window.
uint8_t GetSecondReceiveWindowDataRate(void)
Get the Data Rate that will be used in the second receive window.
void SetRaModel(SatEnums::RandomAccessModel_t randomAccessModel)
Set the random access model.
uint8_t m_secondReceiveWindowDataRate
The Data Rate to listen for during the second downlink transmission.
Class representing the MAC layer of a LoRaWAN device.
RandomAccessModel_t
The defined random access models.
PacketType_t
Packet types.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.