BitTorrent Protocol Specification V1.0

xiaoxiao2021-03-06  16

Note:

http://wiki.theory.org/bittorrentspecification, headline is BitTorrent Protocol Specification V1.0. It is better than

Http://www.bitconjurer.org/bittorrent/Protocol.html is more detailed.

BitTorrent Protocol Specification V1.0

Identification

BitTorrent is a peer-to-peer file sharing protocol designed by Bram Cohen. Visit his pages at http://www.bitconjurer.org. BitTorrent is designed to facilitate file transfers among multiple peers across unreliable networks.

Purpose

The purpose of this specification is to document version 1.0 of the BitTorrent protocol specification in detail. Bram's protocol specification page http://www.bitconjurer.org/BitTorrent/protocol.html outlines the protocol in somewhat general terms, and lacks behaviorial detail in Some area. The Hope is this Document Will Become A Formal Specification, Written In Clear, Unambiguous Terms, Which Can Be Used As A Basis for Discussion and Implementation In The Future.

This document is intended to be maintained and used by the BitTorrent development community. Everyone is invited to contribute to this document, with the understanding that the content here is intended to represent the current protocol, which is already deployed in a number of client implementations.

This is not the place to suggest feature requests. For That, please go to the mailing list.

Scope

This document applies to the first version (ie version 1.0) of the BitTorrent protocol specification. Currently, this applies to the torrent file structure, peer wire protocol, and the Tracker HTTP / HTTPS protocol specifications. As newer revisions of each protocol are defined, The Should Be Specified On Their Own Separate Pages, Not here.

Related Documents

http://www.bitconjurer.org/BitTorrent/protocol.html - The official protocol specification.BitTorrentWishList - A wish list for developers and end users alike.BitTorrentTrackerExtensions - Describes the various extensions of the Tracker protocol that are in use.Conventions

In this Document, a Number of Conventions Are Used In A Concise and Unambiguous Fashion.

peer v / s client:.. In this document, a peer is any BitTorrent client participating in a download The client is also a peer, however it is the BitTorrent client that is running on the local machine Reader of this specification may choose to think of themselves as the client which connects to numerous peers piece v / s block:. in this document, a piece refers to a portion of the downloaded data that is described in the metainfo file, which can be verified by a SHA1 hash A block. is a portion of data that a client may request from a peer Two or more blocks make up a whole piece, which may then be verified defacto standard:.. Large blocks of text in italics indicates a practice so common in various client implementations of BitTorrent That it is considered a defacto standard.

In order help others to find recent changes that have been made to this document, please fill out the change log (last section). This should contain a brief (ie one-line) entry for each major change that you've made to the Document.

Bencoding

Bencoding is a Way to Specify and Organize Data ITA TERSE FORMAT. IT Supports The Following Types: Byte Strings, INTEGERS, LISTS, AND DICTIONARIES.

BYTE STRINGS

Byte strings are encoded as follows: : Note that there is no constant beginning delimiter, and no ending delimiter Example:. 4: spam represents the string "spam" integers

Integers are encoded as follows: i e The initial i and trailing e are beginning and ending delimiters You can have negative numbers such as i-3e You can not prefix the number with a zero such as i04e.. HOWEVER, I0E IS Valid.example I3E Represents the integer "3"

Lists

.

Lists May Contain Any Bencoded Type, Including Integers, Strings, Dictionaries, And Other Lists.

Example: L4: SPAM4: Eggse Repesents The list of two strings: ["spam", "eggs"]

Dictionaries

.

Note that the keys must be bencoded strings. The values ​​may be any bencoded type, including integers, strings, lists, and other dictionaries. Keys must be strings and appear in sorted order (sorted as raw strings, not alphanumerics).

EXAMPLE: D3: COW3: MOO4: SPAM4: Eggse Repesents The DICTIONARY {"COW" => "Moo", "spam" => "Eggs"} Example: D4: spaml1: a1: bee represents the dictionary {"spam" = > ["a", "b"]}

