Skip to content

A multithreaded peer-to-peer file sharing system with centralized indexing, built using Python sockets. Demonstrates secure authentication, real-time peer discovery, file publishing, and TCP-based transfers using custom UDP/TCP application-layer protocols.

Notifications You must be signed in to change notification settings

Skipflap/PeerConnectFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PeerConnectFS

PeerConnectFS is a permissioned, peer-to-peer file sharing system built on a hybrid client-server and P2P architecture, featuring authentication, file publishing, and real-time transfers over UDP and TCP. The system mirrors practical peer-based networks, simulating decentralized file exchanges with a centralized indexing server.


Technologies Used

  • Python 3
  • socket module (UDP & TCP)
  • threading for concurrent execution
  • Custom application-layer protocol

Key Features

  • 🔐 User Authentication
    Authenticated users via a secure UDP channel using a centralized credentials.txt file.

  • 🧭 Central Indexing Server
    Tracks active users and their published files. Clients query the server to locate files.

  • 🫀 Heartbeat Mechanism
    Clients send heartbeat signals every 2 seconds to maintain active status. Server removes inactive users after 3 seconds of silence.

  • 📂 File Publishing & Sharing

    • pub <filename> to publish a file
    • get <filename> downloads directly from another peer using TCP
    • unp <filename> unpublishes a file
  • 🔍 Search & Discovery

    • lap: List all active peers
    • lpf: List your published files
    • sch <substring>: Search for files shared by others
  • 🔄 Multithreaded Architecture
    Separate threads manage:

    • User interaction
    • Heartbeat messages
    • Incoming TCP file requests
    • File transfers (upload/download)

Commands (Client)

get <filename>   # Download file from another peer
pub <filename>   # Publish a file to the network
unp <filename>   # Unpublish a file
lap              # List active peers
lpf              # List your published files
sch <substring>  # Search shared files
xit              # Exit the network

📸 Example Usage

Let's walk through a simple example using three sample users: hans, vader, and yoda.

1. Start the server

python3 server.py 50000

2. Start each client in a separate terminal

python3 client.py 50000

Each client will be prompted to authenticate with a username and password from credentials.txt.

3. Sample interaction

Hans (Uploader)

$ python3 client.py 50000
Username: hans
Password: hanspass
> pub BitTrickle.mp4
> lpf
BitTrickle.mp4

Vader (Downloader)

$ python3 client.py 50000
Username: vader
Password: vaderpass
> sch BitTrickle
BitTrickle.mp4
> get BitTrickle.mp4
Download successful: BitTrickle.mp4

Yoda (Peer Discovery)

$ python3 client.py 50000
Username: yoda
Password: yodapass
> lap
hans
vader

4. Exit the network

> xit

This demonstrates core features: publishing, searching, downloading, peer discovery, and session management—all within a decentralized file sharing system.

About

A multithreaded peer-to-peer file sharing system with centralized indexing, built using Python sockets. Demonstrates secure authentication, real-time peer discovery, file publishing, and TCP-based transfers using custom UDP/TCP application-layer protocols.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages