This file is indexed.

/usr/include/ns3.27/ns3/rv-battery-model.h is in libns3-dev 3.27+dfsg-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
 * Copyright (c) 2010 Network Security Lab, University of Washington, Seattle.
 *
 * 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
 *
 * Authors: Sidharth Nabar <snabar@uw.edu>, He Wu <mdzz@u.washington.edu>
 */

#ifndef RV_BATTERY_MODEL_H
#define RV_BATTERY_MODEL_H

#include "ns3/traced-value.h"
#include "ns3/nstime.h"
#include "ns3/event-id.h"
#include "energy-source.h"

namespace ns3 {

/**
 * \ingroup energy
 * \brief Rakhmatov Vrudhula non-linear battery model.
 *
 * This (energy source) model implements an analytical non-linear battery model.
 * It is capable of capturing load capacity and recovery effects of batteries.
 * Batteries are characterized by 2 parameters, alpha and beta, which can both
 * be obtained from the discharge curve of the batteries.
 *
 * The model is developed by Daler Rakhmatov & Sarma Vrudhula in: "Battery
 * Lifetime Prediction for Energy-Aware Computing" and "An Analytical High-Level
 * Battery Model for Use in Energy Management of Portable Electronic Systems".
 *
 * The real-time algorithm is developed by Matthias Handy & Dirk Timmermann in:
 * "Simulation of Mobile Wireless Networks with Accurate Modeling of non-linear
 * battery effects". The real-time algorithm is modified by the authors of this
 * code for improved accuracy and reduced computation (sampling) overhead.
 *
 */
class RvBatteryModel : public EnergySource
{
public:
  static TypeId GetTypeId (void);
  RvBatteryModel ();
  virtual ~RvBatteryModel ();

  /**
   * \return Initial energy stored (theoretical capacity) in the battery, in Joules.
   *
   * Implements GetInitialEnergy.
   */
  virtual double GetInitialEnergy (void) const;

  /**
   * \returns Supply voltage at the energy source.
   *
   * Implements GetSupplyVoltage.
   */
  virtual double GetSupplyVoltage (void) const;

  /**
   * \return Remaining energy in energy source, in Joules
   *
   * Implements GetRemainingEnergy.
   */
  virtual double GetRemainingEnergy (void);

  /**
   * \returns Energy fraction.
   *
   * Implements GetEnergyFraction. For the RV battery model, energy fraction is
   * equivalent to battery level.
   */
  virtual double GetEnergyFraction (void);

  /**
   * Implements UpdateEnergySource. This function samples the total load (total
   * current) from all devices to discharge the battery.
   */
  virtual void UpdateEnergySource (void);

  /**
   * \param interval Energy update interval.
   *
   * This function sets the interval between each energy update.
   */
  void SetSamplingInterval (Time interval);

  /**
   * \returns The interval between each energy update.
   */
  Time GetSamplingInterval (void) const;

  /**
   * \brief Sets open circuit voltage of battery.
   *
   * \param voltage Open circuit voltage.
   */
  void SetOpenCircuitVoltage (double voltage);

  /**
   * \return Open circuit voltage of battery.
   */
  double GetOpenCircuitVoltage (void) const;

  /**
   * \brief Sets cutoff voltage of battery.
   *
   * \param voltage Cutoff voltage.
   */
  void SetCutoffVoltage (double voltage);

  /**
   * \returns Cutoff voltage of battery.
   */
  double GetCutoffVoltage (void) const;

  /**
   * \brief Sets the alpha value for the battery model.
   *
   * \param alpha Alpha.
   */
  void SetAlpha (double alpha);

  /**
   * \returns The alpha value used by the battery model.
   */
  double GetAlpha (void) const;

  /**
   * \brief Sets the beta value for the battery model.
   *
   * \param beta Beta.
   */
  void SetBeta (double beta);

  /**
   * \returns The beta value used by the battery model.
   */
  double GetBeta (void) const;

  /**
   * \returns Battery level [0, 1].
   */
  double GetBatteryLevel (void);

  /**
   * \returns Lifetime of the battery.
   */
  Time GetLifetime (void) const;

  /**
   * \brief Sets the number of terms of the infinite sum for estimating battery
   * level.
   *
   * \param num Number of terms.
   */
  void SetNumOfTerms (int num);

  /**
   * \returns The number of terms of the infinite sum for estimating battery
   * level.
   */
  int GetNumOfTerms (void) const;

private:
  /// Defined in ns3::Object
  virtual void DoInitialize (void);

  /// Defined in ns3::Object
  virtual void DoDispose (void);

  /**
   * Handles the remaining energy going to zero event. This function notifies
   * all the energy models aggregated to the node about the energy being
   * depleted. Each energy model is then responsible for its own handler.
   */
  void HandleEnergyDrainedEvent (void);

  /**
   * \brief Discharges the battery.
   *
   * \param load Load value (total current form devices, in mA).
   * \param t Time stamp of the load value.
   * \returns Calculated alpha value.
   *
   * Discharge function calculates a value which is then compared to the alpha
   * value to determine if the battery is dead. It will also update the battery
   * level.
   *
   * Note that the load value passed to Discharge has to be in mA.
   */
  double Discharge (double load, Time t);

  /**
   * \brief RV model A function.
   *
   * \param t Current time.
   * \param sk Time stamp in array position k
   * \param sk_1 Time stamp in array position k-1
   * \param beta Beta value used by the battery model.
   * \returns Result of A function.
   *
   * This function computes alpha value using the recorded load profile.
   */
  double RvModelAFunction (Time t, Time sk, Time sk_1, double beta);

private:
  double m_openCircuitVoltage;
  double m_cutoffVoltage;
  double m_alpha; // alpha value of RV model, in Coulomb
  double m_beta;  // beta value of RV model, in second^-1

  double m_previousLoad;  // load value (total current) of previous sampling
  std::vector<double> m_load;     // load profile
  std::vector<Time> m_timeStamps; // time stamps of load profile
  Time m_lastSampleTime;

  int m_numOfTerms; // # of terms for infinite sum in battery level estimation

  /**
   * Battery level is defined as: output of Discharge function / alpha value
   *
   * The output of Discharge function is an estimated charge consumption of the
   * battery.
   *
   * The alpha value is the amount of charges stored in the battery, or battery
   * capacity (in Coulomb).
   *
   * When the battery is fully charged (no charge is consumed from the battery)
   * the battery level is 1. When the battery is fully discharged, the battery
   * level is 0.
   *
   * NOTE Note that the definition in Timmermann's paper is the inverse of this
   * definition. In the paper, battery level = 1 when the battery is drained.
   */
  TracedValue<double> m_batteryLevel;

  double m_lowBatteryTh;           // low battery threshold, as a fraction of the initial energy

  /**
   * (1 / sampling interval) = sampling frequency
   */
  Time m_samplingInterval;
  EventId m_currentSampleEvent;

  TracedValue<Time> m_lifetime;   // time of death of the battery
};

} // namespace ns3

#endif  /* RV_BATTERY_MODEL_H */