Applications are contained in the Projects folder.
This repository contains a Python-based client-server file transfer application created for a networking course. The project implements file upload and download functionality using both TCP and UDP socket programming.
The application allows a client to upload files to a server using a PUT request and download files from the server using a GET request. Separate client and server programs are provided for the TCP and UDP versions.
- Python socket programming
- TCP client and server implementation
- UDP client and server implementation
- File upload support using
PUT - File download support using
GET - Command-line arguments for IP address and port number
- Automatic
downloadsfolder creation on the client side - Automatic
uploadsfolder creation on the server side - Server-side folders organized by client IP address
- File size header handling using
LEN - Error handling for missing files
404response for files that do not exist- UDP stop-and-wait reliability mechanism
- UDP acknowledgements using
ACK - UDP completion signaling using
FIN - Timeout handling for UDP transfers
clientTCP.py- TCP client used to upload files to the server and download files from the serverserverTCP.py- TCP server used to receive uploaded files and send requested files back to the clientclientUDP.py- UDP client that supports file upload and download using stop-and-wait reliabilityserverUDP.py- UDP server that supports file upload and download using acknowledgements, completion messages, and timeout handling
The TCP version uses a reliable connection between the client and server. The client connects to the server, sends either a PUT or GET request, and then transfers the requested file data. TCP handles reliable delivery, ordering, retransmission, congestion control, and flow control.
The UDP version performs similar upload and download operations, but UDP does not guarantee reliable delivery. Because of this, the project implements a basic stop-and-wait reliability mechanism. Each data chunk must be acknowledged with an ACK, and the end of a successful transfer is marked with a FIN message. If the program does not receive expected data or acknowledgements within the timeout window, it handles the timeout and stops the transfer.
Uploaded files are stored on the server in an uploads folder. The server creates a subfolder for each client based on the client’s IP address. Downloaded files are saved on the client side in a downloads folder.
Start the TCP server first:
python serverTCP.py <PORT_NUMBER>Example:
python serverTCP.py 8000Then start the TCP client:
python clientTCP.py <SERVER_IP_ADDRESS> <PORT_NUMBER>Example:
python clientTCP.py 127.0.0.1 8000Start the UDP server first:
python serverUDP.py <PORT_NUMBER>Example:
python serverUDP.py 8000Then start the UDP client:
python clientUDP.py <SERVER_IP_ADDRESS> <PORT_NUMBER>Example:
python clientUDP.py 127.0.0.1 8000Upload a file from the client to the server:
PUT <file_path>
Example:
PUT C:/Users/David/Documents/test.txt
Download a file from the server to the client:
GET <file_name>
Example:
GET test.txt
Quit the client program:
QUIT
When the programs run, they automatically create folders for file storage.
Client side:
downloads/
Server side:
uploads/
The server also creates a subfolder for each client IP address:
uploads/
└── <client_ip_address>/
- Start the server.
python serverTCP.py 8000or
python serverUDP.py 8000- Start the client.
python clientTCP.py 127.0.0.1 8000or
python clientUDP.py 127.0.0.1 8000- Upload a file.
PUT C:/Users/David/Documents/test.txt
- Download the same file.
GET test.txt
- Exit the client.
QUIT
- Python
- TCP sockets
- UDP sockets
- File I/O
- Client-server networking
- Stop-and-wait protocol
- ACK/FIN packet handling
- Timeout handling
- Command-line arguments
This project was created for a networking course to practice client-server communication, socket programming, file transfer protocols, and the differences between TCP and UDP.
The TCP version demonstrates reliable connection-based file transfer, while the UDP version demonstrates how reliability can be manually added using acknowledgements, timeouts, and completion messages.