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
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Groups
Pages
wifi-radio-energy-model.h
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
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
* Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
19
*/
20
21
#ifndef WIFI_RADIO_ENERGY_MODEL_H
22
#define WIFI_RADIO_ENERGY_MODEL_H
23
24
#include "ns3/device-energy-model.h"
25
#include "ns3/nstime.h"
26
#include "ns3/event-id.h"
27
#include "ns3/traced-value.h"
28
#include "ns3/wifi-phy.h"
29
30
namespace
ns3 {
31
38
class
WifiRadioEnergyModelPhyListener
:
public
WifiPhyListener
39
{
40
public
:
41
WifiRadioEnergyModelPhyListener
();
42
virtual
~
WifiRadioEnergyModelPhyListener
();
43
49
void
SetChangeStateCallback
(
DeviceEnergyModel::ChangeStateCallback
callback);
50
58
virtual
void
NotifyRxStart
(
Time
duration);
59
68
virtual
void
NotifyRxEndOk
(
void
);
69
78
virtual
void
NotifyRxEndError
(
void
);
79
88
virtual
void
NotifyTxStart
(
Time
duration);
89
95
virtual
void
NotifyMaybeCcaBusyStart
(
Time
duration);
96
102
virtual
void
NotifySwitchingStart
(
Time
duration, uint16_t toChannel);
103
virtual
void
NotifySensingStart
(
Time
duration);
104
105
private
:
109
void
SwitchToIdle
(
void
);
110
111
private
:
116
DeviceEnergyModel::ChangeStateCallback
m_changeStateCallback
;
117
118
EventId
m_switchToIdleEvent;
119
};
120
121
// -------------------------------------------------------------------------- //
122
147
class
WifiRadioEnergyModel
:
public
DeviceEnergyModel
148
{
149
public
:
153
typedef
Callback<void>
WifiRadioEnergyDepletionCallback
;
154
155
public
:
156
static
TypeId
GetTypeId (
void
);
157
WifiRadioEnergyModel
();
158
virtual
~
WifiRadioEnergyModel
();
159
167
virtual
void
SetEnergySource
(
Ptr<EnergySource>
source);
168
174
virtual
double
GetTotalEnergyConsumption
(
void
)
const
;
175
176
// Setter & getters for state power consumption.
177
double
GetIdleCurrentA (
void
)
const
;
178
void
SetIdleCurrentA (
double
idleCurrentA);
179
double
GetCcaBusyCurrentA (
void
)
const
;
180
void
SetCcaBusyCurrentA (
double
ccaBusyCurrentA);
181
double
GetTxCurrentA (
void
)
const
;
182
void
SetTxCurrentA (
double
txCurrentA);
183
double
GetRxCurrentA (
void
)
const
;
184
void
SetRxCurrentA (
double
rxCurrentA);
185
double
GetSwitchingCurrentA (
void
)
const
;
186
void
SetSwitchingCurrentA (
double
switchingCurrentA);
187
191
WifiPhy::State
GetCurrentState
(
void
)
const
;
192
198
void
SetEnergyDepletionCallback
(
WifiRadioEnergyDepletionCallback
callback);
199
207
virtual
void
ChangeState
(
int
newState);
208
214
virtual
void
HandleEnergyDepletion
(
void
);
215
219
WifiRadioEnergyModelPhyListener
*
GetPhyListener
(
void
);
220
221
222
private
:
223
void
DoDispose
(
void
);
224
230
virtual
double
DoGetCurrentA
(
void
)
const
;
231
238
void
SetWifiRadioState
(
const
WifiPhy::State
state);
239
240
private
:
241
Ptr<EnergySource>
m_source;
242
243
// Member variables for current draw in different radio modes.
244
double
m_txCurrentA;
245
double
m_rxCurrentA;
246
double
m_idleCurrentA;
247
double
m_ccaBusyCurrentA;
248
double
m_switchingCurrentA;
249
250
// This variable keeps track of the total energy consumed by this model.
251
TracedValue<double>
m_totalEnergyConsumption;
252
253
// State variables.
254
WifiPhy::State
m_currentState;
// current state the radio is in
255
Time
m_lastUpdateTime;
// time stamp of previous energy update
256
257
// Energy depletion callback
258
WifiRadioEnergyDepletionCallback
m_energyDepletionCallback;
259
260
// WifiPhy listener
261
WifiRadioEnergyModelPhyListener
*m_listener;
262
};
263
264
}
// namespace ns3
265
266
#endif
/* WIFI_RADIO_ENERGY_MODEL_H */
ns3::WifiRadioEnergyModelPhyListener::NotifySwitchingStart
virtual void NotifySwitchingStart(Time duration, uint16_t toChannel)
Definition:
wifi-radio-energy-model.cc:416
ns3::WifiRadioEnergyModel::SetWifiRadioState
void SetWifiRadioState(const WifiPhy::State state)
Definition:
wifi-radio-energy-model.cc:302
ns3::Time
keep track of time unit.
Definition:
nstime.h:149
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::Callback< void, int >
ns3::DeviceEnergyModel
Base class for device energy models.
Definition:
device-energy-model.h:43
ns3::WifiPhy::State
State
Definition:
wifi-phy.h:127
ns3::WifiRadioEnergyModelPhyListener::NotifySensingStart
virtual void NotifySensingStart(Time duration)
Definition:
wifi-radio-energy-model.cc:430
ns3::WifiRadioEnergyModel::ChangeState
virtual void ChangeState(int newState)
Changes state of the WifiRadioEnergyMode.
Definition:
wifi-radio-energy-model.cc:201
ns3::TracedValue< double >
ns3::WifiRadioEnergyModel::GetTotalEnergyConsumption
virtual double GetTotalEnergyConsumption(void) const
Definition:
wifi-radio-energy-model.cc:104
ns3::WifiRadioEnergyModelPhyListener::NotifyTxStart
virtual void NotifyTxStart(Time duration)
Switches the WifiRadioEnergyModel to TX state and switches back to IDLE after TX duration.
Definition:
wifi-radio-energy-model.cc:388
ns3::WifiRadioEnergyModel::GetPhyListener
WifiRadioEnergyModelPhyListener * GetPhyListener(void)
Definition:
wifi-radio-energy-model.cc:262
ns3::WifiRadioEnergyModelPhyListener::SwitchToIdle
void SwitchToIdle(void)
Definition:
wifi-radio-energy-model.cc:448
ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndOk
virtual void NotifyRxEndOk(void)
Switches the WifiRadioEnergyModel back to IDLE state.
Definition:
wifi-radio-energy-model.cc:366
ns3::WifiRadioEnergyModel::WifiRadioEnergyDepletionCallback
Callback< void > WifiRadioEnergyDepletionCallback
Definition:
wifi-radio-energy-model.h:153
ns3::WifiRadioEnergyModelPhyListener::SetChangeStateCallback
void SetChangeStateCallback(DeviceEnergyModel::ChangeStateCallback callback)
Sets the change state callback. Used by helper class.
Definition:
wifi-radio-energy-model.cc:346
ns3::WifiPhyListener
receive notifications about phy events.
Definition:
wifi-phy.h:44
ns3::WifiRadioEnergyModelPhyListener::NotifyMaybeCcaBusyStart
virtual void NotifyMaybeCcaBusyStart(Time duration)
Definition:
wifi-radio-energy-model.cc:402
ns3::WifiRadioEnergyModelPhyListener::NotifyRxEndError
virtual void NotifyRxEndError(void)
Switches the WifiRadioEnergyModel back to IDLE state.
Definition:
wifi-radio-energy-model.cc:377
ns3::WifiRadioEnergyModel::GetCurrentState
WifiPhy::State GetCurrentState(void) const
Definition:
wifi-radio-energy-model.cc:182
ns3::WifiRadioEnergyModelPhyListener::m_changeStateCallback
DeviceEnergyModel::ChangeStateCallback m_changeStateCallback
Definition:
wifi-radio-energy-model.h:116
ns3::WifiRadioEnergyModel::SetEnergySource
virtual void SetEnergySource(Ptr< EnergySource > source)
Sets pointer to EnergySouce installed on node.
Definition:
wifi-radio-energy-model.cc:96
ns3::WifiRadioEnergyModelPhyListener
Definition:
wifi-radio-energy-model.h:38
ns3::WifiRadioEnergyModel
A WiFi radio energy model.
Definition:
wifi-radio-energy-model.h:147
ns3::WifiRadioEnergyModelPhyListener::NotifyRxStart
virtual void NotifyRxStart(Time duration)
Switches the WifiRadioEnergyModel to RX state.
Definition:
wifi-radio-energy-model.cc:354
ns3::WifiRadioEnergyModel::SetEnergyDepletionCallback
void SetEnergyDepletionCallback(WifiRadioEnergyDepletionCallback callback)
Definition:
wifi-radio-energy-model.cc:189
ns3::EventId
an identifier for simulation events.
Definition:
event-id.h:46
ns3::WifiRadioEnergyModel::DoDispose
void DoDispose(void)
Definition:
wifi-radio-energy-model.cc:273
ns3::WifiRadioEnergyModel::DoGetCurrentA
virtual double DoGetCurrentA(void) const
Definition:
wifi-radio-energy-model.cc:281
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:44
ns3::WifiRadioEnergyModel::HandleEnergyDepletion
virtual void HandleEnergyDepletion(void)
Handles energy depletion.
Definition:
wifi-radio-energy-model.cc:250
src
energy
model
wifi-radio-energy-model.h
Generated on Sun Mar 16 2014 11:25:03 for ns-3 by
1.8.6