A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
wifi-utils.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2016
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: Sébastien Deronne <sebastien.deronne@gmail.com>
19
*/
20
21
#include "
wifi-utils.h
"
22
#include <cmath>
23
24
namespace
ns3
{
25
26
double
27
Log2
(
double
val)
28
{
29
return
std::log (val) / std::log (2.0);
30
}
31
32
33
double
34
DbToRatio
(
double
dB)
35
{
36
double
ratio = std::pow (10.0, dB / 10.0);
37
return
ratio;
38
}
39
40
double
41
DbmToW
(
double
dBm)
42
{
43
double
mW = std::pow (10.0, dBm / 10.0);
44
return
mW / 1000.0;
45
}
46
47
double
48
WToDbm
(
double
w
)
49
{
50
return
10.0 * std::log10 (w * 1000.0);
51
}
52
53
double
54
RatioToDb
(
double
ratio)
55
{
56
return
10.0 * std::log10 (ratio);
57
}
58
59
uint16_t
60
ConvertGuardIntervalToNanoSeconds
(
WifiMode
mode,
bool
htShortGuardInterval,
Time
heGuardInterval)
61
{
62
uint16_t gi;
63
if
(mode.
GetModulationClass
() ==
WIFI_MOD_CLASS_HE
)
64
{
65
gi = heGuardInterval.
GetNanoSeconds
();
66
}
67
else
if
(mode.
GetModulationClass
() ==
WIFI_MOD_CLASS_HT
|| mode.
GetModulationClass
() ==
WIFI_MOD_CLASS_VHT
)
68
{
69
gi = htShortGuardInterval ? 400 : 800;
70
}
71
else
72
{
73
gi = 800;
74
}
75
return
gi;
76
}
77
78
}
//namespace ns3
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
ns3::ConvertGuardIntervalToNanoSeconds
uint16_t ConvertGuardIntervalToNanoSeconds(WifiMode mode, bool htShortGuardInterval, Time heGuardInterval)
Convert the guard interval to nanoseconds based on the wifimode.
Definition:
wifi-utils.cc:60
ns3::DbmToW
double DbmToW(double dBm)
Convert from dBm to Watts.
Definition:
wifi-utils.cc:41
ns3::WIFI_MOD_CLASS_VHT
VHT PHY (Clause 22)
Definition:
wifi-mode.h:60
ns3::WifiMode
represent a single transmission modeA WifiMode is implemented by a single integer which is used to lo...
Definition:
wifi-mode.h:97
ns3::WIFI_MOD_CLASS_HT
HT PHY (Clause 20)
Definition:
wifi-mode.h:58
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::WToDbm
double WToDbm(double w)
Convert from Watts to dBm.
Definition:
wifi-utils.cc:48
ns3::DbToRatio
double DbToRatio(double dB)
Convert from dB to ratio.
Definition:
wifi-utils.cc:34
ns3::RatioToDb
double RatioToDb(double ratio)
Convert from ratio to dB.
Definition:
wifi-utils.cc:54
ns3::Time::GetNanoSeconds
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
Definition:
nstime.h:353
visualizer.higcontainer.w
tuple w
Definition:
higcontainer.py:169
ns3::WifiMode::GetModulationClass
WifiModulationClass GetModulationClass() const
Definition:
wifi-mode.cc:487
ns3::Log2
SpectrumValue Log2(const SpectrumValue &arg)
Definition:
spectrum-value.cc:591
ns3::WIFI_MOD_CLASS_HE
HE PHY (Clause 26)
Definition:
wifi-mode.h:62
wifi-utils.h
src
wifi
model
wifi-utils.cc
Generated on Wed Oct 11 2017 16:39:36 for ns-3 by
1.8.9.1