A Discrete-Event Network Simulator
API
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 namespace ns3 {
30 
31 NS_LOG_COMPONENT_DEFINE ("WifiTxCurrentModel");
32 
33 // ------------------------------------------------------------------------- //
34 
35 NS_OBJECT_ENSURE_REGISTERED (WifiTxCurrentModel);
36 
37 TypeId
39 {
40  static TypeId tid = TypeId ("ns3::WifiTxCurrentModel")
41  .SetParent<Object> ()
42  .SetGroupName ("Wifi")
43  ;
44  return tid;
45 }
46 
48 {
49 }
50 
52 {
53 }
54 
55 double
57 {
58  double mW = std::pow (10.0, dbm / 10.0);
59  return mW / 1000.0;
60 }
61 
62 // ------------------------------------------------------------------------- //
63 
65 
66 TypeId
68 {
69  static TypeId tid = TypeId ("ns3::LinearWifiTxCurrentModel")
71  .SetGroupName ("Wifi")
72  .AddConstructor<LinearWifiTxCurrentModel> ()
73  .AddAttribute ("Eta", "The efficiency of the power amplifier.",
74  DoubleValue (0.10),
77  MakeDoubleChecker<double> ())
78  .AddAttribute ("Voltage", "The supply voltage (in Volts).",
79  DoubleValue (3.0),
82  MakeDoubleChecker<double> ())
83  .AddAttribute ("IdleCurrent", "The current in the IDLE state (in Watts).",
84  DoubleValue (0.273333),
87  MakeDoubleChecker<double> ())
88  ;
89  return tid;
90 }
91 
93 {
94 }
95 
97 {
98 }
99 
100 void
102 {
103  m_eta = eta;
104 }
105 
106 void
108 {
109  m_voltage = voltage;
110 }
111 
112 void
114 {
115  m_idleCurrent = idleCurrent;
116 }
117 
118 double
120 {
121  return m_eta;
122 }
123 
124 double
126 {
127  return m_voltage;
128 }
129 
130 double
132 {
133  return m_idleCurrent;
134 }
135 
136 double
138 {
139  return DbmToW (txPowerDbm) / (m_voltage * m_eta) + m_idleCurrent;
140 }
141 
142 // ------------------------------------------------------------------------- //
143 
144 } // namespace ns3
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
static TypeId GetTypeId(void)
double CalcTxCurrent(double txPowerDbm) const
a linear model of the Wifi transmit current
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: double.h:42
void SetIdleCurrent(double idleCurrent)
A base class which provides memory management and object aggregation.
Definition: object.h:87
Modelize the transmit current as a function of the transmit power and mode.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
Definition: double.h:41
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:904
static double DbmToW(double dbm)
Convert from dBm to Watts.