Step 8. Modeling energy consumption¶
Wireless ad-hoc networks often operate in an energy-constrained environment, and thus it is useful to be able to model the energy consumption of the devices. Consider, for example, wireless motes that operate on battery. The mote’s activity has to be planned so that the battery lasts until it can be recharged or replaced.
In this step, we augment the nodes with components so that we can model (and measure) their energy consumption. For simplicity, we ignore energy constraints and just install infinite energy sources into the nodes.
Energy consumption model¶
In a real system, there are energy consumers like the radio, and energy
sources like a battery or the mains. In the INET model of the radio,
energy consumption is represented by a separate component. This energy
consumption model maps the activity of the core parts of the radio (the
transmitter and the receiver) to power (energy) consumption. The core
parts of the radio themselves do not contain anything about power
consumption; they only expose their state variables. This allows one to
switch to arbitrarily complex (or simple) power consumption models,
without affecting the operation of the radio. The energy consumption
model can be specified in the
energyConsumerType parameter of the
Here, we set the energy consumption model in the node radios to StateBasedEpEnergyConsumer. StateBasedEpEnergyConsumer models radio power consumption based on states like radio mode, transmitter and receiver state. Each state has a constant power consumption that can be set by a parameter. Energy use depends on how much time the radio spends in a particular state.
To go into a little bit more detail: the radio maintains two state variables, receive state and transmit state. At any given time, the radio mode (one of off, sleep, switching, receiver, transmitter, and transceiver) decides which of the two state variables are valid. The receive state may be idle, busy, or receiving, the former two referring to the channel state. When it is receiving, a sub-state stores which part of the signal it is receiving: the preamble, the (physical layer) header, the data, or any (we don’t know/care). Similarly, the transmit state may be idle or transmitting, and a sub-state stores which part of the signal is being transmitted (if any).
StateBasedEpEnergyConsumer expects the consumption in various states
to be specified in watts in parameters like
transmitterTransmittingPreamblePowerConsumption, and so on.
Measuring energy consumption¶
Hosts contain an energy storage component that basically models an
energy source like a battery or the mains. INET contains several energy
storage models, and the desired one can be selected in the
energyStorageType parameter of the host. Also, the radio’s energy
consumption model is preconfigured to draw energy from the host’s energy
storage. (Hosts with more than one energy storage component are also
In this model, we use IdealEpEnergyStorage in hosts. IdealEpEnergyStorage provides an infinite amount of energy, can’t be fully charged or depleted. We use this because we want to concentrate on the power consumption, not the storage.
The energy storage module contains an
energyBalance watched variable
that can be used to track energy consumption. Also, energy consumption
over time can be obtained by plotting the
The visualization of radio signals as expanding bubbles is no longer needed, so we turn it off.
[Config Wireless08] description = Modeling energy consumption extends = Wireless07 *.host*.wlan.radio.energyConsumer.typename = "StateBasedEpEnergyConsumer" *.host*.wlan.radio.energyConsumer.offPowerConsumption = 0mW *.host*.wlan.radio.energyConsumer.sleepPowerConsumption = 1mW *.host*.wlan.radio.energyConsumer.switchingPowerConsumption = 1mW *.host*.wlan.radio.energyConsumer.receiverIdlePowerConsumption = 2mW *.host*.wlan.radio.energyConsumer.receiverBusyPowerConsumption = 5mW *.host*.wlan.radio.energyConsumer.receiverReceivingPowerConsumption = 10mW *.host*.wlan.radio.energyConsumer.transmitterIdlePowerConsumption = 2mW *.host*.wlan.radio.energyConsumer.transmitterTransmittingPowerConsumption = 100mW *.host*.energyStorage.typename = "IdealEpEnergyStorage" *.host*.wlan.radio.displayInterferenceRange = false *.hostR1.wlan.radio.displayCommunicationRange = false *.visualizer.mediumVisualizer.displaySignals = false
The image below shows host A’s
energyBalance variable at the end of
the simulation. The negative energy value signifies the consumption of
residualCapacity statistic of hosts A, R1 and B are plotted on the
following diagram. The diagram shows that host A has consumed the most
power because it transmitted more than the other nodes.
Number of packets received by host B: 1393
Use this page in the GitHub issue tracker for commenting on this tutorial.