📄 bit torrent specification.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0046)http://wiki.theory.org/BitTorrentSpecification -->
<?xml version="1.0" encoding="iso-8859-1"?><HTML
xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>wiki.theory.org - Bit Torrent Specification</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content=index,follow name=robots>
<META
content="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."
name=description>
<META content="Bit Torrent Specification, wiki.theory.org" name=keywords>
<META content=en name=language>
<META content=Public name=document-type>
<META content=General name=document-rating>
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<META content=1.3.7debian name=PHPWIKI_VERSION><LINK
href="/phpwikidata/themes/Theory/images/favicon.ico" rel="shortcut icon"><LINK
title=HomePage href="HomePage" rel=home><LINK title=HowToUseWiki
href="HowToUseWiki" rel=help><LINK title="GNU General Public License"
href="http://www.gnu.org/copyleft/gpl.html#SEC1" rel=copyright><LINK
title="The PhpWiki Programming Team"
href="http://phpwiki.sourceforge.net/phpwiki/ThePhpWikiProgrammingTeam"
rel=author><LINK title=FindPage href="FindPage" rel=search><LINK
title="View Source: BitTorrentSpecification"
href="BitTorrentSpecification?action=viewsource&version=135"
rel=alternate><LINK title=RSS href="RecentChanges?format=rss"
type=application/rss+xml rel=alternate><LINK title=SandBox href="SandBox"
rel=bookmark><LINK title=WikiWikiWeb href="WikiWikiWeb" rel=bookmark><LINK
href="Bit Torrent Specification.files/phpwiki.css" type=text/css
charset=iso-8859-1 rel=stylesheet><LINK media=print
href="Bit Torrent Specification.files/phpwiki-printer.css" type=text/css
charset=iso-8859-1 rel=stylesheet><LINK title=Printer
href="Bit Torrent Specification.files/phpwiki-printer.css" type=text/css
charset=iso-8859-1 rel="alternate stylesheet"><LINK
title="Top & bottom toolbars"
href="Bit Torrent Specification.files/phpwiki-topbottombars.css" type=text/css
charset=iso-8859-1 rel="alternate stylesheet"><LINK title=Modern
href="Bit Torrent Specification.files/phpwiki-modern.css" type=text/css
charset=iso-8859-1 rel="alternate stylesheet"></HEAD>
<BODY>
<DIV id=header><!-- The logo -->
<DIV id=logo align=right><A class=wikilink
href="http://wiki.theory.org/HomePage" target=_top><IMG id=logo-img
alt="wiki.theory.org: HomePage" src="Bit Torrent Specification.files/logo.png"
align=right border=0></A></DIV><!-- The top navigation/search bar -->
<DIV class=toolbar><!-- The top navigation/search bar -->
<FORM accept-charset=iso-8859-1 action=TitleSearch method=get target=_top>
<DIV id=navbuttons><A class=wiki
href="http://wiki.theory.org/RecentChanges">RecentChanges</A> | <A class=wiki
href="http://wiki.theory.org/FindPage">FindPage</A> | <INPUT type=hidden value=1
name=auto_redirect> <INPUT
onmouseover="window.status='Quick Search'; return true;" title="Quick Search"
onmouseout="window.status=''; return true;" maxLength=256 size=12 name=s> | <A
class=wikiaction
href="http://wiki.theory.org/BitTorrentSpecification?action=LikePages">LikePages</A>
| <A class=wikiaction
href="http://wiki.theory.org/BitTorrentSpecification?action=BackLinks">BackLinks</A>
</DIV></FORM></DIV><!-- Page title -->
<H1><A class=backlinks
onmouseover='window.status="BackLinks for BitTorrentSpecification"; return true;'
title="BackLinks for BitTorrentSpecification"
onmouseout="window.status='';return true;"
href="http://wiki.theory.org/BitTorrentSpecification?action=BackLinks">Bit
Torrent Specification</A></H1></DIV>
<DIV class=wikitext>
<P class="tightenable top"><BIG><BIG><BIG><B>Bittorrent Protocol Specification
v1.0</B> </BIG></BIG></BIG></P>
<H2>Identification</H2>
<P class=tightenable><A class=wiki
href="http://wiki.theory.org/BitTorrent">BitTorrent</A> is a peer-to-peer file
sharing protocol designed by Bram Cohen. Visit his pages at <A class=namedurl
href="http://www.bitconjurer.org/"><SPAN style="WHITE-SPACE: nowrap"><IMG
class=linkicon alt="" src="Bit Torrent Specification.files/http.png"
border=0>http://www.bitconjurer.org</SPAN></A>. BitTorrent is designed to
facilitate file transfers among multiple peers across unreliable networks.</P>
<H2>Purpose</H2>
<P class=tightenable>The purpose of this specification is to document version
1.0 of the BitTorrent protocol specification in detail. Bram's protocol
specification page <A class=namedurl
href="http://www.bitconjurer.org/BitTorrent/protocol.html"><SPAN
style="WHITE-SPACE: nowrap"><IMG class=linkicon alt=""
src="Bit Torrent Specification.files/http.png"
border=0>http://www.bitconjurer.org/BitTorrent/protocol.html</SPAN></A> outlines
the protocol in somewhat general terms, and lacks behaviorial detail in some
areas. The hope is that this document will become a <B>formal</B> specification,
written in clear, unambiguous terms, which can be used as a basis for discussion
and implementation in the future.</P>
<P class=tightenable>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.</P>
<P class=tightenable>This is not the place to suggest feature requests. For
that, please go to the mailing list.</P>
<H2>Scope</H2>
<P class=tightenable>This document applies to the first version (i.e. 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, they should be
specified on their own separate pages, <I><B>not here</B></I>.</P>
<H2>Related Documents</H2>
<P class=tightenable><A class=namedurl
href="http://www.bitconjurer.org/BitTorrent/protocol.html"><SPAN
style="WHITE-SPACE: nowrap"><IMG class=linkicon alt=""
src="Bit Torrent Specification.files/http.png"
border=0>http://www.bitconjurer.org/BitTorrent/protocol.html</SPAN></A> - The
official protocol specification.<BR><A class=wiki
href="http://wiki.theory.org/BitTorrentWishList">BitTorrentWishList</A> - A wish
list for developers and end users alike.<BR><A class=wiki
href="http://wiki.theory.org/BitTorrentTrackerExtensions">BitTorrentTrackerExtensions</A>
- Describes the various extensions of the Tracker protocol that are in use.</P>
<H2>Conventions</H2>
<P class="tightenable bottom">In this document, a number of conventions are used
in an attempt to present information in a concise and unambiguous fashion.</P>
<UL>
<LI class="tightenable top bottom"><B>peer</B> v/s <B>client</B>: In this
document, a <B>peer</B> is any BitTorrent client participating in a download.
The <B>client</B> 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 <B>client</B> which connects to numerous <B>peers</B>.
<LI class="tightenable top bottom"><B>piece</B> v/s <B>block</B>: In this
document, a <B>piece</B> refers to a portion of the downloaded data that is
described in the metainfo file, which can be verified by a SHA1 hash. A
<B>block</B> is a portion of data that a <B>client</B> may request from a
<B>peer</B>. Two or more <B>blocks</B> make up a whole <B>piece</B>, which may
then be verified.
<LI class="tightenable top"><B>defacto standard</B>: Large blocks of text in
<I>italics</I> indicates a practice so common in various client
implementations of BitTorrent that it is considered a defacto standard.
</LI></UL>
<P class=tightenable>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 (i.e. one-line) entry for each major change that you've
made to the document.</P>
<H2>bencoding</H2>
<P class=tightenable>Bencoding is a way to specify and organize data in a terse
format. It supports the following types: byte strings, integers, lists, and
dictionaries.</P>
<H3>byte strings</H3>
<P class=tightenable>Byte strings are encoded as follows: <I><string length
encoded in base ten ASCII></I><B>:</B><I><string data></I> <BR>Note
that there is no constant beginning delimiter, and no ending delimiter.
<BR>Example: <B>4:</B><I>spam</I> represents the string "spam"</P>
<H3>integers</H3>
<P class=tightenable>Integers are encoded as follows: <B>i</B><I><integer
encoded in base ten ASCII></I><B>e</B> <BR>The initial <B>i</B> and trailing
<B>e</B> are beginning and ending delimiters. <BR>You can have negative numbers
such as <B>i</B><I>-3</I><B>e</B>. You cannot prefix the number with a zero such
as <B>i</B><I>04</I><B>e</B>. However, <B>i</B><I>0</I><B>e</B> is
valid.<BR>Example <B>i</B><I>3</I><B>e</B> represents the integer "3"</P>
<H3>lists</H3>
<P class=tightenable>Lists are encoded as follows: <B>l</B><I><bencoded
values></I><B>e</B> <BR>The initial <B>l</B> and trailing <B>e</B> are
beginning and ending delimiters.</P>
<P class=tightenable>Lists may contain any bencoded type, including integers,
strings, dictionaries, and other lists.</P>
<P class=tightenable>Example: <B>l</B><I>4:spam4:eggs</I><B>e</B> represents the
list of two strings: ["spam", "eggs"]</P>
<H3>dictionaries</H3>
<P class=tightenable>Dictionaries are encoded as follows:
<B>d</B><I><bencoded string><bencoded element></I><B>e</B> <BR>The
initial <B>d</B> and trailing <B>e</B> are the beginning and ending
delimiters.</P>
<P class=tightenable>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).</P>
<P class=tightenable>Example: <B>d</B><I>3:cow3:moo4:spam4:eggs</I><B>e</B>
represents the dictionary { "cow" => "moo", "spam" => "eggs" }
<BR>Example: <B>d</B><I>4:spaml1:a1:be</I><B>e</B> represents the dictionary {
"spam" => ["a", "b"] }</P>
<H2>Metainfo File Structure</H2>
<P class=tightenable><B>All data in a metainfo file is bencoded</B>. The
specification for bencoding is defined above.</P>
<P class=tightenable>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
<B>required fields</B>:</P>
<UL>
<LI class=tightenable>
<P class="tightenable top"><B>info</B>: 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.</P>
<DL>
<DT class="tightenable bottom">For the case of the <B>single-file</B> mode,
the <B>info</B> dictionary contains the following structure
<DD class="tightenable top">
<UL>
<LI class="tightenable top bottom"><B>length</B>: length of the file in
bytes (integer)
<LI class="tightenable top bottom"><B>md5sum</B>: (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.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -