PageRenderTime 65ms CodeModel.GetById 19ms RepoModel.GetById 0ms 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

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

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