## 4 Proposed Metrics
### Valid Routes
#### 4.2.3 Global Metric
 \tag{11}\]  
The energy model described by the above equations measures the energy used by the main functions of a node belonging to a sensor network, assuming that the functions related to the wireless communications are the most relevant from an energy point of view. With this model, we analyze global and local energies. Let us name the energy of node \(i\) as \(nodeEnergy_{i}\), which is obtained by adding the energy spent by node \(i\) to perform each function in the network. For example, when a node connects to the network, it has zero energy consumed, so \(nodeEnergy_{i}=0\). In this energy model, we have energies that depend directly on the number of transmitted packets and other energies that do not. The energies related to the number of packets that a node carries are: \(E_{TX}\), \(E_{RX}\), \(E_{Switching}\) and \(E_{CSMA}\). The energies that depend only on the node operation are: \(E_{Starting}\), \(E_{Shutdown}\) and \(E_{MC}\). Thus,  
\[ \begin{array}{ll}nodeEnergy_{i}=&\overbrace{E_{TX_{i}}+E_{RX_{i}}+E_{ Switching_{i}}+E_{CSMA_{i}}}^{Packet\;dependent}+\\ &\overbrace{E_{MC_{i}}+E_{Starting_{i}}+E_{Shutdown_{i}}}^{Packet\;dependent} \end{array}  \tag{12}\]  
Now, in order to calculate each node energy, we are going to start with the packet dependent energies. \(E_{TX_{i}}\) will be the transmitted energy in node \(i\), then,  
\[E_{TX_{i}}=(P_{Length}\times T_{TX}\times I_{TX}\times V_{TX})\times(P_{TX_ {i}}+P_{RTX_{i}}) \tag{13}\]  
where \(P_{TX_{i}}\) is the total number of packets transmitted by node \(i\). \(P_{RTX_{i}}\) is the total number of retransmitted packets by node \(i\), due to the ACK packet. Moreover, \(E_{RX_{i}}\) will be the receiving energy in node \(i\), then,  
\[E_{RX_{i}}=(P_{Length}\times T_{RX}\times I_{RX}\times V_{RX})\times P_{RX_ {i}} \tag{14}\]  
where \(P_{RX_{i}}\) is the total number of packets received by node \(i\). In the same way, \(E_{Switching_{i}}\), the switching energy, will be spent when a node switches between transmission and receiving or _vice versa_. The \(E_{Switching_{i}}\) in node \(i\) is given by,  
\[ \begin{array}{ll}E_{Switching_{i}}=&(T_{Switching}\times I_{Switching} \times V_{Switching})\times\\ &(P_{TX_{i}}+P_{RTX_{i}}+P_{RX_{i}})\end{array}  \tag{15}\]  
The term \((P_{TX_{i}}+P_{RTX_{i}}+P_{RX_{i}})\) represents the number of times there is a change of activity (switching) from sending to receiving a packet or _vice versa_. Therefore, when a node sends a packet,in the best case, an acknowledgment is received, then \(P_{TX_{i}}=1\) and \(P_{RX_{i}}=1\). The node received the ACK, so it did not send a retransmission of the packet, then \(P_{RTX_{i}}=0\). It is necessary to note that this switching operation is done in two separate steps: the node uses switching energy to change the state, transmits the packet, and again, it uses switching energy and finally receives the packet. The transmission and receiving energies are considered by Equations (13) and (14), respectively. For each transmitted packet, node \(i\) runs the CSMA/CA algorithm. The corresponding consumed energy, \(E_{CSMA_{i}}\), is given by,  
\[ \begin{array}{ll}E_{CSMA_{i}}=&(T_{CSMA}\times I_{CSMA}\times V_{CSMA})\times \\ &(P_{TX_{i}}+P_{RTX_{i}}+N_{RT_{i}})\end{array}  \tag{16}\]  
where \(N_{RT_{i}}\) is the number of times that the CSMA/CA algorithm backs off since the first time the channel was found busy. It is a random variable, that is it takes a different value in each transmission. The term \((P_{TX_{i}}+P_{RTX_{i}}+N_{RT_{i}})\) implies that before each packet is transmitted, it must go through before the channel listening process (CSMA/CA algorithm). In the best case, the term \((P_{TX_{i}}+P_{RTX_{i}}+N_{RT_{i}})\) will have \(P_{TX_{i}}=1\), with the channel free from the first time, then \(N_{RT_{i}}=0\) (there were no retries listening to the channel), and the packet is successfully transmitted, then \(P_{RTX_{i}}=0\) (no retransmissions).