**2. Description of the Energy Model**

We propose a simple energy model under the basic tasks or activities that nodes perform in the network [38]. Figure 2 conceptually describes this scheme. This model considers all the energy components that contribute to the overall energy consumption under active mode. First of all, a node remains at start time (*tON*) to turn on. Then, it takes a switching time (*tSwitching*) to change status before sending a packet to the medium. Here, the node first runs the CSMA algorithm using a CSMA time (*tCSMA*). Next, the node transmits an information packet expending a transmission time (*tTX*). Now, the node takes a switching time (*tSwitching*) to change activities, it remains inactive (*tInactive*) and changes task again. In addition, it takes a switching time (*tSwitching*) to start receiving information and reporting a reception time (*tRX*). The node performs these activities as many times as it sends and receives information (messages) during the sampling period. Finally, the node turns off expending a shutdown time (*tOFF*). All of this while the microcontroller remains in active mode. This process measures the energy required for each main node activity in the network. Depending on the task and the time a node takes to execute it, this corresponds to a given voltage and current, so that the total energy used by each node can be obtained for each of the activities run for the network based on the previous model [37].

**Figure 2.** Conceptual energy scheme.

To compare the performance of the energy model, we used two types of sensors: CC2530 and CC2650 from Texas Instruments. We have coded the proposed model in a wireless sensor simulator programmed in C ++ based on the previously tested events [10]. The wireless module with antenna CC2530 nodes have 256 KB Flash and 8 KB of RAM sufficient for the implementation of widely known protocols in WSN. They have an IEEE 802.15.4 RF transmitter/receiver in 2.4 GHz high sensitivity (102 dBm). These sensors have four modes of operation in terms of energy savings and 21 general purpose pins, which cover the needs for connection of extra sensors. The CC2650 nodes are ultra-low power 2.4 GHz devices. An active and very low MCU and RF current and a low power mode current consumption offer excellent battery life. These devices contain a 32-bit ARM Cortex-M3 processor that operates at 48 MHz as the main processor and a set of extensive peripheral functions including an ultra-low power single sensor controller ideal for interconnecting external sensors.

Table 2 presents some results to verify the accuracy of the proposed energy model in predicting the total energy used by each node. We have taken as a basis the consumption for each type of energy proposed in the model. The described scenario is a configuration of 25 randomly and evenly distributed nodes and one of them is the coordinating or concentrating node. We left the nodes running from Monday to Sunday (seven days) on a university campus in an area of 500 × 500 m<sup>2</sup> under the conditions described in Table 3. We observed that the model described in Table 1 can be a reliable parameter to measure the general consumption of a wireless network of small to medium sensor size if the nodes are in active mode and the types of energies described give a faithful ideal of the main functions of a node in a network, taking approximately 4 to 5% margin of measurement error.

In this paper, an analytical model is proposed and exemplified by the operation parameters of the Texas Instruments CC2530 chip [35], which has a radio interface as per the IEEE 802.15.4 standard. This model shows the energy expended for each of the activities performed from the moment a node is added to a network and becomes part of it, listens to the channel, receives and sends messages, executes the link layer algorithms data, and changes states, ending with the energy consumed when it turns off and disconnects from the network.


**Table 2.** Energy model tested on two scenarios.

The energy used by the microcontroller depends on the node's operation mode. For example, techniques for turning nodes off reduce energy consumption by setting the microcontroller in idle mode for certain time intervals [39]. However, for this analysis, it is assumed that the mentioned SoC at each node operates in continuous active mode at 32 MHz (the microcontroller's clock frequency) to better study how energy consumption behaves under a specific routing protocol without the influence of techniques used for turning nodes off. Thus, the total energy used by the microcontroller will be given by (1):

$$E\_{\rm MC} = T\_{\rm MC} \times I\_{\rm MC} \times V\_{\rm MC\prime} \tag{1}$$

where *TMC* is the time (seconds) taken by the microcontroller unit to consume *VMC* (Volts) and *IMC* (Amperes).

The starting energy is estimated based on the voltage, current, and time nodes required to turn on and be ready for the network, as described in (2):

$$E\_{\rm ON} = T\_{\rm ON} \times I\_{\rm ON} \times V\_{\rm ON} \tag{2}$$

where *TON* is the time (seconds) that it takes to turn a node on and is given by *VON* (Volts) and *ION* (Amperes).

The model also describes the energy consumed when nodes turn off when the network time has ended (the sampling period). This energy is given by (3) and it is called shutdown energy.

$$E\_{OFF} = T\_{OFF} \times I\_{OFF} \times V\_{OFF} \tag{3}$$

where *TOFF* is the time (seconds) that it takes to turn a node off and is given by *VOFF* (Volts) and *IOFF* (Amperes).

Switching energy is expended when the node changes from receiving to transmission mode or vice versa. It is given by (4):

$$E\_{\text{Switching}} = T\_{\text{Switching}} \times I\_{\text{Switching}} \times V\_{\text{Switching}} \tag{4}$$

where *TSwitching* is the time (seconds) that it takes a node to change from the reception mode to the transmission mode or vice versa and it is given by *VSwitching* (Volts) and *ISwitching* (Amperes).

The CSMA/CA algorithm states that each time a node intends to transmit, it first checks if the channel is free from other transmissions. If it is, then the node proceeds to transmit. Otherwise, it calculates a random waiting time before attempting to listen to the channel again. The energy consumed by the CSMA/CA algorithm is given by (5):

$$E\_{\mathbb{C}SMA} = T\_{\mathbb{C}SMA} \times I\_{\mathbb{C}SMA} \times V\_{\mathbb{C}SMA} \tag{5}$$

where *TCSMA* is the time (seconds) in which a node computes the CSMA/CA algorithm and is given by *VCSMA* (Volts) and *ICSMA* (Amperes).

Transmission energy depends directly on the distance and interference. In this case, the nodes transmit their packets or forward packets from other nodes. Transmission energy is described as (6):

$$E\_{TX} = P\_{Length} \times T\_{TX} \times I\_{TX} \times V\_{TX\prime} \tag{6}$$

where *PLength* is the length of the packet (bytes), *TTX* is the time (seconds) that it takes a node to send a byte and is given by *VTX* (Volts) and *ITX* (Amperes).

As with the transmission mode, a node expends receiving energy when it receives packets. This energy is determined using (7):

$$E\_{\rm RX} = P\_{\rm Length} \times T\_{\rm RX} \times I\_{\rm RX} \times V\_{\rm RX}.\tag{7}$$

where *PLength* is the length of the packet (bytes), *TRX* is the time (seconds) that it takes a node to receive a byte and is given by *VRX* (Volts) and *IRX* (Amperes).

The values of (1)–(7) are presented in Table 1.

Therefore, the total energy can be calculated with (8):

$$E\_{Total} = -E\_{MC} + E\_{ON} + E\_{OFF} + E\_{CSAM} + E\_{Switching} + E\_{TX} + E\_{RX} \tag{8}$$

The simple energy model shown by the aforementioned equations estimates the energy expended by the main tasks of a node within a WSN for any system, where those functions related to wireless communications are the most important from an energy standpoint.

This model can assess global and local energies. A generic case is presented to interpret the analysis of the model. The energy of the node *i* is represented as *EnergyNodei*, which is obtained by adding up the energy consumed by a node *i* to perform each task along the active network. When a node connects to the network, it has consumed zero energy initially, so that *EnergyNodei* = 0.

For this energy model, we segregate energies that depend directly on the number of packets transmitted or not. The energies related to the packets are: *ETX*, *ERX*, *ESwitching* and *ECSMA*. The energies that depend exclusively on node operation are: *EON*, *EOFF*, and *EMC*. Therefore,

$$EnergyNode\_i = \overbrace{E\_{TX\_i} + E\_{RX\_i} + E\_{Sustaining\_i} + E\_{CSMA\_i}}^{Dependent on\ packet} + \tag{9}$$

$$\overbrace{E\_{MC\_i} + E\_{ON\_i} + E\_{OFF\_i}}^{Indendent on\ packet}$$

Now, to calculate the energy consumed by each node starting with packet-dependent energies, *ETXi* will be the energy transmitted in the node *i*, so,

$$E\_{TX\_i} = (P\_{Length} \times T\_{TX} \times I\_{TX} \times V\_{TX}) \times (P\_{TX\_i} + P\_{RTX\_i}),\tag{10}$$

where *PTXi* is the total number of messages transmitted by node *i*. *PRTXi* is the total number of packets retransmitted by node *i*, because a packet receipts acknowledgment, ACK, was not received.

In addition, *ERXi* will be the energy transmitted in the node i, so,

