# Performance Analysis of P2P Networks with Light Communication Links: The Static Managed Case
## Appendix A Markov Chain's Numerical Solution Algorithm  
Algorithm A1 considers the dynamics of the Markov chain by generating random dwelling times with exponential distribution for the output rates of the system, looking for the minimum time (which represents the following transition) and taking advantage of the memoryless property of IID variables with exponential distribution used in the process (the algorithm is reposted and detailed below):  
1. The process begins with the input data of the bandwidths (\(c\) and \(\mu\)) and the control variable (\(\xi\)); those variables will allow fpr the calculation of the system rates (\(\lambda^{\prime}\), \(\tau\)), in addition, the number of iterations (\(iterations\)) is defined, as well as the number of nodes in the scenario (\(nodes\)) and the size of the clusters (\(coverage\)) into which the number of nodes will be divided (the greater coverage, the more peers that one node can reach in the networks; on the other hand, a very small coverage could provide enough information about average download times in the network). These input variables will allow for the calculation of the time in which the information is shared (\(sharing\)) in the proposed networks.
2. Once the input data have been entered into the algorithm, the process will be repeated in the indicated number of iterations (until the chain obtains a steady state in the long term); therefore, for each iteration, it initializes the values of the simulation time (\(tsim\)) and the counters of leechers (\(x\)) and seeds (\(y\)), taking into account that for the studied networks, there must be at least one server in the system at all times.
3. The system starts at state \((0,1)\), which corresponds to the case where the system is in initial conditions (in other words, there is just one seed in the system and the otherpeers are not asking for information yet ); the calculation of the time in which the next transition will take place is equivalent to obtaining the minimum number (\(tmin\)) of the times \(T_{1}\) and \(T_{2}\) calculated with rates \(\lambda^{\prime}\) and \(\tau\), respectively (\(T_{1}\) and \(T_{2}\) are the random times that correspond to an event of conversion from a leecher to seed or an event of a request of information from one peer, and they are modeled as random variables exponentially distributed), as well as the position (\(index\)) of this calculated time.
4. The following step indicates the addition of the calculated minimum time to the simulation time, and then there are two possible conditions: * If the minimum time corresponds to the one created by the \(\lambda\) rate, it indicates that a node has requested information for the first time in the system, indicating the presence of a leecher in the system \((x+1,y)\). * Instead, if the smallest time corresponds to that created by \(\tau\) rate, it indicates that a node has obtained all the circulating chunks, indicating that a conversion from a leecher to a seed has occurred \((x-1,y+1)\).
5. The process continues until all the nodes present in the cluster of the network have become seeds (recalling that the dimension of the clusters can be equal to or less than the number of nodes); it is at this specific moment when the simulation time is added to the sharing time. Finally (at the end of the repetitions), the sharing time is normalized by the number of iterations and the relationship between nodes and clusters.  
```
Data: iterations, \(\mu,c,nodes,coverage,\xi\) Resultsharing \(\leftarrow\) 0; while\(i<=iterations\)do \(y\gets 1\); \(x\gets 0\); \(\lim\gets 0\); while\(y<coverage\)do \(tmin,index\leftarrow\min(x,y,\xi,c,\mu)\); \(tsim\gets tsim+tmin\); if\(index==0\)then \(x\gets x+1\); else \(x\gets x-1\); \(y\gets y+1\); if\(y==nodes\)then \(tsharing\gets tsharing+tsim\); \(tsharing\gets(\frac{nodes}{coverage})(\frac{tsharing}{iterations})\) ;
```  
**Algorithm A1**P2P-LiFi/P2P-WiFi/centralized numerical solution algorithm