Saturday, October 22, 2016

How BitTorrent Really Works

BitTorrent is both ambitious and simple. BitTorrent is a P2P protocol in which peers coordinate to distribute requested files. In order to resist downtime due to real-world seizure of computers, BitTorrent has had to progress to a fully distributed architecture, without any single point of failure. This is an impressive technical feat.

Even more impressive is that BitTorrent gets faster with additional content-fetchers, rather than slower. The classic economics of content distribution is suddenly inverted, rewarding high-desirability content.

It's no surprise then that BitTorrent is used nowadays for everything from sharing Linux ISO files to live broadcast streaming of sports and politics. BitTorrent's name is still controversial in many places because of its role as a subversive software. BitTorrent's power made it the first choice for piracy, which lead to many concluding that BitTorrent is only useful for piracy. While many ISPs and externally-administered networks attempt to block and trace BitTorrent, the fight has largely been lost.

By not placing restrictions on peers, BitTorrent opens itself up to a universe of attacks. Like other architectures, a combination of limited observability and sound mathematics is the solution. As we will see, the architecture prevents an evil actor from serving a corrupted file or causing undue load on the BitTorrent network.

Lastly, BitTorrent is forward-thinking. It contains an extension protocol that allows clients to design protocols that alter the behavior of peers, and enables peers to intelligently fall back upon the extensions supported by each. At the bottom of this is the basic peer protocol; ensuring that clients can agree on enough to simply serve the file if they share no extensions.

The Peer Protocol

When a peer wants to start sharing a file, they construct a metadata file that describes the attributes of the file as well as a number of options. BitTorrent uses bencoding for most data sent, which prefixes a data literal with a character describing its type and its length (if a string). The metadata will describe the files in the torrent, but also includes a SHA1 hash of each of the "pieces" or file fragments in the torrent. These fragments can be downloaded individually, allowing for streaming or for selective downloading.

The file's attributes are known as the "info" block and is what uniquely defines the torrent. The info block's hash is the torrent's unique identifier in the BitTorrent swarm of peers. This metadata file also announces a tracker that the torrent will be associated with. This is outside of the info block, to enable multiple tracker to track the same torrent and to have the same infohash.

This metadata file is half of what a downloader needs to know to download the file. The other half is the list of peers serving the torrent. Conventionally, a peer will query the torrent tracker for a list of peers serving the file. The distributed hash table, peer exchange, and local service discovery are all other methods. We will discuss the first later. The latter two can be thought of as "gossip" protocol extensions that allow peers to become known by the swarm. 

Now once a peer has a list of peers, and has connected to each of them over TCP (or the uTorrent transport protocol, not covered here), it now uses the peer protocol to fetch all of the files. These peer connections are bidirectional and have attributes set on them by either side. Peers will announce when they have finished downloading a piece, so that peers connected to them know whether they want anything from a certain peer.

A side may be interested, which means that they want "pieces" that the other peer has. A side may also be choking, which means that they're busy sharing with another peer. When a connection is both interested and unchoked, then data transmission happens. Peers will use "optimistic unchoking," or rotation of the choke list, to ensure that there is enough choke variability for the swarm to have a fair chance of progressing. Choking is done in order to limit the number of outbound TCP connections, to ensure that the communication switching overhead is low enough for a peer to be useful to those it is connected to.

Transmission only occurs when one side is interested and the other side is not choking. This enables peers to have a tit-for-tat where the peers which share the most freely are the ones which are able to access pieces the most rapidly. This localized enforcement of good behavior enables the network to scale upwards without collapsing. The hashing of all pieces sent ensure that no peers can "poison" the network by sending bad file fragments. This pervasive integrity checking was one of the things that allowed BitTorrent to succeed where its early competitors failed. 

DHT and Magnet Links

BitTorrent uses a DHT protocol to enable peer discovery without requiring communication with the centralized tracker. DHT "nodes" are not the same thing as torrent "peers," although a computer can be both. Nodes listen for DHT requests over UDP, while peers listen for the BitTorrent peer protocol over TCP. BitTorrent clients include a DHT node, which operates mostly as a querying "client" node.

