A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wifi-tx-current-model.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2014 Universita' degli Studi di Napoli "Federico II"
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: Stefano Avallone <stefano.avallone@unina.it>
19  */
20 
21 #include "wifi-tx-current-model.h"
22 #include "ns3/log.h"
23 #include "ns3/boolean.h"
24 #include "ns3/double.h"
25 #include "ns3/string.h"
26 #include "ns3/pointer.h"
27 #include <cmath>
28 
29 NS_LOG_COMPONENT_DEFINE ("WifiTxCurrentModel");
30 
31 namespace ns3 {
32 
33 // ------------------------------------------------------------------------- //
34 
35 NS_OBJECT_ENSURE_REGISTERED (WifiTxCurrentModel);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::WifiTxCurrentModel")
41  .SetParent<Object> ()
42  ;
43  return tid;
44 }
45 
47 {
48 }
49 
51 {
52 }
53 
54 double
56 {
57  double mW = std::pow (10.0, dbm / 10.0);
58  return mW / 1000.0;
59 }
60 
61 // ------------------------------------------------------------------------- //
62 
64 
65 TypeId
67 {
68  static TypeId tid = TypeId ("ns3::LinearWifiTxCurrentModel")
70  .AddConstructor<LinearWifiTxCurrentModel> ()
71  .AddAttribute ("Eta", "The efficiency of the power amplifier.",
72  DoubleValue (0.10),
73  MakeDoubleAccessor (&LinearWifiTxCurrentModel::SetEta,
75  MakeDoubleChecker<double> ())
76  .AddAttribute ("Voltage", "The supply voltage (in Volts).",
77  DoubleValue (3.0),
78  MakeDoubleAccessor (&LinearWifiTxCurrentModel::SetVoltage,
80  MakeDoubleChecker<double> ())
81  .AddAttribute ("IdleCurrent", "The current in the IDLE state (in Watts).",
82  DoubleValue (0.273333),
83  MakeDoubleAccessor (&LinearWifiTxCurrentModel::SetIdleCurrent,
85  MakeDoubleChecker<double> ())
86  ;
87  return tid;
88 }
89 
91 {
92 }
93 
95 {
96 }
97 
98 void
100 {
101  m_eta = eta;
102 }
103 
104 void
106 {
107  m_voltage = voltage;
108 }
109 
110 void
112 {
113  m_idleCurrent = idleCurrent;
114 }
115 
116 double
118 {
119  return m_eta;
120 }
121 
122 double
124 {
125  return m_voltage;
126 }
127 
128 double
130 {
131  return m_idleCurrent;
132 }
133 
134 double
136 {
137  return DbmToW (txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
138 }
139 
140 // ------------------------------------------------------------------------- //
141 
142 } // namespace ns3
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
Definition: object-base.h:38
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
static TypeId GetTypeId(void)
double CalcTxCurrent(double txPowerDbm) const
a linear model of the Wifi transmit current
void SetIdleCurrent(double idleCurrent)
a base class which provides memory management and object aggregation
Definition: object.h:64
Modelize the transmit current as a function of the transmit power and mode.
Hold a floating point type.
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:610
static double DbmToW(double dbm)
Convert from dBm to Watts.