# CARA: A Congestion-Aware Routing Algorithm for Wireless Sensor Networks
## 3 Congestion-Aware Routing Algorithm
### Multiparameter Routing Decision  
Sensor node \(i\) selects a node from the forward neighbor set as the next-hop node based on a given routing policy. Node \(i\) collects routing evaluation parameters for each node of the forward neighbors and establishes the initial judgment matrix \(D\). For the \(j\)th candidate node, its \(k\)th evaluation parameter is \(a_{jk}(1\leq j\leq m,1\leq k\leq n)\). Therefore, we set the initial judgment matrix \(D=\left(a_{jk}\right)_{m\times n}\) accordingly.  
Since the units of each evaluation indicator are different, the initial judgment matrix \(D\) needs to be normalized to eliminate its effects. For benefit parameters, we have  
\[r_{jk}=\frac{a_{jk}-a_{min}}{a_{max}-a_{min}} \tag{12}\]  
So, we get the normalized judgment matrix \(D_{N}=\left(r_{jk}\right)_{m\times n}\).  
For cost parameters, we have  
\[r_{jk}=\frac{a_{max}-a_{jk}}{a_{max}-a_{min}} \tag{13}\]  
Different weights represent the importance of varying evaluation parameters to reconcile the routing process's unevenness. Here, we define the weight vector as \(W=\left[w_{1},w_{2},\cdots,w_{n}\right]^{T}\), where  
\[w_{k}=\frac{\sigma_{k}}{\sum\limits_{k=1}^{n}\sigma_{k}},k=1,2,\cdots,n \tag{14}\]  
In the above equation,\(\sigma_{k}\) is the standard deviation of the \(k\)-th evaluation parameter and \(w_{k}\) is the corresponding weight for each parameter in the formula. This results in a weighted standardized judgment matrix:  
\[D_{T}=D_{N}\bullet W=\left(v_{jk}\right)_{m\times n}=\left(r_{jk}\cdot w_{k} \right)_{m\times n}\left(j=1,2,\ldots,mk=1,2,\cdots,n\right) \tag{15}\]  
The definition of the positive ideal solution in the matrix \(D_{T}\) is \(A^{+}=[v_{1}^{+},v_{2}^{+},v_{3}^{+}]\), wherein \(v_{k}^{+}=max\left\{v_{jk}\right\},j=1,2,\ldots,m\)\(V_{k}^{+}\) indicates that each parameter value has reached the best value in each candidate node. Conversely, the definition of the negative ideal solution is \(A^{-}=[v_{1}^{-},v_{2}^{-},v_{3}^{-}]\), and \(v_{k}^{-}=min\Big{\{}v_{jk}\},j=1,2,\ldots,m\). \(A^{-}\) represents a solution in which each parameter value reaches the worst value of each candidate node.  
We calculate the Euclidean distance from the candidate node \(j\) to the positive \(A^{+}\) and negative \(A^{-}\) ideal values, as follows:  
\[\begin{split} S_{j}^{+}&=\sqrt{\sum\limits_{k=1}^{n }{(v_{jk}-v_{k}^{+})}^{2}}\\ S_{j}^{-}&=\sqrt{\sum\limits_{k=1}^{n}{(v_{jk}-v_{k} ^{-})}^{2}}\end{split} \tag{16}\]  
Here, \(S_{j}^{+}\) indicates the proximity of node \(j\) and the positive ideal solution. Similarly, \(S_{j}^{-}\) represents the proximity of node \(j\) and the negative ideal solution. Thus, the routing strategy that chooses the node close to the positive ideal solution and away from the negative ideal solution can improve performance. Obviously, \(\underset{1\leq j\leq m}{min}\{S_{j}^{+}\}\) and \(\underset{1\leq j\leq m}{max}\{S_{j}^{-}\}\) is the optimal solution.  
Thus, in this paper we establish a two-dimensional plane \((S^{+},S^{-})\) in which each candidate node has its corresponding coordinates. For example, the coordinates of node \(j\) are \((S_{j}^{+},S_{j}^{-})\). Assuming \(A\) is an ideal optimal node, its coordinates are \(\left(\underset{1\leq j\leq m}{min}\{S_{j}^{+}\},\underset{1\leq j\leq m}{max} \{S_{j}^{-}\}\right)\). Each candidate node calculates the Euclidean distance from itself to node \(A\):  
\[R_{j}=\sqrt{\left[S_{j}^{+}-\underset{1\leq j\leq m}{min}\{S_{j}^{+}\}\right] ^{2}+\left[S_{j}^{-}-\underset{1\leq j\leq m}{max}\{S_{j}^{-}\}\right]^{2}} \tag{17}\]  
\(R_{j}\) represents how close the node is to the ideal optimal node. The routing strategy selects the candidate node with the smallest \(R_{j}\) value as the next hop.