# An Equilibrium Strategy-Based Routing Optimization Algorithm for Wireless Sensor Networks
## 3 ESRA Routing Algorithm
### Link Cost  
Due to the limited communication distance of the sensor nodes, the nodes generally need to transmit the sensed data to the base station in a multi-hop manner. Therefore, how to establish a path with the least energy consumption from source node to the sink node is a priority for the routing algorithm. Here, in order to avoid data backhaul and ensure that data are transmitted forward along the direction of the sink, according to the model of [25], the forward neighbor node set of node \(i\) is defined as follows:  
\[FN(i)=\left\{j|d_{ij}\leq R,d_{js}<d_{is}\right\} \tag{3}\]  
where \(d_{ij}\) is the distance from node \(i\) to node \(j\), \(d_{is}\) and \(d_{js}\) are the distance from node \(i\) and node \(j\) to sink respectively, \(R\) represents the maximum communication radius of node \(i\). As shown in Figure 1, after taking the spatial positional relationship between the current node \(i\), the next hop \(j\), and the sink node, as well as the energy level of each node into consideration, a data transmission path reducing energy consumption and delay is established in this paper. For source node \(i\), the smaller the energy consumption of the single-hop transmission is to next hop node \(j\), the slower the energy consumption caused by the data transmission. But for the overall path, if the path with a small single-hop distance (that is, the transmission energy consumption is small) is selected multiple times, there may exist more unnecessary energy loss and larger path hops will be caused due to the detour (such as the path: \(i\to K\to M\to Q\to sink\)). Therefore, in the process of generating the link cost, the forward distance of next hop \(j\) should also be considered, because the closer the next hop is to the sink, and the less path hops it will be, thus the faster that data can be transmitted to the sink. Based on the above analysis, in order to reduce the energy consumption and transmission delay of node \(i\), the path where the next hop is located should be as close as possible to the straight line of node \(i\) to the sink node. Therefore, in this paper, from the perspective of energy consumption and hop count, we take into account the residual energy, the energy consumption of single-hop transmission, and the forward energy consumption, the link cost \(u_{i,j}\) between node \(i\) and node \(j\) is defined, and its expression is as follows:  
\[u_{i,j}=\alpha\frac{e_{ij}}{E_{i}}+\beta\frac{e_{js}}{E_{j}},j\in FN(i) \tag{4}\]where \(j\) belongs to the forward neighbor node set of current node \(i\) to avoid the return of data packets, \(e_{ij}\) is the transmission energy consumption from node \(i\) to node \(j\), \(e_{js}\) is the forward energy consumption from node \(j\) to sink, and both of them can be calculated by the energy consumption model in [34]. \(E_{i}\), \(E_{j}\) are the current residual energy of node \(i\) and node \(j\) respectively. Besides, it should be noted that the link cost is set to infinity when the distance between node \(i\) and node \(j\) is longer than the communication radius \(R\). Simultaneously, in Equation (4), \(\alpha\), \(\beta\) are the positive harmonic coefficients, and satisfy \(\alpha+\beta=1\). When the value of \(\alpha\) is larger, the selection of next hop tends to consider the residual energy of the current node and the transmission energy consumption of a single hop, seeking to minimize the energy consumption of transmission and maximize the residual energy, so that the ratio of the two is as small as possible. Conversely, when the value of \(\alpha\) is smaller, the residual energy and forward energy consumption of forward node are considered to select the next hop, trying to make the ratio of the two as small as possible to reduce the hop counts, so that the data can be transmitted to sink faster. Therefore, by adjusting the relative values of \(\alpha\) and \(\beta\), different requirements of network performance in hop counts and energy consumption can be obtained.