← Computer Networksภาษาไทย

APPLICATION LAYER · PEER-TO-PEER DISTRIBUTION

One file. Many peers. No single sender.

Watch a synthetic classroom file split into pieces, spread through a swarm, survive peer departures and become complete again through verified exchange.

SWARM SIMULATOR

How does the swarm decide what to request next?

This page is a closed simulation: it never opens a torrent, contacts a tracker or joins a public swarm.

READY · Build the synthetic swarm.
Verified blocks0
Messages0
Availability0.0

Why rarest-first?

A peer requests the least replicated piece it can currently obtain. This protects scarce pieces, raises swarm availability and reduces dependence on the original seeder. Sequential download feels intuitive but may leave the whole swarm holding the same prefix.

Choke, unchoke and optimistic unchoke

Choking controls upload slots; it is not a permanent ban. A peer periodically unchokes useful partners and reserves one exploratory slot so a new or previously slow peer can prove its value.

A block crosses only after protocol state allows it

handshakebitfieldinterestedunchokerequestpiecehash verify
Run an exchange to inspect messages.

Tracker, DHT, PEX and magnet links

Tracker

A rendezvous service returns peer addresses; it does not carry file pieces.

DHT

A distributed lookup maps an info-hash to peers without one central tracker.

PEX

Connected peers introduce other peers they already know.

Magnet

Starts from a content identifier; metadata can then be discovered and verified.

PROTOCOL ANATOMY

Data, metadata and trust are separate layers

Piece → block

A file is hashed by piece, while requests normally transfer smaller blocks. A failed hash rejects the assembled piece.

Bitfield + HAVE

Bitfield announces the initial inventory; HAVE reports each newly verified piece.

Endgame mode

Near completion, duplicate requests may go to several peers; the first valid block wins and the rest are cancelled.

Integrity is not authorship. A matching hash proves bytes match the metadata, not that the publisher is trustworthy or owns distribution rights.

CLASSROOM INVESTIGATION

Questions worth answering from evidence

  1. Compare rarest-first and sequential after the seeder leaves.
  2. Explain why availability may be below 1.0 even when many total blocks exist.
  3. Identify the messages required before the first piece block can arrive.
  4. Show how a corrupt block is detected and why only verified pieces trigger HAVE.
  5. Discuss the trade-off between playback order and swarm health.