Backed out changeset b025c78789fb
This commit is contained in:
52
src/wifi/model/wifi-utils.cc
Normal file
52
src/wifi/model/wifi-utils.cc
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2016
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* Author: Sébastien Deronne <sebastien.deronne@gmail.com>
|
||||
*/
|
||||
|
||||
#include "wifi-utils.h"
|
||||
#include <cmath>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
double
|
||||
DbToRatio (double dB)
|
||||
{
|
||||
double ratio = std::pow (10.0, dB / 10.0);
|
||||
return ratio;
|
||||
}
|
||||
|
||||
double
|
||||
DbmToW (double dBm)
|
||||
{
|
||||
double mW = std::pow (10.0, dBm / 10.0);
|
||||
return mW / 1000.0;
|
||||
}
|
||||
|
||||
double
|
||||
WToDbm (double w)
|
||||
{
|
||||
return 10.0 * std::log10 (w * 1000.0);
|
||||
}
|
||||
|
||||
double
|
||||
RatioToDb (double ratio)
|
||||
{
|
||||
return 10.0 * std::log10 (ratio);
|
||||
}
|
||||
|
||||
} //namespace ns3
|
||||
@@ -21,57 +21,40 @@
|
||||
#ifndef WIFI_UTILS_H
|
||||
#define WIFI_UTILS_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace ns3 {
|
||||
|
||||
/**
|
||||
* Convert from dBm to Watts.
|
||||
*
|
||||
* \param dbm the power in dBm
|
||||
*
|
||||
* \return the equivalent Watts for the given dBm
|
||||
*/
|
||||
constexpr double DbmToW (double dbm)
|
||||
{
|
||||
return std::pow (10.0, dbm / 10.0) / 1000.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from dB to ratio.
|
||||
*
|
||||
* \param db
|
||||
*
|
||||
* \return ratio
|
||||
*/
|
||||
constexpr double DbToRatio (double db)
|
||||
{
|
||||
return std::pow (10.0, db / 10.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from Watts to dBm.
|
||||
*
|
||||
* \param w the power in Watts
|
||||
*
|
||||
* \return the equivalent dBm for the given Watts
|
||||
*/
|
||||
constexpr double WToDbm (double w)
|
||||
{
|
||||
return 10.0 * std::log10 (w * 1000.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert from ratio to dB.
|
||||
*
|
||||
* \param ratio
|
||||
*
|
||||
* \return dB
|
||||
*/
|
||||
constexpr double RatioToDb (double ratio)
|
||||
{
|
||||
return 10.0 * std::log10 (ratio);
|
||||
}
|
||||
/**
|
||||
* Convert from dBm to Watts.
|
||||
*
|
||||
* \param dbm the power in dBm
|
||||
*
|
||||
* \return the equivalent Watts for the given dBm
|
||||
*/
|
||||
double DbmToW (double dbm);
|
||||
/**
|
||||
* Convert from dB to ratio.
|
||||
*
|
||||
* \param db
|
||||
*
|
||||
* \return ratio
|
||||
*/
|
||||
double DbToRatio (double db);
|
||||
/**
|
||||
* Convert from Watts to dBm.
|
||||
*
|
||||
* \param w the power in Watts
|
||||
*
|
||||
* \return the equivalent dBm for the given Watts
|
||||
*/
|
||||
double WToDbm (double w);
|
||||
/**
|
||||
* Convert from ratio to dB.
|
||||
*
|
||||
* \param ratio
|
||||
*
|
||||
* \return dB
|
||||
*/
|
||||
double RatioToDb (double ratio);
|
||||
|
||||
} // namespace ns3
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
def build(bld):
|
||||
obj = bld.create_ns3_module('wifi', ['network', 'propagation', 'energy', 'spectrum', 'antenna', 'mobility'])
|
||||
obj.source = [
|
||||
'model/wifi-utils.cc',
|
||||
'model/wifi-information-element.cc',
|
||||
'model/wifi-information-element-vector.cc',
|
||||
'model/wifi-channel.cc',
|
||||
|
||||
Reference in New Issue
Block a user