## 3 The Proposed SensorAnt Protocol
### SensorAnt Description
#### 3.6.3 Path Discovery Steps  
When the SN senses data to forward to the base-station (sink), it will check inside its routing table to verify the existing route to the sink. If no data is available, the sender sensor will start to broadcast Ant-F to find out the route to the sink; otherwise, it will send unicast Ant-F using the pheromone information and quality function of both path and hop to select the next hop from \(x\) to \(y\) toward sink \(z\). It uses the ant agent probability \(Pr_{xy}^{z}\) given as follows:  
\[Pr_{xy}^{z}=\frac{(P_{x}^{y})^{\beta}}{\sum_{y\in N_{x}^{z}(P_{x}^{y})^{\beta}}} \tag{9}\]  
where \(P_{x}^{y}\) is the pheromone trail value of the link (\(x\),\(y\)) and \(\beta\) is the weight factor of the pheromone trail. During the reception of an Ant-F message from the sensor node \(x\) to the sink \(z\) through \(y\), it starts assessing the function quality of the ant route, \(F(ph)_{xyz}^{z}\) as follows:  
\[F(ph)_{xyz}^{z}=\ F(ph)_{xyz}^{y}+Enc_{xy}^{Tx}/F(hp)_{xy} \tag{10}\]  
where \(F(ph)_{xyz}^{y}\) is the quality of the route from the sender of Ant-F at the intermediate sensor \(y\), \(Enc_{xy}^{Tx}\) is the consumed energy to forward the data from \(x\) to \(y\) and \(F(hp)_{xy}\) is the function to assess the quality between neighbor sensors \(x\) and \(y\), and is given as:  
\[F(hp)_{xy}=e^{y}*e_{min}^{y}*\left(\frac{e_{av}^{y}+e^{y}}{e_{mv}^{y}*h^{y}}\right) \tag{11}\]  
where \(e^{y}\) is the current residual energy of sensor \(y\), \(e_{min}^{y}\) is minimum residual energy of sensors visited by Ant-F given as Min\([e_{min}^{x},e^{y}]\), \(e_{av}^{y}\) is the average residual energy of the route from sender \(x\) until the current sensor \(y\), \(h^{y}\) is hop count up to \(y\) and \(e_{mv}^{y}\) is the total average of the whole network residual energies which is computed as the initial energy of the sensor at the first time and later updated with Ant-F and Ant-B using:  
\[e_{nw}^{y}=\alpha e_{nw}^{x}+(1-\alpha)e_{nw}^{y} \tag{12}\]  
where \(\alpha\) is the parameter for updating the ratio of predictable and received network average energy. Consequently, based on the hop function \(F(hp)_{xy}\), our model satisfies the balancing of energy consumption that reduces sensor's energy usage in the path and prolong the network life span. This is done by preventing the frequent usage of sensor nodes based on a minimum energy level used here. Hence, the sensor nodes with maximum residual energy will take the role of transmitting the data. Moreover, the paths with high average residual energy will get more opportunities to route the data to the sink. In addition, the results of hop quality function will be applied to Equation (10) to measure the whole ant tour route from the sender sensor node to the sink. In this case the higher value associated with this route function will be given less path average, which is the better path to be chosen. As a result, the protocol will use this to update the pheromone trail \(P_{x}^{y}\) at the pheromone table as follows:  
\[P_{x}^{y}=(1-\omega)P_{x}^{y}+\Delta P_{xyz}^{z} \tag{13}\]where \(\omega\) is the parameter used to control the decay of the pheromone during the searching process since the last update and \(\Delta P^{\mathrm{z}}_{x\mathrm{yz}}\) is the increasing value of the ant deposit trail during the journey from the sender node to the sink. This is given as the inverse of function quality of the route from source sensor to the sink:  
\[\Delta P^{\mathrm{z}}_{x\mathrm{yz}}=1/F(ph)^{\mathrm{z}}_{x\mathrm{yz}} \tag{14}\]  
Therefore, the route with better quality that has both highest value of minimum residual energy and average route energy will get the higher pheromone trail. In this way the route with best path quality will reinforce and get a better chance to be chosen.