A Java-based P2P file sharing system that allows peers to share, discover, and download files directly from each other.
- Tracker Server: Central coordinator that maintains registry of peers and their shared files
- Peer Nodes: Each peer acts as both client (to request files) and server (to serve files)
- File Transfer: Files are split into chunks for efficient transfer
TrackerServer.java: Main tracker server that listens for peer connectionsTrackerHandler.java: Handles individual peer communications with the tracker
PeerServer.java: Handles incoming file requests from other peersPeerClient.java: Handles outgoing requests to tracker and other peers (includes CLI)
FileChunker.java: Utilities for splitting files into chunks and retrieving chunksHashUtil.java: Utilities for calculating file hashes (MD5) for integrity verification
java tracker.TrackerServerIn separate terminal windows:
# First peer on port 8001
java peer.PeerClient localhost 5000 8001
# Second peer on port 8002
java peer.PeerClient localhost 5000 8002Once a peer is running, you'll see a menu:
- Share file - Share a local file with the network
- Search file - Search for files shared by other peers
- Download file - Download a file from other peers
- Exit - Shut down the peer
- Start tracker:
java tracker.TrackerServer - Start peer 1:
java peer.PeerClient localhost 5000 8001 - Start peer 2:
java peer.PeerClient localhost 5000 8002 - In peer 1's interface, choose option 1 to share a file (e.g., a test text file)
- In peer 2's interface, choose option 2 to search for the file
- In peer 2's interface, choose option 3 to download the file from peer 1
- Files are stored in each peer's local filesystem
- The tracker only maintains metadata (peer addresses and file names)
- Actual file transfers happen directly between peers
- Files are split into 64KB chunks for transfer
- MD5 hashing is used to verify file integrity after download