The Kademlia-like DHT works by giving each DHT node an ID. IDs have a "closeness" metric that is computed by XORing two IDs together and interpreting the result as an unsigned integer. Nodes will know about other nodes which have a low XOR distance and will know about few nodes that have a high XOR distance.

A client makes a query for a torrent by using the hash of the metadata's info as an ID, and finding the node that it knows that is closest to the key. This node is then sent the request. If the node doesn't have the torrent, the node forwards the request to the node that is the closest to the ID that it knows. This process iteratively finds the node in the network that is the closest to the query's key. If the peer can't find a peer tracking the metadata's info hash, it will have to insert itself as the node responsible for the key into the DHT by introducing itself to the nodes closest to the key. 

In order to prevent a bad actor from registering other peers for torrents, the DHT includes a paper trail. The query will return a token. If the query fails, this token must be presented by the peer trying to register itself as responsible for the key. Tokens are only valid for approximately ten minutes.

A node constructs a list of peers by searching the DHT for nodes closest to its own node ID. Most of the peers the node knows will have nearly keys. A few exceptions will exist because of other observed nodes through other network operations. In this way, nodes tend to construct a very "localized" view of the network that makes it faster to narrow in on a single key quickly. 

Now this DHT is quite simple, it associates peers with a torrent. In order to get the querying node enough information to begin downloading the torrent, the network must serve the torrent's metadata file as well. This newer feature is referred to as a "magnet" link, and enables a peer to complete an entire download using only the node ID. Trackers using magnet links need only provide links with hashes, rather than indexing and serving a collection of torrent metadata files.

Private Torrents

BitTorrent is a very inclusive network in its default state. The Distributed Hash Table, peer exchange, and local service discovery can all help a peer find other peers without having to rely on the tracker. While this is typically a good thing, it can be undesirable to remove the ability to control file distribution centrally.

One frequent use case for centralized control is to enforce a share ratio. When a community shares many files, it becomes important to enforce that peers upload an acceptable ratio of data to what they download.

This fine-grained access control is done by restricting peer information querying to those peers that the private tracker decides should be able to download the file. This is really security through obscurity.
Once an intruder peer has obtained the IP address and port of a peer, regardless of the source, the intruder can initiate a connection to that peer and trade pieces with the peer. Once in the swarm, the intruder is granted equal treatment as all other peers. 

What happens is that the torrent's metadata file includes a "private" flag that tells peers to only use the tracker to exchange peers. Furthermore, a client may only use the peers from a single private tracker at a given time for a given torrent. This prevents a peer from uploading a private metadata file to a public tracker and having the existing swarm serve the file.


We're seeing a lot of new innovation in the BitTorrent sphere recently.

BitTorrent's power is proportional to its convenience. The associations with piracy have led to BitTorrent software that requires that one jump through a lot of hoops in order to use the software sometimes. You can only download from BitTorrent what peers are seeding through BitTorrent. Convenience is largely the reason that many consumers have abandoned piracy torrents in exchange for services like Netflix and Spotify.

