Loading...
Searching...
No Matches
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#include <stdint.h>
33
34namespace ns3
35{
36
38// LinkAdrRequest commands management //
40
42{
49
50 public:
51 static TypeId GetTypeId(void);
52
53 // Constructor
55 // Destructor
56 virtual ~LoraAdrComponent();
57
58 void OnReceivedPacket(Ptr<const Packet> packet,
59 Ptr<LoraEndDeviceStatus> status,
60 Ptr<LoraNetworkStatus> networkStatus);
61
62 void BeforeSendingReply(Ptr<LoraEndDeviceStatus> status, Ptr<LoraNetworkStatus> networkStatus);
63
64 void OnFailedReply(Ptr<LoraEndDeviceStatus> status, Ptr<LoraNetworkStatus> networkStatus);
65
66 private:
67 void AdrImplementation(uint8_t* newDataRate,
68 uint8_t* newTxPower,
69 Ptr<LoraEndDeviceStatus> status);
70
71 uint8_t SfToDr(uint8_t sf);
72
73 double RxPowerToSNR(double transmissionPower);
74
76
78
80
82
84
86
88
89 int GetTxPowerIndex(int txPower);
90
91 // TX power from gateways policy
93
94 // Number of previous packets to consider
96
97 // Received SNR history policy
99
100 // SF lower limit
101 const int min_spreadingFactor = 7;
102
103 // Minimum transmission power (dBm) (Europe)
105
106 // Maximum transmission power (dBm) (Europe)
107 const int max_transmissionPower = 14;
108
109 // Device specific SNR margin (dB)
110 // const int offset = 10;
111
112 // Bandwidth (Hz)
113 const int B = 125000;
114
115 // Noise Figure (dB)
116 const int NF = 6;
117
118 // Vector containing the required SNR for the 6 allowed SF levels
119 // ranging from 7 to 12 (the SNR values are in dB).
120 double treshold[6] = {-20.0, -17.5, -15.0, -12.5, -10.0, -7.5};
121
123};
124} // namespace ns3
125
126#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
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.