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 "lora-device-address.h"
29 #include "lora-frame-header.h" // RxParamSetupReq
30 #include "lorawan-mac-end-device.h" // LorawanMacEndDevice
31 #include "lorawan-mac.h" // Packet
32 
33 #include <stdint.h>
34 
35 namespace ns3
36 {
37 
42 {
43  public:
44  static TypeId GetTypeId(void);
45 
46  TypeId GetInstanceTypeId(void) const;
47 
49  LorawanMacEndDeviceClassA(Ptr<Node> node,
50  uint32_t satId,
51  uint32_t beamId,
52  Ptr<SatSuperframeSeq> seq);
54 
56  // Sending methods //
58 
64  virtual void SendToPhy(Ptr<Packet> packet);
65 
67  // Receiving methods //
69 
78  virtual void Receive(Ptr<Packet> packet);
79 
80  virtual void FailedReception(Ptr<const Packet> packet);
81 
87  virtual void TxFinished();
88 
94  void SetRaModel(SatEnums::RandomAccessModel_t randomAccessModel);
95 
99  void OpenFirstReceiveWindow(void);
100 
104  void OpenSecondReceiveWindow(void);
105 
109  void CloseFirstReceiveWindow(void);
110 
114  void CloseSecondReceiveWindow(void);
115 
117  // Getters and Setters //
119 
127  virtual Time GetNextClassTransmissionDelay(Time waitingTime);
128 
134  uint8_t GetFirstReceiveWindowDataRate(void);
135 
141  void SetSecondReceiveWindowDataRate(uint8_t dataRate);
142 
148  uint8_t GetSecondReceiveWindowDataRate(void);
149 
155  void SetSecondReceiveWindowFrequency(double frequencyMHz);
156 
162  double GetSecondReceiveWindowFrequency(void);
163 
165  // MAC command methods //
167 
177  virtual void OnRxClassParamSetupReq(Ptr<RxParamSetupReq> rxParamSetupReq);
178 
179  private:
183  Ptr<SatSuperframeSeq> m_superframeSeq;
184 
189 
194 
199 
204 
209 
216 
223 
231 
236 
241 
245  uint8_t m_rx1DrOffset;
246 
247 }; /* LorawanMacEndDeviceClassA */
248 } /* namespace ns3 */
249 #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.