As seen from the EnergyModel Class definition above, there is only a
single class variable energy_ which represents the
level of energy in the node at any given time. The constructor
EnergyModel(energy) requires the initial-energy to be passed along as a
parameter. The other class methods are
used to decrease the energy level of the node for every packet transmitted
( DecrTxEnergy(txtime, P_tx)) and every packet received (
DecrRcvEnergy (rcvtime, P_rcv)) by
the node. P_tx and P_rcv are the
transmitting and
receiving power (respectively) required by the node's interface or PHY.
At the beginning of simulation, energy_ is set to
initialEnergy_ which is then
decremented for every transmission and reception of packets at the node.
When the energy level at the node goes down to zero, no more packets can
be received or transmitted by the node. If tracing is turned on, line
DEBUG: node node-id dropping pkts due to energy = 0
is printed in the tracefile.