Fichier Torrent

From Shareaza Wiki
Revision as of 15:09, 31 March 2014 by Ji d (talk | contribs)
Jump to navigation Jump to search

Un fichier torrent stocke les métadonnée utilisées pour BitTorrent. Il est défini dans les spécifications de BitTorrent. Lors d'un téléchargement classique sur Internet, un fichier (ou groupe de fichiers) est transmis d'un ordinateur (généralement un serveur) à un autre ordinateur (un client). Les données sont conservées dans un emplacement centralisé et est récupéré à la demande d'un seul utilisateur.

BitTorrent distribue les données différemment à plusieurs niveaux. Tout d'abord, un fichier *.torrent qui n'est pas le véritable fichier que l'on souhaite télécharger. Le fichier torrent est simplement un fichier de données qui contient les informations sur le fichier que l'on souhaite télécharger. Le torrent divise le fichier cible en une série de morceaux de dimensions égales qui sont affectés une somme de contrôle d'identification.

Le transfert du fichier torrent se fait entre différents et nombreux pairs.

Plutôt que les données transférées d'une machine à l'autre, les diverses pièces du dossier sont tenues sur plusieurs ordinateurs différents. Le client torrent communiquer avec d'autres pairs afin de vérifier quelles pièces ils disposent et les échanges pour ceux dont ils ont besoin. De cette façon, le transfert de fichiers via un torrent est un peu comme un éclair rapide, jeu numérique automatisé de "Go Fish". Pairs échangent des morceaux de fichiers avec autant d'ordinateurs différents que possible et, éventuellement, de combiner les différentes parties dans l'ensemble, la demande de fichier.


The transfer of the torrent file is done between many different peers. Rather than the data being transferred from one machine to the next, the various pieces of the file are held on many different computers. The torrent client communicate with other peers in order to check which pieces they have and exchanges them for the ones they need. In this way, transferring files via a torrent is sort of like a lightning fast, digitally automated game of "Go Fish." Peers swap pieces of files with as many different computers as possible and eventually combine the various parts into the whole, requested file.

A torrent file contains the URLs of multiple trackers and integrity metadata about all the pieces. It can also contain additional metadata defined in extensions to the BitTorrent specification.<ref>Template:Cite web</ref> These are known as "BitTorrent Enhancement Proposals". Examples of such proposals include metadata for stating who created the torrent, and when.

File structure

A torrent file is a bencoded dictionary with the following keys:

  • announce - the URL of the tracker
  • info - this maps to a dictionary whose keys are dependent on whether one or more files are being shared:
    • name - suggested file/directory name where the file(s) is/are to be saved
    • piece length - number of bytes per piece. This is commonly <math>2^{18}</math> = 256KiB = 262144B.
    • pieces - concatenation of each piece's SHA-1 hash. As SHA-1 returns a 160-bit hash, pieces will be a string whose length is a multiple of 160-bits.

And exactly one of length (corresponds to when only one file is being shared) or files (corresponds to when multiple files are being shared):

    • length - size of the file (in bytes)
    • files - a list of dictionaries (each dictionary corresponds to a file) with the following keys:
      • path - a list of strings corresponding to subdirectory names, the last of which is the actual file name
      • length - size of the file (in bytes).

All strings must be UTF-8 encoded.

Extensions

Draft extensions

These extensions are under consideration for standardization.

Distributed hash tables

BEP-0005<ref>Template:Cite web</ref> extends BitTorrent to support distributed hash tables.

A trackerless torrent dictionary does not have an announce key. Instead, a trackerless torrent has a nodes key:

{
...
'nodes': [["<host>", <port>], ["<host>", <port>], ...]
...
}

For example,

'nodes': [["127.0.0.1", 6881], ["your.router.node", 4804]]

The specification recommends that nodes "should be set to the K closest nodes in the torrent generating client's routing table. Alternatively, the key could be set to a known good node such as one operated by the person generating the torrent."

Multiple trackers

BEP-0012<ref>Template:Cite web</ref> extends BitTorrent to support multiple trackers.

A new key, announce-list, is placed in the top-most list (i.e. with announce and info). This key's value is a list of tracker "tiers". Each tier is a list of URLs:

{
...
'announce-list': [["http://tracker.site1.com/announce"], ["http://tracker.site2.com/announce"]]
...
}

HTTP seeds

BEP-0017<ref>Template:Cite web</ref> extends BitTorrent to support HTTP seeds.

A new key, httpseeds, is placed in the top-most list (i.e. with announce and info). This key's value is a list of web addresses where torrent data can be retrieved:

{
...
'httpseeds': ['http://www.site1.com/source1.php', 'http://www.site2.com/source2.php']
...
}

Private torrents

BEP-0027<ref>Template:Cite web</ref> extends BitTorrent to support private torrents.

A new key, private, is placed in the info dictionary. This key's value is 1 if the torrent is private:

{
...
'private': 1
...
}

Merkle trees

BEP-0030<ref>Template:Cite web</ref> extends BitTorrent to support Merkle trees.

A torrent file using Merkle trees does not have a pieces key in the info list. Instead, such a torrent file has a root hash key in the info list. This key's value is the root hash of the Merkle hash:

{
...
'info': {
...
'root hash': e6bdebcc5d55da0a77f4bb1b57d88de794838577
...
}
...
}

Examples

Single file

Here is what a de-bencoded torrent file (with piece length 256KiB = 262144 bytes) for a file debian-503-amd64-CD-1.iso (whose size is 647MiB = 678301696 bytes) might look like:

{'announce': 'http://bttracker.debian.org:6969/announce'
'info': {'name': 'debian-503-amd64-CD-1.iso',
'piece length': 262144,
'length': 678301696,
'pieces': '841ae846bc5b6d7bd6e9aa3dd9e551559c82abc1 ... d14f1631d776008f83772ee170c42411618190a4'
}
}

Note: pieces here would be a ceil(length/piece length) * 160-bit = ceil(678301696/262144) * 160-bit = ceil(2587.515625) * 160-bit = 2588 * 160-bit = 414080-bit = 51KiB value.

Multiple files

Here is what a de-bencoded torrent file (with piece length 256KiB = 262144) for two files, 111.txt & 222.txt, might look like:

{'announce': 'http://tracker.site1.com/announce',
'info: {'name': 'directoryName',
'piece length': 262144,
'files': [ {'path': '111.txt', 'length': 111},
{'path': '222.txt', 'length': 222}
],
'pieces': '6a8af7eda90ba9f851831073c48ea6b7b7e9feeb...8a43d9d965a47f75488d3fb47d2c586337a20b9f'
}
}

References

Template:Reflist

External links

Template:BitTorrent