# Performance Analysis of P2P Networks with Light Communication Links: The Static Managed Case
## Appendix B DES Algorithm  
As previously mentioned, we developed a discrete event simulator that captures the dynamics of the system in order to validate the analytical results of the Markov chain. This method allows for analysis of the proposed networks from a different approach to the previous numerical solution (Algorithm A1); therefore, the particularities of the Algorithm A2 (reposted) that describe this process are detailed below:  
1. As an initial step, input variables for bandwidths (\(\mu,c\)), iterations (_iterations_), nodes (_nodes_), and cluster dimensions (_coverage_) are entered. It is important to highlight that at the end of this process, the average time in which a file of a certain size is shared in all the nodes of the network (_sharing_) will be obtained.
2. Subsequently, the process will be repeated according to the number of iterations, so the following step is to initialize the simulation time (_tsim_), the counter concerned with the nodes that contain full chunks (\(y\)), and the counter concerned with nodes that do not contain all the information available in the system (\(x\)).
3. In the succeeding stage, a seed (state \((0,1)\)) is added to the queue with its respective initial parameters such as occurrence time, ID, chunk list, upload status, and connection list (depending on the range of coverage and the nature of the technology). Afterward, this process is repeated for all the leechers that are in the scenario (\(coverage-1\)), remembering there are additional parameters in these kinds of nodes with respect to the seeds (downloading connection status, list of downloading connections, etc.).
4. Once all nodes have been initialized and added to the queue, the below subroutine is initialized until the number of seeds is equal to the nodes present in the cluster: * Total conversions from leechers to seeds (_conversions_) are calculated between the time the last event occurred to the time at which simulation is located (generally time among events). Above is an important point in the system simulation, because the number of conversions is found through all the nodes present in the network by the chunk-updating function (\(updateChunks\)). * Chunk updating is conducted by inspecting each node in the queue, and includes the processes of search and link between nodes; these connections depend on the occupancy states, the limit of uploading and downloading connections, the coverage lists, and even the transmission efficiency (nodes that can transmit a greater number of chunks between them are more likely to connect). * Next, conversions are added to the number of seeds, and those same conversions are subtracted from the number of leechers, obtaining the new state: \((x-conversions,y+conversions)\). Subsequently, the time of the following state in the queue is taken, and the subroutine is repeated.
5. When the previous point is completed, the simulation time is added to the total sharing time and a new iteration of the process begins. At the end of the iterations, the sharing time is normalized.  
```
Data: iterations, \(\mu,c,nodes,coverage\) Result:tsharing \(t\gets 0\); while\(i<-\) iterationsdo \(y\gets 1\); \(x\gets 0\); \(Add(Seed(ID,status,connections,chunks))\); \(y\gets y+1\); \(tsim\gets 0\); for\(k\gets 0;k<coverage-1;k=k+1\)do \(List.add(Lecher(t,ID,chunks,state,connections))\); \(x\gets x+1\); whileseeds \(<\) coveragedo \(conversions=updateChunks(tsim,seeds,lechers)\); \(y\gets y+\) conversions; \(x\gets x-conversions\); \(tsim\gets tsim+List.timeFirst()\); if\(y=\) coveragethen \(tsharing\getssharing+tsim\); \(clearList(List)\); \(tsharing\leftarrow(\)\(\dfrac{nodes}{coverage})(\)(\dfrac{tsharing}{iterations})\) ;
```  
**Algorithm 2**P2-LiFi/P2P-WiFi/centralized DES solution algorithm