### 4.1 Opportunistic transmission and anypath cost

In opportunistic transmission, a packet sent from one node may be received possibly by any of its neighbors. The forwarders are the nodes in these neighbors which have received this packet and are closer to the destination. A forwarder has higher priority to do the forwarding if it is closer to the destination. A forwarding list (or say a forwarding set) is the set of forwarders. Apparently, more forwarders which a forwarding list has cause a higher probability of forwarding a packet successfully. In anypath routing [9], authors design a calculation method of anypath cost to present this relationship. They define an anypath cost {C}_{i}^{p} for forwarding packet *p* at node *i* by

{C}_{i}^{p}={c}_{\mathit{\text{iJ}}}^{\phantom{\rule{0.3em}{0ex}}p}+{C}_{J}^{p},

(1)

where {c}_{\mathit{\text{iJ}}}^{\phantom{\rule{0.3em}{0ex}}p} is the broadcast cost from *i* to a forwarding list *J*, and {C}_{J}^{p} is the anypath cost of *J*. According to the ETX metric [33] and assuming that the loss for each link is independent, cost {c}_{\mathit{\text{iJ}}}^{\phantom{\rule{0.3em}{0ex}}p} can be calculated by

{c}_{\mathit{\text{iJ}}}^{\phantom{\rule{0.3em}{0ex}}p}=\frac{1}{1-\prod _{j\in J}\left(1-{d}_{\mathit{\text{ij}}}\right)},

(2)

where *d*_{
ij
} is the packet delivery ratio (PDR) from *i* to *j*. The remaining anypath cost {C}_{J}^{p} is defined as a *weighted average* of the costs of the nodes in forwarding set *J* by

{C}_{J}^{p}=\sum _{j\in J}{w}_{\mathit{\text{ij}}}{C}_{j}^{p},

(3)

where the weight *w*_{
ij
} is the probability of node *j* being the relaying node of *p* from node *i* and \sum _{j\in J}{w}_{\mathit{\text{ij}}}=1. Let *J*={1,2,…,*n*} with anypath cost {C}_{1}^{p}\le {C}_{2}^{p}\le \dots \le {C}_{n}^{p}, the weight *w*_{
ij
} is simplified to

{w}_{\mathit{\text{ij}}}=\frac{{d}_{\mathit{\text{ij}}}\prod _{k=1}^{j-1}\left(1-{d}_{\mathit{\text{ik}}}\right)}{1-\prod _{j\in J}\left(1-{d}_{\mathit{\text{ij}}}\right)}.

(4)

With the above settings, some conclusions can be achieved in the anypath cost.

#### Lemma 4.1

For a fixed transmission rate, let *C*_{
iJ
} be the cost^{b} of a node *i* via forwarding set *J* and set *C*_{i,J} be the cost via forwarding set *J*^{′}=*J*∪{*k*}. We have {C}_{i{J}^{\prime}}\le {C}_{\mathit{\text{iJ}}} if and only if *C*_{
i
}≥*C*_{
k
}.

Lemma 4.1 is the key conclusion in anypath routing. With this lemma, if we want to reduce the cost of a forwarding set, we need to add a new forwarder which has lower cost into the forwarding set. In other words, the cost of a forwarding set is optimal if and only if there is no node in the neighbors with lower cost than that of this sender.

#### Lemma 4.2

For a fixed transmission rate, assume a forwarding set {1,2,…,*k*} with cost *C*_{1}≤*C*_{2}≤…≤*C*_{
k
}. If *C*_{i(j)} is the cost from node *i* via forwarding set {1,2,…,*j*}, for 1≤*j*≤*k*, then we always have *C*_{i(1)}≥*C*_{i(2)}≥…≥*C*_{i(k)}=*δ*_{
i
}, where *δ*_{
i
} is the optimal cost of node *i*.

Lemma 4.2 shows the variation tendency of anypath cost with varying number of forwarders. It is the extension of Lemma 4.1 to demonstrate that the reduction of the forwarders in a forwarding list will cause the increase of the anypath cost of this opportunistic transmission.

### 4.2 Inter-flow network coding

Before discussing the issues of IRNC in opportunistic routing, we would like to give a definition of IRNC formally. For a network coding structure, w.l.o.g., we assume that there is only one coding node and multiple decoding nodes. All potential encoded flows should be encoded at the coding node and decoded at the decoding nodes. Considering a multihop wireless network, a flow runs possibly on a multihop path which starts at a source and ends at a destination. We denote a flow from source *i* to destination *j* by *f*_{
ij
}. If a native flow *f*_{
ij
} is encoded into an encoded flow, we mark it as a virtual native flow by {f}_{\mathit{\text{ij}}}^{\prime}. A path {\mathcal{P}}_{\mathit{\text{ij}}} means a set of links connecting node *i* to node *j*. We say a flow on a path {\mathcal{P}}_{\mathit{\text{ij}}} if and only if this flow passes the nodes *i* and *j*. According to the denotation of a flow, we distinguish a flow on a path by the start and end of this path. For example, given two flows *f*_{
ab
} and *f*_{
cd
}, if *f*_{
ab
} is on the path {\mathcal{P}}_{\mathit{\text{ij}}}, we say *f*_{
cd
} is distinguishable from *f*_{
ab
} on {\mathcal{P}}_{\mathit{\text{ij}}} if and only if *f*_{
cd
} is not on {\mathcal{P}}_{\mathit{\text{ij}}}. Based on this setting of path distinction, we give the definition of IRNC by

**Definition** **4.1**.

For path identifiable flows, we say a network coding is inter-flow network coding if and only if all virtual native flows of one encoded flow are distinguishable on the paths from coding node to the decoding nodes.

Definition 4.1 can be used as the rule to distinguish IANC and IRNC. Based on the definition of IRNC, we can achieve two following lemmas.

#### Lemma 4.3.

In inter-flow network coding, for each encoded flow, the decoding nodes for achieving different native flows must be different.

*Proof*.

This lemma is easy to be proved by Definition 4.1. If two virtual native flows have the same decoding node, they cannot be distinguished on the path from the coding node to decoding node

#### Lemma 4.4.

In inter-flow network coding, for each encoded flow, no node is both the decoding node of one virtual native flow and also the forwarding node of another virtual native flow.

*Proof*.

If node *m* is the decoding node of a virtual native flow {f}_{i}^{\prime} from the encoded flow *f*_{
i
}⊕*f*_{
j
}, this suggests *m* has overheard *f*_{
j
}. If *m* is also the forwarding node of the encoded flow for the other decoding node to obtain {f}_{j}^{\prime}, it implies *m* is the potential decoding node of *f*_{
j
}. This contradicts Lemma 4.3

### 4.3 General coding condition

Considering an intermediate node *k* on the path {\mathcal{P}}_{\mathit{\text{ij}}} of flow *f*_{
ij
}, we denote the upstream part of {\mathcal{P}}_{\mathit{\text{ij}}} at *k* by *U*_{
k
}(*f*_{
ij
}) and the corresponding downstream part by *D*_{
k
}(*f*_{
ij
}). Before doing network coding, the coding node must guarantee that the encoded flow is decodable. That means there is at least one node in the downstream which can decode this encoded flow. For doing this, the coding node must know the decoding knowledge before making any coding decision. In inter-flow network coding, decoding knowledge is the flow’s overheard information which is defined by a set of possible nodes which had or overheard this flow. This information can be achieved by *learning neighbor state* method. We denote the overheard information of flow *f* before node *i* by {O}_{i}\left(\phantom{\rule{0.3em}{0ex}}f\right)={\cup}_{j\in {U}_{i}\left(\phantom{\rule{0.3em}{0ex}}f\right)}\left({N}_{j}\cup \left\{j\right\}\right), where *N*_{
j
}is the neighbor of node *j* with a high PDR. The nodes in *O*_{
i
}(*f*) can be considered as the potential decoding nodes for the flows which are encoded with *f*. Hence, the general coding condition is given as follows.

#### Coding condition.

For *f*_{
k
} and *f*_{
j
} intersecting at node *i*, if we denote that *f*_{
k
} can be encoded into *f*_{
j
} by {\Omega}_{{f}_{k}\to {f}_{j}}^{i}={O}_{i}\left(\phantom{\rule{0.3em}{0ex}}{f}_{j}\right)\cap {D}_{i}\left(\phantom{\rule{0.3em}{0ex}}{f}_{k}\right), and similarly {\Omega}_{{f}_{j}\to {f}_{k}}^{i}={O}_{i}\left({f}_{k}\right)\cap {D}_{i}\left(\phantom{\rule{0.3em}{0ex}}{f}_{j}\right), then *f*_{
j
} and *f*_{
k
} can be encoded together and the following should hold:

\left|{\Omega}_{{f}_{j}\to {f}_{k}}^{i}\right|\xb7\left|{\Omega}_{{f}_{k}\to {f}_{j}}^{i}\right|\ne 0.

(5)

For encoding *m*>2 flows together, every two of them should hold the coding condition. Intuitively, the more flows are encoded together, the more NC gain can be achieved. How to encode the maximum flows together, however, can be summarized as finding the maximum clique in an undirected graph [3]. The *maximum clique problem* is NP-complete. In [19], authors point out that the maximum number of flows that can be encoded with a given flow is bounded by a small number. Meanwhile, the probability of encoding *m*>2 flows is very low with random flows in multihop networks. For example, if we assume that every flow is generated randomly and with probability *p* to encode with another flow, the probability of encoding *m*>2 flows together is only *p*^{m(m−1)/2}. Moreover, from our work, encoding more flows together will cost more OR price in the transmission (we will discuss this issue in following sections). So it seems to be not worth to design an encoding multiple flow scheme for OR. Hence, in this paper, we only consider a two-flow encoding case, and we believe that the multiple flow encoding case can be achieved by extending our work.