A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
wifi-radio-energy-model.h
Go to the documentation of this file.
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 
39 {
40 public:
43 
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);
103 
104 private:
108  void SwitchToIdle (void);
109 
110 private:
116 
118 };
119 
120 // -------------------------------------------------------------------------- //
121 
147 {
148 public:
153 
154 public:
155  static TypeId GetTypeId (void);
157  virtual ~WifiRadioEnergyModel ();
158 
166  virtual void SetEnergySource (Ptr<EnergySource> source);
167 
173  virtual double GetTotalEnergyConsumption (void) const;
174 
175  // Setter & getters for state power consumption.
176  double GetIdleCurrentA (void) const;
177  void SetIdleCurrentA (double idleCurrentA);
178  double GetCcaBusyCurrentA (void) const;
179  void SetCcaBusyCurrentA (double ccaBusyCurrentA);
180  double GetTxCurrentA (void) const;
181  void SetTxCurrentA (double txCurrentA);
182  double GetRxCurrentA (void) const;
183  void SetRxCurrentA (double rxCurrentA);
184  double GetSwitchingCurrentA (void) const;
185  void SetSwitchingCurrentA (double switchingCurrentA);
186 
190  WifiPhy::State GetCurrentState (void) const;
191 
198 
206  virtual void ChangeState (int newState);
207 
213  virtual void HandleEnergyDepletion (void);
214 
219 
220 
221 private:
222  void DoDispose (void);
223 
229  virtual double DoGetCurrentA (void) const;
230 
237  void SetWifiRadioState (const WifiPhy::State state);
238 
239 private:
241 
242  // Member variables for current draw in different radio modes.
243  double m_txCurrentA;
244  double m_rxCurrentA;
248 
249  // This variable keeps track of the total energy consumed by this model.
251 
252  // State variables.
253  WifiPhy::State m_currentState; // current state the radio is in
254  Time m_lastUpdateTime; // time stamp of previous energy update
255 
256  // Energy depletion callback
258 
259  // WifiPhy listener
261 };
262 
263 } // namespace ns3
264 
265 #endif /* WIFI_RADIO_ENERGY_MODEL_H */