File Transfer Protocol (FTP) Architecture and Operations

Application Layer Protocols and Network Architecture

  • Network Interface and Communication Layering:
    • The Application layer provides the primary interface between human user applications and underlying data networks.
    • In the Open Systems Interconnection (OSI) Model, network communication is divided into seven distinct layers:
    • Application Layers (Upper Layers): Layer 7 (Application), Layer 6 (Presentation), Layer 5 (Session).
    • Data Flow Layers (Lower Layers): Layer 4 (Transport), Layer 3 (Network), Layer 2 (Data Link), Layer 1 (Physical).
    • In the TCP/IP Model, the architecture consists of four functional layers:
    • Application Layer (combining OSI Application, Presentation, and Session functions).
    • Transport Layer.
    • Internet Layer.
    • Network Access Layer.

Interfacing Human and Data Networks

OSI Model vs TCP/IP Model

  • Core Application Layer Protocols:

    • Domain Name System (DNS): Matches human-readable domain names with corresponding numerical IP addresses.
    • Hypertext Transfer Protocol (HTTP): Transfers web page data and media between web servers and clients using a web browser.
    • Simple Mail Transfer Protocol (SMTP) & Post Office Protocol (POP3): Handles email messaging, sending and retrieving messages across client devices and mail servers over the internet.
    • File Transfer Protocol (FTP): Facilitates the upload and download of files between a client device and a host server.
    • Telnet: Enables users to log in to a host machine from a remote location and take administrative control over a virtual connection as if sitting directly at the terminal.
    • Dynamic Host Configuration Protocol (DHCP): Automatically assigns IP addresses, subnet masks, default gateways, DNS server configurations, and other parameters to clients as they log in to the network.
  • Server Farm Architecture:

    • Enterprise networks organize dedicated server infrastructure where specialized server instances handle dedicated application protocols connected through centralized switching and routing hardware.
    • Dedicated server roles include DNS Server, Telnet Server, E-mail Server, DHCP Server, Web Server, and FTP Server.

Server Farm Network Setup

File Transfer Protocol Architecture and Port Mechanics

  • Dual-Connection Architecture:

    • FTP uses the transport services provided by TCP.
    • Unlike standard single-connection client-server services, FTP requires two distinct TCP connections simultaneously:
    • Control Connection: Dedicated to exchanging control commands and server response codes. Uses well-known port 21.
    • Data Connection: Dedicated to actual data file transfers and directory listing transmissions. Uses well-known port 20 on the server side.
  • Internal Process Roles:

    • User Interface: Handles direct user interaction on the client machine.
    • Control Processes: Established on both client and server sides to manage command parsing and response exchanges over the control connection.
    • Data Transfer Processes: Established on both client and server sides to handle storage, retrieval, and disk read/write interactions over the data connection.

FTP Architecture and Connections

Establishing Control and Data Connections

  • Control Connection Establishment:
    • Passive Open by Server: The server's control process issues a passive open on well-known port 21, waiting for connection requests.
    • Active Open by Client: The client's control process issues an active open from an ephemeral port (e.g., port 62010) directed to server port 21.

Control Connection Establishment

  • Data Connection Establishment Sequence:
    1. Passive Open by Client: The client issues a passive open on a local ephemeral port (e.g., port 63000) dedicated for data transfer.
    2. Port Announcement: The client sends a PORT command (e.g., PORT 63000) over the established control connection to inform the server of the designated ephemeral port.
    3. Active Open by Server: The server receives the client's ephemeral port number and initiates an active open from well-known port 20 to the client's specified ephemeral port.
    4. Child Server Allocation: The server spawns a child server process along with an ephemeral port to service the client's data transfer requirements.

Data Connection Establishment Steps

Data Transfer Definitions and Specifications

  • Data Connection Parameter Definition:
    • Before data transmission begins, the client explicitly defines three transfer specifications: File Type, Data Structure, and Transmission Mode.

Data Connection Parameter Specification

  • File Type Options:

    • ASCII or EBCDIC: Text representations using default TELNET formatting controls for nonprint characters.
    • Image: Binary file representation where data is transferred as continuous streams of bits without formatting modification.
  • Data Structure Options:

    • File Structure: Continuous stream of unorganized bytes.
    • Record Structure: File is structured and divided into discrete individual records.
    • Page Structure: File is divided into independent, indexed, or numbered pages.
  • Transmission Mode Options:

    • Stream Mode: Standard transfer mode where data is sent as an unformatted stream of bytes.
    • Block Mode: Data is encapsulated into structured block units pre-formatted with header bytes.
    • Compressed Mode: Data is encoded and compressed prior to network transmission to conserve bandwidth.

Command Processing and Data Connection Functions

  • Command Processing Categories:
    • Commands pass from client control process to server control process, and numeric status responses return from server to client over port 21.
    • Functional Command Categories:
    • Access Commands: Control authentication and session access (e.g., USER, PASS, QUIT).
    • File Management Commands: Manage directory structures and files (e.g., LIST).
    • Data Formatting Commands: Define operational formatting parameters (e.g., TYPE, STRU).
    • Port Defining Commands: Announce client port configurations for data setup (e.g., PORT).
    • File Transfer Commands: Request upload and download actions (e.g., STOR, RETR).
    • Miscellaneous Commands: Manage utility sessions and status queries.

Control Connection Commands and Responses

  • Data Connection Operations:
    • Storing a File: Transfers file contents from client disk to server storage (STOR).
    • Retrieving a File: Transfers file contents from server storage to client disk (RETR).
    • Retrieving a List: Transmits directory contents or file lists from server to client (LIST).

Data Connection File Transfer Operations

Complete FTP Transmission Examples

  • Example 1: Directory Listing Interaction Trace
    • Control Connection Message Sequence:
    • Server -> Client: 220 (Service ready)
    • Client -> Server: USER forouzan
    • Server -> Client: 331 (User name OK. Password?)
    • Client -> Server: PASS XXXXXX
    • Server -> Client: 230 (User login OK )
    • Client -> Server: PORT 8888
    • Server -> Client: 150 (Data connection will open shortly)
    • Client -> Server: LIST /usr/user/report
    • Server -> Client: 125(Data connection OK)
    • Data Connection Activity:
    • Server Data Transfer Process -> Client Data Transfer Process: List of files or directories
    • Session Termination:
    • Server -> Client: 226 (Closing data connection)
    • Client -> Server: QUIT
    • Server -> Client: 221 (Service closing)

FTP Transmission Example 1 - Directory Listing

  • Example 2: Structured File Upload Protocol Trace
    • Control Connection Message Sequence:
    • Server -> Client: 220 (Service ready)
    • Client -> Server: USER forouzan
    • Server -> Client: 331 (User name OK. Password?)
    • Client -> Server: PASS XXXXXX
    • Server -> Client: 230 (User login OK)
    • Client -> Server: PORT 1267
    • Server -> Client: 150 (Data connection will open shortly)
    • Client -> Server: TYPE EBCDIC
    • Server -> Client: 200 (OK)
    • Client -> Server: STRU R
    • Server -> Client: 200 (OK)
    • Client -> Server: STOR /usr/user/report
    • Server -> Client: 250 (OK)
    • Data Connection Activity:
    • Client Data Transfer Process -> Server Data Transfer Process: Records of file ..........
    • Session Termination:
    • Server -> Client: 226 (Closing data connection)
    • Client -> Server: QUIT
    • Server -> Client: 221 (Service closing)

FTP Transmission Example 2 - File Upload

FTP User Interface Sessions and Anonymous FTP

  • Command-Line User Interface Session:

    • Session step-by-step trace:
    • Terminal invocation: % ftp challenger.atc.fhda.edu
    • Server response: Connected to challenger.atc.fhda.edu
    • Status code: 220 Server ready
    • User input: Name: forouzan
    • Password input: Password: xxxxxxx
    • FTP prompt command: ftp > ls /usr/user/report
    • Server response: 200 OK
    • Status response: 150 Opening ASCII mode ...........
    • Transfer completion: 226 transfer complete
    • Close connection: ftp > close
    • Server response: 221 Goodbye
    • Exit interface: ftp > quit
  • Anonymous FTP Access:

    • Concept: Provides public access to files without requiring an individual account on the host system.
    • Standard login procedures utilize anonymous as the username and guest (or an email address) as the password.
    • Session step-by-step trace:
    • Terminal invocation: % ftp internic.net
    • Server response: Connected to internic.net
    • Status code: 220 Server ready
    • User input: Name: anonymous
    • Server response: 331 Guest login OK, send “guest” as password
    • Password input: Password: guest
    • Print working directory: ftp > pwd
    • Server response: 257 '/' is current directory
    • List directory contents: ftp > ls
    • Status response: 200 OK
    • Transfer status: 150 Opening ASCII mode
    • Output listing: bin ...
    • Close connection: ftp > close
    • Server response: 221 Goodbye
    • Exit interface: ftp > quit