Network programming @ Noppa | @ wiki - Updated: — Jussi Laakkonen 2011/10/17 15:40

Assignment6: FTP client

In sixth assignment you'll implement a FTP client. It must comply to RFC specification of FTP and must be able to interact with FTP servers.


Create a FTP client based on RFC 959.


  • Client
    • Run with:
      ./ftpclient -h <hostname> -p <port>
      • If no port defined (no -p <port>) use default FTP port.
    • Client must be interactive.
    • Support both IP address and hostname of server.
    • Support stream mode only.
    • Support both upload and download.
    • Support ascii and binary transfer mode only.
      • Use file-structure as data structure.
      • Since we are dealing with x86 architecture there is no need to take care of different byte sizes.
    • Support active and passive modes of FTP
    • Support anonymous FTP servers (no authentication).
    • Must not crash in any circumstances.
    • Client must support following:
      • Access control commands:
        • open - open connection to server (send anonymous as user name and empty password if no authentication is implemented)
        • cd - change working directory
        • close - close connection to server
      • Transfer parameter commands:
        • active - change mode to active
        • passive - change mode to passive
      • FTP service commands:
        • get - retrieve a file from server
        • put - send a file to server
        • ls - request a list of files on the server in current working directory
      • Other commands:
        • ascii - change transfer mode to ascii
        • binary - change transfer mode to binary
        • quit - quit the client
      • Process replies for these commands sent by server.
    • Must be compatible with standard FTP servers
    • Show transfer speed after transmission and the total size of the file.
    • Implement support for user authentication.
    • Implement commands (and handle replies properly):
      • SYST
      • STATUS
      • HELP


Additional notes and hints

  • Read the RFC carefully.
  • Remember that \n is not the line end marker in FTP.
  • Some FTP servers to use for testing
    • Anonymous FTP server in University network, no outside access:
      • Name:
      • IP:
      • Port: Standard FTP port (21)
      • Instructions:
        • Username: anonymous
        • Password: <blank i.e. no password>
        • Folders
          • read/ - Readonly access, contains example files (3 binary and 1 text).
            • the sample.txt seems to contain linefeed+carriage return at the end of each line, new text file will be added without \r.
          • write/ - Write and read access, place to upload data. Will be cleared at 6:00 every morning, quota is 2GB (?).
    • Funet FTP server:
      • Address:
      • Port: Standard FTP port (21)
      • Anonymous access from everywhere.
      • Read only access.
      • Provided by Funet
      • Lots of different sized data (RFCs, Linux/UNIX images …)
    • Or you can install a FTP server on your own machine, some FTP servers:


  • TBA

Network programming @ Noppa | @ wiki