A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lora-utils.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 University of Padova
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
18 */
19
20#include "lora-utils.h"
21
22#include <cmath>
23
24namespace ns3
25{
26namespace lorawan
27{
28
29double
30DbToRatio(double dB)
31{
32 double ratio = std::pow(10.0, dB / 10.0);
33 return ratio;
34}
35
36double
37DbmToW(double dBm)
38{
39 double mW = std::pow(10.0, dBm / 10.0);
40 return mW / 1000.0;
41}
42
43double
44WToDbm(double w)
45{
46 return 10.0 * std::log10(w * 1000.0);
47}
48
49double
50RatioToDb(double ratio)
51{
52 return 10.0 * std::log10(ratio);
53}
54
55} // namespace lorawan
56} // namespace ns3
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition: lora-utils.cc:37
double WToDbm(double w)
Convert from Watts to dBm.
Definition: lora-utils.cc:44
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition: lora-utils.cc:50
double DbToRatio(double dB)
Convert from dB to ratio.
Definition: lora-utils.cc:30
Every class exported by the ns3 library is enclosed in the ns3 namespace.