中查找“BitTorrent协议详解”更多相关内容
中查找“BitTorrent协议详解”更多相关内容
- ·上一篇文章:SIP
- ·下一篇文章:Multicast
BitTorrent协议详解
BitTorrent is a protocol for distributing files. It identifies content by URL and is designed to integrate seamlessly with the web. Its advantage over plain HTTP is that when multiple downloads of the same file happen concurrently, the downloaders upload to each other, making it possible for the file source to support very large numbers of downloaders with only a modest increase in its load.
A BitTorrent file distribution consists of these entities:
- An ordinary web server
- A static 'metainfo' file
- A BitTorrent tracker
- An 'original' downloader
- The end user web browsers
- The end user downloaders
There are ideally many end users for a single file.
To start serving, a host goes through the following steps:
- Start running a tracker (or, more likely, have one running already).
- Start running an ordinary web server, such as apache, or have one already.
- Associate the extension .torrent with mimetype application/x-bittorrent on their web server (or have done so already).
- Generate a metainfo (.torrent) file using the complete file to be served and the URL of the tracker.
- Put the metainfo file on the web server.
- Link to the metainfo (.torrent) file from some other web page.
- Start a downloader which already has the complete file (the 'origin').
To start downloading, a user does the following:
- Install BitTorrent (or have done so already).
- Surf the web.
- Click on a link to a .torrent file.
- Select where to save the file locally, or select a partial download to resume.
- Wait for download to complete.
- Tell downloader to exit (it keeps uploading until this happens).
The connectivity is as follows:
- The web site is serving up static files as normal, but kicking off the BitTorrent helper app on the clients.
- The tracker is receiving information from all downloaders and giving them random lists of peers. This is done over HTTP or HTTPS.
- Downloaders are periodically checking in with the tracker to keep it informed of their progress, and are uploading to and downloading from each other via direct connections. These connections use the BitTorrent peer protocol, which operates over TCP.
- The origin is uploading but not downloading at all, since it has the entire file. The origin is necessary to get the entire file into the network. Often for popular downloads the origin can be taken down after a while since several downloads may have completed and been left running indefinitely.
Metainfo file and tracker responses are both sent in a simple, efficient, and extensible format called bencoding (pronounced 'bee encoding'). Bencoded messages are nested dictionaries and lists (as in Python), which can contain strings and integers. Extensibility is supported by ignoring unexpected dictionary keys, so additional optional ones can be added later.
本消息共4页,当前在第1页 1 2 3 4