This GitHub repo contains the solution for Project 1 for the Computer Networks course taught by Professor Yasir Zaki at NYU Abu Dhabi. Here, we implement a simple file transfer protocol designed to handle multiple concurrent client connections and file transfers. The team members for this project are Avinash Gyawali and Aadim Nepal.
To run the code in your terminal, please follow these steps:
-
Clone the Repository:
git clone https://github.com/Tauke190/CNHW1.git
-
Navigate to the Server and Client Directories:
Inspect the directories closely. The server directory contains:
- Three subdirectories:
Bob
,Harry
, andRon
- A text file:
users.txt
The subdirectories
Bob
,Harry
, andRon
are for the authenticated users stored on the server. Theusers.txt
file contains usernames and passwords that the server authenticates before running the program. - Three subdirectories:
-
Open Four Terminals:
- One for the server
- Three for the clients:
Bob
,Harry
, andRon
-
Run the Server Code:
- Navigate to the server directory:
cd server
- Compile the makefile.
- Navigate to the server directory:
-
Run the Client Code:
- In each client terminal, navigate to the client directory:
cd client
- Compile the makefile for all three clients.
- In each client terminal, navigate to the client directory:
-
Start Authenticating:
- Follow the procedures displayed by the terminal. Typically, you will input:
USER <username>
PASS <password>
- Commands like
RETR <filename>
,STOR <filename>
,CWD <directory>
,!CWD <directory>
,LIST <directory>
,!LIST <directory>
,QUIT
- Follow the procedures displayed by the terminal. Typically, you will input:
The code should handle concurrent connections smoothly.
-
Directory Changes:
- Once the client changes the server directory, it cannot revert.
- Once you change the client directory, you cannot revert.
-
File Overwrites:
- If the client attempts to send a filename that already exists, the new file overwrites the existing file.
-
Users.txt Format:
- The
users.txt
file should not have a comma between username and password. - Each username and password pair should be on one line, separated by a space. Example:
Aadim Nepal Avinash Gyawali
- The
-
Port Selection:
- We used port
9013
instead of the default ports21
and20
due to availability issues on MacOS. - If you encounter a "cannot bind to address" error, change the port by navigating to:
#DEFINE CMD_PORT 9013
- You can try different port numbers if necessary.
- We used port
-
Implementation of PORT Command:
- The client sends a PORT command to the server before initiating a new TCP connection for file transfer.
- We use a random free port provided by the OS instead of implementing
N+i
. - This approach was discussed and approved by both the professor and the TA.