Skip to content
Back to the surface

Eirbone

Large files shared peer to peer: a tracker in C, peers in Java that swap the file piece by piece.

10 MB
sent piece by piece
10,240
pieces of 1 KB
4
people
Role
Team of 4
Stack
CJavaTCP socketsSwing
Eirbone

The idea

Sharing a large file without a central server. A small tracker only knows who holds what; the file itself travels directly between peers, cut into pieces of 1,024 bytes. Each peer fetches the pieces it lacks from whoever has them, and shares every piece as soon as it has it.

The peer that shares: two files, seeding at 100 %.
The peer that shares: two files, seeding at 100 %.

Watch a file being shared

One peer has the whole file; three peers join with nothing. Each downloader asks for missing pieces from whoever holds them, including other downloaders. An illustration of the principle, not the real code.

0 from the seeder0 between peers

The protocol, in plain text over TCP

  1. announceA peer tells the tracker which files it shares, and on which port it listens.
  2. lookIt asks the tracker for files by name or size; the tracker answers with a list and the files' keys.
  3. getfileFor one key, the tracker returns the addresses of the peers that hold it.
  4. interested · haveTwo peers exchange their buffer maps: one bit per piece, owned or not.
  5. getpieces · dataThe downloader asks for a few pieces at a time; the answer is a header followed by the raw bytes.
  6. updateEvery peer keeps the tracker up to date as its pieces arrive.

Three terminals, one real session

The tracker in C on the left half, the two peers in Java on the right, on one machine: announce, look, getfile, then 10 MB piece by piece. The file arrived identical, byte for byte, in about ten seconds.

Recorded on 27 November 2026. Pauses longer than 1.2 s are shortened; every line keeps its real time stamp.

The interface

A desktop window in Java Swing: the files the peer shares or downloads, with their progress, their peers and their status; a search that asks the tracker; a click on a result starts the download.

Searching the tracker for a file by name.
Searching the tracker for a file by name.
The result: name, size and key of the file.
The result: name, size and key of the file.
A click, and the download starts: leeching from one peer.
A click, and the download starts: leeching from one peer.
Done: the downloader now seeds the file in turn.
Done: the downloader now seeds the file in turn.

Captured on 27 November 2026 from the real app, running on one machine.

What the logs also show

  • A flood of retries: the downloader printed “4 pieces released for retry” 2,560 times in a fraction of a second, re-queuing pieces it had only just reserved.
  • “Download finished” twice: the download manager reported the end of fichier.bin twice, five seconds apart.
  • A small file left behind: test.txt, one single piece, was still at 0 of 1 when the peers stopped four seconds later.
  • One connection for everything: the console's command loop owns the link to the tracker. When the console input closes, the peer stops and the window's search fails with “Socket closed”.

Found while recording this page. They are the next things to fix, and they are shown as they are.

How it is built

  • The tracker, in C: about 3,360 lines, a pool of worker threads behind a poll loop, a table of peers and a table of files; up to 90 peers.
  • The peers, in Java: 12 files, about 2,430 lines: the tracker client, the file manager with its buffer maps, the download manager that picks pieces to ask for, the peer-to-peer server, and the interface.
  • Pieces and checks: each file is described by its size, its piece size and an MD5 key; each peer keeps a small JSON file of the pieces it owns.

The team

A school project at ENSEIRB-MATMECA, from March to May 2026, in a team of four. My part: announcing the shared files to the tracker, the look request between peers, the Swing interface and the demo.