If you’re really addicted to the Internet, you should’ve definitely used torrents (especially BitTorrent). Let’s jump into it. Wait, Wait… I don’t wanna explain the whole thing, and I won’t..!!! That’s not really the point of my blog posts. What I really wanna do, is make things much simpler (just following the “Occam’s Razor“, like I’ve told you before) so that even a layman can understand (that’s our motto).
Wherever you go around and search for the magical mystery behind this “thing”, you’ll come across the introductory definition, that BitTorrent is a peer-to-peer (P2P) file-sharing protocol. Say what, the project site itself is a good place to start, as people say. µTorrent, BitTorrent, etc. are a few examples of the clients that use this BitTorrent protocol (precisely, it’ the software you use). Next stop, File sharing…
To help us analogy-fy, let’s introduce the characters in play Amy, Bob, John & Robert. Now, let’s say that Amy has a chocolate. Not quite… We’re discussing tech stuff. So, let’s smooth out this discussion by using upload, download and transfer rates. I can’t give up chocolates, and so I’ll include both. Amy has a file which the other people like to download. She can also have chocolates for my desire.
Downloading from “Hello world”…
Before we begin to understand this P2P scheme, let’s skim carefully through downloading. In normal downloading, your browser is the client. You open a webpage, click the link and download the file. A few things are going on here. When you click the download link, the client requests permission to gain access to the file. The server handles a protocol, which are simply a set of rules, that govern how the data transfer should be going on, etc. You should’ve heard HTTP or FTP (they’re the “them”). Now, it locates and gives you a copy of that file (using the protocol).
John’s hands (client) target Amy’s chocolate. Amy can give it any way she likes*. She can throw it directly, or ask John to come to her and get it (the protocols). This has a few issues. What if Bob and Robert were race to the front? Amy doesn’t have a lot of hands and now, someone is gonna experience a delay. This is what we call traffic. Hence, the transfer rate for this kind of sharing depends on a number of parameters like traffic, number of users allowed at a time, type of protocol, etc. You should imagine this much better. Because in reality, there won’t be just John and Bob aiming Amy…
[*]: The chocolate analogy is very crude. It looks like it holds good. But, think again… No free lunches (like you get in computer). How can you get a copy of the chocolate? That’s where it sucks.
Let’s begin the P2P file sharing…
Here, we have a whole new set of things such as seeds, peers, trackers, etc., which enforces us to give up chocolates. A few weeks ago, a post caught my sight on Quora covering the same topic. As I think it would fit our simplicity motto, I’ll incorporate the basic idea (precisely) into this post. And, I‘m quite dumb to make such beautiful graphics. So, I’ll go with the classic tables…
Okay… Now, Amy has a 12 MB file in her PC and John wants it. Bob & Robert too wanna rob it. Before that, let’s declare that everyone can transfer up/down at a rate of 3 MBps. So, Amy decides to do it this way. Amy sends the file to all the three at the same time (1 MBps to each). Amy’s upload rate (3 MBps) is fully occupied. But, John, Robert and Bob have only got 1 MBps download rate. So, it takes literally 12 seconds for the whole file to be shared.
|Upload (MB/s)||Download (MB/s)|
Amy is somewhat clever and thinks of a new efficient way (a new protocol). Amy divides the file into four pieces (a,b,c,d). During Phase 1, the first piece (a) is sent to John, (b) to Bob, (c) to Robert and she keeps the “fourth” (d) with herself. So, the first time the pieces are shared, Amy’s bandwidth is fully occupied. But, the other three experience only 1 MBps down and “NO” up speed. 3 seconds gone.
|(PHASE 1)||Upload (MB/s) / Pieces||Download (MB/s) / Pieces|
|Amy||3 / (a,b,c)||—|
|John||—||1 / (a)|
|Bob||—||1 / (b)|
|Robert||—||1 / (c)|
During the Phase 2, Amy uploads her 4th piece. John downloads 4th piece from Amy, along with 2nd piece from Bob and 3rd piece from Robert, while he uploads the 1st piece. His download rate is fully occupied now. The same goes to Bob & Robert.
|(PHASE 2)||Upload (MB/s) / Pieces||Download (MB/s) / Pieces|
|Amy||3 / (d)||—|
|John||1 / (a)||3 / (b,c,d)|
|Bob||1 / (b)||3 / (a,c,d)|
|Robert||1 / (c)||3 / (a,b,d)|
Within the next 3 seconds (totally, 6 seconds), the file has been shared successfully. Somehow, Amy’s new set of rules (protocol) has reduced the transfer time by one-half. This is what BitTorrent does. Again, you should imagine this much
better bigger. Because in reality, there won’t be just John, Robert and Bob targeting Amy. Think of the traffic…
Clever BitTorrent protocol…
Seeds are those who have the complete files (here, it’s Amy) and Peers are those who have the partial files (pieces). For example, if (somehow) Bob unfortunately got struck by a power shutdown and loses his connection and returns back after a few minutes, he sees 3 seeders (now, he’s a peer). There are bad people (like me) who, once they’ve got the whole file, quit their seeding (I’m not merciless, that I do seed sometimes). By this way, the up/down rate of others are terribly affected (especially, when the torrent has low seeds). So, these people are called as bloody leechers. In order to reduce this effect (unlike normal P2P sharing), BitTorrent uses the “up/down at the same time” method. You may have noticed this in Amy’s efficient way…
Now, have a look at this horrible thing…
Note the pieces. BitTorrent does its work smartly & effectively, by dividing the stuff into thousands of pieces, so that the individual pieces are always multiples of bytes (n=18, here). For any kind of file, you won’t be able to upload until you get your first piece (which can be at any positions of the download). But once you get the piece (takes only a matter of seconds), BitTorrent starts your uploading automatically. As for my file above, though I have more than half the pieces, I can’t (by any means) complete my download. Why? Look again, The seeds..!!! They’re zero, which means that the estimated time is literally “infinite” (unless you’re lucky, that someone peeks up sometime and spews some pieces for you, which reasons out why I have this for more than two weeks).
No matter how many peers a torrent has got, if it has no seeds, then it’s dead for sure…