Skip to main content

Torrent

SpecTitleStatus
BEP03The BitTorrent Protocol Specification🟢
BEP04Known Number Allocations🟢
BEP05DHT Protocol
BEP06Fast Extension
BEP07IPv6 Tracker Extension📝
BEP08Tracker Peer Obfuscation🟡
BEP09Extension for Peers to Send Metadata Files
BEP10Extension Protocol
BEP11Peer Exchange (PEX)
BEP12Multitracker Metadata Extension
BEP14Local Service Discovery
BEP15UDP Tracker Protocol
BEP16Superseeding📝
BEP17HTTP Seeding (Hoffman-style)📝
BEP18Search Engine Specification🟡
BEP19WebSeed - HTTP/FTP Seeding (GetRight-style)
BEP20Peer ID Conventions🟢
BEP21Extension for Partial Seeds📝
BEP22BitTorrent Local Tracker Discovery Protocol🟡
BEP23Tracker Returns Compact Peer Lists
BEP24Tracker Returns External IP📝
BEP26Zeroconf Peer Advertising and Discovery🟡
BEP27Private Torrents
BEP28Tracker exchange🟡
BEP29uTorrent transport protocol
BEP30Merkle tree torrent extension📝
BEP31Tracker Failure Retry Extension📝
BEP32IPv6 extension for DHT📝
BEP33DHT scrape📝
BEP34DNS Tracker Preferences📝
BEP35Torrent Signing📝
BEP36Torrent RSS feeds📝
BEP38Finding Local Data Via Torrent File Hints📝
BEP39Updating Torrents Via Feed URL📝
BEP40Canonical Peer Priority📝
BEP41UDP Tracker Protocol Extensions📝
BEP42DHT Security Extension📝
BEP43Read-only DHT Nodes📝
BEP44Storing arbitrary data in the DHT📝
BEP45Multiple-address operation for the BitTorrent DHT📝
BEP46Updating Torrents Via DHT Mutable Items📝
BEP47Padding files and extended file attributes📝
BEP48Tracker Protocol Extension: Scrape📝
BEP49Distributed Torrent Feeds📝
BEP50Publish/Subscribe Protocol📝
BEP51DHT Infohash Indexing📝
BEP52The BitTorrent Protocol Specification v2📝
BEP53Magnet URI extension - Select specific file indices for download📝
BEP54The lt_donthave extension📝
BEP55Holepunch extension
BEP1000Pending Standards Track Documents🟢

🟢 - Final & Active ✅ - Accepted 📝 - Draft 🟡 - Deferred

BEP03

.torrent

  • bencode meta file
metainfo.json
{
"announce": "",
"announce-list": [[""]],
"comment": "",
"created by": "",
"creation date": 0,
"encoding": "UTF-8",
"info": {
"name": "file",
"piece length": 262144,
"pieces": [[]],
"length": 0,
"files": [
{
"length": 0,
"path": ["file.mkv"]
}
]
},
// 非标准字段
"nodes": [["", 0]],
"saved by": "",
"save date": 0,
"hash": ""
}
  • announce 有时为 数组
  • info 为主要内容 - infohash 基于 sha1(info)
    • piece length
      • 源文件切分块大小
        • 2^18 = 256 K - BitTorrent 3.2+
        • 2^20 = 1 M
    • pieces - [][]byte
      • sh1 数组 - sha1 长为 20
      • md4
    • length - 单文件时存在
    • files - 目录时存在
      • path
      • length
caution
  • piece 可能包含多文件 - 有的客户端会生成 padding 文件

BEP05 DHT

  • router.bittorrent.com

BEP30 Merkle hash torrent extension

  • SHA1

BEP48

Scrape for HTTP Tracker

GET http://tracker/scrape?info_hash=xxxxxxxxxxxxxxxxxxxx&info_hash=yyyyyyyyyyyyyyyyyyyy
bencode
d5:filesd20:xxxxxxxxxxxxxxxxxxxxd8:completei11e10:downloadedi13772e10:incompletei19e
20:yyyyyyyyyyyyyyyyyyyyd8:completei21e10:downloadedi206e10:incompletei20eee
{
"files": {
"xxxxxxxxxxxxxxxxxxxx": { "complete": 11, "downloaded": 13772, "incomplete": 19 },
"yyyyyyyyyyyyyyyyyyyy": { "complete": 21, "downloaded": 206, "incomplete": 20 }
}
}

BEP52 BitTorrent v2

  • metainfo
    • announce
    • info
      • name
      • piece length
      • meta version=2
        • v1 不会设置
      • file tree
        • <path> - UTF-8, 不能有 . 和 .., root 必须是目录
          • 文件包含 空 key
          • length - 文件长度
          • pieces root
            • root hash of a merkle tree with a branching factor of 2
            • 32 bytes
            • N*16KiB
            • SHA2-256
      • files - 兼容 v1
        • attr=p 为 padding 文件
        • length
        • path
    • piece layers
      • root -> tree

  • infohash - sha2-256
    • 有时作为 torrent id 会截取 20 bytes