Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ICSI416 - Computer Communication Networks

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.

Features

  • 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 downloads folder creation on the client side
  • Automatic uploads folder creation on the server side
  • Server-side folders organized by client IP address
  • File size header handling using LEN
  • Error handling for missing files
  • 404 response 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

Project Files

  • clientTCP.py - TCP client used to upload files to the server and download files from the server
  • serverTCP.py - TCP server used to receive uploaded files and send requested files back to the client
  • clientUDP.py - UDP client that supports file upload and download using stop-and-wait reliability
  • serverUDP.py - UDP server that supports file upload and download using acknowledgements, completion messages, and timeout handling

How It Works

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.

Running the TCP Version

Start the TCP server first:

python serverTCP.py <PORT_NUMBER>

Example:

python serverTCP.py 8000

Then start the TCP client:

python clientTCP.py <SERVER_IP_ADDRESS> <PORT_NUMBER>

Example:

python clientTCP.py 127.0.0.1 8000

Running the UDP Version

Start the UDP server first:

python serverUDP.py <PORT_NUMBER>

Example:

python serverUDP.py 8000

Then start the UDP client:

python clientUDP.py <SERVER_IP_ADDRESS> <PORT_NUMBER>

Example:

python clientUDP.py 127.0.0.1 8000

Supported Commands

Upload 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

Folder Structure

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>/

Example Workflow

  1. Start the server.
python serverTCP.py 8000

or

python serverUDP.py 8000
  1. Start the client.
python clientTCP.py 127.0.0.1 8000

or

python clientUDP.py 127.0.0.1 8000
  1. Upload a file.
PUT C:/Users/David/Documents/test.txt
  1. Download the same file.
GET test.txt
  1. Exit the client.
QUIT

Technologies Used

  • Python
  • TCP sockets
  • UDP sockets
  • File I/O
  • Client-server networking
  • Stop-and-wait protocol
  • ACK/FIN packet handling
  • Timeout handling
  • Command-line arguments

Purpose

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.

About

Computer Communication Networks

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages