rohitrangan/FTP-Client-Server
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
CS 349 - Assignment 3 Authors:- Rohit Rangan 11012333 Siddharth Ancha 11010175 ------------------------------------------------------------------------------- PROJECT DESIGN ------------------------------------------------------------------------------- ------------- |/---------\| || User || -------- ||Interface|<--->| User | |\----^----/| -------- ---------- | | | |/------\| FTP Commands |/----V----\| ||Server|<---------------->| User || || PI || FTP Replies || PI || |\--^---/| |\----^----/| | | | | | | -------- |/--V---\| Data |/----V----\| -------- | File |<--->|Server|<---------------->| User |<--->| File | |System| || DTP || Connection || DTP || |System| -------- |\------/| |\---------/| -------- ---------- ------------- Server-FTP USER-FTP NOTES: 1. The data connection may be used in either direction. 2. The data connection need not exist all of the time. Figure 1 Model for FTP Use ------------- Server Design ------------- We need the server to support multiple connections at a time. To support this, we process each new client connection in a separate thread. We process both the data and the control connections for a particular user in a single thread, i.e. once a data connection is initialized, no control packets can be sent. We close the data connection on completion of the transfer. Once the client issues a quit command, we close the control connection, thereby terminating all communications. ------------- Client Design ------------- The client connects to the advertised port of the server. After establishing the connection, the client starts an interactive shell. This shell processes input from the user and sends a request to the server. We print the server's response to the terminal and store/send a file from/to the server. Once the user types the quit command, we close the connection to the server and exit. --------------- Project Modules --------------- We have the following modules:- 1. Client Module - Contains the main code for the client. This module's only function is to send/receive messages to/from the server and call functions to process the messages received from the server. The module also contains an interactive shell which processes user input and transforms them into messages for the client to send. 2. Message Module - Contains fucntions to interpret messages from the server as well as the client. Also contains functions to package messages from the server and the client. 3. Server Module - Contains the main code for the server. This module's only function is to send/receive messages to/from the client(s) and call functions to process the messages. ------------------ Module Interaction ------------------ Client Side ----------- Sending messages for communication with the server. -------- --------- |Client|<--->|Message| |Module| |Module | -------- --------- ^ ^ \ / Starting \ / Processing commands the module \ / and creating messages to process \ / in reply to those. data. \ / V ------------- |Interactive| | Shell | ------------- Figure 2 Client side module interaction Server Side ----------- Sending messages for communication with the client. -------- --------- |Server|<--->|Message| |Module| |Module | -------- --------- Figure 3 Server side module interaction (Interaction between the client and the server in shown in Figure 1) ------------------------------------------------------------------------------- PROJECT DIRECTORY STRUCTURE ------------------------------------------------------------------------------- --{root} - The assignment's root directory. +--Makefile - The Makefile for compiling the code. +--README - This file! +--include/ - Contains the header files. | +--client.h - Client header file. | +--request.h - FTP client request header file. | +--response.h - FTP server response header file. | +--return_code.h - FTP server return codes. | +--server.h - Server header file. | +--socket.h - Wrapper for UNIX socket implementation. +--src/ - Contains the source code. | +--client.cpp - Client source code. | +--client_main.cpp - Client main function. | +--request.cpp - FTP client request implementation. | +--response.cpp - FTP server response implementation. | +--server.cpp - Server source code. | +--server_main.cpp - Server main code. | +--socket.cpp - UNIX socket implemented as a class. ------------------------------------------------------------------------------- REQUIREMENTS ------------------------------------------------------------------------------- 1. GCC or clang (To compile the C++ code). 2. GNU Make. ------------------------------------------------------------------------------- INSTRUCTIONS TO COMPILE ------------------------------------------------------------------------------- 1. At the root directory (the directory containing this README), execute the "make" command. 2. After make finishes executing, the executables will be named - client and server, for the client and the server respectively. ------------------------------------------------------------------------------- INSTRUCTIONS TO RUN THE CODE ------------------------------------------------------------------------------- 1. To run the server, execute "./server PORT_NUMBER" if the server program is in the current directory. PORT_NUMBER is the port which the server listens to, for any incoming connections. It must be positive and less than 65535. To terminate the server gracefully, give the input "CTRL + C". It will then initiate server shutdown as indicated in the sample output of the server. 2. To run the client, execute "./client HOST_NAME PORT" if the client program is in the current directory. HOST_NAME is the URL or the IP Address of the server we connect to. PORT specifies the listen port of the server. ------------------------------------------------------------------------------- SAMPLE OUTPUT - SERVER ------------------------------------------------------------------------------- RangansMacBookPro:FTP-Client-Server rohitrangan$ ./server 1221 Server Initialized! Accepted connection from - 127.0.0.1:53630 ^C Initiating Server Shutdown... Closing All Connections... Success! All Connections Closed. Exiting... ------------------------------------------------------------------------------- SAMPLE OUTPUT - CLIENT ------------------------------------------------------------------------------- RangansMacBookPro:FTP-Client-Server rohitrangan$ ./client 127.0.0.1 1221 220 FTP-Server ftp> pwd 250 /Users/rohitrangan/Workspace/FTP-Client-Server ftp> ls 200 Connection Success 150 Sending Directory Information Makefile README client include server src 226 Success ftp> cd /Users/rohitrangan/Workspace/FTP-Client-Server/src 250 Changed Directory ftp> pwd 250 /Users/rohitrangan/Workspace/FTP-Client-Server/src ftp> !pwd /Users/rohitrangan/Workspace/FTP-Client-Server ftp> get client.cpp 200 Connection Success 125 Sending file 226 File send success ftp> !ls Makefile README client client.cpp include server src ftp> quit 221 Terminating ------------------------------------------------------------------------------- NOTE ------------------------------------------------------------------------------- 1. All terminal commands are given in quotes 2. The code was written and tested on MacOSX 10.7.5 and compiled with clang-425.0.28 -------------------------------------------------------------------------------
About
FTP Client and Server for Networks Assignment
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published