# How is 'availability' calculated in BitTorrent?

What does availability mean?

If three peers have 50% of all pieces but they have the same pieces, is the availability 0.5 or 1.5?

https://wiki.vuze.com/w/Availability suggests that it would be 0.5.

The major number of the Availability tells you how many copies of the least available piece of the torrent you currently see.

But then how is the fractional part calculated?

That Availability > 1.0 condition can be also reached with several peers having different pieces of data, so that combined they have all the pieces.

If there are no seeds, how can availability exceed 1?

Availability is calculated by the percent of pieces that can be downloaded. If the availability is 1 or more, then it is calculated by the piece with the least amount of peers having it.

The fractional is calculated by the percent of pieces that have more peers than the piece with the least.

For example (for a file with 10 pieces):

• One peer has only 8 pieces -> 0.8
• Three peers have the same 5 pieces -> 0.5
• Peer A has the first 5 pieces while Peer B has the last 5 -> 1.0
• Peer A have the first 8 pieces, while Peer B have the last 8 -> 1.6 (as all 10 pieces can be downloaded, and 6/10 pieces are carried by both peers)
• So is it `(# of peers who have the piece with the least peers) + (# of pieces that more people have than the piece with the least number of peers) / (total pieces)`? If that is true, there are 10 pieces, Peer A has pieces 0 to 5, Peer B has 2 to 7, and Peer C has 4 to 9, then the availability would be 1.6 (1 peer has piece 0, and more than one peer has pieces 2 to 7, even tough 3 peers have pieces 4 and 5). Jun 9, 2016 at 3:43
• Yeah pretty much. Jun 9, 2016 at 4:16

When a BitTorrent client calculates the availability of a torrent,
it first, for every piece, sums up how many different peers that piece can be downloaded from.

Then it finds the lowest sum. That sum is the integer part of the Availability.

After that it checks how many pieces that has that lowest sum.
The fractional part of the Availability is then calculated as:

``````(Nr_of_Pieces_in_torrent - Nr_of_Pieces_with_lowest_sum) / Nr_of_Pieces_in_torrent
``````

A Seed is a peer that has all the pieces in the torrent. Even if there is no seed in the swarm,
the availability can exceed 1 as long as every individual piece in the torrent is available from at least one peer.