lorawan-mac.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  *
20  * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21  */
22 
23 #ifndef LORAWAN_MAC_H
24 #define LORAWAN_MAC_H
25 
27 #include "satellite-lora-phy-rx.h"
28 #include "satellite-mac.h"
29 #include "satellite-phy.h"
30 
31 #include <ns3/object.h>
32 #include <ns3/packet.h>
33 
34 #include <array>
35 
36 namespace ns3
37 {
38 
46 class LorawanMac : public SatMac
47 {
48  public:
49  static TypeId GetTypeId(void);
50 
51  LorawanMac();
52  LorawanMac(uint32_t satId, uint32_t beamId);
53  virtual ~LorawanMac();
54 
55  typedef std::array<std::array<uint8_t, 6>, 8> ReplyDataRateMatrix;
56 
62  Ptr<SatPhy> GetPhy(void);
63 
69  void SetPhy(Ptr<SatPhy> phy);
70 
76  Ptr<SatLoraPhyTx> GetPhyTx(void);
77 
83  void SetPhyTx(Ptr<SatLoraPhyTx> phyTx);
84 
90  virtual void Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
91 
97  virtual void Send(Ptr<Packet> packet) = 0;
98 
104  virtual void Receive(SatPhy::PacketContainer_t packets,
105  Ptr<SatSignalParameters> /*rxParams*/) = 0;
106 
113  virtual void FailedReception(Ptr<const Packet> packet) = 0;
114 
118  virtual void TxFinished() = 0;
119 
125  void SetDevice(Ptr<NetDevice> device);
126 
132  Ptr<NetDevice> GetDevice(void);
133 
140 
147 
156  uint8_t GetSfFromDataRate(uint8_t dataRate);
157 
165  double GetBandwidthFromDataRate(uint8_t dataRate);
166 
176  double GetDbmForTxPower(uint8_t txPower);
177 
190  Time GetOnAirTime(Ptr<Packet> packet, LoraTxParameters txParams);
191 
198  void SetSfForDataRate(std::vector<uint8_t> sfForDataRate);
199 
207  void SetBandwidthForDataRate(std::vector<double> bandwidthForDataRate);
208 
216  void SetMaxAppPayloadForDataRate(std::vector<uint32_t> maxAppPayloadForDataRate);
217 
226  void SetTxDbmForTxPower(std::vector<double> txDbmForTxPower);
227 
235  void SetReplyDataRateMatrix(ReplyDataRateMatrix replyDataRateMatrix);
236 
242  void SetNPreambleSymbols(int nPreambleSymbols);
243 
249  int GetNPreambleSymbols(void);
250 
254  void setRegenerative(bool isRegenerative);
255 
256  protected:
263  TracedCallback<Ptr<const Packet>> m_cannotSendBecauseDutyCycle;
264 
268  TracedCallback<Ptr<const Packet>> m_receivedPacket;
269 
274  TracedCallback<Ptr<const Packet>> m_sentNewPacket;
275 
279  Ptr<SatPhy> m_phy;
280 
284  Ptr<NetDevice> m_device;
285 
290 
294  std::vector<uint8_t> m_sfForDataRate;
295 
299  std::vector<double> m_bandwidthForDataRate;
300 
305  std::vector<uint32_t> m_maxAppPayloadForDataRate;
306 
311 
315  std::vector<double> m_txDbmForTxPower;
316 
322 
326  uint32_t m_beamId;
327 
332 };
333 
334 } /* namespace ns3 */
335 
336 #endif /* LORAWAN_MAC_H */
This class supports LorawanMac instances by managing a list of the logical channels that the device i...
Class representing the LoRaWAN MAC layer.
Definition: lorawan-mac.h:47
TracedCallback< Ptr< const Packet > > m_receivedPacket
Trace source that is fired when a packet reaches the MAC layer.
Definition: lorawan-mac.h:268
ReplyDataRateMatrix m_replyDataRateMatrix
The matrix that decides the DR the GW will use in a reply based on the ED's sending DR and on the val...
Definition: lorawan-mac.h:321
void SetReplyDataRateMatrix(ReplyDataRateMatrix replyDataRateMatrix)
Set the matrix to use when deciding with which DataRate to respond.
Definition: lorawan-mac.cc:251
virtual ~LorawanMac()
Definition: lorawan-mac.cc:72
virtual void Send(Ptr< Packet > packet)=0
Send a packet.
std::vector< uint32_t > m_maxAppPayloadForDataRate
A vector holding the maximum app payload size that corresponds to a certain DataRate.
Definition: lorawan-mac.h:305
std::vector< double > m_bandwidthForDataRate
A vector holding the bandwidth each Data Rate corresponds to.
Definition: lorawan-mac.h:299
int m_nPreambleSymbols
The number of symbols to use in the PHY preamble.
Definition: lorawan-mac.h:310
int GetNPreambleSymbols(void)
Get the number of PHY preamble symbols this MAC is set to use.
Definition: lorawan-mac.cc:238
void SetTxDbmForTxPower(std::vector< double > txDbmForTxPower)
Set the vector to use to check up which transmission power in Dbm corresponds to a certain TxPower va...
Definition: lorawan-mac.cc:226
Time GetOnAirTime(Ptr< Packet > packet, LoraTxParameters txParams)
Compute the time that a packet with certain characteristics will take to be transmitted.
Definition: lorawan-mac.cc:164
uint32_t m_beamId
ID of beam for UT.
Definition: lorawan-mac.h:326
Ptr< SatPhy > GetPhy(void)
Get the underlying PHY layer.
Definition: lorawan-mac.cc:96
TracedCallback< Ptr< const Packet > > m_cannotSendBecauseDutyCycle
The trace source that is fired when a packet cannot be sent because of duty cycle limitations.
Definition: lorawan-mac.h:263
bool m_isRegenerative
Indicates if satellite is regenerative on the link where this layer is sending packets.
Definition: lorawan-mac.h:331
Ptr< SatPhy > m_phy
The PHY instance that sits under this MAC layer.
Definition: lorawan-mac.h:279
virtual void Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Send a packet.
Definition: lorawan-mac.cc:78
void SetBandwidthForDataRate(std::vector< double > bandwidthForDataRate)
Set the vector to use to check up correspondence between bandwidth and DataRate.
Definition: lorawan-mac.cc:214
virtual void FailedReception(Ptr< const Packet > packet)=0
Function called by lower layers to inform this layer that reception of a packet we were locked on fai...
static TypeId GetTypeId(void)
Definition: lorawan-mac.cc:35
TracedCallback< Ptr< const Packet > > m_sentNewPacket
Trace source that is fired when a new APP layer packet arrives at the MAC layer.
Definition: lorawan-mac.h:274
void SetSfForDataRate(std::vector< uint8_t > sfForDataRate)
Set the vector to use to check up correspondence between SF and DataRate.
Definition: lorawan-mac.cc:208
void SetMaxAppPayloadForDataRate(std::vector< uint32_t > maxAppPayloadForDataRate)
Set the maximum App layer payload for a set DataRate.
Definition: lorawan-mac.cc:220
uint8_t GetSfFromDataRate(uint8_t dataRate)
Get the SF corresponding to a data rate, based on this MAC's region.
Definition: lorawan-mac.cc:123
void SetPhyTx(Ptr< SatLoraPhyTx > phyTx)
Set the underlying PHY TX layer.
Ptr< NetDevice > GetDevice(void)
Get the device this MAC layer is installed on.
Definition: lorawan-mac.cc:90
Ptr< NetDevice > m_device
The device this MAC layer is installed on.
Definition: lorawan-mac.h:284
LoraLogicalChannelHelper GetLoraLogicalChannelHelper(void)
Get the logical lora channel helper associated with this MAC.
Definition: lorawan-mac.cc:111
std::vector< double > m_txDbmForTxPower
A vector holding the power that corresponds to a certain TxPower value.
Definition: lorawan-mac.h:315
double GetDbmForTxPower(uint8_t txPower)
Get the transmission power in dBm that corresponds, in this region, to the encoded 8-bit txPower.
Definition: lorawan-mac.cc:151
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)=0
Receive a packet from the lower layer.
Ptr< SatLoraPhyTx > GetPhyTx(void)
Get the underlying PHY TX layer.
void SetNPreambleSymbols(int nPreambleSymbols)
Set the number of PHY preamble symbols this MAC is set to use.
Definition: lorawan-mac.cc:232
void SetLoraLogicalChannelHelper(LoraLogicalChannelHelper helper)
Set the LoraLogicalChannelHelper this MAC instance will use.
Definition: lorawan-mac.cc:117
void SetPhy(Ptr< SatPhy > phy)
Set the underlying PHY layer.
Definition: lorawan-mac.cc:102
void SetDevice(Ptr< NetDevice > device)
Set the device this MAC layer is installed on.
Definition: lorawan-mac.cc:84
LoraLogicalChannelHelper m_channelHelper
The LoraLogicalChannelHelper instance that is assigned to this MAC.
Definition: lorawan-mac.h:289
void setRegenerative(bool isRegenerative)
Indicates if the satellite is regenerative on the link this layer is sending packets.
Definition: lorawan-mac.cc:244
std::vector< uint8_t > m_sfForDataRate
A vector holding the SF each Data Rate corresponds to.
Definition: lorawan-mac.h:294
virtual void TxFinished()=0
Perform actions after sending a packet.
double GetBandwidthFromDataRate(uint8_t dataRate)
Get the BW corresponding to a data rate, based on this MAC's region.
Definition: lorawan-mac.cc:137
std::array< std::array< uint8_t, 6 >, 8 > ReplyDataRateMatrix
Definition: lorawan-mac.h:55
Base MAC class for SatNetDevices.
Definition: satellite-mac.h:52
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
Definition: satellite-phy.h:78
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.
Structure to collect all parameters that are used to compute the duration of a packet (excluding payl...