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 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Romagnolo Stefano <romagnolostefano93@gmail.com>
7 */
8
9#include "lora-utils.h"
10
11#include <cmath>
12
13namespace ns3
14{
15namespace lorawan
16{
17
18double
19DbToRatio(double dB)
20{
21 double ratio = std::pow(10.0, dB / 10.0);
22 return ratio;
23}
24
25double
26DbmToW(double dBm)
27{
28 double mW = std::pow(10.0, dBm / 10.0);
29 return mW / 1000.0;
30}
31
32double
33WToDbm(double w)
34{
35 return 10.0 * std::log10(w * 1000.0);
36}
37
38double
39RatioToDb(double ratio)
40{
41 return 10.0 * std::log10(ratio);
42}
43
44} // namespace lorawan
45} // namespace ns3
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition lora-utils.cc:26
double WToDbm(double w)
Convert from Watts to dBm.
Definition lora-utils.cc:33
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition lora-utils.cc:39
double DbToRatio(double dB)
Convert from dB to ratio.
Definition lora-utils.cc:19
Every class exported by the ns3 library is enclosed in the ns3 namespace.