Jump to content

BitTorrent

From Pulsed Media Wiki


BitTorrent is the protocol a seedbox exists to run. A Pulsed Media seedbox sits in our own datacenter in Finland, on our own network (AS203003), and has been seeding since 2010 — sixteen years of torrents that keep running after your own computer is switched off.

Underneath that, BitTorrent is a peer-to-peer file-transfer protocol. Rather than one server holding a complete file, the file is split into pieces and the participants trade those pieces with each other. No single machine carries the whole transfer, and a popular file moves faster as more peers join it.

How a transfer works

A transfer starts from metadata: a .torrent file or a magnet link. Both describe the same things: the file name and total size, the size of each piece, a hash for every piece, and how peers can be found.

With that metadata, the client works through the file piece by piece:

  • A piece is typically a few hundred KiB to a few MiB. When a piece completes, the client checks it against the hash from the metadata, so a corrupted or false piece is discarded and fetched again.
  • A peer holding the complete file is a seeder. A peer still downloading is a leecher. Together they form the swarm for that file.
  • Peers tell each other which pieces they hold, which is how a client knows who to ask for a missing piece.
  • A peer that finishes downloading usually becomes a seeder and keeps uploading until it is stopped.

The order is not sequential. A client may hold piece 74 while piece 3 is still missing, and it requests the rarest missing pieces first, which keeps rare pieces present in the swarm.

Finding peers

Before any piece can move, a client needs to find peers. Two mechanisms do that:

  • A tracker reports the peers currently in a swarm. The client announces itself and receives a peer list. Tracker (BitTorrent) explains that exchange.
  • DHT, a distributed hash table, lets clients find peers with no tracker at all, and peer exchange lets clients pass their own peer lists around. A magnet link usually carries no tracker list, so it relies on these.

Most torrents use both: a tracker for a quick first peer list, and DHT as the fallback when a tracker is slow or unreachable.

Seeding and ratio

Uploading is what keeps a swarm alive. A torrent with one seeder and twenty leechers moves slowly, because a single peer has to serve the whole file. As downloaders finish and keep seeding, capacity grows with the swarm.

Ratio is uploaded data divided by downloaded data. Many private trackers require a minimum ratio, so continuing to seed after a download completes is what maintains it there. A connection that stays on and has bandwidth to spare is the simplest way to build that ratio, which is what a seedbox is for.

Which client to run

For a Pulsed Media seedbox, keep the default: RTorrent on RuTorrent. It is the client PMSS installs, configures and watches, so it is the one that behaves predictably when a torrent goes wrong, and PMSS keeps a watchdog on it. qBittorrent and Deluge can be enabled if you prefer their interface, and both speak the same protocol, but there is no reason to move off the default for ordinary seeding.

BitTorrent on a Pulsed Media seedbox

  • The default client is rTorrent, managed through the ruTorrent web interface.
  • DHT is enabled, so magnet links and torrents without a tracker work.
  • Tracker Cleaner removes a short list of known problematic public trackers from your torrents, which keeps the client responsive on a busy shared server. It does not touch torrents marked private.
  • The client runs under your own account and keeps seeding while you are away, which is why a swarm sees a seedbox as a steady peer.

See also