Design Article
Guide to Embedded Systems Architecture - Part 4: Application layer networking protocol examples
Tammy Noergaard
5/10/2010 2:00 PM EDT
10.4.1 File Transfer Protocol (FTP) Client Application Example
FTP (File Transfer Protocol) is one of the simplest protocols used to securely exchange files over a network. FTP is based upon RFC959 and can be implemented as a standalone application, solely dedicated to transferring files between networked devices, or within applications such as browsers and MP3 applications. As shown in Figure 10-29, the FTP protocol defines the communication mechanisms between the device initiating the transfer, called the FTP client or user-protocol interpreter (user PI), and the device receiving the FTP connection, called the FTP Server or FTP Site.

Two types of connections can exist between FTP client and servers: the control connection in which commands are transmitted between the devices, and the data connection in which the files are transmitted. An FTP session starts with the FTP client initiating a control connection by establishing a TCP connection to port 21 of the destination device. The FTP protocol requires its underlying transport protocol to be a reliable, ordered data stream channel, such as TCP (as shown in Figure 10-29). Note: the FTP connection mechanism is in part based upon RFC854, the Telnet (terminal emulation) protocol.
The FTP client, after transmitting its commands, waits for the FTP Site to respond with a reply code over the control connection; these codes are defined in RFC 959 and shown in Table 10-9.
Table 10-9: FTP reply codes [10-6]
| Code | Definition |
| 110 | Restart marker reply |
| 120 | Service ready in "x" minutes |
| 125 | Data connection already open |
| 150 | File status ok |
| 200 | Command ok |
| 202 | Command not implemented |
| 211 | System help |
| .... | ..... |
If the response from the FTP site is favorable, the FTP client then sends commands, like the ones shown in Table 10-10, that specify parameters for access control, such as username or password, transfer criteria (i.e., data port, transfer mode, representation type, and file structure, etc.), as well as the transaction (store, retrieve, append, delete, etc.).
Table 10-10: FTP commands [10-6]
| Code | Definition |
| USER | Username – access control command |
| PASS | Password – access control command |
| QUIT | Logout – access control command |
| PORT | Data Port – transfer parameter command |
| TYPE | Representation Type – transfer parameter command |
| MODE | Transfer mode – transfer parameter command |
| DELE | Delete – FTP service command |
| .... | ..... |
Next: Pseudocode example (FTP)

