OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) Waterford Institute of Technology, 2013, Julien Mineraud, BioFI
NT. |
| 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: Julien Mineraud <julien.mineraud@gmail.com> |
| 19 * |
| 20 * Acknowledgements: |
| 21 * This work has received support from Science Foundation Ireland via the |
| 22 * "A Biologically inspired framework supporting network management for |
| 23 * the Future Internet" starting investigator award (grant no. 09/SIRG/I1643). |
| 24 */ |
| 25 |
| 26 #ifndef PGBR_POWER_MANAGER_H_ |
| 27 #define PGBR_POWER_MANAGER_H_ |
| 28 |
| 29 #include "ns3/node.h" |
| 30 #include "ns3/nstime.h" |
| 31 #include "ns3/traced-callback.h" |
| 32 |
| 33 /*! |
| 34 * \namespace ns3::pgbr |
| 35 * Namespace regrouping all objects and functions to run PGBR. |
| 36 */ |
| 37 namespace ns3 { |
| 38 namespace pgbr { |
| 39 |
| 40 /*! |
| 41 * \class PowerManager |
| 42 * \brief class used by PGBR to enable perform energy management |
| 43 * |
| 44 * This class enables energy aware protocol to put nodes / netDevices to sleep |
| 45 * and to wake them up. |
| 46 */ |
| 47 class PowerManager : public Object { |
| 48 |
| 49 public: |
| 50 |
| 51 /*! |
| 52 * \brief Static function that is required for each ns3::Object. |
| 53 * \fn static TypeId GetTypeId (void) |
| 54 * \sa ns3::Object::GetTypeId () |
| 55 * \return the TypeId corresponding to the power manager |
| 56 */ |
| 57 static TypeId GetTypeId (void); |
| 58 |
| 59 /*! |
| 60 * The constructor |
| 61 */ |
| 62 PowerManager (); |
| 63 |
| 64 /*! |
| 65 * The destructor |
| 66 */ |
| 67 virtual ~PowerManager (); |
| 68 |
| 69 /*! |
| 70 * \brief Set the node that is using the power manager |
| 71 * |
| 72 * \fn void SetNode (Ptr<Node> node, bool awake) |
| 73 * \param[in] node the node |
| 74 * \param[in] awake true if the node is awake at start, false otherwise |
| 75 */ |
| 76 void SetNode (Ptr<Node> node, bool awake); |
| 77 |
| 78 /*! |
| 79 * \brief Turn the node on by setting all its interface up |
| 80 * |
| 81 * \fn void TurnNodeOn (void) |
| 82 */ |
| 83 void TurnNodeOn (void); |
| 84 |
| 85 /*! |
| 86 * \brief Turn the node on by setting a list of its interface up |
| 87 * |
| 88 * \fn void TurnNodeOn (uint32_t devices[], uint32_t nDevices) |
| 89 * \param[in] devices the list of interface numbers |
| 90 * \param[in] nDevices the number of interfaces to turn on |
| 91 */ |
| 92 void TurnNodeOn (uint32_t devices[], uint32_t nDevices); |
| 93 |
| 94 /*! |
| 95 * \brief Turn the node off by setting all its interface down |
| 96 * |
| 97 * \fn void TurnNodeOff (void) |
| 98 */ |
| 99 void TurnNodeOff (void); |
| 100 |
| 101 /*! |
| 102 * \brief Switch-on a particular netdevice |
| 103 * |
| 104 * \fn void TurnDeviceOn (uint32_t dev) |
| 105 * \param[in] dev the id of the interface to be switch-on |
| 106 */ |
| 107 void TurnDeviceOn (uint32_t dev); |
| 108 |
| 109 /*! |
| 110 * \brief Switch-off a particular netdevice |
| 111 * |
| 112 * \fn void TurnDeviceOff (uint32_t dev) |
| 113 * \param[in] dev the id of the interface to be switch-off |
| 114 */ |
| 115 void TurnDeviceOff (uint32_t dev); |
| 116 |
| 117 /*! |
| 118 * \brief This method allows a netdevice to be discarded from the calculation. |
| 119 * |
| 120 * This method was introduced to remove the interface or routers to be include
d calculation of |
| 121 * the energy consumption of the entire network, when some of these nodes woul
d not participate in routing. |
| 122 * \fn void DiscardDevice (bool discard, uint32_t dev) |
| 123 * \param[in] discard If true the interface dev will be discarded when calcula
ting the energy consumption of the router. |
| 124 * \param[in] dev the id of the interface to be discarded or not |
| 125 */ |
| 126 void DiscardDevice (bool discard, uint32_t dev); |
| 127 |
| 128 /*! |
| 129 * \brief This method allows a node to be discarded from the calculation. |
| 130 * |
| 131 * This method was introduced to remove the interface or routers to be include
d calculation of |
| 132 * the energy consumption of the entire network, when some of these nodes woul
d not participate in routing. |
| 133 * \fn void DiscardNode (bool discard) |
| 134 * \param[in] discard If true the node will be discarded when calculating the
energy consumption of the router. |
| 135 */ |
| 136 void DiscardNode (bool discard); |
| 137 |
| 138 /*! |
| 139 * \brief Check if the interface is discarded from the computation |
| 140 * |
| 141 * This method was introduced to remove the interface or routers to be include
d calculation of |
| 142 * the energy consumption of the entire network, when some of these nodes woul
d not participate in routing. |
| 143 * \fn bool GetDiscardedDevice (uint32_t dev) const |
| 144 * \param[in] dev the id of the interface |
| 145 * \return true if the netdevice is not part of the computation, false otherwi
se |
| 146 */ |
| 147 bool GetDiscardedDevice (uint32_t dev) const; |
| 148 |
| 149 /*! |
| 150 * \brief Check if the node is discarded from the computation |
| 151 * |
| 152 * This method was introduced to remove the interface or routers to be include
d calculation of |
| 153 * the energy consumption of the entire network, when some of these nodes woul
d not participate in routing. |
| 154 * \fn bool GetDiscardedNode (void) const |
| 155 * \return true if the node is not part of the computation, false otherwise |
| 156 */ |
| 157 bool GetDiscardedNode (void) const; |
| 158 |
| 159 /*! |
| 160 * \brief Initialise the node once the DoStart () method is called by the Node |
| 161 * |
| 162 * \fn void Initialise (void) |
| 163 */ |
| 164 void Initialise (void); |
| 165 |
| 166 /*! |
| 167 * \brief Return the number of devices that are powered-on |
| 168 * |
| 169 * \fn uint32_t GetNAwakenDevices (void) const |
| 170 * \return the number of devices that are powered-on |
| 171 */ |
| 172 uint32_t GetNAwakenDevices (void) const; |
| 173 |
| 174 /*! |
| 175 * \brief Return the number of devices |
| 176 * |
| 177 * \fn uint32_t GetNDevices (void) const |
| 178 * \return the number of devices |
| 179 */ |
| 180 uint32_t GetNDevices (void) const; |
| 181 |
| 182 /*! |
| 183 * \brief Return the number of devices that are powered-on and not discarded |
| 184 * |
| 185 * \fn uint32_t GetNAwakenAndWatchedDevices (void) const |
| 186 * \return the number of devices that are powered-on and not discarded |
| 187 */ |
| 188 uint32_t GetNAwakenAndWatchedDevices (void) const; |
| 189 |
| 190 /*! |
| 191 * \brief Return the current consumption in watts per hour |
| 192 * |
| 193 * \fn double_t GetCurrentConsumptionPerHour (void) const |
| 194 * \return the current consumption in watts per hour |
| 195 */ |
| 196 double_t GetCurrentConsumptionPerHour (void) const; |
| 197 |
| 198 /*! |
| 199 * \brief Return the current consumption in watts |
| 200 * |
| 201 * \fn double_t GetCurrentConsumption (void) const |
| 202 * \return the current consumption in watts |
| 203 */ |
| 204 double_t GetCurrentConsumption (void) const; |
| 205 |
| 206 /*! |
| 207 * \brief Return the total current consumption in watts per hour |
| 208 * |
| 209 * \fn double_t GetCurrentConsumptionPerHourIncludingDiscarded (void) const |
| 210 * \return the total current consumption in watts per hour |
| 211 */ |
| 212 double_t GetCurrentConsumptionPerHourIncludingDiscarded (void) const; |
| 213 |
| 214 /*! |
| 215 * \brief Return the total current consumption in watts |
| 216 * |
| 217 * \fn double_t GetCurrentConsumption (void) const |
| 218 * \return the total current consumption in watts |
| 219 */ |
| 220 double_t GetCurrentConsumptionIncludingDiscarded (void) const; |
| 221 |
| 222 /*! |
| 223 * \brief Return the total current consumption in watts per hour when all devi
ces are on |
| 224 * |
| 225 * \fn double_t GetCurrentAbsoluteConsumptionPerHour (void) const |
| 226 * \return the total current consumption in watts per hour when all devices ar
e on |
| 227 */ |
| 228 double_t GetCurrentAbsoluteConsumptionPerHour (void) const; |
| 229 |
| 230 /*! |
| 231 * \brief Check if a device is powered on or off |
| 232 * |
| 233 * \fn bool GetDeviceState (uint32_t iif) const |
| 234 * \param[in] iif the interface number |
| 235 * \return true if the device is on, false otherwise |
| 236 */ |
| 237 bool GetDeviceState (uint32_t iif) const; |
| 238 |
| 239 /*! |
| 240 * \brief Check if a device is powered on or off |
| 241 * |
| 242 * \fn bool GetDeviceState (Ipv4Address address) const |
| 243 * \param[in] address the Ipv4Address of the interface |
| 244 * \return true if the device is on, false otherwise |
| 245 */ |
| 246 bool GetDeviceState (Ipv4Address address); |
| 247 |
| 248 /*! |
| 249 * \brief Return the energy consumption of the chassis in Watts |
| 250 * |
| 251 * \fn double_t GetChassisConsumption (void) const |
| 252 * \return the energy consumption of the chassis in Watts |
| 253 */ |
| 254 double_t GetChassisConsumption (void) const; |
| 255 |
| 256 /*! |
| 257 * \brief Return the energy consumption of a line-card in Watts |
| 258 * |
| 259 * Currently, all lines cards on the same routers have a similar energy consum
ption, but this could be changed |
| 260 * \fn double_t GetLineCardConsumption (void) const |
| 261 * \return the energy consumption of a line-card in Watts |
| 262 */ |
| 263 double_t GetLineCardConsumption (void) const; |
| 264 |
| 265 protected: |
| 266 |
| 267 /*! |
| 268 * \brief DoInitialize is called for each object aggregated to a node. |
| 269 * |
| 270 * This one just call Initialise() |
| 271 * \fn virtual void DoInitialize (void) |
| 272 */ |
| 273 virtual void DoInitialize (void); |
| 274 |
| 275 /*! |
| 276 * \brief Update the consumption if the state of the interface changed. |
| 277 * |
| 278 * \fn virtual void UpdateConsumption (uint32_t oldNAwakenDevices, uint32_
t oldNAwakenAndWatched) |
| 279 * \param[in] oldNAwakenDevices The number of all the powered-on devices b
efore the change |
| 280 * \param[in] oldNAwakenAndWatched The number of powered-on device that ar
e not discarded before the change |
| 281 */ |
| 282 virtual void UpdateConsumption (uint32_t oldNAwakenDevices, uint32_t oldNAwake
nAndWatched); |
| 283 |
| 284 Ptr<Node> m_node; /*!< The node associated with the power manager. */ |
| 285 |
| 286 private: |
| 287 bool m_awake; /*!< Let us know if the node is switch on or off */ |
| 288 bool *m_awakeDevices; /*!< same for the interfaces. */ |
| 289 bool *m_discaredDevices; /*!< same devices that are discarded for the consumpt
ion */ |
| 290 uint32_t m_nAwakenDevices; /*!< The number of powered-on interfaces */ |
| 291 |
| 292 double_t m_chassisConsumption; /*!< The chassis power consumption in W-h */ |
| 293 double_t m_lineCardConsumption; /*!< The line-card power consumption in W-h */ |
| 294 |
| 295 //Relative to the powerConsumption |
| 296 double_t m_currentConsumptionPerHour; /*!< The current power consumption in W-
h */ |
| 297 double_t m_currentConsumption; /*!< The power consumed so far par the network.
*/ |
| 298 double_t m_currentConsumptionPerHourIncludingDiscarded; /*!< The current total
power consumption in W-h (including the discarded) */ |
| 299 double_t m_currentConsumptionIncludingDiscarded; /*!< The power consumed so fa
r par the network. (including the discarded) */ |
| 300 Time m_lastTimeChanged; /*!< The last time the state of power manager changed
*/ |
| 301 |
| 302 bool m_enabled; /*!< True if the power manager has been initialised */ |
| 303 |
| 304 TracedCallback<uint32_t> m_awakenDevicesTrace; /*!< Trace to look at the numbe
r of powered-on devices */ |
| 305 |
| 306 }; |
| 307 |
| 308 }} //namespace pgbr, ns3 |
| 309 |
| 310 #endif /* PGBR_POWER_MANAGER_H_ */ |
OLD | NEW |