Skip to main content
  • Products
  • Evaluate our Software
  • Downloads
  • Free Utilities
  • Purchase
  • Support
  • About Us
  • Blog
  • Forum
  • Search
    • Contact Us
    • Forum
    • Wiki
    • Web Shop
    • Newsletter
    • RSS
  •   Jobs
  •   Videos
  •   Blog
  •   Sustainability
  • emFTP—FTP Client
    SEGGER - emFTP Product Icon

    emFTP Client – File Transfer Protocol Client

    • Low memory footprint.
    • Multiple connections supported.
    • Independent of the file system: Any file system can be used.
    • Independent of the TCP/IP stack: Any stack with sockets can be used.
    • Demo application included.
    • Project for executable on PC for Microsoft Visual Studio included.
    1. 1.emFTP Client – File Transfer Protocol Client
    2. 2.FTP backgrounds
      1. 2.1.Active Mode FTP
      2. 2.2.Passive mode FTP
      3. 2.3.Supported client FTP commands
    3. 3.Requirements
    4. 4.Resource Usage
    5. 5.Relevant Parts

    emFTP Client – File Transfer Protocol Client

    The emFTP client is an optional extension which adds the client part of FTP protocol to an IP stack such as emNet. FTP stands for File Transfer Protocol. It is the basic mechanism for moving files between machines over TCP/IP based networks such as the Internet. FTP is a client/server protocol, meaning that one machine, the client, initiates a file transfer by contacting another machine, the server and making requests.

    FTP backgrounds

    The File Transfer Protocol (FTP) is an application layer protocol. FTP is an unusual service in that it utilizes two ports, a 'Data' port and a 'CMD' (command) port. Traditionally these are port 21 for the command port and port 20 for the data port. FTP can be used in two modes, active and passive. Depending on the mode, the data port is not always on port 20.

    FTP background

    When an FTP client contacts a server, a TCP connection is established between the two machines. The server does a passive open (a socket is listen) when it begins operation; thereafter clients can connect with the server via active opens. This TCP connection persists for as long as the client maintains a session with the server, (usually determined by a human user) and is used to convey commands from the client to the server, and the server replies back to the client. This connection is referred to as the FTP command connection.

    The FTP commands from the client to the server consist of short sets of ASCII characters, followed by optional command parameters. For example, the FTP command to display the current working directory is PWD (Print Working Directory). All commands are terminated by a carriage return-linefeed sequence (CRLF) (ASCII 10,13; or Ctrl-J, Ctrl-M). The servers replies consist of a 3 digit code (in ASCII) followed by some explanatory text. Generally codes in the 200s are success and 500s are failures. See the RFC for a complete guide to reply codes. Most FTP clients support a verbose mode which will allow the user to see these codes as commands progress.

    If the FTP command requires the server to move a large piece of data (like a file), a second TCP connection is required to do this. This is referred to as the FTP data connection (as opposed to the aforementioned command connection). In active mode the data connection is opened by the server back to a listening client. In passive mode the client opens also the data connection. The data connection persists only for transporting the required data. It is closed as soon as all the data has been sent.

    Active Mode FTP

    In active mode FTP the client connects from a random unprivileged port P (P > 1023) to the FTP server's command port, port 21. Then, the client starts listening to port P+1 and sends the FTP command PORT P+1 to the FTP server. The server will then connect back to the client's specified data port from its local data port, which is port 20.

    embos ip ftp active mode

    Passive mode FTP

    In passive mode FTP the client connects from a random unprivileged port P (P > 1023) to the FTP server's command port, port 21. In opposite to an active mode FTP connection where the client opens a passive port for data transmission and waits for the connection from server-side, the client sends in passive mode the "PASV" command to the server and expects an answer with the information on which port the server is listening for the data connection.

    After receiving this information, the client connects to the specified data port of the server from its local data port.

    embos ip ftp passive mode

    Supported client FTP commands

    emNet FTP client supports a subset of the defined FTP commands. Refer to [RFC 959] for a complete detailed description of the FTP commands.
    The following FTP commands are implemented:

    FTP commandDescription
    CDUPChange to parent directory
    CWDChange working directory
    LISTList directory
    MKDMake directory
    PASSPassword
    PWDPrint the current working directory
    RETRRetrieve
    RMDRemove directory
    STORStore
    TYPETransfer type
    USERUser name

    Requirements

    The emNet FTP client requires a TCP/IP stack. It is optimized for emNet, but any RFC-compliant TCP/IP stack can be used. The shipment includes a Win32 simulation, which uses the standard Winsock API and an implementation which uses the socket API of emNet.

    Resource Usage

    The ROM usage depends on the compiler options, the compiler version and the used CPU. The memory requirements of the FTP client presented in the tables below have been measured on an ARM and a Cortex-M4 system. Details about the further configuration can be found in the sections of the specific example.

    Configuration Used

    #define FTPC_BUFFER_SIZE 512
    #define FTPC_CTRL_BUFFER_SIZE 256
    #define FTPC_SERVER_REPLY_BUFFER_SIZE 128  // Only required in debug builds with enabled logging.

    ROM Usage on an ARM System: The following resource usage has been measured on an ARM system using SEGGER Embedded Studio, Thumb mode, no interwork, size optimization.

    Add-onROM
    emFTP clientApproximately 2 KByte

    ROM Usage on a Cortex-M4 System: The following resource usage has been measured on a Cortex-M4 system using SEGGER Embedded Studio, size optimization.

    Add-onROM
    emFTP clientApproximately 1.7 KByte

    RAM Usage: Almost all of the RAM used by the web server is taken from task stacks. The amount of RAM required for every child task depends on the configuration of your client. The table below shows typical RAM requirements for your task stacks.

    BuildDescriptionRAM
    ReleaseA task used for the FTP client without debugging features and disabled debug outputs.Approximately 1400 Byte

    The approximately task stack size required for the FTP client can be calculated as follows:

    TaskStackSize = 2 * FTPC_BUFFER_SIZE + FTPC_CTRL_BUFFER_SIZE
    BuildDescriptionRAM
    DebugA task used for the FTP client with debugging features and enabled debug outputs.Approximately 1550 Byte

    The approximately task stack size required for the FTP client can be calculated as follows:

    TaskStackSize = 2 * FTPC_BUFFER_SIZE + FTPC_CTRL_BUFFER_SIZE + FTPC_SERVER_REPLY_BUFFER_SIZE

    Relevant Parts

    The FTP client implements the relevant parts of the following RFCs.

    RFC#Description
    [RFC 959]Direct Link: FTP - File Transfer Protocol

    More Information

    Purchase

    • Pricing

    About us

    • The Company
    • Partners
    • Job Offers
    • Media
    • Contact us

    Support

    • Technical Support
    • Blog
    • Forum
    • Wiki

    Downloads

    • Application Notes
    • Embedded Studio
    • embOS
    • emCompress
    • emCrypt
    • emFile
    • emLib
    • emLoad
    • emModbus
    • emNet
    • emPower
    • emSecure
    • emSSH
    • emSSL
    • emUSB-Device
    • emUSB-Host
    • emWin
    • Flasher
    • Free Utilities
    • IoT
    • J-Link / J-Trace
    • Linux Studio
    • SystemView
    • CE / REACH

    Social Media

    Headquarters

    SEGGER Microcontroller GmbH

    Ecolab-Allee 5
    40789 Monheim am Rhein, Germany
    info@segger.com
    Tel.: +49-2173-99312-0
    Fax: +49-2173-99312-28

    Locations

    USA: SEGGER Microcontroller Systems LLC

    Boston area
    101 Suffolk Lane
    Gardner, MA 01440, USA
    us-east@segger.com
    Tel.: +1-978-874-0299
    Fax: +1-978-874-0599

    Silicon Valley
    Milpitas, CA 95035, USA
    us-west@segger.com
    Tel.: +1-408-767-4068

    China: SEGGER Microcontroller China Co., Ltd.

    Room 218, Block A, Dahongqiaoguoji
    No. 133 Xiulian Road
    Minhang District, Shanghai 201199, China
    china@segger.com
    Tel.: +86-133-619-907-60

    ISO 9001 certified

    ISO 9001

    30+ years of experience

    First-class embedded software tools since 1992
    • Imprint
    • Disclaimer
    • Privacy Policy

    © 2022 SEGGER - All rights reserved.