# Blockchain-Empowered Fair Computational Resource Sharing System in the D2D Network +
## 4 System Modelling
### Connectivity Model  
Assuming the connection between a requester \(p_{i}\) and a helper \(h_{j}\) to be symmetric, we denote the random variable \(B_{i,j}(\tau)=1\) (or \(B_{i,j}(\tau)=0\)) to represent that \(p_{i}\) and \(h_{j}\) are connected (or disconnected) at time \(\tau\geq 0\). Moreover, let random variable \(S_{i,j}^{1}\) denote the sojourn time that \(p_{i}\) and \(h_{j}\) are in the connected state and \(S_{i,j}^{0}\) denote that in the disconnected state. We consider that both \(S_{i,j}^{1}\) and \(S_{i,j}^{0}\) follow the exponential distribution with parameters \(\lambda_{i,j}\) and \(\mu_{i,j}\), respectively. Therefore, we have the cumulative distribution functions (CDF) of \(S_{i,j}^{1}\) and \(S_{i,j}^{0}\) given by:  
\[\Pr(S_{i,j}^{1}\leq\tau)=1-e^{\mu_{i,j}\tau}, \tag{1}\]  
and:  
\[\Pr(S_{i,j}^{0}\leq\tau)=1-e^{\lambda_{i,j}\tau}. \tag{2}\]  
We represent the continuous time Markov chain (CTMC) model with two states illustrated in Figure 4 and let \(P_{i,j}(\tau)\) denote the \(2\times 2\) matrix with entries \(p_{i,j}^{x,y}(\tau)=\Pr(B_{i,j}(\tau)=y|B_{i,j}(0)=x)\), where \(x,y\in\{0,1\}\). Referring to [24], we have the solution of \(P_{i,j}(\tau)\) given by:  
\[P_{i,j}(\tau)=\left(\begin{array}{cc}\frac{\lambda_{i,j}}{\Psi}+\frac{\mu_ {i,j}}{\Psi}\kappa&\frac{\mu_{i,j}}{\Psi}-\frac{\mu_{i,j}}{\Psi}\kappa\\ \frac{\lambda_{i,j}}{\Psi}-\frac{\lambda_{i,j}}{\Psi}\kappa&\frac{\mu_{i,j}} {\Psi}+\frac{\lambda_{i,j}}{\Psi}\kappa\end{array}\right), \tag{3}\]  
where \(\kappa=e^{-(\mu_{i,j}+\lambda_{i,j})\tau}\) and \(\psi=\mu_{The parameters \(\mu_{i,j}\) and \(\lambda_{i,j}\) used in (3) for \(p_{i}\) and \(h_{j}\) can be obtained by maximum likelihood estimation (MLE) on each of them. Specifically, without loss of generality, consider that \(p_{i}\) and \(h_{j}\) were disconnected initially, and the connectivity between \(p_{i}\) and \(h_{j}\) has changed \(m\) times before the current time \(\tau\). Therefore, \(p_{i}\) and \(h_{j}\) have recorded a vector of time \(\overline{\tau}_{i,j}=(\tau_{1},...,\tau_{m})\in R_{+}^{m}\), where each element \(\tau_{i,j}^{z}<\tau(z=1,...,m)\) represents the time when the connectivity between \(p_{i}\) and \(h_{j}\) changed. Assume \(p_{i}\) and \(h_{j}\) are currently connected (then, \(m\) must be an odd number, and the case that \(p_{i}\) and \(h_{j}\) are currently disconnected can be analysed via following approach similarly); \(\mu_{i,j}\) and \(\lambda_{i,j}\) estimated by MLE up to current time \(\tau\) are given by:  
\[\hat{\mu}_{i,j}^{t}=\frac{m-1}{2\sum_{z=1}^{\frac{m-1}{2}}(t_{i,j}^{2z}-t_{i,j }^{2z-1})}, \tag{4}\]  
and:  
\[\hat{\lambda}_{i,j}^{t}=\frac{m-1}{2\sum_{z=1}^{\frac{m-1}{2}}(t_{i,j}^{2z+1}- t_{i,j}^{2z})}. \tag{5}\]  
Because the connections between \(p_{i}\) and \(h_{j}\) are assumed symmetric, the same results are obtained on \(p_{i}\) and \(h_{j}\). For the people who study or work together, \(\overline{\tau}_{i,j}\) is kept being recorded by both \(p_{i}\) and \(h_{j}\) as the system time increases. According to (4) and (5), \(\hat{\mu}_{i,j}^{t}\) and \(\hat{\lambda}_{i,j}^{t}\) will converge. We denote \(\hat{\mu}_{i,j}=\lim_{t\rightarrow\infty}\hat{\mu}_{i,j}^{t}\) and \(\hat{\lambda}_{i,j}=\lim_{t\rightarrow\infty}\hat{\lambda}_{i,j}^{t}\), which are the MLE of \(\hat{\mu}_{i,j}\) and \(\hat{\lambda}_{i,j}\), respectively. Given the connection station \(B_{i,j}(\tau)\) between \(p_{i}\) and \(h_{j}\) at time \(\tau\), the probability that they are connected at future time \(\tau^{\prime}\geq\tau\) is given by:  
\[\Pr(B_{i,j}(\tau^{\prime})=1|B_{i,j}(\tau))=\begin{cases}\frac{\lambda_{i,j}- \lambda_{i,j}e^{-(\lambda_{i,j}+\mu_{i,j})(\tau^{\prime}-t)}}{\lambda_{i,j}+ \mu_{i,j}},&B_{i,j}(\tau)=0,\\ \frac{\lambda_{i,j}+\mu_{i,j}e^{-(\lambda_{i,j}+\mu_{i,j})(\tau^{\prime}-t)}} {\lambda_{i,j}+\mu_{i,j}},&B_{i,j}(\tau)=1.\end{cases} \tag{6}\]