## 3 Methodology
\[\mathcal{P}_{cn}(\varepsilon)=\frac{[\alpha_{cn}(\varepsilon)]^{max(wa)}\cdot[ \beta_{cn}(\varepsilon)]^{min(w\beta)}\cdot[\delta_{cn}(\varepsilon)]^{min(w \gamma)}}{\sum_{\varepsilon\in cn}^{\infty}[\alpha_{cn}(\varepsilon)]^{max( nu)}\cdot[\beta_{cn}(\varepsilon)]^{min(w\beta)}\cdot[\delta_{cn}( \varepsilon)]^{min(w\gamma)}} \tag{2}\]  
The process starts when the node is turned on, and the initial battery capacity that is calculated by the battery power management [45] is stored in the variable (\(batt_{i}\)) by Equation (3). \[batt_{i}=tbc-batt_{ce} \tag{3}\]  
where \(tbc\) is the total battery capacity, and \(batt_{ce}\) is the current energy of the battery or batteries connected to the sensor node. \(batt_{i}\) is then attached to the current time (\(ct\)), based on which the energy consumption (\(batt_{ce}\)) is measured. \(batt_{ce}\) is based on the average \(batt_{ce}\) rate multiplied by the time taken for a single operation. \(batt_{ce}\) is the result of transmitting, receiving, and processing the signals in addition to the consumption in inactive mode [46; 47]. Every time any process takes place in the node, \(\delta\) is updated as in Equation (3) [45]. \[\delta=batt_{i}-batt_{ce} \tag{4}\]  
The \(\delta\) parameter is mostly known as the state of charge (SoC), expressed as a percentage, where an empty battery is 0% and full is 100%. In the P-BIOSARP case, \(\delta\) is retained to avoid multiple calculations and battery consumption. P-BIOSARP depends on BIOSARP, that is, an on-demand routing protocol, which means that when it is necessary to forward the data packet, the neighbor information is collected and stored in a routing table to generate the optimal \(n\) decision, as shown in the flow chart in Figure 2.  
Figure 2: P-BIOSARP process flow. Therefore, the source node begins with the broadcasting of route request (RREQ) packets, and all of the neighboring nodes at a single hop, meaning those in the range of the source node, receive them. In response, the node receives the RREQ packet, builds the route reply (RREP) packet with its own information, and sends the RREP packet to the source node. This RREP packet of the WSN with MAC and physical layers of IEEE standard 802.15.4 includes the \(\delta\) value. P-BIOSARP running at the source node decrypts and stores the information in its routing table with the \(n\) identity (_ID_), as shown in Figure 2.  
When the route discovery procedure is completed, the source node starts calculating the probability of each \(n\) in the routing table by Equation (2). The \(\mathcal{P}_{cn}(\varepsilon)\) value is also recorded in the routing table for each \(n\). After filling all of the required fields of the routing table, the source node searches for the highest \(\mathcal{P}_{cn}(\varepsilon)\) value and returns the \(n\)_ID_ against it. The data packets in the queue are then forwarded to the selected \(n\). In the event of rerouting or forwarding the data packet, the same process of selecting the best \(n\) is conducted, and it continues until the destination and the sink node of the WSN. The proposed mechanism was developed with the assumption that the included mobile nodes do not move at high speed. The mobile nodes do not move out of the given region. The gateway or the sink node is a trusted body. If no neighboring node is found, the mobile node moves towards the location of the gateway. The pseudo-random function to provide the master key and the _ID_ of the nodes is embedded in the program. The collision avoidance and the channels between devices are managed by the 802.15.4 MAC layer.