To run this project, you have to run the following files, ensuring that the tcp_server.py file is run before any clients are spun up:
- tcp_server.py
- tcp_client.py
- second_tcp_client.py
After these are all running, you can then log into each client using the following login information (or sign up):
1. Username: czalpha, Password: D10686712
2. Username: wdonzcar, Password: sandwich1
From here, you can register files to the netowrk to enable subscription to the files. To subscribe to a file, you must request the file. Once you have requested and received a file, you will have that file synced upon updates to that file. To update the file, you must upload an updated version of that file. To unsubscribe from a file, you can simply press the 'remove synced resource' button. To remove a resource from the index, you can deregister the resource. You can also list all online users, all shared resources, as well as the synced resources you currently possess.
A peer to peer file sharing networking project for our Computer Networking class.
Figure 1: Network Diagram.Protocol Research & Message Types In a peer-to-peer (P2P) file-sharing network, different message types allow peers to register, request, and manage shared files. Below, we outline each message type, what it does, and how it is used.
- What it does: Registers a file or resource with the network's index or directory.
- How it's used: When a peer wants to share a file, it sends a registration request to an index server. The server updates its records to include the new resource.
- What it does: Removes a file or resource from the network’s index.
- How it's used: If a peer removes a file from its system, it sends a deregistration request to ensure it is no longer listed for others.
- What it does: Requests a specific file from another peer.
- How it's used: A peer sends a download request to another peer that has the file, asking for access to the data.
- What it does: Transfers the actual file data from one peer to another.
- How it's used: After acknowledging a download request, the peer sends the requested file’s data over the network.
- What it does: Provides a list of all available files in the network’s index.
- How it's used: A peer can request this list from an index server to see what files are available for download.
- What it does: Allows a peer to search for specific files.
- How it's used: A peer sends a search query to the index server, which then returns a list of matching files.
- What it does: Confirms receipt or successful processing of a request.
- How it's used: When a peer receives a request (e.g., a download request), it sends an acknowledgment to confirm it has been processed.
- What it does: Notifies a peer of a failed operation or issue.
- How it's used: If a request fails (e.g., a file is missing), the peer sends an error message to inform the requester.
For communication between peers, we will use TCP (Transmission Control Protocol). TCP ensures reliable, connection-based communication, which is ideal for file sharing. Here’s how each message type is handled using TCP:
A peer sends a TCP message containing file details (e.g., file name, size, and peer ID) to the index server, which then adds the file to its index.
When a file is removed, the peer sends a TCP message to notify the server, which then updates the index.
A peer sends a request for a file. The server or another peer responds with either an acknowledgment or the file itself.
The requested file is transferred over TCP, possibly in chunks for large files.
A peer requests the current list of available files from the server, which sends back the indexed resources.
A peer queries the server for specific files, and the server returns a list of matches or a notification if none are found.
A simple TCP message is sent to confirm receipt or successful processing of a request.
If an operation fails, an error message is sent over TCP detailing the issue.
** By using TCP, we ensure a secure and reliable way for peers to communicate, register, search, and transfer files efficiently in the P2P network.
Figure 2: File Transfer Sequence. Figure 3: Login Protocol. Figure 3: Registration Protocol. Figure 4: Deregistration Protocol.



