## 5 Analytical Modeling
### Dynamic Transmission Model of Coded Packets during One Cycle
\begin{cases}\lambda\Big{(}\sum\limits_{j=1}^{i}X_{j}\cdot P (i,j)+\sum\limits_{j=i+1}^{H}X_{j}+1-P(i,i)\Big{)}&0<t\leq T_{s\_r}\\ 0&T_{s\_r}<t\leq T_{s\_r}+T_{w\_r}\end{cases} \qquad(i=1,2,...,H-1) \tag{8}\]\[\text{Re}_{H}(t)= \begin{cases}\lambda\cdot\left(\sum\limits_{j=1}^{H}X_{j}\cdot P(H,j)-P(H,H)+1\right)&0<t\leq T_{s,r}\\ 0&T_{s,r}<t\leq T_{s,r}+T_{w,r}\end{cases}  \tag{9}\]  
For destination node:  
\[\text{Re}_{i}^{d}(t)=\lambda\cdot\left(\sum\limits_{j=1}^{i}X_{j}\cdot P(i,j) +\sum\limits_{j=i+1}^{H}X_{j}+1\right) \left(i=0,1,2,...,M_{r}-1\right)\enspace, \tag{10}\]  
During packet diffusion phase \(T_{w,r}\) nodes of type \(v_{0}\) could obtain a packet from any encountered node that stored packets. For nodes of \(v_{j}\), there was a probability that they could obtain a new packet from an encountered node. During the waiting period \(T_{w,r}\), all relay nodes would no longer receive any coded packet, so the receiving rates was 0. But note that the destination node could receive coded packets in all time periods. Therefore, the receiving rate of the destination node in both \(T_{s,r}\) and \(T_{w,r}\) periods can be obtained from Formula (10). Apparently, \(P(i,j)\) and \(X_{i}(t)\) had to be obtained to calculate the \(Re_{i}(t)\):  
* The calculation of \(P(i,j)\)  
In the packet diffusion phase, when a type \(v_{i}\) node \(m_{i}\) encounters a type \(v_{j}\) node \(m_{j}\), the replication operation will not take place if a packet to be copied to \(m_{i}\) already exists in the cache of \(m_{i}\). Therefore, there is a certain probability for node \(m_{i}\) to obtain a new independent packet at \(m_{j}\), which is denoted as \(P(i,j)\). We assumed that the \(i\) packets carried by \(m_{i}\) were evenly distributed among the \(M_{r}\) code packets sent by the source. This assumption was reasonable if the global rarest policy, which could maintain close to even proportions of \(K\) packets in the network, was used. Thus, the calculation of \(P(i,j)\) can be conducted, as shown in Equation (11):  
\[P(i,j)= \begin{cases}1&i<j\\ 1-\frac{c_{i}^{j}}{c_{M_{r}}^{j}}&i\geq j\end{cases}  \tag{11}\]  
When \(i<j\), \(m_{i}\) must get a new independent packet at \(m_{j}\); otherwise, under the assumption of uniform distribution of coded packets, the probability that all packets in \(m_{j}\) have copies in \(m_{i}\) is \(\frac{c_{i}^{j}}{c_{M_{r}}^{j}}\). A similar analysis has been applied to BitTorrent, such as P2P file sharing systems. * The calculation of \(X_{i}(t)\)  
\(X_{i}(t)\) represents the number of nodes of type \(v_{i}\). When the type of nodes changes from \(v_{i-1}\) to \(v_{i}\) after receiving a new coded packet, \(X_{i}(t)\) increases; \(v_{i}\) becomes \(v_{i+1}\) after receiving a new coded packet, then \(X_{i}(t)\) decreases. The change rate of \(X_{i}(t)\) is related to the receiving rate of nodes in type \(v_{j}\) over a very short time interval. In this way, the following ordinary differential Equation (12) can be used to calculate \(X_{i}(t)\):  
\[ \begin{array}{c}\frac{dX_{i}(t)}{dt}=\text{Re}_{i-1}(t)\cdot X_{i-1}(t)- \text{Re}_{i}(t)\cdot X_{i}(t)\quad(i=1,2,...,H-1)\\ \frac{dX_{i}(t)}{dt}=\text{Re}_{H-1}(t)\cdot X_{H-1}(t)\end{array}  \tag{12}\]  
where \(Re_{i}(t)\) is a function of \(X_{i}(t)\). Then Equation (12) can be solved with the initial values \(X_{i}(t)=0\), for \(i=1,2,\ldots,H-1\). Thus, substitute \(X_{i}(t)\) back into Equations (7)-(10), the receiving rate \(Re_{i}(t)\) and \(Re_{i}{}^{d}(t)\) can be derived. Substitute \(Re_{i}(t)\) and \(Re_{i}{}^{d}(t)\) back into Equations (5) and (6), then the \(F_{i}(t)\), the CDF of the time that the destination obtains \(i\) packets, for \(i=1,\ldots,H\), can be finally calculated. The above analysis was conducted under the assumption that each node could forward at most one packet every time they met a neighbor. There may be situations where bandwidth could support multiple packets transmission in practical applications. The solution was similar to the above method, which will be taken as the future research content.