Metainfo File Structure

All Data I MetaInfo File Is Bencoded. The Specification for Bencoding IS Defined Above.

.. The content of a metainfo file (the file ending in ".torrent") is a bencoded dictionary, containing the keys listed below All character string values ​​are UTF-8 encoded Keys not marked 'optional' are required fields: info: a dictionary that describes the file (s) of the torrent There are two possible forms:. one for the case of a 'single-file' torrent with no directory structure, and one for the case of a 'multi-file' torrent, which CAN Contain Subdirectory Trees.

For the case of the

SINGLE-FILE MODE, THE

Info Dictionary Contains The Following Structure

length: length of the file in bytes (integer) md5sum:. (optional) a 32-character hexadecimal string corresponding to the MD5 sum of the file This is not used by BitTorrent at all, but it is included by some programs for greater compatibility . name: the filename of the file This is purely advisory (string) piece length:.. number of bytes in each piece (integer) pieces: string consisting of the concatenation of all 20-byte SHA1 hash values, one per piece (byte String)

For the case of the

Multi-file mode, the

Info Dictionary Contains The Following Structure

Files: a List of Dictionaries, One for Each File. Each Dictionary in this List Contains The Following Keys:

length: length of the file in bytes (integer) md5sum:. (optional) a 32-character hexadecimal string corresponding to the MD5 sum of the file This is not used by BitTorrent at all, but it is included by some programs for greater compatibility . path: a list containing one or more string elements that together represent the path and filename Each element in the list corresponds to either a directory name or (in the case of the final element) the filename For example, a the file ".. Dir1 / Dir2 / File.ext "Would Consist of Three String Elements:" DIR1 "," Dir2 ", and" file.ext ". this is encode as a bencoded list of strings such as L4: Dir14: Dir28: file.exte name: the name of the top-most directory in the structure - the directory which contains all of the files listed in the above files list (character string) piece length: number of bytes in each piece (integer) pieces: string consisting. Of The Concatenation of All 20-byte Sha1 Hash Values, One Per Piece (Byte String) Announce: The Announce URL of the tracker (string) announce-list: (optional) this is an extention to the official specification, which is also backwards compatible This key is used to implement lists of backup trackers The full specification can be found at http:.. // Home.elitracker-spec.txt Creage Date: (optional) The Cree Of EPOCH FORMAT (Integer Seconds Since 1-Jan-1970 00:00:00 UTC) Comment : (OPTIONAL) Free-form textual comments of the author (string) create by: (optional) name and version of the program named to create the .torrent (String)

Notes

The piece length specifies the nominal piece size, and is usually a power of 2. The piece size is typically chosen based on the total amount of file data in the torrent, constrained by the fact that too small a piece size will result in a large .torrent metadata file, and piece sizes too large cause inefficiency The general rule of thumb seems to be to pick the smallest piece size that results in a .torrent file no greater than approx 50 -.. 75 kB The most common sizes are 256. kB, 512 kB, and 1 MB. Every piece is of equal length except for the final piece, which is irregular. The number of pieces is thus determined by 'ceil (total length / piece size)'. for the purposes of piece boundaries in the multi-file case, consider the file data as one long continuous stream, composed of the concatenation of each file in the order listed in the files list. The number of pieces and their boundaries are then determined in the same manner as the case OF A SINGLE FILE. PIECES May Overlap File Boun daries. Each piece has a corresponding SHA1 hash of the data contained within that piece. These hashes are concatenated to form the pieces value in the above info dictionary. Note that this is not a list but rather a single string. The length of the string Must be a multiple of 20 bytes.tracker http / https protocol

