## 6 Optimization of Routing Decision in WSNs with Different-Success-Rate Links
### Establishment of ANCR Model  
The problem of minimizing transmission count by using network coding is formulated. Suppose that in a wireless network, there has already existed \(K\) data streams, now, \(H\) new data streams are added into the network. For a new data stream \(h\) (\(1\leq h\leq H\)), its source and destination nodes are respectively \(s(h)\) and \(d(h)\). If a path \(P\in R_{h}\) is selected, where \(R_{h}\) is the potential path set of the data stream \(h\), then \(f_{h}(P)=1\), otherwise \(f_{h}(P)=0\). \(P_{h}\) denotes the path of the data stream \(h\). \(M_{h}\) denotes the set of nodes on the path \(P_{h}\). \(M\) denotes the set of nodes on the paths of all the \(H\) data streams. \(1/t(e_{j})\) denotes the ETX of the link \(e_{j}\), where \(t(e_{j})\) denotes the transmission success rate of the link \(e_{j}\). We use \(T_{i}^{\{e\}},\forall e\in E^{+}(i),i\in N\) (\(N\) represents the node set of the network) to denote the sum of the transmission counts caused by transmitting packets through all the output links of the node \(i\). For a link \(e=(i,j)\), \(\tilde{e}=(j,i)\) denotes its reverse link. The following optimization solution aims to minimize the ETX of the paths for all the incoming data streams under the given conditions, such as the data stream conservation, network coding and competition constraint, etc. Specifically, the model is as follows. Minimum  
\[\sum_{i\in M}T_{i}^{\{e\}},\forall e\in E^{+}(i),M=\bigcup_{h=1}^{H}M_{h},M_{ h}=\{m|\forall m\in P_{h}\} \tag{5}\]  
Subject to  
\[\sum_{P\in R_{h}}f_{h}(P)=1,\forall 1\leq h\leq H,f_{h}(P)=\left\{ \begin{array}{ ll}1,&\mbox{if $P$ is selected as the path of the data stream $h$}\\ 0,&\mbox{others}\end{array} \right. \tag{6}\]  
\[T_{i}^{\{e_{1},e_{2}\}}\leq\sum_{k=1}^{K}\sum_{\sigma_{1}\sigma_{2}\in P}\sum _{j=1}^{3}\frac{1}{t(e_{j})}+\prod_{j=1}^{3}sgn[t(e_{j})]\times\sum_{h=1}^{H }\sum_{\sigma_{2}\in P}f_{h}(P)[\sum_{j=1}^{3}\frac{1}{t(e_{j})}],\forall e_{ 1},e_{2}\in E^{+}(i),i\in N \tag{7}\]  
\[T_{i}^{\{e_{1},e_{2}\}}\leq\sum_{k=1}^{K}\sum_{\sigma_{1}\sigma_{1}\in P}\sum _{j=1}^{3}\frac{1}{t(e_{j})}+\prod_{j=1}^{3}sgn[t(e_{j})]\times\sum_{h=1}^{H }\sum_{\sigma_{2}\in P}f_{h}(P)[\sum_{j=1}^{3}\frac{1}{t(e_{j})}],\forall e_{ 1},e_{2}\in E^{+}(i),i\in N \tag{8}\]  
\[T_{i}^{\{e\}}\leq\prod_{j=1}^{3}sgn[t(e_{j})]\times\sum_{h=1}^{H}\sum_{e\in P _{s}(h)=i}f_{h}(P)[\sum_{j=1}^{3}\frac{1}{t(e_{j})}]+\sum_{k=1}^{K}[\sum_{e \in P_{s}(h)=i}\sum_{j=1}^{3}\frac{1}{t(e_{j})}+ \tag{9}\]  
\[AX(P_{h})=U_{h},\;\forall 1\leq h\leq H \tag{10}\]  
* Constraint (6) denotes the path selection constraint, which means that from the source node to the destination node, a data stream \(h\) has one and only one path to select in the set \(R_{h}\) of potential paths determined by the constraint (10). * Constraints (7) and (8) denote the constraints for the maximum ETX of broadcast transmission of the node \(i\) carrying out network coding. Constraint (7) denotes the constraint for the maximum ETX of the path \(\tilde{e}_{2}\)\(e_{1}\). Constraint (8) denotes the constraint for the maximum ETX of the path \(\tilde{e}_{1}\)\(e_{2}\). When the variable of the sign function \(sgn\) is 0 (the transmission success rate of a link is 0), which indicates that the link can not be used, the value of the sign function is 0. At this moment, the last parts of the right of the two inequalities are all 0, which means that there is only one-way transmission limitation. In this case, if \(T_{i}^{\{\epsilon_{1},\epsilon_{2}\}}\) needs to simultaneously satisfy the constraints (7) and (8), \(T_{i}^{\{\epsilon_{1},\epsilon_{2}\}}\) must be 0. Since the bidirectional unreachable link is not within the optimization range of the optimization equation, the sign function constrains the coding opportunity of unidirectional unreachable links. * Constraints (9) shows the ETX of unicast transmission of raw packets transmitted by the node \(i\). * Constraints (10) limits the potential paths of the data stream \(h\).