PopcornTime ( is an example of the power of BitTorrent with good content indexing and a nice UI. While it is plagued by the fact that it is a piracy-focused tool, PopcornTime represents a fairly flexible CDN system for popular media. One can imagine clones for open-access media and for news. What's worth noting is that the cost of running PopcornTime is absolutely minuscule for the software creators, especially compared to the behemoth infrastructure of Netflix. With good copy protection on media, BitTorrent may one day be seen as the powerful content-agnostic technology that it is.

BitTorrent is useful for a lot more than shuffling around large files though. WebTorrent uses the newer webrtc browser features which enable P2P data channels. Browsers are now able to act as peers, making the ecosystem much more flexible. It's worth noting that WebTorrent peers are not compatible with BitTorrent peers due to the use of webrtc for transport, rather than naked tcp sockets. As well as serving large media files, torrents can now serve static websites. Peers can send messages and media between each other in realtime chats without relying on a centralized server. With enough adopters, webTorrent may invert the economics of web hosting. Popular sites will be cheaper to host than less popular sites, without having to fall back on advertisement networks.

The web2web ( project uses bitcoin and BitTorrent together to replace the entire web stack. The blockchain is searched for the last outgoing transaction from a given address. This transaction uses the OP_RETURN bitcoin opcode to define the transaction as invalid, and stashes the torrent infohash in the transaction's body. This hash is enough to fetch the website being served through WebTorrent.

CacheP2P ( uses WebTorrent to offer a website cache. The reasoning is that popular content is likely to have a nearby peer which is closer than the nearest CDN server. CacheP2P, it's worth noting, costs the website maintainer nothing and costs each of the site's visitors a very small amount of traffic. This stands in contrast to the expensive caching infrastructure necessary to blanket a country or the globe. If a site becomes more popular in a certain area, CacheP2P will bring more cache servers to the region automatically. This latter point is a good enough argument alone.



  1. Bittorrent is going to get a lot of innocent people thrown in jail once hackers figure out that the justice system in America is stupid enough to not know how torrenting works with regards to kiddy porn.

    1. In other words, said hacker (say from russia or china) hacks your PC, opens up a background torrenting connection downloading and streaming kiddy porn, FBI or whoever gets tipped off about said kiddy porn, and then traces the streaming IP to your house where your PC has 101 local copies of said offending item, then you are facing life in prison in some states. (like oklahoma)

      I have a friend that is having this exact thing happen to him because he was stupid enough to clean other people's windows PC's of viruses and connecting them to the internet. The pc had run at startup torrenting software running in the background and it was streaming out child pornography from his IP without his knowledge.

      Imagine if this happened to 1% of all the people compromised in botnets. The motivation is there certainly.

    2. In other words, said hacker (say from russia or china) hacks your PC, opens up a background torrenting connection downloading and streaming kiddy porn, FBI or whoever gets tipped off about said kiddy porn, and then traces the streaming IP to your house where your PC has 101 local copies of said offending item, then you are facing life in prison in some states. (like oklahoma)

      I have a friend that is having this exact thing happen to him because he was stupid enough to clean other people's windows PC's of viruses and connecting them to the internet. The pc had run at startup torrenting software running in the background and it was streaming out child pornography from his IP without his knowledge.

      Imagine if this happened to 1% of all the people compromised in botnets. The motivation is there certainly.

  2. I have a small doubt. When a peer(say A) wants to download a file which is present with 4 other peers (say B, C, D, E). And the file has 32 "pieces" or hashes. How does A ask for fragments of file from B, C, D and E without repeating the same fragment request to different peers ? For example, It might be possible that A is asking for piece number 15 , and both D and E are sending that fragment. How is this avoided ?

    1. It's generally solved with a handshake where the client decides from whom it's going to accept the offered pieces.

      Some client might actually download redundant data during this step, to gauge the possible upload rates of the different peers.

    2. Oh meaning during the handshake, the client will mention a list of pieces it wishes to download from each peer. So in way, A already decides which pieces to ask for from each peer. Right? Something like A decides pieces 1,3,5,7 from B and 2,4,6,8 from C. And then it initiates request to the peers.

  3. The article that you had shared with us was really very interesting. I read your complete article again & again and found that something is missing. To make it more interesting or easily understandable for end user you should cover this topic also. Just have a look to this What is Torrenting, you will definitely got something new.

  4. Actually this was an awesome blog post. You have a very inspiring way of exploring and sharing your thoughts. I enjoyed reading your stuff.  hank you. Xmodgames App
    Xmodgames android features

  5. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.

    Virtual Edge

  6. Thanks for sharing your honest experience. When I first took a look at my head shots,
    I wasn’t too thrilled with mine but you’ve given me a new perspective!

    Virtual Edge

  7. So you are suggested to scan every file that you download for viruses, download the movie released by trusted sources in the community and check comments and ratings to see whether others suffer from virus attacks with the torrents. NordVPN Torrenting

  8. Apple finally released iOS 11 beta 4 download profile for iPhone and iPad developers. The iOS 11 update is available to download. There is no need to register an iOS UDID to run the latest firmware.

  9. We know Apple is preparing next-generation iPhone 8, and it will be running all-new iOS 11 firmware.

  10. Thank you for your article, it is very useful for me! I agree that Bittorrent is a fast program. With it, I manage to download files very quickly. But recently there was a problem. I did not know how to open .torrent file . As usual, Google helped me! Now I can quickly download and open files.

  11. This aides in accelerating the downloading and this gets clustered together and made into a greater unit. how to torrent download

  12. I read full article its very helpful for me thanks.
    Perfect Cracks

  13. It is good for everyone having this thing best IDM Free Download Crack

  14. Apple is getting ready for the launch of iOS 12 beta for developers. If you are interested in downloading/installing iOS 12 beta on iPhone or iPad device. It is now time to prepare for the rollout of iOS 12 update for your devices.

  15. This is conceivable by setting off to the transfer page of the site and searching for something that says 'Tracker URL'.

  16. This comment has been removed by the author.

  17. best pressure cooker. specific adversary techniques (You can change this and create your own metrics. This is just my opinion)

  18. sad shayari. and i don't want to learn theirs".

  19. There is a new mod that allows multiple new functionalities that were not available originally on the default version.

  20. Wondershare Filmora Crack is a simple but powerful video editing software. This software, with the benefit of a modern and elegant interface, encourages you to use it over and over again to beautify your videos.

  21. I have read some good stuff here. Certainly price bookmarking for revisiting. I surprise how so much effort you put to create this sort of fantastic informative web site.Express Invoice Crack

  22. God gave you a gift of 86,400 seconds today. Have you used one to say, ‘thank you’
    Shadow Defender Crack Setup

  23. Great Article. I am learning to be social on SM and learning to blog etc. So all your info helps
    IObit Malware Fighter Pro Crack Setup

  24. i love this 1 best luck

  25. i love this 1 best for all

  26. best way to recover your phone

  27. Best way to break your phone unlock

  28. I know this site provides good content and more information,
    Are there any websites that offer these features and quality?
    wondershare safeeraser crack
    autopano video pro crack
    reimage pc repair 2019 crack

  29. Yeah Thats the VST Crack Site You Can Download From Given Link WavSupply Nick Mira Gasolina 3 Torrent

  30. I really love your blog.. Great colors & theme.
    Did you develop this website yourself? Please reply
    back as I’m hoping to create my own site and would love to know
    where you got this from or just what the theme is named.
    Thank you!
    navicat premium crack
    revo uninstaller pro crack
    kmplayerpro crack
    samdrivers crack
    movavi pdf editor crack
    advanced system care ultimate crack

  31. It is critical to recall that during the game, the primary concern is to stop as expected so as not to lose all the cash or not go into a misfortune
    Wise Registry Cleaner Pro Crack
    Positive site, where did u come up with the information on this posting?
    Tuneup Utilities Pro Crack
    I'm pleased I discovered it though,
    Safe365 SD Card Data Recovery Wizard Crack
    ill be checking back soon to find out what additional posts you include
    MKVToolNix Crack
    The aftereffect of the wager is consistently speedy, for instance, a single move of dice,
    Cyberlink PowerDVD Crack
    Regardless, everybody can locate an appropriate kind of betting for themselves.

  32. Huh! Thank you! I need to write similar content permanently on my website. Can I put parts of your posts on your website?
    mixpad 6 09 crack
    minitool video converter crack
    anytrans crack
    blufftiler ultimate crack
    nordvpn crack


  33. Is this a paid topic or do you change it yourself?
    However, stopping by with great quality writing, it's hard to see any good blog today.

    UltraISO Crack

  34. I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me
    Garritan CFX Concert Grand Crack
    ProgDVB Professional Crack
    WinCatalog Crack
    BlueStacks Crack

  35. Its in truth robust for you essentially all window programming set up. This page is confounding its article are critical and charming. I took pride in and bookmark this page on-line on my chrome. This is in which you may get all harm programming in easy way.

  36. Its in reality strong for you basically all window programming installation. This page is confounding its article are important and charming. I took delight in and bookmark this web page on-line on my chrome. This is wherein you may get all harm programming in smooth manner.

  37. Google's algorithms for websites and their content are updated on a regular basis. As a result, web-based SEO professionals are always attempting to understand Google's new algorithms in order to build up websites appropriately. Every day, a new SEO myth arises, leaving the SEO community perplexed as to what they should do to reclaim organic and other targeted traffic to their websites. Your site will not operate effectively without adequate Search Engine Optimization, and you will not be able to see the intended results. Many businesses provide various sorts of SEO services. If you want to learn more about SEO and the many fallacies surrounding it, check out our list of 10 SEO Myths.
    N-Track Studio Suite Crack

    Quick Heal Antivirus Pro Crack

    Personal Backup Crack

    Avid Pro Tools Crack

    ReaConverter Pro Crack

    AquaSoft Stages Crack

  38. I am very thankful for the effort put on by you, to help us, Thank you so much for the post it is very helpful.
    HWMonitor pro crack
    Winthruster Crack
    Duplicate Cleaner Pro Crack
    Netbalancer Crack
    Dbschema Crack

  39. Positive Grid BIAS FX 2 Crack Mac is a professional plugin for guitar effects. Bias FX continues to use Positive Grid’s positive algorithms and techniques, and precise component simulations guarantee sound quality.
    Adguard Crack
    Zemana Antimalware Crack
    iPhone Backup Extractor Crack

  40. Appreciation is a wonderful thing...thanks for sharing kepp it up.BitTorrent Pro Crack

  41. This site have particular software articles which emits an impression of being a significant and significant for you individual, able software installation.This is the spot you can get helps for any software installation, usage and cracked.

    UltraISO Premium Crack
    Extreme Picture Finder crack
    Wondershare Recoverit Crack
    iTools crack
    ScriptCase Crack

  42. Thanks for the detailed article on this topic. I would like to see more such awesome articles from you. Also you can get the new and best features of FMWhatsapp which are coming in 2022-

    FMWhatsapp APK

  43. Thanks For Sharing, Here New Version Available;

  44. wonderful software, I use this software. Very nice. og whatsapp

  45. Someone is necessarily helping in creating critical articles I can name.
    This is the first time you visit your site and so far? I was amazed at the analysis you did to create this amazing current edition.
    Fantastic Process!
    pycharm crack
    plex media server crack

  46. Wow, great blog structure! How long has
    have you ever blogged? They made it easy to blog.
    The overall look of your website is great to say the least
    iobit start menu 8 pro crack
    sketchup pro crack
    zemana antimalware crack

  47. Hi! This is a great problem, but I'd love suggestions from a reliable blog.
    Is it difficult to begin your own blog? I'm not the best at technical.
    But, I am able to grasp the concepts quickly.
    I'm contemplating creating my own version of it, however I'm not sure how to start.
    Do you have any thoughts or suggestions?
    winarchiver crack


  48. The reason being that features available on this mod are far superior to that of present in the default versions. FMWhatsApp will help you to run Dual Whatsapp account in a single Android device.

  49. Strokes Maker Crack is a unique software product designed for creating vector engraving and vector art of raster images.The app has evolved to improve its functionality and add cool new effects in the coming years.
    Key Features Of Strokes Maker 2022:
    Vector drawing
    Quality vector graphics
    Friendly interface

  50. Nice information. I’ve bookmarked your site, and I’m adding your RSS feeds to my Google account to get updates instantly. AnyMP4 Video Converter Crack

  51. your article so amazing and informative. Your writing skill is also very well. Your article is really addictive. Keep posting. keep sharing the knowledge. I love to read your articles.
    english stories english short stories with moral value What is the factorial of 100

  52. This is very informative and interesting for those who are interested in blogging field. Try the latest version of Whatsapp Aero Apk

  53. Really Good Work Done By You...However, stopping by with great quality writing, it's hard to see any good blog today.
    Dragon Naturally Speaking Crack
    Crack Softwares Free Download

  54. I admire your work. This is fantastic data. I'm blown away by your post because it's very helpful to me and provides me with new information.

  55. I like and appreciate your efforts, and I appreciate you sharing them with us.
    BitTorrent pro Crack

  56. Thanks for sharing this with us. I just loved your way of presentation. I enjoyed reading this .Thanks for sharing and keep writing.
    Audio Hijack Crack
    SoftMaker Office Pro Crack
    Camtasia Studio Crack


  57. Pretty great post. I simply stumbled upon your blog and wanted to mention that I have really loved surfing around your blog posts. Great set of tips from the master himself. Excellent ideas. Thanks for Awesome tips Keep it