The tracker is an HTTP / HTTPS service which responds to HTTP GET requests. The requests include metrics from clients that help the tracker keep overall statistics about the torrent. The response includes a peer list that helps the client participate in the torrent. The base URL consists of the "announce URL" as defined in the metadata (.torrent) file. The parameters are then added to this URL, using standard CGI methods (ie a '?' after the announce URL, followed by 'param = value' sequences Separated by '&') Note That All Binary Data IN THE URL (Particular INFO_HASH AND Peer_ID) Must Be Properly Escaped. This Means Any Byte Not in The Set 0-9, AZ, AZ, And $ -_. ! * ' (), Must Be encoded sales the "% nn" format, where nn is the hexadecimal value of the byte. (see rfc1738 for details).

The Parameters Used in The Client-> Tracker Get Request Area Follows:

info_hash:. 20-byte SHA1 hash of the value of the info key from the Metainfo file Note that the value will be a bencoded dictionary, given the definition of the info key above Note:. This string is always urlencoded, as opposed to peer_id , which needs to be unencoded peer_id:... 20-byte string used as a unique ID for the client, generated by the client at startup This is allowed to be any value, and may be binary data There are currently no guidelines for generating this peer ID. However, one may rightly presume that it must at least be unique for your local machine, thus should probably incorporate things like process ID and perhaps a timestamp recorded at startup. See peer_id below for common client encodings of this field. port : The port number that the client is listening on Ports reserved for BitTorrent are typically 6881-6889 Clients may choose to give up if it can not establish a port within this range uploaded:... The total amount uploaded (since the client sent the ' Started 'EV ent to the tracker) in base ten ASCII While not explicitly stated in the official specification, the concensus is that this should be the total number of bytes uploaded downloaded:.. The total amount downloaded (since the client sent the 'started'

. Event to the tracker) in base ten ASCII While not explicitly stated in the official specification, the consensus is that this should be the total number of bytes downloaded left:. The number of bytes this client still has to download, encoded in base ten ASCII no_peer_id:... Seems to be used by Experimental BitTorrent client and Clients such as ABC to tell the tracker if the client has no peer_id 1 means that the client has a peer id and 0 means unknown Peer id Trackers should not allow this to be 0. compact: Used in some bittorrent trackers to check if the Tracker is in compact mode event:. If specified, must be one of started, completed, stopped, (or empty which is the same as not being specified) If not. specified, then this request is one performed at regular intervals.started: The first request to the tracker must include the event key with the started value stopped:. Must be sent to the tracker if the client is shutting down gracefully completed:. Must be Sent to the Tracker Whe N The Download Was Already 100% Complete When the client started. PResum all, this is to allow the tracker to increment the "completed downloads"

metric based soley on this event ip:. Optional The true IP address of the client machine, in dotted quad format or rfc3513 defined hexed IPv6 address Notes:.. In general this parameter is not necessary as the address of the client can be determined from the IP address from which the HTTP request came. The parameter is only needed in the case where the IP address that the request came in on is not the IP address of the client. This happens if the client is communicating to the tracker through a proxy (or a transparent web proxy / cache.) It also is necessary when both the client and the tracker are on the same local side of a NAT gateway. The reason for this is that otherwise the tracker would give out the internal (RFC1918) address of the client, which is not routeable. Therefore the client must explicitly state its (external, routeable) IP address to be given out to external peers. Various trackers treat this parameter differently. Some only honor it only if the IP address that the requ est came in on is in RFC1918 space Others honor it unconditionally, while others ignore it completely In case of IPv6 address... (eg: 2001: db8: 1: 2 :: 100) it indicates only that client can communicate via IPv6 numwant :.. Optional Number of peers that the client would like to receive from the tracker This value is permitted to be zero If omitted, typically defaults to 50 peers.The tracker responds with "text / plain" document consisting of a bencoded dictionary with. The Following Keys:

failure reason:. If present, then no other keys may be present The value is a human-readable error message as to why the request failed (string) interval:. Interval in seconds that the client should wait between sending regular requests to the tracker complete: number of peers with the entire file, ie seeders (integer) incomplete: number of non-seeder peers, aka "leechers" (integer) peers: The value is a list of dictionaries, each with the following keys: peer id: Peer's self-selected id, as described Above for the Tracker Request (String) IP: Peer's IP Address (Either IPv6 or IPv4) or DNS Name (String) Port: Peer's Port Number (Integer)

As mentioned above, the list of peers is length 50 by default. If there are fewer peers in the torrent, then the list will be smaller. Otherwise, the tracker randomly selects peers to include in the response. The tracker may choose to implement a More Intelligent Mechanism for Peer Selection When Responding to a Request. for Instance, Reporting Seeds To Other Seeders Could Be Avoided.

Clients may send a request to the tracker more often than the specified interval, if an event occurs (ie stopped or completed) or if the client needs to learn about more peers. However, it is considered bad practice to "hammer" on a tracker To get Multiple Peers. if aclient Wants A Large Peer List in The Response, Then It Should Specify The Numwant Parameter.

Tracker 'Scrape' Convention

By convention most trackers support another form of request, which queries the state of a given torrent (or all torrents) that the tracker is managing. This is referred to as the "scrape page" because it automates the otherwise tedious process of "screen scraping "the tracker's stats page.The scrape URL is also a HTTP GET method, similar to the one described above However the base URL is different to derive the scrape URL use the following steps:... Begin with the announce URL Find the last ' / 'in it. If the text immediately following that' / 'is not' announce 'it will be taken as a sign that that tracker does not support the scrape convention. If it does, substitute' scrape 'for' announce ' To find the scrape page.

Examples: (Announce Url -> Scrape URL)

Http://spam.com/announce -> http://spam.com/scrape

Http://spam.com/x/announce -> http://spam.com/x/scrape

Http://spam.com/announce.php -> http://spam.com/scrape.php

http://spam.com/a -> (Scrape Not Supported)

Http://spam.com/announce?x=244 -> http://spam.com/scrape?x=244

Http://spam.com/announce?x=2/4 -> (Scrape Not Supported)

http://spam.com/x4announce -> (Scrape Not Supported)

Note Especially That Entity UNQUOTING IS DOCUMENTED ARCHIVE: http://group.yahoo.com/group/bittorrent/Message/3275

The scrape URL may be supplimented by the optional parameter info_hash, a 20-byte value as described above. This restricts the tracker's report to that particular torrent. Otherwise stats for all torrents that the tracker is managing are returned. Software authors are strongly encouraged to use the info_hash parameter when at all possible, to reduce the load and bandwidth of the tracker.The response of this HTTP GET method is a "text / plain" document consisting of a bencoded dictionary, containing the following keys

files: a dictionary containing one key / value pair for each torrent for which there are stats If info_hash was supplied and was valid, this dictionary will contain a single key / value Each key consists of a 20-byte binary info_hash value The... Value of That Key Is Yet Another Nested Dictionary Containing The Following:

complete: number of peers with the entire file, ie seeders (integer) downloaded: total number of times the tracker has registered a completion ( "event = complete", ie a client finished downloading the torrent) incomplete: number of non-seeder peers , AKA "Leechers" (Integer) Name: (optional) The Torrent's Internal Name, as specified by the "name" file in the info section of the .torrent file

Note That this response Has Three Levels of Dictionary Nesting. Here's An Example:

D5: filesd20: .................... D8: companyTei5e10: Downloadedi50E10: Incompletei10eeee

WHERE .................. is The 20 byte info_hash and there. 5 Seeders, 10 Leechers, And 50 Complete Downloads.

Peer Wire Protocol (TCP)

Overview

.

Note here that the original specification also used the term "piece" when describing the peer protocol, but as a different term than "piece" in the metainfo file. For that reason, the term "block" will be used in this specification to describe THE DATA THAT I Exchanged Between Peers over The Wire.a Client Must Maintain State Information for Each Connection That It Has with a Remote Peer:

choked: Whether or not the remote peer has choked this client When a peer chokes the client, it is a notification that no requests will be answered until the client is unchoked The client should not attempt to send requests for blocks, and it should.. consider all pending (unanswered) requests to be discarded by the remote peer interested:. Whether or not the remote peer is interested in something this client has to offer This is a notification that the remote peer will begin requesting blocks when the client unchokes them. .

Note that this also implies that the client will also need to keep track of whether or not is interested in the remote peer, and if it has the remote peer choked or unchoked So, the real list looks something like this it.:

AM_CHOKING: This Client Is Choking The Peer AM_INTERESTED: This Client Is INTERESTED in The Peer Peer_choking: Peer Is Choking this client peer_interested: Peer is INTERESTED in this client

Client Connections Start Out as "Choked" and "not interested". In Other Words:

am_choking = 1 am_interested = 0 peer_choking = 1 peer_interested = 0

A block is downloaded by the client when the client is interested in a peer, and that peer is not choking the client. A block is uploaded by a client when the client is not choking a peer, and that peer is interested in the client. It is important for the client to keep its peers informed as to whether or not it is interested in them. This state information should be kept up-to-date with each peer even when the client is choked. This will allow peers to know if The Client Will Begin Downloading WHEN IT ITOKED (AND Vice-Versa).

Data Types

Unless Spectherwise, All Integers in The Peer Wire Protocol Are Encoded As Four ByTe Big-endian Values. This include The Length Prefix ON All Messages That Come After The Handshake.

Message flow

............... ..

Handshake

.

Handshake:

pstrlen: string length of , as a single raw byte pstr: string identifier of the protocol reserved:. eight (8) reserved bytes All current implementations use all zeroes Each bit in these bytes can be used to change the behavior of. . the protocol An email from Bram suggests that trailing bits should be used first, so that leading bits may be used to change the meaning of trailing bits info_hash:.. 20-byte SHA1 hash of the info key in the metainfo file This is the same info_hash that is transmitted in tracker requests peer_id:. 20-byte string used as a unique ID for the client This is the same peer_id that is transmitted in tracker requests.In version 1.0 of the BitTorrent protocol, pstrlen = 19, and pstr. = "BitTorrent Protocol".

The initiator of a connection is expected to transmit their handshake immediately. The recipient may wait for the initiator's handshake, if it is capable of serving multiple torrents simultaneously (torrents are uniquely identified by their info_hash). However, the recipient must respond as soon as IT SEES The Info_hash Part of The Handshake. The Tracker's Nat-Cheer_id Field of The Handshake.

IF a Client Receives A Handshake with An Info_hash That It Is Not Currently Serving, The Client Must Drop The Connection.

If the initiator of the connection receives a handshake in which the peer_id does not match the expected peer_id, then the initiator is expected to drop the connection. Note that the initiator presumably received the peer information from the tracker, which includes the peer_id that was registered ..............

Peer_id

There are mainly two conventions how to encode client and client version information into the peer_id, Azureus-style and Shadow's-style.Azureus-style uses the following encoding: '-', two characters for client id, four ascii digits for version number, '-', Followed by Random Numbers.

For example: '-az2060-de

KNown Clients That Uses this Encoding Style Are:

'AZ' - Azureus 'BB' - BitBuddy 'CT' - CTORRENT 'MT' - MOONLIGHTTORENT 'LT' - LIBTORRENT 'BX' - BITTORRENT X 'TS' - TORRENTSTORM 'TN' - TorrentDotNet 'SS' - SWARMSCOPE 'XT' - Xantorrent 'BS' - BTSLAVE 'ZT' - ZIPTORRENT

Shadow's Style Uses The Following Encoding: One Ascii Alphaumeric for Client Identification, Three Ascii Digits for Version Number, '----', Followed by Random Numbers.

For example: 'S587 ----'...

KNown Clients That Uses this Encoding Style Are:

'S' - Shadow's Client 'U' - UPNP NAT Bit Torrent 'T' - BitTornado 'A' - ABC

BRAM's Client Now Uses this style ... 'M3-4-2 -'.

BitComet does something different still. Its peer_id consists of four ASCII characters 'exbc', followed by a null byte, followed by a single ASCII numeric digit, followed by random characters. The digit seems to denote the version of the software, though it appears To have no connection with the real version number. The Digit Is Increment with each New Bitcomet Release.

Many Clients Are Using All Random Numbers or 12 Zeroes Followed by Random Numbers (Like Older Versions Of Bram's Client).

Messages

All of the remaining messages in the protocol take the form of . The length prefix is ​​a four byte big-endian value. The message ID is a single decimal character. The payload is message dependent Keep-alive:

The keep-alive message is a message with zero bytes, specified with the length prefix set to zero. There is no message ID and no payload. Peers may close a connection if they receive no messages for a certain period of time, so a keep -Alive Message Can Be Sent to Maintain The Connection. a Keep-Alive Message Is Generally Sent Once Every Two Minutes.

Choke:

The Choke Message Is Fixed-Length And Has No Payload.

UNCHOKE:

The Unchoke Message IS Fixed-Length And Has No Payload.

Interested:

The INTERESTED Message IS Fixed-Length And Has No Payload.

NOT INTERESTED:

The Not Interedment Message IS Fixed-Length And Has No Payload.

Have:

................ ..

Bitfield:

The Bitfield Message May Only Be Sent Immediely After The Handshaking Sequence Is Completed, And Before Any Other Messages Are Sent. It is Optional, And NOTBECES.

The bitfield message is variable length, where X is the length of the bitfield. The payload is a bitfield representing the pieces that have been successfully downloaded. The high bit in the first byte corresponds to piece index 0. Bits that are cleared indicated a missing piece, and set bits indicate a valid and available piece. Spare bits at the end are set to zero.A bitfield of the wrong length is considered an error. Clients should drop the connection if they receive bitfields that are not of the correct size, Or if The bitfield has any of the spare bits set.

Request:

THE

Request Message is fixed length, and is buy to request a block. The payload Contains the Following Information

index: integer specifying the zero-based piece index begin: integer specifying the zero-based byte offset within the piece length:.. integer specifying the requested length This value should normally be 2 ^ 14 (16384) bytes Smaller values ​​may be used but Are USUALLY NOT NEEDED EXCEPT IN RARE CASES LIKE A PIECE LENGTH NOT DIVISIBLE BY 16384.

The Observant Reader Will Note That A BLOCK IS TYPICLY SMALLER THAN A PIECE (Which IS Common "= 2 ^ 18 bytes). A Client May Close The Connection IF IT Receives A Request for more Than 16384 bytes.

Piece:

THE

Piece Message Is Variable Length, Where x is the length of the block. The febyload

index: integer specifying the zero-based piece index begin: integer specifying the zero-based byte offset within the piece block: block of data, which is a subset of the piece specified by index.

Cancel: The Cancel Message IS Fixed Length, and is buy to cancel block requests. The payload is identical to what of the "request" message. IT IS TYPICALLY Used During "End Game" (See the Algorithms Section Below).

Algorithms

Super Seeding

(This was not part of the original specification)

The super-seed feature in S-5.5 and on is a new seeding algorithm designed to help a torrent initiator with limited bandwidth "pump up" a large torrent, reducing the amount of data it needs to upload in order to spawn new seeds in the Torrent.

When a seeding client enters "super-seed mode", it will not act as a standard seed, but masquerades as a normal client with no data As clients connect, it will then inform them that it received a piece -. A piece that .

When the client has finished downloading the piece, the seed will not inform it of any other pieces until it has seen the piece it had sent previously present on at least one other client. Until then, the client will not have access to any of the Other Pieces of The Seed, And Therefore Will Not Waste The Seed's Bandwidth.

This method has resulted in much higher seeding efficiencies, by both inducing peers into taking only the rarest data, reducing the amount of redundant data sent, and limiting the amount of data sent to peers which do not contribute to the swarm. Prior to this, a seed might have to upload 150% to 200% of the total size of a torrent before other clients became seeds. However, a large torrent seeded with a single client running in super-seed mode was able to do so after only uploading 105% of the data. This is 150-200% more efficient than when using a standard seed.Super-seed mode is NOT recommended for general use. While it does assist in the wider distribution of rare data, because it limits the selection of pieces a client can downlad, it also limits the ability of those clients to download data for pieces they have already partially retrieved. Therefore, super-seed mode is only recommended for initial seeding servers.

Why not rename it to e.g. "INITIAL SEEDING MODE" or "release mode" THEN?

Piece Downloading Strategy

Clients May Choose to Download Pieces in Random ORDER.

A better strategy is to download pieces in rarest first order. The client can determine this by keeping the initial bitfield from each peer, and updating it with every have message. Then, the client can download the pieces that appear least frequently in these peer bitfields .

End Game

When a download is almost complete, there's a tendency for the last few blocks to trickle in slowly. To speed this up, the client sends requests for all of its missing blocks to all of its peers. To keep this from becoming horribly inefficient, the Client Also Sends a Cancel to Everyone else Every Time A Block Arrives.

There is no docutented thresholds, recommented percentages, or block countries That Could Be Used as a guide or recommented best practice here.choking and optimistic unchoking

Choking is done for several reasons. TCP congestion control behaves very poorly when sending over many connections at once. Also, choking lets each peer use a tit-for-tat-ish algorithm to ensure that they get a consistent download rate.

The choking algorithm described below is the currently deployed one. It is very important that all new algorithms work well both in a network consisting entirely of themselves and in a network consisting mostly of this one.

There are several criteria a good choking algorithm should meet. It should cap the number of simultaneous uploads for good TCP performance. It should avoid choking and unchoking quickly, known as 'fibrillation'. It should reciprocate to peers who let it download. Finally, IT SHOULD TRY OUSED CONNECTIONS ONCE IN A While To Find Out Iw Might Be Better Than THE CURRENTLY Used Ones, known as Optimistic UNCHOKING.

THE CURRENTLY Deployed Choking Algorithm Avoids Fibrillation by Only Changing Choked Peers Once Every Ten Seconds.

Reciprocation and number of uploads capping is managed by unchoking the four peers which have the best upload rate and are interested. This maximizes the client's download rate. These four peers are referred to as downloaders, because they are interested in downloading from the client.

Peers which have a better upload rate (as compared to the downloaders) but are not interested get unchoked. If they become interested, the downloader with the worst upload rate gets choked. If a client has a complete file, it uses its upload rate rather than its download rate to decide which peers to unchoke.For optimistic unchoking, at any one time there is a single peer which is unchoked regardless of it's upload rate (if interested, it counts as one of the four allowed downloaders). Which peer is optimistically unchoked rotates every 30 seconds. Newly connected peers are three times as likely to start as the current optimistic unchoke as anywhere else in the rotation. This gives them a decent chance of getting a complete piece to upload.

Anti-Snubbing (Extension Not in The OffiIffial Protocol)

Occasionally a BitTorrent peer will be choked by all peers which it was formerly downloading from. In such cases it will usually continue to get poor download rates until the optimistic unchoke finds better peers. To mitigate this problem, when over a minute goes by without getting a single piece from a particular peer, BitTorrent assumes it is "snubbed" by that peer and does not upload to it except as an optimistic unchoke. This frequently results in more than one concurrent optimistic unchoke, (an exception to the exactly one optimistic UNCHOKE Rule Mentioned Above, Which Causes Download Rates To Recover Much More Quickly WHEN THEY FALTER.

转载请注明原文地址:https://www.9cbs.com/read-44961.html

New Post(0)