Java 17+TCP socketsMultithreadingSHA-1BitTorrent-style

Peer-to-peer file sharing,
piece by verified piece.

EasyShare splits files into chunks, exchanges the chunks directly between connected peers and validates every piece with a SHA-1 hash. No central file server: every downloader becomes an uploader.

Download project (.zip) Read the user manual

The peer-to-peer network runs on your own computers (Windows, JDK 17+). This website is the project's documentation and download page.

How it works

A tracker only answers "who has this file?". Pieces flow directly between peers, several at once, and each piece is checked against its SHA-1 hash before it is written to disk.

Tracker info hash → list of peers (no file data) announceannounceget peers Alice · seeder sample-video.bin · 48 pieces Bob · seeder same file, same info hash Carol · downloading pieces from 2 peers in parallel pieces 0, 3, 7 … over TCP pieces 1, 4, 5 … bad SHA-1 → re-download

1 · Chunk & hash

Each shared file is cut into 256 KB pieces. The SHA-1 of every piece and of the metadata (the info hash) is computed.

2 · Discover peers

Peers announce their files to a tracker every 15 s, or find each other on the LAN with UDP multicast, or connect by IP.

3 · Download in parallel

One thread per peer. A shared piece manager hands out the rarest missing piece, never the same piece twice.

4 · Verify every piece

Bad pieces are discarded and fetched again; peers sending 5 bad pieces are blocked. The whole file is verified at the end.

Features

Everything is plain Java — sockets, threads, MessageDigest — with no external libraries.

ConceptImplementation
File chunkingFixed-size pieces written at their byte offset into a pre-allocated .part file
Cryptographic hashingSHA-1 per piece, whole-file SHA-1, info hash = SHA-1 of the metadata
Multithreaded socket streamsThread-pool upload server; coordinator + one worker thread per peer for downloads
Peer discoveryTracker (TCP text protocol), LAN discovery (UDP multicast), manual connect ip:port
SwarmingRarest-first piece selection; partial downloads are shared immediately; completed files are seeded
ResumePieces on disk are re-verified after a restart; only missing pieces are downloaded
InterfacesConsole commands and a live web dashboard served by Java's built-in HttpServer
TestingAutomated end-to-end self-test: 12 checks with a tracker and 7 peers

Quick start

Needs a JDK 17 or newer. Everything else is in the zip.

  1. Download and extract the project.
  2. Double-click build.bat to compile EasyShare.jar.
  3. Double-click demo.bat. A tracker and three peers (Alice, Bob, Carol) open in separate windows.
  4. In Carol's window type search then get 3, or use her dashboard at http://localhost:8003.
  5. Allow Java through Windows Firewall if asked.
Carol> get 3
Downloading sample-video.bin (12.0 MB, 48 pieces)
  ! Piece #31 from Bob failed SHA-1 check
    -> discarded, will download again
  [##############################] 100%

DOWNLOAD COMPLETE
  Pieces received from each peer:
    Alice (127.0.0.1:6001)   25 pieces
    Bob (127.0.0.1:6002)     23 pieces
  Corrupted pieces re-downloaded: 3
  Integrity: VERIFIED

Demonstration scenarios

Each one proves a concept from the project brief. Step-by-step instructions are in the user manual.

Multi-source download

Carol receives pieces from Alice and Bob at the same time — shown per peer in the summary and dashboard.

Integrity checking

Bob runs with --corrupt 15. Every damaged piece is caught by SHA-1 and never written to disk.

Pause & resume

Press Enter, close the program, start it again and type resume — verified pieces are kept.

Swarm

A 4th peer, Dave, downloads pieces from Carol while Carol is still downloading.

No tracker needed

Close the tracker and use discover (UDP multicast) or connect ip:port.

Messenger (like IPMsg)

Run messenger.bat on each PC: everyone on the LAN is listed; select a PC, attach files and click Send.

PC ↔ phone

Run phone.bat and open the printed address on a phone: download files from the PC or upload photos to it.

Tamper detection

Edit a shared file and run verify: the changed piece is reported as corrupted.

Scripts

FileWhat it does
build.batCompiles the Java sources into EasyShare.jar
messenger.batIP Messenger-style window: other PCs appear automatically; send messages, files and folders
demo.batStarts a tracker and three peers on one computer with sample files
demo-dave.batAdds a fourth peer to the running demo
start-tracker.batStarts a tracker for a real LAN setup
start-peer.batStarts a peer; asks for name, port and tracker address
phone.batLets a phone on the same Wi-Fi download and upload files in its browser
run-tests.batRuns the automated end-to-end tests
clean-demo.batDeletes demo folders to start fresh