This project implements a simple Peer-to-Peer (P2P) file transfer system using Python. The sender and receiver communicate over a local area network to transfer a file. P2P systems allow direct communication between peers without the need for a central server, providing advantages as discussed below.
-
Decentralization: P2P systems eliminate the need for a central server, distributing the workload across multiple peers.
-
Scalability: P2P networks can easily scale as more peers join, making them suitable for large-scale file sharing.
-
Redundancy: The distributed nature of P2P systems enhances data redundancy and fault tolerance.
-
Efficiency: Peers can directly communicate with each other, leading to faster file transfers and reduced network bottlenecks.
- Socket Initialization: Creates a socket for communication.
- File Selection: Uses Tkinter to prompt the user to select a file for transfer.
- Connection Establishment: Listens for incoming connections and establishes a connection with the receiver.
- File Size Transmission: Sends the size of the selected file to the receiver.
- File Transmission: Sends the file data in chunks to the receiver.
- Socket Initialization: Creates a socket to connect to the sender.
- Connection Establishment: Connects to the sender using the provided IP address and port.
- File Size Reception: Receives the size of the incoming file.
- File Saving Dialog: Prompts the user to select a location and name for the received file.
- File Reception: Receives file data in chunks and saves it to the specified file.
- Socket (
socket
): For creating and managing network sockets to facilitate communication between the sender and receiver. - Os (
os
): For interacting with the operating system and retrieving information about the selected file, such as its size. - Tkinter (
tkinter
): A GUI toolkit used for building the user interface for the sender. It provides a file dialog for selecting the file to be sent and prompting the user for interaction. - Filedialog (
tkinter.filedialog
): A submodule of Tkinter specifically used to create file selection and saving dialogs. It simplifies the process of interacting with the file system, allowing users to choose a file for sending or specify the location to save the received file. - Struct (
struct
): Although not explicitly imported, it is implicitly used for converting file size to bytes and vice versa. This is done through theto_bytes
andfrom_bytes
methods for encoding and decoding integers.
- Run
Sender.py
on the machine you want to send the file from. - Note the IP address displayed by the sender.
- Run
Receiver.py
on the machine you want to receive the file on. - Enter the sender's IP address when prompted.
- Select a file for transfer on the sender side.
- The file will be transferred and saved on the receiver side.
- Security: Implement encryption and authentication for secure file transfers.
- User Interface: Develop a more user-friendly graphical user interface (GUI) using a dedicated framework.
- Error Handling: Enhance error handling to provide better feedback to users in case of connection issues or file transfer failures.
- Concurrency: Use threading to handle multiple file transfers simultaneously.
- Protocol Enhancements: Design a custom protocol to support additional functionalities, such as resuming interrupted transfers or providing file metadata.
To gain a deeper understanding and clearer insights into the Peer-to-Peer File Transfer System, it is recommended to refer to the accompanying report and PowerPoint presentation. These supplementary materials provide a comprehensive overview, detailed explanations, and visual aids to enhance your comprehension of the project.
This Peer-to-Peer File Transfer System is brought to you by: