PageRenderTime 61ms CodeModel.GetById 25ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/_SolutionItems_/Documents/BitTorrentSpecification - TheoryOrg.mht

https://bitbucket.org/titolarz/bitspecslibrary
Unknown | 6548 lines | 6497 code | 51 blank | 0 comment | 0 complexity | 3e35ac6feb90327a6c4170a32cd0a36c MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1From: "Saved by Windows Internet Explorer 9"
   2Subject: BitTorrentSpecification - TheoryOrg
   3Date: Thu, 8 Sep 2011 06:20:06 +0800
   4MIME-Version: 1.0
   5Content-Type: multipart/related;
   6	type="text/html";
   7	boundary="----=_NextPart_000_0000_01CC6DEF.5A1D4220"
   8X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.17609
   9
  10This is a multi-part message in MIME format.
  11
  12------=_NextPart_000_0000_01CC6DEF.5A1D4220
  13Content-Type: text/html;
  14	charset="utf-8"
  15Content-Transfer-Encoding: quoted-printable
  16Content-Location: http://wiki.theory.org/BitTorrentSpecification
  17
  18=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  19<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" =
  20"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><HTML=20
  21dir=3D"ltr" lang=3D"en"><HEAD><TITLE>BitTorrentSpecification - =
  22TheoryOrg</TITLE>
  23<META content=3D"text/html; charset=3Dutf-8" =
  24http-equiv=3D"Content-Type">
  25<META name=3D"GENERATOR" content=3D"MSHTML 9.00.8112.16434"><LINK =
  26rel=3D"shortcut icon"=20
  27href=3D"/favicon.ico"><LINK title=3D"TheoryOrg (en)" rel=3D"search" =
  28type=3D"application/opensearchdescription+xml"=20
  29href=3D"/opensearch_desc.php"><LINK title=3D"Creative Commons" =
  30rel=3D"meta" type=3D"application/rdf+xml"=20
  31href=3D"/index.php?title=3DBitTorrentSpecification&amp;action=3Dcreativec=
  32ommons"><LINK=20
  33rel=3D"copyright" =
  34href=3D"http://www.gnu.org/licenses/old-licenses/fdl-1.2.txt">
  35<LINK title=3D"TheoryOrg Atom feed" rel=3D"alternate" =
  36type=3D"application/atom+xml"=20
  37href=3D"/index.php?title=3DSpecial:RecentChanges&amp;feed=3Datom"><LINK =
  38rel=3D"stylesheet"=20
  39href=3D"http://wiki.theory.org/skins/common/shared.css?270" =
  40media=3D"screen"><LINK=20
  41rel=3D"stylesheet" =
  42href=3D"http://wiki.theory.org/skins/common/commonPrint.css?270"=20
  43media=3D"print"><LINK rel=3D"stylesheet" =
  44href=3D"http://wiki.theory.org/skins/monobook/main.css?270"=20
  45media=3D"screen"><!--[if lt IE 5.5000]><link rel=3D"stylesheet" =
  46href=3D"/skins/monobook/IE50Fixes.css?270" media=3D"screen" =
  47/><![endif]--><!--[if IE 5.5000]><link rel=3D"stylesheet" =
  48href=3D"/skins/monobook/IE55Fixes.css?270" media=3D"screen" =
  49/><![endif]--><!--[if IE 6]><link rel=3D"stylesheet" =
  50href=3D"/skins/monobook/IE60Fixes.css?270" media=3D"screen" =
  51/><![endif]--><!--[if IE 7]><link rel=3D"stylesheet" =
  52href=3D"/skins/monobook/IE70Fixes.css?270" media=3D"screen" =
  53/><![endif]-->
  54<LINK rel=3D"stylesheet" =
  55href=3D"/index.php?title=3DMediaWiki:Common.css&amp;usemsgcache=3Dyes&amp=
  56;ctype=3Dtext%2Fcss&amp;smaxage=3D18000&amp;action=3Draw&amp;maxage=3D180=
  5700">
  58<LINK rel=3D"stylesheet" =
  59href=3D"/index.php?title=3DMediaWiki:Print.css&amp;usemsgcache=3Dyes&amp;=
  60ctype=3Dtext%2Fcss&amp;smaxage=3D18000&amp;action=3Draw&amp;maxage=3D1800=
  610"=20
  62media=3D"print"><LINK rel=3D"stylesheet" =
  63href=3D"/index.php?title=3DMediaWiki:Monobook.css&amp;usemsgcache=3Dyes&a=
  64mp;ctype=3Dtext%2Fcss&amp;smaxage=3D18000&amp;action=3Draw&amp;maxage=3D1=
  658000">
  66<LINK rel=3D"stylesheet" =
  67href=3D"http://wiki.theory.org/index.php?title=3D-&amp;action=3Draw&amp;m=
  68axage=3D18000&amp;gen=3Dcss">
  69<SCRIPT>=0A=
  70var skin=3D"monobook",=0A=
  71stylepath=3D"/skins",=0A=
  72wgUrlProtocols=3D"http\\:\\/\\/|https\\:\\/\\/|ftp\\:\\/\\/|irc\\:\\/\\/|=
  73gopher\\:\\/\\/|telnet\\:\\/\\/|nntp\\:\\/\\/|worldwind\\:\\/\\/|mailto\\=
  74:|news\\:|svn\\:\\/\\/",=0A=
  75wgArticlePath=3D"/$1",=0A=
  76wgScriptPath=3D"",=0A=
  77wgScriptExtension=3D".php",=0A=
  78wgScript=3D"/index.php",=0A=
  79wgVariantArticlePath=3Dfalse,=0A=
  80wgActionPaths=3D{},=0A=
  81wgServer=3D"http://wiki.theory.org",=0A=
  82wgCanonicalNamespace=3D"",=0A=
  83wgCanonicalSpecialPageName=3Dfalse,=0A=
  84wgNamespaceNumber=3D0,=0A=
  85wgPageName=3D"BitTorrentSpecification",=0A=
  86wgTitle=3D"BitTorrentSpecification",=0A=
  87wgAction=3D"view",=0A=
  88wgArticleId=3D1427,=0A=
  89wgIsArticle=3Dtrue,=0A=
  90wgUserName=3Dnull,=0A=
  91wgUserGroups=3Dnull,=0A=
  92wgUserLanguage=3D"en",=0A=
  93wgContentLanguage=3D"en",=0A=
  94wgBreakFrames=3Dfalse,=0A=
  95wgCurRevisionId=3D4218,=0A=
  96wgVersion=3D"1.16.5",=0A=
  97wgEnableAPI=3Dtrue,=0A=
  98wgEnableWriteAPI=3Dtrue,=0A=
  99wgSeparatorTransformTable=3D["", ""],=0A=
 100wgDigitTransformTable=3D["", ""],=0A=
 101wgMainPageTitle=3D"Main Page",=0A=
 102wgFormattedNamespaces=3D{"-2": "Media", "-1": "Special", "0": "", "1": =
 103"Talk", "2": "User", "3": "User talk", "4": "TheoryOrg", "5": "TheoryOrg =
 104talk", "6": "File", "7": "File talk", "8": "MediaWiki", "9": "MediaWiki =
 105talk", "10": "Template", "11": "Template talk", "12": "Help", "13": =
 106"Help talk", "14": "Category", "15": "Category talk"},=0A=
 107wgNamespaceIds=3D{"media": -2, "special": -1, "": 0, "talk": 1, "user": =
 1082, "user_talk": 3, "theoryorg": 4, "theoryorg_talk": 5, "file": 6, =
 109"file_talk": 7, "mediawiki": 8, "mediawiki_talk": 9, "template": 10, =
 110"template_talk": 11, "help": 12, "help_talk": 13, "category": 14, =
 111"category_talk": 15, "image": 6, "image_talk": 7},=0A=
 112wgSiteName=3D"TheoryOrg",=0A=
 113wgCategories=3D["PhpWiki"],=0A=
 114wgRestrictionEdit=3D[],=0A=
 115wgRestrictionMove=3D[];=0A=
 116</SCRIPT>
 117
 118<SCRIPT =
 119src=3D"http://wiki.theory.org/skins/common/wikibits.js?270"></SCRIPT>
 120
 121<SCRIPT =
 122src=3D"http://wiki.theory.org/skins/common/ajax.js?270"></SCRIPT>
 123
 124<SCRIPT =
 125src=3D"http://wiki.theory.org/index.php?title=3D-&amp;action=3Draw&amp;ge=
 126n=3Djs&amp;useskin=3Dmonobook&amp;270"></SCRIPT>
 127</HEAD>
 128<BODY class=3D"mediawiki ltr ns-0 ns-subject =
 129page-BitTorrentSpecification skin-monobook">
 130<DIV id=3D"globalWrapper">
 131<DIV id=3D"column-content">
 132<DIV id=3D"content"><A id=3D"top"></A>
 133<H1 id=3D"firstHeading" =
 134class=3D"firstHeading">BitTorrentSpecification</H1>
 135<DIV id=3D"bodyContent">
 136<H3 id=3D"siteSub">From TheoryOrg</H3>
 137<DIV id=3D"contentSub"></DIV>
 138<DIV id=3D"jump-to-nav">Jump to: <A =
 139href=3D"http://wiki.theory.org/BitTorrentSpecification#column-one">naviga=
 140tion</A>,=20
 141<A=20
 142href=3D"http://wiki.theory.org/BitTorrentSpecification#searchInput">searc=
 143h</A></DIV><!-- start content -->
 144<P><BIG><BIG><BIG> <I><B>Bittorrent Protocol Specification v1.0</B></I>=20
 145</BIG></BIG></BIG></P>
 146<TABLE id=3D"toc" class=3D"toc">
 147  <TBODY>
 148  <TR>
 149    <TD>
 150      <DIV id=3D"toctitle">
 151      <H2>Contents</H2></DIV>
 152      <UL>
 153        <LI class=3D"toclevel-1 tocsection-1"><A =
 154href=3D"http://wiki.theory.org/BitTorrentSpecification#Identification"><S=
 155PAN=20
 156        class=3D"tocnumber">1</SPAN> <SPAN=20
 157        class=3D"toctext">Identification</SPAN></A></LI>
 158        <LI class=3D"toclevel-1 tocsection-2"><A =
 159href=3D"http://wiki.theory.org/BitTorrentSpecification#Purpose"><SPAN=20
 160        class=3D"tocnumber">2</SPAN> <SPAN =
 161class=3D"toctext">Purpose</SPAN></A></LI>
 162        <LI class=3D"toclevel-1 tocsection-3"><A =
 163href=3D"http://wiki.theory.org/BitTorrentSpecification#Scope"><SPAN=20
 164        class=3D"tocnumber">3</SPAN> <SPAN =
 165class=3D"toctext">Scope</SPAN></A></LI>
 166        <LI class=3D"toclevel-1 tocsection-4"><A =
 167href=3D"http://wiki.theory.org/BitTorrentSpecification#Related_Documents"=
 168><SPAN=20
 169        class=3D"tocnumber">4</SPAN> <SPAN class=3D"toctext">Related=20
 170        Documents</SPAN></A></LI>
 171        <LI class=3D"toclevel-1 tocsection-5"><A =
 172href=3D"http://wiki.theory.org/BitTorrentSpecification#Conventions"><SPAN=
 173=20
 174        class=3D"tocnumber">5</SPAN> <SPAN=20
 175        class=3D"toctext">Conventions</SPAN></A></LI>
 176        <LI class=3D"toclevel-1 tocsection-6"><A =
 177href=3D"http://wiki.theory.org/BitTorrentSpecification#Bencoding"><SPAN=20
 178        class=3D"tocnumber">6</SPAN> <SPAN =
 179class=3D"toctext">Bencoding</SPAN></A>
 180        <UL>
 181          <LI class=3D"toclevel-2 tocsection-7"><A =
 182href=3D"http://wiki.theory.org/BitTorrentSpecification#Bencoded_Strings">=
 183<SPAN=20
 184          class=3D"tocnumber">6.1</SPAN> <SPAN =
 185class=3D"toctext">Bencoded=20
 186          Strings</SPAN></A></LI>
 187          <LI class=3D"toclevel-2 tocsection-8"><A =
 188href=3D"http://wiki.theory.org/BitTorrentSpecification#Integers"><SPAN=20
 189          class=3D"tocnumber">6.2</SPAN> <SPAN=20
 190          class=3D"toctext">Integers</SPAN></A></LI>
 191          <LI class=3D"toclevel-2 tocsection-9"><A =
 192href=3D"http://wiki.theory.org/BitTorrentSpecification#Lists"><SPAN=20
 193          class=3D"tocnumber">6.3</SPAN> <SPAN=20
 194          class=3D"toctext">Lists</SPAN></A></LI>
 195          <LI class=3D"toclevel-2 tocsection-10"><A =
 196href=3D"http://wiki.theory.org/BitTorrentSpecification#Dictionaries"><SPA=
 197N=20
 198          class=3D"tocnumber">6.4</SPAN> <SPAN=20
 199          class=3D"toctext">Dictionaries</SPAN></A></LI>
 200          <LI class=3D"toclevel-2 tocsection-11"><A =
 201href=3D"http://wiki.theory.org/BitTorrentSpecification#Implementations"><=
 202SPAN=20
 203          class=3D"tocnumber">6.5</SPAN> <SPAN=20
 204          class=3D"toctext">Implementations</SPAN></A></LI></UL></LI>
 205        <LI class=3D"toclevel-1 tocsection-12"><A =
 206href=3D"http://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Stru=
 207cture"><SPAN=20
 208        class=3D"tocnumber">7</SPAN> <SPAN class=3D"toctext">Metainfo =
 209File=20
 210        Structure</SPAN></A>
 211        <UL>
 212          <LI class=3D"toclevel-2 tocsection-13"><A =
 213href=3D"http://wiki.theory.org/BitTorrentSpecification#Info_Dictionary"><=
 214SPAN=20
 215          class=3D"tocnumber">7.1</SPAN> <SPAN class=3D"toctext">Info=20
 216          Dictionary</SPAN></A>
 217          <UL>
 218            <LI class=3D"toclevel-3 tocsection-14"><A =
 219href=3D"http://wiki.theory.org/BitTorrentSpecification#Info_in_Single_Fil=
 220e_Mode"><SPAN=20
 221            class=3D"tocnumber">7.1.1</SPAN> <SPAN =
 222class=3D"toctext">Info in Single=20
 223            File Mode</SPAN></A></LI>
 224            <LI class=3D"toclevel-3 tocsection-15"><A =
 225href=3D"http://wiki.theory.org/BitTorrentSpecification#Info_in_Multiple_F=
 226ile_Mode"><SPAN=20
 227            class=3D"tocnumber">7.1.2</SPAN> <SPAN =
 228class=3D"toctext">Info in=20
 229            Multiple File Mode</SPAN></A></LI></UL></LI>
 230          <LI class=3D"toclevel-2 tocsection-16"><A =
 231href=3D"http://wiki.theory.org/BitTorrentSpecification#Notes"><SPAN=20
 232          class=3D"tocnumber">7.2</SPAN> <SPAN=20
 233          class=3D"toctext">Notes</SPAN></A></LI></UL></LI>
 234        <LI class=3D"toclevel-1 tocsection-17"><A =
 235href=3D"http://wiki.theory.org/BitTorrentSpecification#Tracker_HTTP.2FHTT=
 236PS_Protocol"><SPAN=20
 237        class=3D"tocnumber">8</SPAN> <SPAN class=3D"toctext">Tracker =
 238HTTP/HTTPS=20
 239        Protocol</SPAN></A>
 240        <UL>
 241          <LI class=3D"toclevel-2 tocsection-18"><A =
 242href=3D"http://wiki.theory.org/BitTorrentSpecification#Tracker_Request_Pa=
 243rameters"><SPAN=20
 244          class=3D"tocnumber">8.1</SPAN> <SPAN class=3D"toctext">Tracker =
 245Request=20
 246          Parameters</SPAN></A></LI>
 247          <LI class=3D"toclevel-2 tocsection-19"><A =
 248href=3D"http://wiki.theory.org/BitTorrentSpecification#Tracker_Response">=
 249<SPAN=20
 250          class=3D"tocnumber">8.2</SPAN> <SPAN class=3D"toctext">Tracker =
 251
 252          Response</SPAN></A></LI></UL></LI>
 253        <LI class=3D"toclevel-1 tocsection-20"><A =
 254href=3D"http://wiki.theory.org/BitTorrentSpecification#Tracker_.27scrape.=
 25527_Convention"><SPAN=20
 256        class=3D"tocnumber">9</SPAN> <SPAN class=3D"toctext">Tracker =
 257'scrape'=20
 258        Convention</SPAN></A>
 259        <UL>
 260          <LI class=3D"toclevel-2 tocsection-21"><A =
 261href=3D"http://wiki.theory.org/BitTorrentSpecification#Unofficial_extensi=
 262ons_to_scrape"><SPAN=20
 263          class=3D"tocnumber">9.1</SPAN> <SPAN =
 264class=3D"toctext">Unofficial=20
 265          extensions to scrape</SPAN></A></LI></UL></LI>
 266        <LI class=3D"toclevel-1 tocsection-22"><A =
 267href=3D"http://wiki.theory.org/BitTorrentSpecification#Peer_wire_protocol=
 268_.28TCP.29"><SPAN=20
 269        class=3D"tocnumber">10</SPAN> <SPAN class=3D"toctext">Peer wire =
 270protocol=20
 271        (TCP)</SPAN></A>
 272        <UL>
 273          <LI class=3D"toclevel-2 tocsection-23"><A =
 274href=3D"http://wiki.theory.org/BitTorrentSpecification#Overview"><SPAN=20
 275          class=3D"tocnumber">10.1</SPAN> <SPAN=20
 276          class=3D"toctext">Overview</SPAN></A></LI>
 277          <LI class=3D"toclevel-2 tocsection-24"><A =
 278href=3D"http://wiki.theory.org/BitTorrentSpecification#Data_Types"><SPAN =
 279
 280          class=3D"tocnumber">10.2</SPAN> <SPAN class=3D"toctext">Data=20
 281          Types</SPAN></A></LI>
 282          <LI class=3D"toclevel-2 tocsection-25"><A =
 283href=3D"http://wiki.theory.org/BitTorrentSpecification#Message_flow"><SPA=
 284N=20
 285          class=3D"tocnumber">10.3</SPAN> <SPAN =
 286class=3D"toctext">Message=20
 287          flow</SPAN></A></LI>
 288          <LI class=3D"toclevel-2 tocsection-26"><A =
 289href=3D"http://wiki.theory.org/BitTorrentSpecification#Handshake"><SPAN=20
 290          class=3D"tocnumber">10.4</SPAN> <SPAN=20
 291          class=3D"toctext">Handshake</SPAN></A>
 292          <UL>
 293            <LI class=3D"toclevel-3 tocsection-27"><A =
 294href=3D"http://wiki.theory.org/BitTorrentSpecification#peer_id"><SPAN=20
 295            class=3D"tocnumber">10.4.1</SPAN> <SPAN=20
 296            class=3D"toctext">peer_id</SPAN></A></LI></UL></LI>
 297          <LI class=3D"toclevel-2 tocsection-28"><A =
 298href=3D"http://wiki.theory.org/BitTorrentSpecification#Messages"><SPAN=20
 299          class=3D"tocnumber">10.5</SPAN> <SPAN=20
 300          class=3D"toctext">Messages</SPAN></A>
 301          <UL>
 302            <LI class=3D"toclevel-3 tocsection-29"><A =
 303href=3D"http://wiki.theory.org/BitTorrentSpecification#keep-alive:_.3Clen=
 304.3D0000.3E"><SPAN=20
 305            class=3D"tocnumber">10.5.1</SPAN> <SPAN =
 306class=3D"toctext">keep-alive:=20
 307            &lt;len=3D0000&gt;</SPAN></A></LI>
 308            <LI class=3D"toclevel-3 tocsection-30"><A =
 309href=3D"http://wiki.theory.org/BitTorrentSpecification#choke:_.3Clen.3D00=
 31001.3E.3Cid.3D0.3E"><SPAN=20
 311            class=3D"tocnumber">10.5.2</SPAN> <SPAN =
 312class=3D"toctext">choke:=20
 313            &lt;len=3D0001&gt;&lt;id=3D0&gt;</SPAN></A></LI>
 314            <LI class=3D"toclevel-3 tocsection-31"><A =
 315href=3D"http://wiki.theory.org/BitTorrentSpecification#unchoke:_.3Clen.3D=
 3160001.3E.3Cid.3D1.3E"><SPAN=20
 317            class=3D"tocnumber">10.5.3</SPAN> <SPAN =
 318class=3D"toctext">unchoke:=20
 319            &lt;len=3D0001&gt;&lt;id=3D1&gt;</SPAN></A></LI>
 320            <LI class=3D"toclevel-3 tocsection-32"><A =
 321href=3D"http://wiki.theory.org/BitTorrentSpecification#interested:_.3Clen=
 322.3D0001.3E.3Cid.3D2.3E"><SPAN=20
 323            class=3D"tocnumber">10.5.4</SPAN> <SPAN =
 324class=3D"toctext">interested:=20
 325            &lt;len=3D0001&gt;&lt;id=3D2&gt;</SPAN></A></LI>
 326            <LI class=3D"toclevel-3 tocsection-33"><A =
 327href=3D"http://wiki.theory.org/BitTorrentSpecification#not_interested:_.3=
 328Clen.3D0001.3E.3Cid.3D3.3E"><SPAN=20
 329            class=3D"tocnumber">10.5.5</SPAN> <SPAN =
 330class=3D"toctext">not=20
 331            interested: &lt;len=3D0001&gt;&lt;id=3D3&gt;</SPAN></A></LI>
 332            <LI class=3D"toclevel-3 tocsection-34"><A =
 333href=3D"http://wiki.theory.org/BitTorrentSpecification#have:_.3Clen.3D000=
 3345.3E.3Cid.3D4.3E.3Cpiece_index.3E"><SPAN=20
 335            class=3D"tocnumber">10.5.6</SPAN> <SPAN =
 336class=3D"toctext">have:=20
 337            &lt;len=3D0005&gt;&lt;id=3D4&gt;&lt;piece =
 338index&gt;</SPAN></A></LI>
 339            <LI class=3D"toclevel-3 tocsection-35"><A =
 340href=3D"http://wiki.theory.org/BitTorrentSpecification#bitfield:_.3Clen.3=
 341D0001.2BX.3E.3Cid.3D5.3E.3Cbitfield.3E"><SPAN=20
 342            class=3D"tocnumber">10.5.7</SPAN> <SPAN =
 343class=3D"toctext">bitfield:=20
 344            =
 345&lt;len=3D0001+X&gt;&lt;id=3D5&gt;&lt;bitfield&gt;</SPAN></A></LI>
 346            <LI class=3D"toclevel-3 tocsection-36"><A =
 347href=3D"http://wiki.theory.org/BitTorrentSpecification#request:_.3Clen.3D=
 3480013.3E.3Cid.3D6.3E.3Cindex.3E.3Cbegin.3E.3Clength.3E"><SPAN=20
 349            class=3D"tocnumber">10.5.8</SPAN> <SPAN =
 350class=3D"toctext">request:=20
 351            =
 352&lt;len=3D0013&gt;&lt;id=3D6&gt;&lt;index&gt;&lt;begin&gt;&lt;length&gt;<=
 353/SPAN></A></LI>
 354            <LI class=3D"toclevel-3 tocsection-37"><A =
 355href=3D"http://wiki.theory.org/BitTorrentSpecification#piece:_.3Clen.3D00=
 35609.2BX.3E.3Cid.3D7.3E.3Cindex.3E.3Cbegin.3E.3Cblock.3E"><SPAN=20
 357            class=3D"tocnumber">10.5.9</SPAN> <SPAN =
 358class=3D"toctext">piece:=20
 359            =
 360&lt;len=3D0009+X&gt;&lt;id=3D7&gt;&lt;index&gt;&lt;begin&gt;&lt;block&gt;=
 361</SPAN></A></LI>
 362            <LI class=3D"toclevel-3 tocsection-38"><A =
 363href=3D"http://wiki.theory.org/BitTorrentSpecification#cancel:_.3Clen.3D0=
 364013.3E.3Cid.3D8.3E.3Cindex.3E.3Cbegin.3E.3Clength.3E"><SPAN=20
 365            class=3D"tocnumber">10.5.10</SPAN> <SPAN =
 366class=3D"toctext">cancel:=20
 367            =
 368&lt;len=3D0013&gt;&lt;id=3D8&gt;&lt;index&gt;&lt;begin&gt;&lt;length&gt;<=
 369/SPAN></A></LI>
 370            <LI class=3D"toclevel-3 tocsection-39"><A =
 371href=3D"http://wiki.theory.org/BitTorrentSpecification#port:_.3Clen.3D000=
 3723.3E.3Cid.3D9.3E.3Clisten-port.3E"><SPAN=20
 373            class=3D"tocnumber">10.5.11</SPAN> <SPAN =
 374class=3D"toctext">port:=20
 375            =
 376&lt;len=3D0003&gt;&lt;id=3D9&gt;&lt;listen-port&gt;</SPAN></A></LI></UL>
 377          </LI></UL></LI>
 378        <LI class=3D"toclevel-1 tocsection-40"><A =
 379href=3D"http://wiki.theory.org/BitTorrentSpecification#Algorithms"><SPAN =
 380
 381        class=3D"tocnumber">11</SPAN> <SPAN =
 382class=3D"toctext">Algorithms</SPAN></A>
 383        <UL>
 384          <LI class=3D"toclevel-2 tocsection-41"><A =
 385href=3D"http://wiki.theory.org/BitTorrentSpecification#Queuing"><SPAN=20
 386          class=3D"tocnumber">11.1</SPAN> <SPAN=20
 387          class=3D"toctext">Queuing</SPAN></A></LI>
 388          <LI class=3D"toclevel-2 tocsection-42"><A =
 389href=3D"http://wiki.theory.org/BitTorrentSpecification#Super_Seeding"><SP=
 390AN=20
 391          class=3D"tocnumber">11.2</SPAN> <SPAN class=3D"toctext">Super=20
 392          Seeding</SPAN></A></LI>
 393          <LI class=3D"toclevel-2 tocsection-43"><A =
 394href=3D"http://wiki.theory.org/BitTorrentSpecification#Piece_downloading_=
 395strategy"><SPAN=20
 396          class=3D"tocnumber">11.3</SPAN> <SPAN class=3D"toctext">Piece =
 397downloading=20
 398          strategy</SPAN></A></LI>
 399          <LI class=3D"toclevel-2 tocsection-44"><A =
 400href=3D"http://wiki.theory.org/BitTorrentSpecification#End_Game"><SPAN=20
 401          class=3D"tocnumber">11.4</SPAN> <SPAN class=3D"toctext">End=20
 402          Game</SPAN></A></LI>
 403          <LI class=3D"toclevel-2 tocsection-45"><A =
 404href=3D"http://wiki.theory.org/BitTorrentSpecification#Choking_and_Optimi=
 405stic_Unchoking"><SPAN=20
 406          class=3D"tocnumber">11.5</SPAN> <SPAN =
 407class=3D"toctext">Choking and=20
 408          Optimistic Unchoking</SPAN></A>
 409          <UL>
 410            <LI class=3D"toclevel-3 tocsection-46"><A =
 411href=3D"http://wiki.theory.org/BitTorrentSpecification#Anti-snubbing"><SP=
 412AN=20
 413            class=3D"tocnumber">11.5.1</SPAN> <SPAN=20
 414            =
 415class=3D"toctext">Anti-snubbing</SPAN></A></LI></UL></LI></UL></LI>
 416        <LI class=3D"toclevel-1 tocsection-47"><A =
 417href=3D"http://wiki.theory.org/BitTorrentSpecification#Official_Extension=
 418s_To_The_Protocol"><SPAN=20
 419        class=3D"tocnumber">12</SPAN> <SPAN class=3D"toctext">Official =
 420Extensions To=20
 421        The Protocol</SPAN></A>
 422        <UL>
 423          <LI class=3D"toclevel-2 tocsection-48"><A =
 424href=3D"http://wiki.theory.org/BitTorrentSpecification#Fast_Peers_Extensi=
 425ons"><SPAN=20
 426          class=3D"tocnumber">12.1</SPAN> <SPAN class=3D"toctext">Fast =
 427Peers=20
 428          Extensions</SPAN></A></LI>
 429          <LI class=3D"toclevel-2 tocsection-49"><A =
 430href=3D"http://wiki.theory.org/BitTorrentSpecification#Distributed_Hash_T=
 431able"><SPAN=20
 432          class=3D"tocnumber">12.2</SPAN> <SPAN =
 433class=3D"toctext">Distributed Hash=20
 434          Table</SPAN></A></LI>
 435          <LI class=3D"toclevel-2 tocsection-50"><A =
 436href=3D"http://wiki.theory.org/BitTorrentSpecification#Connection_Obfusca=
 437tion"><SPAN=20
 438          class=3D"tocnumber">12.3</SPAN> <SPAN =
 439class=3D"toctext">Connection=20
 440          Obfuscation</SPAN></A></LI></UL></LI>
 441        <LI class=3D"toclevel-1 tocsection-51"><A =
 442href=3D"http://wiki.theory.org/BitTorrentSpecification#Unofficial_Extensi=
 443ons_To_The_Protocol"><SPAN=20
 444        class=3D"tocnumber">13</SPAN> <SPAN class=3D"toctext">Unofficial =
 445Extensions=20
 446        To The Protocol</SPAN></A>
 447        <UL>
 448          <LI class=3D"toclevel-2 tocsection-52"><A =
 449href=3D"http://wiki.theory.org/BitTorrentSpecification#Azureus_Messaging_=
 450Protocol"><SPAN=20
 451          class=3D"tocnumber">13.1</SPAN> <SPAN =
 452class=3D"toctext">Azureus Messaging=20
 453          Protocol</SPAN></A></LI>
 454          <LI class=3D"toclevel-2 tocsection-53"><A =
 455href=3D"http://wiki.theory.org/BitTorrentSpecification#WebSeeding"><SPAN =
 456
 457          class=3D"tocnumber">13.2</SPAN> <SPAN=20
 458          class=3D"toctext">WebSeeding</SPAN></A></LI>
 459          <LI class=3D"toclevel-2 tocsection-54"><A =
 460href=3D"http://wiki.theory.org/BitTorrentSpecification#Extension_protocol=
 461"><SPAN=20
 462          class=3D"tocnumber">13.3</SPAN> <SPAN =
 463class=3D"toctext">Extension=20
 464          protocol</SPAN></A></LI>
 465          <LI class=3D"toclevel-2 tocsection-55"><A =
 466href=3D"http://wiki.theory.org/BitTorrentSpecification#Extension_Negotiat=
 467ion_Protocol"><SPAN=20
 468          class=3D"tocnumber">13.4</SPAN> <SPAN =
 469class=3D"toctext">Extension=20
 470          Negotiation Protocol</SPAN></A></LI>
 471          <LI class=3D"toclevel-2 tocsection-56"><A =
 472href=3D"http://wiki.theory.org/BitTorrentSpecification#BitTorrent_Locatio=
 473n-aware_Protocol_1.0"><SPAN=20
 474          class=3D"tocnumber">13.5</SPAN> <SPAN =
 475class=3D"toctext">BitTorrent=20
 476          Location-aware Protocol 1.0</SPAN></A></LI>
 477          <LI class=3D"toclevel-2 tocsection-57"><A =
 478href=3D"http://wiki.theory.org/BitTorrentSpecification#SimpleBT_Extension=
 479_Protocol"><SPAN=20
 480          class=3D"tocnumber">13.6</SPAN> <SPAN =
 481class=3D"toctext">SimpleBT Extension=20
 482          Protocol</SPAN></A></LI>
 483          <LI class=3D"toclevel-2 tocsection-58"><A =
 484href=3D"http://wiki.theory.org/BitTorrentSpecification#BitComet_Extension=
 485_Protocol"><SPAN=20
 486          class=3D"tocnumber">13.7</SPAN> <SPAN =
 487class=3D"toctext">BitComet Extension=20
 488          Protocol</SPAN></A></LI></UL></LI>
 489        <LI class=3D"toclevel-1 tocsection-59"><A =
 490href=3D"http://wiki.theory.org/BitTorrentSpecification#Reserved_Bytes"><S=
 491PAN=20
 492        class=3D"tocnumber">14</SPAN> <SPAN class=3D"toctext">Reserved=20
 493        Bytes</SPAN></A></LI>
 494        <LI class=3D"toclevel-1 tocsection-60"><A =
 495href=3D"http://wiki.theory.org/BitTorrentSpecification#Change_Log"><SPAN =
 496
 497        class=3D"tocnumber">15</SPAN> <SPAN class=3D"toctext">Change=20
 498        Log</SPAN></A></LI>
 499        <LI class=3D"toclevel-1 tocsection-61"><A =
 500href=3D"http://wiki.theory.org/BitTorrentSpecification#Related_Links"><SP=
 501AN=20
 502        class=3D"tocnumber">16</SPAN> <SPAN class=3D"toctext">Related=20
 503        Links</SPAN></A></LI></UL></TD></TR></TBODY></TABLE>
 504<SCRIPT>if (window.showTocToggle) { var tocShowText =3D "show"; var =
 505tocHideText =3D "hide"; showTocToggle(); } </SCRIPT>
 506
 507<H2> <SPAN id=3D"Identification" class=3D"mw-headline"> Identification =
 508</SPAN></H2>
 509<P><A class=3D"new" title=3D"BitTorrent (page does not exist)" =
 510href=3D"http://wiki.theory.org/index.php?title=3DBitTorrent&amp;action=3D=
 511edit&amp;redlink=3D1">BitTorrent</A>=20
 512is a peer-to-peer file sharing protocol designed by Bram Cohen.  Visit =
 513his pages=20
 514at <A class=3D"external free" href=3D"http://www.bittorrent.com/"=20
 515rel=3D"nofollow">http://www.bittorrent.com/</A> BitTorrent is designed =
 516to=20
 517facilitate file transfers among multiple peers across unreliable =
 518networks.</P>
 519<H2> <SPAN id=3D"Purpose" class=3D"mw-headline"> Purpose </SPAN></H2>
 520<P>The purpose of this specification is to document version 1.0 of the=20
 521BitTorrent protocol specification in detail.  Bram's  <A =
 522class=3D"external text"=20
 523href=3D"http://bittorrent.org/beps/bep_0003.html" =
 524rel=3D"nofollow">protocol=20
 525specification page</A> outlines the protocol in somewhat general terms, =
 526and=20
 527lacks behaviorial detail in some areas.  The hope is that this document =
 528will=20
 529become a <B>formal</B> specification, written in clear, unambiguous =
 530terms, which=20
 531can be used as a basis for discussion and implementation in the =
 532future.</P>
 533<P>This document is intended to be maintained and used by the BitTorrent =
 534
 535development community.  Everyone is invited to contribute to this =
 536document, with=20
 537the understanding that the content here is intended to represent the =
 538current=20
 539protocol (What if the current protocol is 2.0? The scope is then =
 540conflicting),=20
 541which is already deployed in a number of existing client =
 542implementations.</P>
 543<P>This is not the place to suggest feature requests.  For that, please =
 544go to=20
 545the <A class=3D"external text" =
 546href=3D"http://lists.ibiblio.org/mailman/listinfo/bittorrent"=20
 547rel=3D"nofollow">mailing list</A>.</P>
 548<H2> <SPAN id=3D"Scope" class=3D"mw-headline"> Scope </SPAN></H2>
 549<P>This document applies to the first version (i.e. version 1.0) of the=20
 550BitTorrent protocol specification. Currently, this applies to the =
 551torrent file=20
 552structure, peer wire protocol, and the Tracker HTTP/HTTPS protocol=20
 553specifications. As newer revisions of each protocol are defined, they =
 554should be=20
 555specified on their own separate pages, <B>not here</B>.</P>
 556<H2> <SPAN id=3D"Related_Documents" class=3D"mw-headline"> Related =
 557Documents=20
 558</SPAN></H2>
 559<UL>
 560  <LI> <A class=3D"external text" =
 561href=3D"http://bittorrent.org/beps/bep_0003.html"=20
 562  rel=3D"nofollow">Official protocol specification</A></LI>
 563  <LI> <A title=3D"BitTorrentWishList" =
 564href=3D"http://wiki.theory.org/BitTorrentWishList">Developer=20
 565  and user wishlist</A></LI>
 566  <LI> <A title=3D"BitTorrentTrackerExtensions" =
 567href=3D"http://wiki.theory.org/BitTorrentTrackerExtensions">Tracker=20
 568  protocol extensions</A></LI></UL>
 569<H2> <SPAN id=3D"Conventions" class=3D"mw-headline"> Conventions =
 570</SPAN></H2>
 571<P>In this document, a number of conventions are used in an attempt to =
 572present=20
 573information in a concise and unambiguous fashion.</P>
 574<UL>
 575  <LI> <I>peer</I> v/s <I>client</I>: In this document, a <I>peer</I> is =
 576any=20
 577  BitTorrent client participating in a download.  The <I>client</I> is =
 578also a=20
 579  peer, however it is the BitTorrent client that is running on the local =
 580
 581  machine.  Readers of this specification may choose to think of =
 582themselves as=20
 583  the <I>client</I> which connects to numerous <I>peers</I>.</LI>
 584  <LI> <I>piece</I> v/s <I>block</I>: In this document, a <I>piece</I> =
 585refers to=20
 586  a portion of the downloaded data that is described in the metainfo =
 587file, which=20
 588  can be verified by a SHA1 hash.  A <I>block</I> is a portion of data =
 589that a=20
 590  <I>client</I> may request from at least one <I>peer</I>.  Two or more=20
 591  <I>blocks</I> make up a whole <I>piece</I>, which may then be =
 592verified.</LI>
 593  <LI> <I>defacto standard</I>: Large blocks of text in <I>italics</I> =
 594indicates=20
 595  a practice so common in various client implementations of BitTorrent =
 596that it=20
 597  is considered a defacto standard.</LI></UL>
 598<P>In order to help others find recent changes that have been made to =
 599this=20
 600document, please fill out the change log (last section).  This should =
 601contain a=20
 602brief (i.e. one-line) entry for each major change that you've made to =
 603the=20
 604document.</P>
 605<H2> <SPAN id=3D"Bencoding" class=3D"mw-headline"> Bencoding =
 606</SPAN></H2>
 607<P>Bencoding is a way to specify and organize data in a terse format.  =
 608It=20
 609supports the following types: byte strings, integers, lists, and =
 610dictionaries.
 611</P>
 612<H3> <SPAN id=3D"Bencoded_Strings" class=3D"mw-headline"> Bencoded =
 613Strings=20
 614</SPAN></H3>
 615<P>Bencoded strings are encoded as follows: <I>&lt;string length encoded =
 616in base=20
 617ten ASCII&gt;<B>:</B>&lt;string data&gt;</I>, or =
 618<I>key</I>:<I>value</I><BR>Note=20
 619that there is no constant beginning delimiter, and no ending =
 620delimiter.</P>
 621<DL>
 622  <DD><B>Example</B>: <I>4<B>:</B>spam</I> represents the string =
 623"spam"</DD></DL>
 624<H3> <SPAN id=3D"Integers" class=3D"mw-headline"> Integers </SPAN></H3>
 625<P>Integers are encoded as follows: <I><B>i</B>&lt;integer encoded in =
 626base ten=20
 627ASCII&gt;<B>e</B></I><BR>The initial <B>i</B> and trailing <B>e</B> are=20
 628beginning and ending delimiters. You can have negative numbers such as=20
 629<I><B>i</B>-3<B>e</B></I>. Only the significant digits should be used, =
 630one=20
 631cannot pad the Integer with zeroes. such as <I><B>i</B>04<B>e</B></I>.  =
 632However,=20
 633<I><B>i</B>0<B>e</B></I> is valid.</P>
 634<DL>
 635  <DD><B>Example</B>: <I><B>i</B>3<B>e</B></I> represents the integer =
 636"3"
 637</DD></DL>
 638<UL>
 639  <LI> <I>NOTE:</I> The maximum number of bit of this integer is =
 640unspecified,=20
 641  but to handle it as a signed 64bit integer is mandatory to handle =
 642"large=20
 643  files" aka .torrent for more that 4Gbyte.</LI></UL>
 644<H3> <SPAN id=3D"Lists" class=3D"mw-headline"> Lists </SPAN></H3>
 645<P>Lists are encoded as follows: <I><B>l</B>&lt;bencoded=20
 646values&gt;<B>e</B></I><BR>The initial <B>l</B> and trailing <B>e</B> are =
 647
 648beginning and ending delimiters. Lists may contain any bencoded type, =
 649including=20
 650integers, strings, dictionaries, and even lists within other lists.</P>
 651<DL>
 652  <DD><B>Example:</B> <I><B>l</B>4:spam4:eggs<B>e</B></I> represents the =
 653list of=20
 654  two strings: [ "spam", "eggs" ]</DD></DL>
 655<H3> <SPAN id=3D"Dictionaries" class=3D"mw-headline"> Dictionaries =
 656</SPAN></H3>
 657<P>Dictionaries are encoded as follows: <I><B>d</B>&lt;bencoded=20
 658string&gt;&lt;bencoded element&gt;<B>e</B></I> <BR>The initial <B>d</B> =
 659and=20
 660trailing <B>e</B> are the beginning and ending delimiters. Note that the =
 661keys=20
 662must be bencoded strings.  The values may be any bencoded type, =
 663including=20
 664integers, strings, lists, and other dictionaries.  Keys must be strings =
 665and=20
 666appear in sorted order (sorted as raw strings, not alphanumerics). The =
 667strings=20
 668should be compared using a binary  comparison, not a culture-specific =
 669"natural"=20
 670comparison.</P>
 671<DL>
 672  <DD><B>Example</B>: <I><B>d</B>3:cow3:moo4:spam4:eggs<B>e</B> =
 673represents the=20
 674  dictionary { "cow" =3D&gt; "moo", "spam" =3D&gt; "eggs" } =
 675<BR></I></DD>
 676  <DD><B>Example</B>: <I><B>d</B>4:spaml1:a1:b<B>ee'</B> represents the=20
 677  dictionary { "spam" =3D&gt; [ "a", "b" ] } <BR></I></DD>
 678  <DD><B>Example</B>:=20
 679  =
 680<I><B>d</B>9:publisher3:bob17:publisher-webpage15:www.example.com18:publi=
 681sher.location4:home<B>e</B></I>=20
 682  represents { "publisher" =3D&gt; "bob", "publisher-webpage" =3D&gt;=20
 683  "www.example.com", "publisher.location" =3D&gt; "home" }</DD></DL>
 684<H3> <SPAN id=3D"Implementations" class=3D"mw-headline"> Implementations =
 685
 686</SPAN></H3>
 687<UL>
 688  <LI> <A class=3D"external text" =
 689href=3D"http://funzix.git.sourceforge.net/git/gitweb.cgi?p=3Dfunzix/funzi=
 690x;a=3Dblob;f=3Dbencode/bencode.c"=20
 691  rel=3D"nofollow">C</A> by <A class=3D"new" title=3D"User:Vapier (page =
 692does not exist)"=20
 693  =
 694href=3D"http://wiki.theory.org/index.php?title=3DUser:Vapier&amp;action=3D=
 695edit&amp;redlink=3D1">Mike=20
 696  Frysinger</A></LI>
 697  <LI> <A class=3D"external text" =
 698href=3D"http://search.cpan.org/dist/Convert-Bencode/lib/Convert/Bencode.p=
 699m"=20
 700  rel=3D"nofollow">Perl</A></LI>
 701  <LI> <A class=3D"external text" =
 702href=3D"http://www.koders.com/java/fid47111A56F2466C232E09AEF75A39915EC70=
 703D3536.aspx#L52"=20
 704  rel=3D"nofollow">Java</A></LI>
 705  <LI> <A title=3D"Decoding bencoded data with python" =
 706href=3D"http://wiki.theory.org/Decoding_bencoded_data_with_python">Python=
 707</A>=20
 708  by <A class=3D"new" title=3D"User:Hackeron (page does not exist)" =
 709href=3D"http://wiki.theory.org/index.php?title=3DUser:Hackeron&amp;action=
 710=3Dedit&amp;redlink=3D1">Hackeron</A>
 711  </LI>
 712  <LI> <A title=3D"Decoding encoding bencoded data with haskell" =
 713href=3D"http://wiki.theory.org/Decoding_encoding_bencoded_data_with_haske=
 714ll">Decoding=20
 715  encoding bencoded data with haskell</A> by <A class=3D"new" =
 716title=3D"User:Edi (page does not exist)"=20
 717  =
 718href=3D"http://wiki.theory.org/index.php?title=3DUser:Edi&amp;action=3Ded=
 719it&amp;redlink=3D1">Edi</A>
 720  </LI>
 721  <LI> <A class=3D"external text" =
 722href=3D"http://www.stupendous.net/projects/bencoding-obj-c-class/"=20
 723  rel=3D"nofollow">Objective-C</A> by <A class=3D"new" =
 724title=3D"User:Chrome (page does not exist)"=20
 725  =
 726href=3D"http://wiki.theory.org/index.php?title=3DUser:Chrome&amp;action=3D=
 727edit&amp;redlink=3D1">Chrome</A>
 728  </LI>
 729  <LI> <A title=3D"JScript: Converting a torrent file to a JScript =
 730dictionary"=20
 731  =
 732href=3D"http://wiki.theory.org/JScript:_Converting_a_torrent_file_to_a_JS=
 733cript_dictionary">JScript</A>=20
 734  by <A class=3D"new" title=3D"User:Sergej B. (page does not exist)" =
 735href=3D"http://wiki.theory.org/index.php?title=3DUser:Sergej_B.&amp;actio=
 736n=3Dedit&amp;redlink=3D1">Sergej=20
 737  B.</A></LI>
 738  <LI> <A class=3D"external text" =
 739href=3D"http://demon.tw/my-work/javascript-bencode.html"=20
 740  rel=3D"nofollow">JavaScript</A> by <A class=3D"external text" =
 741href=3D"http://demon.tw/"=20
 742  rel=3D"nofollow">Demon</A>]</LI>
 743  <LI> <A class=3D"external text" =
 744href=3D"http://demon.tw/my-work/vbs-bencode.html"=20
 745  rel=3D"nofollow">VBScript</A> by <A class=3D"external text" =
 746href=3D"http://demon.tw/"=20
 747  rel=3D"nofollow">Demon</A>]</LI>
 748  <LI> <A class=3D"external text" =
 749href=3D"http://nakkaya.com/2009/11/02/decoding-bencoded-streams-in-clojur=
 750e/"=20
 751  rel=3D"nofollow">Clojure</A> by <A class=3D"new" title=3D"User:Nakkaya =
 752(page does not exist)"=20
 753  =
 754href=3D"http://wiki.theory.org/index.php?title=3DUser:Nakkaya&amp;action=3D=
 755edit&amp;redlink=3D1">nakkaya</A>
 756  </LI>
 757  <LI> <A title=3D"Decoding encoding bencoded data with erlang" =
 758href=3D"http://wiki.theory.org/Decoding_encoding_bencoded_data_with_erlan=
 759g">Erlang</A>
 760  </LI>
 761  <LI> <A title=3D"Decoding encoding bencoded data with PHP" =
 762href=3D"http://wiki.theory.org/Decoding_encoding_bencoded_data_with_PHP">=
 763PHP</A>
 764  </LI>
 765  <LI> <A class=3D"external text" =
 766href=3D"http://code.google.com/p/php-bencode-extension/"=20
 767  rel=3D"nofollow">PHP Extension</A></LI>
 768  <LI> <A class=3D"external text" =
 769href=3D"http://snipplr.com/view/37790/bencoding-encoder-and-decoder/"=20
 770  rel=3D"nofollow">C#</A> by <A class=3D"new" title=3D"User:SuprDewd =
 771(page does not exist)"=20
 772  =
 773href=3D"http://wiki.theory.org/index.php?title=3DUser:SuprDewd&amp;action=
 774=3Dedit&amp;redlink=3D1">SuprDewd</A>
 775  </LI>
 776  <LI> <A class=3D"external text" =
 777href=3D"http://cvs.savannah.gnu.org/viewvc/mldonkey/mldonkey/src/networks=
 778/bittorrent/bencode.ml?view=3Dmarkup"=20
 779  rel=3D"nofollow">OCaml</A> by <A class=3D"external text" =
 780href=3D"http://mldonkey.sourceforge.net/Main_Page"=20
 781  rel=3D"nofollow">MLDonkey</A></LI>
 782  <LI> <A class=3D"external text" =
 783href=3D"https://github.com/jsz/gorrent/tree/master/bencode"=20
 784  rel=3D"nofollow">Go</A> by <A class=3D"external text" =
 785href=3D"http://jsz.github.com/"=20
 786  rel=3D"nofollow">Leon Szpilewski</A></LI></UL>
 787<H2> <SPAN id=3D"Metainfo_File_Structure" class=3D"mw-headline"> =
 788Metainfo File=20
 789Structure </SPAN></H2>
 790<P>All data in a metainfo file is bencoded.  The specification for =
 791bencoding is=20
 792defined above.</P>
 793<P>The content of a metainfo file (the file ending in ".torrent") is a =
 794bencoded=20
 795dictionary, containing the keys listed below. All character string =
 796values are=20
 797UTF-8 encoded.</P>
 798<UL>
 799  <LI> <B>info</B>: a dictionary that describes the file(s) of the =
 800torrent. =20
 801  There are two possible forms: one for the case of a 'single-file' =
 802torrent with=20
 803  no directory structure, and one for the case of a 'multi-file' torrent =
 804(see=20
 805  below for details)</LI>
 806  <LI> <B>announce</B>: The announce URL of the tracker (string)</LI>
 807  <LI> <B>announce-list</B>: (optional) this is an extention to the =
 808official=20
 809  specification, offering backwards-compatibility.  (list of lists of =
 810strings).
 811  <UL>
 812    <LI>The official request for a specification change is <A =
 813class=3D"external text"=20
 814    href=3D"http://bittorrent.org/beps/bep_0012.html" =
 815rel=3D"nofollow">here</A>.
 816  </LI></UL></LI>
 817  <LI> <B>creation date</B>: (optional) the creation time of the =
 818torrent, in=20
 819  standard UNIX epoch format (integer, seconds since 1-Jan-1970 00:00:00 =
 820UTC)
 821  </LI>
 822  <LI> <B>comment</B>: (optional) free-form textual comments of the =
 823author=20
 824  (string)</LI>
 825  <LI> <B>created by</B>: (optional) name and version of the program =
 826used to=20
 827  create the .torrent (string)</LI>
 828  <LI> <B>encoding</B>: (optional) the string encoding format used to =
 829generate=20
 830  the <B>pieces</B> part of the <B>info</B> dictionary in the .torrent =
 831metafile=20
 832  (string)</LI></UL>
 833<H3> <SPAN id=3D"Info_Dictionary" class=3D"mw-headline">Info =
 834Dictionary</SPAN></H3>
 835<P>This section contains the field which are common to both mode, =
 836"single file"=20
 837and "multiple file".</P>
 838<UL>
 839  <LI> <B>piece length</B>: number of bytes in each piece (integer)</LI>
 840  <LI> <B>pieces</B>: string consisting of the concatenation of all =
 84120-byte SHA1=20
 842  hash values, one per piece (byte string, i.e. not urlencoded)</LI>
 843  <LI> <B>private</B>: (optional) this field is an integer. If it is set =
 844to "1",=20
 845  the client MUST publish its presence to get other peers ONLY via the =
 846trackers=20
 847  explicitly described in the metainfo file. If this field is set to "0" =
 848or is=20
 849  not present, the client may obtain peer from other means, e.g. PEX =
 850peer=20
 851  exchange, dht. Here, "private" may be read as "no external peer =
 852source".
 853  <UL>
 854    <LI> <B>NOTE:</B> There is much debate surrounding private =
 855trackers.</LI>
 856    <LI> The official request for a specification change is <A =
 857class=3D"external text"=20
 858    href=3D"http://bittorrent.org/beps/bep_0027.html" =
 859rel=3D"nofollow">here</A>.
 860</LI>
 861    <LI> Azureus was the first client to respect private trackers, <A =
 862class=3D"external text"=20
 863    href=3D"http://www.azureuswiki.com/index.php/Secure_Torrents"=20
 864    rel=3D"nofollow">see their wiki</A> for more =
 865details.</LI></UL></LI></UL>
 866<H4> <SPAN id=3D"Info_in_Single_File_Mode" class=3D"mw-headline">Info in =
 867Single File=20
 868Mode</SPAN></H4>
 869<P>For the case of the <B>single-file</B> mode, the <B>info</B> =
 870dictionary=20
 871contains the following structure:</P>
 872<UL>
 873  <LI> <B>name</B>: the filename.  This is purely advisory. =
 874(string)</LI>
 875  <LI> <B>length</B>: length of the file in bytes (integer)</LI>
 876  <LI> <B>md5sum</B>: (optional) a 32-character hexadecimal string =
 877corresponding=20
 878  to the MD5 sum of the file.  This is not used by BitTorrent at all, =
 879but it is=20
 880  included by some programs for greater compatibility.</LI></UL>
 881<H4> <SPAN id=3D"Info_in_Multiple_File_Mode" class=3D"mw-headline">Info =
 882in Multiple=20
 883File Mode</SPAN></H4>
 884<P>For the case of the <B>multi-file</B> mode, the <B>info</B> =
 885dictionary=20
 886contains the following structure:</P>
 887<UL>
 888  <LI> <B>name</B>: the file path of the directory in which to store all =
 889the=20
 890  files.  This is purely advisory. (string)</LI>
 891  <LI> <B>files</B>: a list of dictionaries, one for each file. Each =
 892dictionary=20
 893  in this list contains the following keys:
 894  <UL>
 895    <LI> <B>length</B>: length of the file in bytes (integer)</LI>
 896    <LI> <B>md5sum</B>: (optional) a 32-character hexadecimal string=20
 897    corresponding to the MD5 sum of the file.  This is not used by =
 898BitTorrent at=20
 899    all, but it is included by some programs for greater =
 900compatibility.</LI>
 901    <LI> <B>path</B>: a list containing one or more string elements that =
 902
 903    together represent the path and filename.  Each element in the list=20
 904    corresponds to either a directory name or (in the case of the final =
 905element)=20
 906    the filename.  For example, a the file "dir1/dir2/file.ext" would =
 907consist of=20
 908    three string elements: "dir1", "dir2", and "file.ext".  This is =
 909encoded as a=20
 910    bencoded list of strings such as=20
 911    =
 912<I>l<B>4</B>:dir1<B>4</B>:dir2<B>8</B>:file.ext<B>e</B></I></LI></UL></LI=
 913></UL>
 914<H3> <SPAN id=3D"Notes" class=3D"mw-headline">Notes</SPAN></H3>
 915<UL>
 916  <LI> The <B>piece length</B> specifies the nominal piece size, and is =
 917usually=20
 918  a power of 2.  The piece size is typically chosen based on the total =
 919amount of=20
 920  file data in the torrent, and is constrained by the fact that =
 921too-large piece=20
 922  sizes cause inefficiency, and too-small piece sizes cause large =
 923.torrent=20
 924  metadata file.  Historically, piece size was chosen to result in a =
 925.torrent=20
 926  file no greater than approx. 50 - 75 kB (presumably to ease the load =
 927on the=20
 928  server hosting the torrent files). =20
 929  <UL>
 930    <LI>Current best-practice is to <I>keep the piece size to 512KB or =
 931less,</I>=20
 932    for torrents around 8-10GB, even if that results in a larger =
 933.torrent file. =20
 934    This results in a more efficient swarm for sharing files.   The most =
 935common=20
 936    sizes are 256 kB, 512 kB, and 1 MB.  </LI>
 937    <LI>Every piece is of equal length except for the final piece, which =
 938is=20
 939    irregular.  The number of pieces is thus determined by 'ceil( total =
 940length /=20
 941    piece size )'.  </LI>
 942    <LI>For the purposes of piece boundaries in the multi-file case, =
 943consider=20
 944    the file data as one long continuous stream, composed of the =
 945concatenation=20
 946    of each file in the order listed in the <I>files</I> list.  The =
 947number of=20
 948    pieces and their boundaries are then determined in the same manner =
 949as the=20
 950    case of a single file.  Pieces may overlap file =
 951boundaries.</LI></UL></LI>
 952  <LI> Each piece has a corresponding SHA1 hash of the data contained =
 953within=20
 954  that piece.  These hashes are concatenated to form the <I>pieces<B> =
 955value in=20
 956  the above </B></I><B>info</B> dictionary.  Note that this is =
 957<B>not</B> a list=20
 958  but rather a single string. The length of the string must be a =
 959multiple of 20.
 960  </LI></UL>
 961<H2> <SPAN id=3D"Tracker_HTTP.2FHTTPS_Protocol" class=3D"mw-headline"> =
 962Tracker=20
 963HTTP/HTTPS Protocol </SPAN></H2>
 964<P>The tracker is an HTTP/HTTPS service which responds to HTTP GET =
 965requests. The=20
 966requests include metrics from clients that help the tracker keep overall =
 967
 968statistics about the torrent. The response includes a peer list that =
 969helps the=20
 970client participate in the torrent. The base URL consists of the =
 971"announce URL"=20
 972as defined in the metainfo (.torrent) file.  The parameters are then =
 973added to=20
 974this URL, using standard CGI methods (i.e. a '?' after the announce URL, =
 975
 976followed by 'param=3Dvalue' sequences separated by '&amp;').</P>
 977<P>Note that all binary data in the URL (particularly info_hash and =
 978peer_id)=20
 979must be properly escaped.  This means any byte not in the set 0-9, a-z, =
 980A-Z,=20
 981'.', '-', '_' and '~', must be encoded using the "%nn" format, where nn =
 982is the=20
 983hexadecimal value of the byte. (See <A class=3D"external text" =
 984href=3D"http://www.faqs.org/rfcs/rfc1738.html"=20
 985rel=3D"nofollow">RFC1738</A> for details.) </P>
 986<P>For a 20-byte hash of=20
 987\x12\x34\x56\x78\x9a\xbc\xde\xf1\x23\x45\x67\x89\xab\xcd\xef\x12\x34\x56\=
 988x78\x9a,<BR>
 989The right encoded form =
 990is&nbsp;%124Vx%9A%BC%DE%F1%23Eg%89%AB%CD%EF%124Vx%9A</P>
 991<H3> <SPAN id=3D"Tracker_Request_Parameters" =
 992class=3D"mw-headline">Tracker Request=20
 993Parameters</SPAN></H3>
 994<P>The parameters used in the client-&gt;tracker GET request are as =
 995follows:</P>
 996<UL>
 997  <LI> <B>info_hash</B>: urlencoded 20-byte SHA1 hash of the =
 998<I>value</I> of the=20
 999  <I>info</I> key from the Metainfo file.  Note that the <I>value</I> =
1000will be a=20
1001  bencoded dictionary, given the definition of the <I>info</I> key =
1002above. </LI>
1003  <LI> <B><A=20
1004  =
1005href=3D"http://wiki.theory.org/BitTorrentSpecification#peer_id">peer_id</=
1006A></B>:=20
1007  urlencoded 20-byte string used as a unique ID for the client, =
1008generated by the=20
1009  client at startup.  This is allowed to be any value, and may be binary =
1010data. =20
1011  <I>There are currently no guidelines for generating this peer ID.  =
1012However,=20
1013  one may rightly presume that it must at least be unique for your local =
1014
1015  machine, thus should probably incorporate things like process ID and =
1016perhaps a=20
1017  timestamp recorded at startup. See <A =
1018href=3D"http://wiki.theory.org/BitTorrentSpecification#peer_id">peer_id=20
1019  </A> below for common client encodings of this field.</I></LI>
1020  <LI> <B>port</B>: The port number that the client is listening on.  =
1021Ports=20
1022  reserved for BitTorrent are typically 6881-6889.  Clients may choose =
1023to give=20
1024  up if it cannot establish a port within this range.</LI>
1025  <LI> <B>uploaded</B>: The total amount uploaded (since the client sent =
1026the=20
1027  'started' event to the tracker) in base ten ASCII.  While not =
1028explicitly=20
1029  stated in the official specification, the concensus is that this =
1030should be the=20
1031  total number of bytes uploaded.</LI>
1032  <LI> <B>downloaded</B>: The total amount downloaded (since the client =
1033sent the=20
1034  'started' event to the tracker) in base ten ASCII.  While not =
1035explicitly=20
1036  stated in the official specification, the consensus is that this =
1037should be the=20
1038  total number of bytes downloaded.</LI>
1039  <LI> <B>left</B>: The number of bytes this client still has to =
1040download in=20
1041  base ten ASCII.</LI>
1042  <LI> <B>compact</B>: Setting this to 1 indicates that the client =
1043accepts a=20
1044  compact response. The announce-list is replaced by a peers string with =
10456 bytes=20
1046  per peer. The first four bytes are the host (in network byte order), =
1047the last=20
1048  two bytes are the port (again in network byte order). It should be =
1049noted that=20
1050  some trackers only support compact responses (for saving bandwidth) =
1051and either=20
1052  refuse requests without "compact=3D1" or simply send a compact =
1053response unless=20
1054  the request contains "compact=3D0" (in which case they will refuse the =
1055request.)
1056  </LI>
1057  <LI> <B>no_peer_id</B>: Indicates that the tracker can omit peer id =
1058field in=20
1059  announce-list dictionary. This option is ignored if compact is =
1060enabled.</LI>
1061  <LI> <B>event</B>: If specified, must be one of <I>started</I>,=20
1062  <I>completed</I>, <I>stopped</I>, (or empty which is the same as not =
1063being=20
1064  specified).  If not specified, then this request is one performed at =
1065regular=20
1066  intervals.
1067  <UL>
1068    <LI> <B>started</B>: The first request to the tracker <I>must</I> =
1069include=20
1070    the event key with this value.</LI>
1071    <LI> <B>stopped</B>: Must be sent to the tracker if the client is =
1072shutting=20
1073    down gracefully.</LI>
1074    <LI> <B>completed</B>: Must be sent to the tracker when the download =
1075
1076    completes.  However, must not be sent if the download was already =
1077100%=20
1078    complete when the client started.  Presumably, this is to allow the =
1079tracker=20
1080    to increment the "completed downloads" metric based solely on this =
1081event.
1082    </LI></UL></LI>
1083  <LI> <B>ip</B>: Optional.  The true IP address of the client machine, =
1084in=20
1085  dotted quad format or rfc3513 defined hexed IPv6 address.  <I>Notes: =
1086In=20
1087  general this parameter is not necessary as the address of the client =
1088can be=20
1089  determined from the IP address from which the HTTP request came.  The=20
1090  parameter is only needed in the case where the IP address that the =
1091request=20
1092  came in on is not the IP address of the client.  This happens if the =
1093client is=20
1094  communicating to the tracker through a proxy (or a transparent web=20
1095  proxy/cache.)  It also is necessary when both the client and the =
1096tracker are=20
1097  on the same local side of a NAT gateway.  The reason for this is that=20
1098  otherwise the tracker would give out the internal (RFC1918) address of =
1099the=20
1100  client, which is not routable.  Therefore the client must explicitly =
1101state its=20
1102  (external, routable) IP address to be given out to external peers.  =
1103Various=20
1104  trackers treat this parameter differently.  Some only honor it only if =
1105the IP=20
1106  address that the request came in on is in RFC1918 space.  Others honor =
1107it=20
1108  unconditionally, while others ignore it completely. In case of IPv6 =
1109address=20
1110  (e.g.: 2001:db8:1:2::100) it indicates only that client can =
1111communicate via=20
1112  IPv6.</I></LI>
1113  <LI> <B>numwant</B>: Optional.  Number of peers that the client would =
1114like to=20
1115  receive from the tracker.  This value is permitted to be zero.  If =
1116omitted,=20
1117  typically defaults to 50 peers.</LI>
1118  <LI> <B>key</B>: Optional. An additional client identification =
1119mechanism that=20
1120  is not shared with any peers. It is intended to allow a client to =
1121prove their=20
1122  identity should their IP address change.</LI>
1123  <LI> <B>trackerid</B>: Optional. If a previous announce contained a =
1124tracker=20
1125  id, it should be set here.</LI></UL>
1126<H3> <SPAN id=3D"Tracker_Response" class=3D"mw-headline">Tracker=20
1127Response</SPAN></H3>
1128<P>The tracker responds with "text/plain" document consisting of a =
1129bencoded=20
1130dictionary with the following keys:</P>
1131<UL>
1132  <LI> <B>failure reason</B>: If present, then no other keys may be =
1133present. =20
1134  The value is a human-readable error message as to why the request =
1135failed=20
1136  (string).</LI>
1137  <LI> <B>warning message</B>: (new, optional) Similar to failure =
1138reason, but=20
1139  the response still gets processed normally. The warning message is =
1140shown just=20
1141  like an error.</LI>
1142  <LI> <B>interval</B>: Interval in sec…

Large files files are truncated, but you can click here to view the full file