Mathematics of Torrenting

I'm going to assume that users $U_1,\ldots,U_p$ are peers and users $U_{p+1},\ldots,U_N$ are seeders. I'm also only going to look at the steady state, where each for each pair of users $u_i,u_j$, there's at least one block that $i$ has and $j$ doesn't, and also a block that $j$ has and $i$ doesn't.

Inidivudally, peer $i$ can at most download with bandwith $$ b_i \leq \min \left\{d_i, \sum_{j\in\{1,\ldots,N\} \setminus \{i\}} u_i\right\} \text{.} $$ i.e. his download speed is limited by the combined upload speeds of all other users, or his own downstream bandwith, whatever is smaller. Additionally, the sum of download bandwiths over all peers cannot exceed the sum of upload bandwidths over all users, i.e. $$ \sum_{i=1}^p b_i \leq \sum_{i=1}^N u_i \text{.} $$ The total time it takes for all $p$ peers to finish their download is then $$ T = B\cdot\max_{i=1}^p \frac{1}{b_i} = \frac{B}{\min_{i=1}^p b_i}\text{,} $$ assuming that at any time, the data distribution allows all peers to use the whole bandwidth $b_i$ available to them.

Now assume the download bandwiths $b_i$ are alloted as follows:

  1. Each peers gets a fair share of the upload bandwith of all other users, meaning one $p$-th of the upload bandwith of all seeders, and one $(p-1)$-th of the upload bandwith of all peers (a peer can't upload to itself!), i.e. $$ \hat b_i = \sum_{j=\{1,\ldots,p\}\setminus\{i\}} \frac{u_i}{p-1} + \sum_{j=p+1}^N \frac{u_i}{p} $$

  2. Whenever $\hat b_i$ exceeds $d_i$, i.e. the user's downstream bandwith, the bandwidth is (naturally!) clamped to $d_i$, and the excessive bandwidth is distributed evenly over all users with higher downstream bandwiths.

Now look at the user with the smallest $b_i$. There are two cases - either $b_i = \hat b_i$, or $b_i = d_i$. Thus $$\begin{eqnarray} T = \max \left\{ \frac{B}{\min_{i=1}^p d_i}, \frac{B}{\min_{i=1}^p \hat b_i} \right\} \end{eqnarray}$$