Loading...
Searching...
No Matches
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
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#include <stdint.h>
36#include <vector>
37
38namespace ns3
39{
40
48class LorawanMac : public SatMac
49{
50 public:
51 static TypeId GetTypeId(void);
52
53 LorawanMac();
54 LorawanMac(uint32_t satId, uint32_t beamId);
55 virtual ~LorawanMac();
56
57 typedef std::array<std::array<uint8_t, 6>, 8> ReplyDataRateMatrix;
58
64 Ptr<SatPhy> GetPhy(void);
65
71 void SetPhy(Ptr<SatPhy> phy);
72
78 Ptr<SatLoraPhyTx> GetPhyTx(void);
79
85 void SetPhyTx(Ptr<SatLoraPhyTx> phyTx);
86
92 virtual void Send(Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
93
99 virtual void Send(Ptr<Packet> packet) = 0;
100
106 virtual void Receive(SatPhy::PacketContainer_t packets,
107 Ptr<SatSignalParameters> /*rxParams*/) = 0;
108
115 virtual void FailedReception(Ptr<const Packet> packet) = 0;
116
120 virtual void TxFinished() = 0;
121
127 void SetDevice(Ptr<NetDevice> device);
128
134 Ptr<NetDevice> GetDevice(void);
135
142
149
158 uint8_t GetSfFromDataRate(uint8_t dataRate);
159
167 double GetBandwidthFromDataRate(uint8_t dataRate);
168
178 double GetDbmForTxPower(uint8_t txPower);
179
192 Time GetOnAirTime(Ptr<Packet> packet, LoraTxParameters txParams);
193
200 void SetSfForDataRate(std::vector<uint8_t> sfForDataRate);
201
209 void SetBandwidthForDataRate(std::vector<double> bandwidthForDataRate);
210
218 void SetMaxAppPayloadForDataRate(std::vector<uint32_t> maxAppPayloadForDataRate);
219
228 void SetTxDbmForTxPower(std::vector<double> txDbmForTxPower);
229
237 void SetReplyDataRateMatrix(ReplyDataRateMatrix replyDataRateMatrix);
238
244 void SetNPreambleSymbols(int nPreambleSymbols);
245
251 int GetNPreambleSymbols(void);
252
256 void setRegenerative(bool isRegenerative);
257
258 protected:
265 TracedCallback<Ptr<const Packet>> m_cannotSendBecauseDutyCycle;
266
270 TracedCallback<Ptr<const Packet>> m_receivedPacket;
271
276 TracedCallback<Ptr<const Packet>> m_sentNewPacket;
277
281 Ptr<SatPhy> m_phy;
282
286 Ptr<NetDevice> m_device;
287
292
296 std::vector<uint8_t> m_sfForDataRate;
297
301 std::vector<double> m_bandwidthForDataRate;
302
307 std::vector<uint32_t> m_maxAppPayloadForDataRate;
308
313
317 std::vector<double> m_txDbmForTxPower;
318
324
328 uint32_t m_beamId;
329
334};
335
336} /* namespace ns3 */
337
338#endif /* LORAWAN_MAC_H */
This class supports LorawanMac instances by managing a list of the logical channels that the device i...
TracedCallback< Ptr< const Packet > > m_receivedPacket
Trace source that is fired when a packet reaches the MAC layer.
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...
void SetReplyDataRateMatrix(ReplyDataRateMatrix replyDataRateMatrix)
Set the matrix to use when deciding with which DataRate to respond.
virtual ~LorawanMac()
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.
std::vector< double > m_bandwidthForDataRate
A vector holding the bandwidth each Data Rate corresponds to.
int m_nPreambleSymbols
The number of symbols to use in the PHY preamble.
int GetNPreambleSymbols(void)
Get the number of PHY preamble symbols this MAC is set to use.
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...
Time GetOnAirTime(Ptr< Packet > packet, LoraTxParameters txParams)
Compute the time that a packet with certain characteristics will take to be transmitted.
uint32_t m_beamId
ID of beam for UT.
Ptr< SatPhy > GetPhy(void)
Get the underlying PHY layer.
TracedCallback< Ptr< const Packet > > m_cannotSendBecauseDutyCycle
The trace source that is fired when a packet cannot be sent because of duty cycle limitations.
bool m_isRegenerative
Indicates if satellite is regenerative on the link where this layer is sending packets.
Ptr< SatPhy > m_phy
The PHY instance that sits under this MAC layer.
virtual void Send(Ptr< Packet > packet, const Address &dest, uint16_t protocolNumber)
Send a packet.
void SetBandwidthForDataRate(std::vector< double > bandwidthForDataRate)
Set the vector to use to check up correspondence between bandwidth and DataRate.
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)
TracedCallback< Ptr< const Packet > > m_sentNewPacket
Trace source that is fired when a new APP layer packet arrives at the MAC layer.
void SetSfForDataRate(std::vector< uint8_t > sfForDataRate)
Set the vector to use to check up correspondence between SF and DataRate.
void SetMaxAppPayloadForDataRate(std::vector< uint32_t > maxAppPayloadForDataRate)
Set the maximum App layer payload for a set DataRate.
uint8_t GetSfFromDataRate(uint8_t dataRate)
Get the SF corresponding to a data rate, based on this MAC's region.
void SetPhyTx(Ptr< SatLoraPhyTx > phyTx)
Set the underlying PHY TX layer.
Ptr< NetDevice > GetDevice(void)
Get the device this MAC layer is installed on.
Ptr< NetDevice > m_device
The device this MAC layer is installed on.
LoraLogicalChannelHelper GetLoraLogicalChannelHelper(void)
Get the logical lora channel helper associated with this MAC.
Ptr< SatLoraPhyTx > GetPhyTx(void)
Get the underlying PHY TX layer.
std::vector< double > m_txDbmForTxPower
A vector holding the power that corresponds to a certain TxPower value.
double GetDbmForTxPower(uint8_t txPower)
Get the transmission power in dBm that corresponds, in this region, to the encoded 8-bit txPower.
virtual void Receive(SatPhy::PacketContainer_t packets, Ptr< SatSignalParameters >)=0
Receive a packet from the lower layer.
void SetNPreambleSymbols(int nPreambleSymbols)
Set the number of PHY preamble symbols this MAC is set to use.
void SetLoraLogicalChannelHelper(LoraLogicalChannelHelper helper)
Set the LoraLogicalChannelHelper this MAC instance will use.
void SetPhy(Ptr< SatPhy > phy)
Set the underlying PHY layer.
void SetDevice(Ptr< NetDevice > device)
Set the device this MAC layer is installed on.
LoraLogicalChannelHelper m_channelHelper
The LoraLogicalChannelHelper instance that is assigned to this MAC.
void setRegenerative(bool isRegenerative)
Indicates if the satellite is regenerative on the link this layer is sending packets.
std::vector< uint8_t > m_sfForDataRate
A vector holding the SF each Data Rate corresponds to.
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.
std::array< std::array< uint8_t, 6 >, 8 > ReplyDataRateMatrix
Definition lorawan-mac.h:57
SatMac()
Construct a SatMac.
SatSignalParameters::PacketsInBurst_t PacketContainer_t
Define PacketContainer in SatPhy.
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...