# Teletraffic Analysis of DoS and Malware Cyber Attacks on P2P Networks under Exponential Assumptions
## 5 Mathematical Model
### Basic P2P Model  
This model assumes that there are two types of users: leechers and seeds. The Markov chain that describes this system is composed of two states, \((x,y)\), where \(x\) is the number of leechers, and \(y\) is the number of seeds. Note that there has to be at least one seed in the system to share a file, which is, in fact, the only node that has the complete file at the beginning of the downloading procedure. Hence, this represents an irreducible continuous-time Markov chain with valid state space \((\Omega_{x,y})\) where the state system space \((x,y)\) is with \(x=0,1,2,\ldots,\) and \(y=1,2,3,\ldots\). This chain is irreducible because any state can be accessed by any other state, and all states communicate with each other.  
Figure 3: Flow chart for the operation of the DoS attack in the P2P network.  
Peers arrive in the system with no chunks (i.e., arriving as leechers) at the rate \(\lambda\) and leave the system before finishing the complete download of the file at the rate \(\theta\). Hence, the model considers that nodes become impatient or simply have to leave the downloading procedure for a random time with an exponential distribution and the mean \(1/\theta\). Once a leecher downloads the complete file, it becomes a seed at the rate \(\tau\). Seeds dwell in the system for a random exponentially distributed time with the mean \(1/\gamma\). This passage from leecher to seed can be further explained as follows: Two scenarios of conditions are considered. The first one is _penury_, in which there is a scarcity of users that, in turn, is reflected as a scarcity of resources since there are very few peers sharing the file, and the system's bandwidth is denoted by \(\mu[(\eta\cdot x)+y]\), where \(\mu\) is the upload rate, and \(\eta\) is the parameter that reflects the efficiency of the file sharing among leechers. Indeed, not all leechers that connect among these can interchange chunks of the file because they may have duplicated chunks. This is especially true when there are few leechers in the system or when the chunks are not uniformly distributed by the seeds, i.e., there are chunks that are widely distributed, while other chunks are rare. However, as the number of leechers increases, and the system uses good chunk distribution policies, the efficiency increases, reaching a value close to 0.9. Assuming that nodes can download the file at a maximum rate \(c\), in penury conditions, the available bandwidth is not sufficient for the nodes to download at this rate. Hence, \(\mu(\eta\cdot x+y)<(c\cdot x)\). Indeed, the total download rate of the system is \(c\cdot x\) because only leechers are downloading the file, and seeds have already completed the download. The second scenario is _abundance_, in which the number of users is sufficient to allow leechers to download at the maximum rate, \((c\cdot x)\). Hence, the leecher-to-seed transition rate can be expressed as:  
\[\tau=\min[\mu(\eta\cdot x)+y),cx] \tag{1}\]  
We numerically solve the aforementioned chain to obtain the average number of seeds and leechers in the system. Moreover, this Markov chain can be represented as depicted in Figure 4.