• No results found

We first consider an n-node network with a simple upload capacities distribution, where all peers upload at the same rate. In particular each peer uploads one packet per round. Under the assumptions of Section4.1 we show that the deficit experience by any peer is at most O(log n) with high probability.

Let us assume that the protocol proceeds in rounds. In each round each node sends a packet, either a load packet or a reciprocating packet. We measure the deficit of each peer in the end of each round. First, we prove the following theorem, that states that at the end of any round t, no peer observes a maximum positive deficit, greater than O(log n) with high probability.

Theorem 1 For some constant k1 > 2, in an n-node FairTorrent network, where all nodes upload at the same rate, at the end of any given round t, Emax+ < k1log n, with probability at least 1 − n−Ω(k1−2).

Proof: The proof proceeds in two steps. First we show a lemma that demonstrates the upper bound on the total number of blocks owed in the system in a given round.

We use that fact to find a lower bound on the reciprocation rate of the peers who owe packets to a particular peer Li.

Let N (t) represent the total number of packets owed in the system in end of round t.

Lemma 2 At the end of a given round t, P rob[N (t) ≥ 3n/2] ≤ (e/4)n/2.

Proof: Let us assume that at the end of a given round t, N (t) ≥ 3n/2. Then, let us consider the earliest round (i.e. the smallest such t ) such that N (t) ≥ 3n/2, and N (t − 1) < 3n/2. Let k be the number of peers who “owe” at least one packet in the end of round t − 1. Then in round t, k peers will each send a reciprocation packet, and n − k peers will each send a load packet.

Thus, we can conclude that

N (t) = N (t − 1) + (n − k) − k = N (t − 1) + n − 2k . (4.2)

Since N (t) ≥ 3n/2, we have that

N (t − 1) + n − 2k ≥ 3n/2 (4.3)

N (t − 1) ≥ n/2 + 2k. (4.4)

This implies that, in the end of round t − 1 there were at least n/2 + 2k packets owed just by k nodes, as the other n − k nodes owe no packets. Also, observe that

k ≤ n/2, because, if k > n/2, then the number of load packets in round t decreases rather than increases, contradicting our premise.

Let Ef be the event that k peers contain all of the N (t1) = n/2+2k load packets in the system in some round t1. (and the rest of the n-k peers do not owe any packets).

(Remember, that k ≤ n/2).

Let us first consider a related process from the classic “Balls in Bins” problem where m balls are thrown at random into n bins. Let us consider an event Er where the N (t − 1) = n/2 + 2k balls are thrown at random into n bins and they all end up in some subset of at most k bins. Let Erk be Er for a particular value of k.

Clearly, P ron[Er0] = 0, as the probability of all the balls going into 0 bins is zero. For 1 ≤ k ≤ n/2,

P rob[Erk] =n k



∗ (k/n)n/2+2k. (4.5)

In the rest of the proof of Lemma 2, we first use Lemma 3 to show that P rob[Erk] takes its maximum value at maximum k, where k ≤ n/2. This will give us the bound on P rob[Er]. Then, in Lemma4, we will show that P rob[Ef] ≤ P rob[Er], and thus the bound on P rob[Er] is also the bound on P rob[Ef].

Lemma 3 When throwing n/2 + 2k balls at random into n bins, for 1 ≤ k ≤ n/2, the probability of having all the balls fall into a set of only k bins, takes its highest value at the maximum value of k ≤ n/2. Simply put, P rob[Erk] ≤ P rob[Erbn/2c].

Proof: Let Rk = P rob[EP rob[Erk+1k ]

r] . To prove Lemma 3 it suffices to show that Rk ≥ 1 ∀k : 1 ≤ k ≤ bn/2c − 1.

Rk = (k+1n )∗(k+1/n)n/2+2k+2

(nk)∗(k/n)n/2+2k (4.6)

= n−kk+1 ∗ (k+1k )n/2+2k∗ (k+1n )2 (4.7)

= (n−k)(k+1)n2 ∗ (1 + 1k)n/2+2k. (4.8)

Using the first three terms of the expanded form of (1 + 1k)n/2+2k we have:

Rk≥ (n − k)(k + 1)

Breaking out the first fraction into 1 + 3/8, and rearranging the rest we get:

Rk ≥ 1 + A + B + C + D + E where (4.11)

