lora-adr-component.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: Matteo Perin <matteo.perin.2@studenti.unipd.2>
19  *
20  * Modified by: Bastien Tauran <bastien.tauran@viveris.fr>
21  */
22 
23 #ifndef LORA_ADR_COMPONENT_H
24 #define LORA_ADR_COMPONENT_H
25 
27 #include "lora-network-status.h"
28 
29 #include <ns3/object.h>
30 #include <ns3/packet.h>
31 
32 namespace ns3
33 {
34 
36 // LinkAdrRequest commands management //
38 
40 {
42  {
46  };
47 
48  public:
49  static TypeId GetTypeId(void);
50 
51  // Constructor
53  // Destructor
54  virtual ~LoraAdrComponent();
55 
56  void OnReceivedPacket(Ptr<const Packet> packet,
57  Ptr<LoraEndDeviceStatus> status,
58  Ptr<LoraNetworkStatus> networkStatus);
59 
60  void BeforeSendingReply(Ptr<LoraEndDeviceStatus> status, Ptr<LoraNetworkStatus> networkStatus);
61 
62  void OnFailedReply(Ptr<LoraEndDeviceStatus> status, Ptr<LoraNetworkStatus> networkStatus);
63 
64  private:
65  void AdrImplementation(uint8_t* newDataRate,
66  uint8_t* newTxPower,
67  Ptr<LoraEndDeviceStatus> status);
68 
69  uint8_t SfToDr(uint8_t sf);
70 
71  double RxPowerToSNR(double transmissionPower);
72 
74 
76 
78 
80 
82 
84 
86 
87  int GetTxPowerIndex(int txPower);
88 
89  // TX power from gateways policy
91 
92  // Number of previous packets to consider
94 
95  // Received SNR history policy
97 
98  // SF lower limit
99  const int min_spreadingFactor = 7;
100 
101  // Minimum transmission power (dBm) (Europe)
102  const int min_transmissionPower = 2;
103 
104  // Maximum transmission power (dBm) (Europe)
105  const int max_transmissionPower = 14;
106 
107  // Device specific SNR margin (dB)
108  // const int offset = 10;
109 
110  // Bandwidth (Hz)
111  const int B = 125000;
112 
113  // Noise Figure (dB)
114  const int NF = 6;
115 
116  // Vector containing the required SNR for the 6 allowed SF levels
117  // ranging from 7 to 12 (the SNR values are in dB).
118  double treshold[6] = {-20.0, -17.5, -15.0, -12.5, -10.0, -7.5};
119 
121 };
122 } // namespace ns3
123 
124 #endif
enum CombiningMethod tpAveraging
uint8_t SfToDr(uint8_t sf)
double GetMinSNR(LoraEndDeviceStatus::ReceivedPacketList packetList, int historyRange)
double GetAverageSNR(LoraEndDeviceStatus::ReceivedPacketList packetList, int historyRange)
enum CombiningMethod historyAveraging
void OnFailedReply(Ptr< LoraEndDeviceStatus > status, Ptr< LoraNetworkStatus > networkStatus)
Method that is called when a packet cannot be sent in the downlink.
double RxPowerToSNR(double transmissionPower)
void OnReceivedPacket(Ptr< const Packet > packet, Ptr< LoraEndDeviceStatus > status, Ptr< LoraNetworkStatus > networkStatus)
Method that is called when a new packet is received by the NetworkServer.
static TypeId GetTypeId(void)
double GetMinTxFromGateways(LoraEndDeviceStatus::GatewayList gwList)
void AdrImplementation(uint8_t *newDataRate, uint8_t *newTxPower, Ptr< LoraEndDeviceStatus > status)
double GetAverageTxFromGateways(LoraEndDeviceStatus::GatewayList gwList)
void BeforeSendingReply(Ptr< LoraEndDeviceStatus > status, Ptr< LoraNetworkStatus > networkStatus)
double GetMaxSNR(LoraEndDeviceStatus::ReceivedPacketList packetList, int historyRange)
int GetTxPowerIndex(int txPower)
double GetMaxTxFromGateways(LoraEndDeviceStatus::GatewayList gwList)
double GetReceivedPower(LoraEndDeviceStatus::GatewayList gwList)
std::list< std::pair< Ptr< const Packet >, ReceivedPacketInfo > > ReceivedPacketList
std::map< Address, PacketInfoPerGw > GatewayList
Generic class describing a component of the NetworkController.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.