$$E\_{RX\_i} = \left(P\_{Length} \times T\_{RX} \times I\_{RX} \times V\_{RX}\right) \times P\_{RX\_{i'}} \tag{11}$$

where *PRXi* is the total number of packets received by node *i*.

In the same way, *ESwitchingi* is the switching energy consumed when a node changes from transmission to reception or vice versa. The *ESwitchingi* energy for node i is given by (12):

$$\begin{array}{ll} E\_{\text{Switching}\_{i}} = & (T\_{\text{Switching}} \times I\_{\text{Switching}} \times V\_{\text{Switching}}) \times \\ & (P\_{TX\_{i}} + P\_{RTX\_{i}} + P\_{RX\_{i}})\_{\text{\textquotedblleft}} \end{array} \tag{12}$$

The term (*PTXi* + *PRTXi* + *PRXi* ) represents the number of times there is switching or changing in state activity from the time the packet is sent to the time the packet is received or vice versa. Therefore, the best option is when a node sends a packet to a channel that is free and an acknowledgment ACK is

received. Then, *PTXi* = 1 and *PRXi* = 1. If the node receives the ACK, it does not retransmit the packet and *PRTXi* = 0. This switching operation is performed in two different stages: the node uses switching energy to change state, transmits the information, uses again switching energy, and receives the packet information.

Transmission and receiving energies are considered by (10) and (11), respectively.

For each packet transmitted, the node *i* executes the CSMA/CA algorithm. The corresponding energy consumed, *ECSMAi* is given by (13):

$$\begin{array}{ll}E\_{\text{CSMA}\_i} = & \left(T\_{\text{CSMA}} \times I\_{\text{CSMA}} \times V\_{\text{CSMA}}\right) \times \\ & \left(P\_{TX\_i} + P\_{RTX\_i} + N\_{RT\_i}\right)\_t \end{array} \tag{13}$$

where *NRTi* is the number of times that the CSMA/CA algorithm goes back to calculate a delay from the time the channel was found to be busy. This is a random variable. That is, it takes a different value for each transmission. The (*PTXi* + *PRTXi* + *NRTi* ) term implies that before each message transmission, the channel auditing process must be executed (CSMA/CA algorithm). In the best case, *PTXi* = 1 in the (*PTXi* + *PRTXi* + *NRTi* ) term, because the channel was free. Then *NRTi* = 0, (there were no retries listening to the channel, i.e., CSMA retries), and the packet is transmitted successfully with *PRTXi* = 0 (without retransmissions). However, the network conditions are not always ideal and there will be collisions causing packet retransmissions and retries when listening to the channel. Then, the *NRTi* and *PRTXi* variables will exhibit non-zero values.

Throughout the sampling time (*TSampling*), the node consumes energy from the microcontroller in active mode for this model. Therefore,

$$E\_{\rm MC\_i} = T\_{\rm Sampling} \times I\_{\rm MC} \times V\_{\rm MC}.\tag{14}$$

Now, when the sampling time begins, all nodes turn on. Then, the initial energy consumed by the node *i* is *EONi* = *TON* × *ION* × *VON*. Finally, when the time has finished, node *i* turns off, consuming shutdown energy, so *EOFFi* = (*TOFF* × *IOFF* × *VOFF*).

At the end of the sampling period, the node reports the total energy consumed by all the functions it performed during the network processes, which will be the local energy of the node. Thus,

$$\begin{array}{ll}\text{EnergyNode}\_{i} = & E\_{ON\_{i}} + E\_{MC\_{i}} + E\_{OFF\_{i}} + \\ & E\_{Switching\_{i}} + E\_{CSMA\_{i}} + E\_{TX\_{i}} + E\_{RX\_{i}}.\end{array} \tag{15}$$

To obtain the total node energy to assess the global energy of the network, we add the total energy of each node when the sampling time has ended as shown in (16):

$$Total\_{Energ}y = \sum\_{i=1}^{Total\_{Nodes}} EnergyNode\_{i\prime} \tag{16}$$

where *totalNodes* is the total number of nodes.

Equation (15) describes the actions performed by node *i* since it turns on (consuming initial energy *EONi* ), and becomes part of a network, until the moment it turns off. The most complex stage is when the node listens to the channel. This activity causes the node to decide whether to transmit packets. All packets sent (either transmitted or retransmitted) imply that the node must first listen to the channel. That is, the node executed the CSMA/CA algorithm using CSMA energy (*ECSMAi* ). If the channel is free, the node consumes transmission energy (*ETXi* ) to transmit the packet (*PTXi* ). If the channel is busy, the node generates a retry variable (*NRTi* ) because it has to execute the CSMA/CA algorithm again. After the node sends the packet, it receives an acknowledgment, ACK, using reception energy (*ERXi* ) and receives the packet (*PRXi* ). On the contrary, if the node does not receive an ACK, it retransmits the packet generated as a retransmission (*PRTXi* ). For all activity changes, the node consumes switching energy (*ESwitchingi* ). After this basic single packet cycle, the node continues to receive, listen, transmit,

and changes states until the simulation time has ended and the node turns off using shutdown energy (*EOFFi* ). During all the processes performed by a node as part of a network, the node is in active mode and the microcontroller remains active throughout the sampling period, consuming microcontroller energy (*EMCi* ).

Algorithm 1 shows the model operation pseudo-code for each of the energies previously exposed in the main processes executed by a node within the network.