B = 8k94kn3 = 9n−68kn > 0 for n ≥ 1.

C = 114n4kn2 = 11n−16k4n211n−8n4n2 > 0 for k ≤ n/2.

D = 7k2n5kn22 = 7kn−10k2n2 27kn−5kn2n2 > 0 for k ≤ n/2.

E > 0, because all of the components are positive.

Therefore, Rk ≥ 1.

From Lemma 3 it follows that P rob[Er] ≤ P rob[Erbn/2c]. Therefore:

P rob[Er] ≤

 n n/2



∗ (1/2)3n/2 ≤ (e/4)n/2. (4.17)

This probability grows exponentially small with n.

It remains to show that P rob[Ef] ≤ P rob[Er] with the following Lemma:

Lemma 4 P rob[Ef] ≤ P rob[Er].

Proof: To prove Lemma 4 we need to show that under FairTorrent the event of n/2 + 2k load packets sent to a set of just k nodes, is not more likely to occur than the event where n/2 + 2k balls thrown at random are dropped into k bins.

Let us consider the FairTorrent process and how it differs from the random process of assigning packets to nodes. In FairTorrent a node will send out load packets based on the ordering of its locally randomized permutation of neighbors. When a peer Li has no negative deficit with a peer, it will send a load packet to the first peer on its randomized permutation Pi, with whom it has deficit 0. Thus, if Pi = {Lj, Lk, Ll, ...}

it will first send a load packet to Lj, then to Lk, then to Ll, etc... Since each neighbor is equally likely to occur in a given position of the list, each neighbor is equally likely to receive a load packet from Li, or any other peer. In fact, the way FairTorrent sends load packets is very similar to a random process.

However, there are two subtle difference between FairTorrent and a random pro-cess. First, Li never appears on its own randomized list, because it never sends a packet to itself. So in fact, the first peer on its list is selected at random from n − 1 total peers, instead of n. Second, because the list of peers is a permutation, each neighbor occurs only once on the list. Therefore, and this is the key difference, if Li sends 2 load packets, these packets will always go to different neighbors. It is because of this behavior that the load packets end up being “spread” in more balanced way than under a random process.

Let event Eli1 be the event that a FairTorrent peer Li sends a load packet to a particular subset S, of k peers in a n-node network. We want to show that P rob[Eli1] ≤ k/n, where k/n is the probability that a random process drops a ball into a subset S of k out of n bins.

First, let us consider the first load packet that Li sends, which it sends to the first neighbor on its randomized list. Let event Esi be the event that peer Li is itself a member of the subset S, and event cEsi be the event that it is not in this set.

P rob[Eli1] = P rob[Eli1|Esi] ∗ P rob[Esi] + P rob[Eli1|cEsi] ∗ P rob[cEsi] . (4.18) P rob[Esi] can be computed as the number of combinations of k peers that include Li divided by the total number of combinations of k peers. Thus,

P rob[Esi] =

If event Esi occurs, since Li does not send a packet to itself it can only choose among the remaining k − 1 members of the subset from the total of n − 1 neighbors.

Therefore, P rob[Eli1|Esi] = k−1n−1. If event cEsi occurs, then Li can send the first load packet to any of the k members of the subset, and P rob[Eli1|cEsi] = n−1k . Putting all these values into Equation 4.18, we have:

P rob[Eli1] = k − 1 n − 1∗k

n+ k

n − 1∗n − k

n = k

n∗k − 1 + n − k n − 1 = k

n∗n − 1 n − 1 = k

n . (4.21)

So the probability that Li sends the first packet to one of the peers in set S is k/n, or exactly the same as the random process choosing among n bins. The reason for this result is that two factors cancel each other out. On the one hand Li must hit one of the k − 1 peers if it happens to be a member of S, lowering the probability.

On the other hand, it only chooses among n − 1 neighbors and not n, increasing the probability.

Now let us consider what happens in case Li sends two load packets. Let Eli2 be the event that Li sends both load packets to the members of S. We have:

P rob[Eli2|Esi] = k−1n−1k−2n−2 and P rob[Eli2|cEsi] = n−1kn−1k−1. Observe that the numer-ator and the denominnumer-ator for the probability of the second packet are always reduced by one, because Li excludes from the set the peer to whom it sent the first packet.

We have:

P rob[Eli2] = P rob[Eli2|Esi] ∗ P rob[Esi] + P rob[Eli2|cEsi] ∗ P rob[cEsi] (4.22)

= k−1n−1n−2k−2kn+ n−1kn−1k−1n−kn (4.23)

= nkk−1n−1k−2+n−kn−2 (4.24)

= nkn−1k−1n−2n−2 (4.25)

= nkk−1n−1 (4.26)

< (k/n)2 f or 1 ≤ k < n . (4.27)

Therefore, P rob[Eli2] < (k/n)2, where (k/n)2 is the probability that a random process drops two balls in a subset of k bins. Using similar calculations we can show that the probability that a FairTorrent peer sends d ≥ 2 packets to the subset S is

< (k/n)d.

To sum up, if the total load on the system consists only of some peers sending a packet to the first peer on their respective lists, then P rob[Ef] = P rob[Er]. However, if some peers are responsible for more than 2 packets out of all the load packets, then P rob[Ef] < P rob[Er]. In all cases, P rob[Ef] ≤ P rob[Er]. We should point out that if the load on the system gets close to 3n/2 as was the bound suggested by Lemma 2, then on average each peer contributes 3/2 packets, and thus, P rob[Ef] < P rob[Er].

So we have P rob[Ef] ≤ P rob[Er] ≤ (e/4)n/2 This also concludes the proof of Lemma 2.

Using Lemma 2, we now prove the theorem. Since at the end of round t, the total number of owed packets in the system is at most 3n/2 with high probability, it implies that at the end of round t at most n/2 nodes have a queue of size ≥ 3.

Therefore, for a given Lj in the end of round t we have:

P rob[qj ≥ 3] ≤ 1/2 . (4.28)

Let us now consider the maximum deficit accumulated by a given peer Li in the end of round t. Lisends packets to peers in order of its locally randomized list. Let us consider the probability of the event Ek that Li incurs a deficit of at least (k1∗ log n) by the end of round t.

Let us observe that if there are at least 3 peers with queue sizes of ≤ 3 among the first (k1 ∗ log n) peers on L0is randomized list, then even if Li has sent a load packet to each of the first (k1 ∗ log n) peers by the end of round t − 3, at least 3 of these peers will reciprocate with a packet by the end of round t. Therefore, the probability of event Ek occurring is bounded by the probability that there are no 3 peers among the first (k1 ∗ log n) on L0is list that have a load of ≤ 3 in the end of round t − 3.

Conversely Ekdoes not occur if at least (k1∗ log n) − 2 of these peers have queue sizes greater than 3.

P rob[Ek] ≤ kk1log n

1log n−2 ∗ (1/2)k1log n−2+ kk1log n

1log n−1 ∗ (1/2)k1log n−1 (4.29) + kk1log n

1log n ∗ (1/2)k1log n (4.30)

< 6(k1nlog n)k1 2 . (4.31)

Taking the union bound over all n peers, the probability that Ek does not occur for any leecher Li in round t is at least 1 − 6(kn1k1−1log n)2.

Combining with the proof of the Lemma 2, we have that the probability no node

accrues more than k1∗ log(n) deficit in the end of round t is

P rob[N (t − 3) ≤ 3n/2] AN D P rob[Ek = F alse ∀Li] ≥ (4.32)

≥ 1 −6(k1log n)2

nk1−1 − (e/4)n/2 ≥ 1 − n−Ω(k1−2) . (4.33)

(The exponential term is dominated). This concludes the proof of Theorem 1.

We can now prove the following theorem that applies not just for a given round, but over a long duration of the experiment:

Theorem 5 For some positive constants k1, k2, where k1 > k2+ 2 > 0, in a n-node FairTorrent network over the duration of O(nk2) rounds, Emax+ ≤ k1log n blocks with probability at least 1 − n−Ω(k1−k2−2) .

This theorem follows from a simple union bound taken over O(nk2) rounds.

As an example, of the application of the theorem, consider a network of n = 100 leechers sharing a 1GB file, where each leecher uploads a 16KB block each second.

The download takes less than n2.5 rounds. Let k1 = 4.5, k2 = 2.5. With probability at least 1 − n12, no peer will ever accumulate a deficit of more than 4.5 log n or 30 blocks throughout the download of the file. Conversely, no peer will be ever owed more than 480 KB of data throughout the download of a 1GB file!