The FTP defines a standard protocol for transferring files

an article added by: Daniel R. at 12062007


In: Categories » » Ethernet » The FTP defines a standard protocol for transferring files

The File Transfer Protocol defines a standard protocol for transferring files between computers. The main documents that define FTP are RFC 959: File Transfer Protocol (FTP) and RFC 1123: Requirements for Internet Hosts -- Application and Support.

Requirements

An embedded system can function as an FTP client or server. A client initiates communications with a server and sends requests to transmit or receive files. In most cases, an embedded system that needs to exchange files with a single PC should function as a client. Many embedded systems don’t have a lot of resources to spare, and running an FTP server that is always available requires processing time and memory. Running a server also puts the system at a greater security risk because any computer in the network might be able to gain access to the system’s files. But if the embedded system needs to make its files available to anyone on the network, or if the files need to be available to other computers at all times, the system will need to function as a server. A computer that uses FTP must have a file system, which enables the system to store information in named entities called files. Files are of course useful in desktop computers, where you select files to run programs, view documents and images, and perform other tasks. Embedded systems can support file systems as well. A small embedded system may just store data in specified locations in memory, with no need to place the data in named files. But for many embedded systems, a file system provides a useful structure for accessing information, both locally and over a network. For example, a system can store collected data or configuration settings in files.

A system functioning as an FTP client can initiate communications periodically with a remote computer to request to send or receive files. A system functioning as an FTP server can make its files available on request and can allow remote computers to send files that the system will use. The user that communicates with the embedded system can be a human using an FTP program or a process that functions without human intervention. For example, a PC can be programmed to retrieve a file once a day from an embedded system. In PCs, the file system includes the ability to store files in a directory structure and to specify attributes such as whether a file is write-protected or accessible to certain users. Under Windows XP, from the My Computer folder, you can browse the directories and view file names and attributes. (In the View menu, click Choose Details to specify what information to display and click Details to view the information.) The TINI supports a similar file system, which you can browse from the slush shell using commands such as ls -l and cd. A very basic file system might just consist of a structure with a series of entries that each store the name, starting address in memory, and length of a file. In Dynamic C, entries in an HttpSpec or ServerSpec structure can specify files that are accessible to a Web or FTP server. Each entry includes a file name, the address in memory where the file’s length and contents are stored, and optional security information. On a PC, you can perform FTP transfers using an FTP client application such as WS_FTP from Ipswitch, Inc. Two other ways to perform FTP transfers are from a command prompt and from a browser. To use the command- line interface, enter ftp at a command prompt and enter ? for a list of commands. The browser interface is explained later in this networking tutorial. Ipswitch and others also offer applications that enable a PC to function as an FTP server.

Transferring a File

To transfer a file, an FTP session uses two channels, or communications paths, one for control information and one for the file being transferred. Each channel has a separate TCP connection. On the server, the default port for the control channel is 21 and the default port for the data channel is 20. The client can use any available port or ports. The default for the client is to use the same port for both the control and data channels. However, transfers that use FTP’s stream mode, which requires a new data connection for each file, should send a PORT command to specify a new, non-default port for each file transfer. Requesting a new port for each transfer prevents problems due to TCP’s timeout requirements. When a connection closes, TCP requires a timeout before the same connection can be reused. The timeout prevents a new connection that is identical to a recently closed connection from receiving data intended for the previous connection. When transferring multiple files in a single session, if a transfer tries to use the same port as the previous connection, the port may be unavailable because thes timeout for the previous connection hasn’t expired. Specifying a different port for each data connection eliminates the problem. Other alternatives are to use the block or compressed transfer modes, which don’t require a new data connection for each file. These are typical steps in sending a file to a server in stream mode, where the file’s contents are sent without a header or any assumed structure for the file’s data:

1. The client opens a control channel between any available local port and port 21 on the server. The client sends commands to establish communications and request to send a file.

2. The server opens a data channel between the server’s port 20 and the port the client is using for the control channel.

3. The client sends the file’s contents, closes the data channel, and requests the server to close the control channel.

4. The server closes the control channel.

In a similar way, these are the steps in receiving a file from a server in stream mode:

1. The client opens a control channel between any available local port and port 21 on the server. The client sends commands to establish communications and request a file.

2. The server opens a data channel between the server’s port 20 and the port the client is using for the control channel. The server sends the file and closes the data channel.

3. The client requests the server to close the control channel.

4. The server closes the control channel.

A client that is communicating from behind a firewall may find that the firewall blocks the server’s request to open the data connection. To get around this limitation without having to reconfigure the firewall, the client can send a command that requests a passive transfer process (PASV or EPSV), where the client, rather than the server, opens the data connection. The client must send the command to request a passive transfer preceding each transfer. When a client specifies the location of a file on a server, the location is relative to the directories that the server makes available to the client. This location can differ from the file’s absolute location in the computer. For example, a computer functioning as a server may allow the user to access the directory /ftp/user1 and its subdirectories. The server’s root directory for that user is then /user1. To access a file at /ftp/user1/data/test.txt, the client would specify the location on the server as /data/test.txt, which is the file’s location relative to the user’s root directory.

legal notice

Our website is not responsible for the information contained by this article. Web-articles is a free articles resource.
Suggestion: If you need fresh, daily updated content for your website, feel free to use our service. Click here for more information.

Useful tools and features

Link to this article from your page    Send this article to you or to a friend
If you like this article (tutorial), please link to it from your web page using the information above.

related articles

1. Ubicom IP2022 Wireless Network Processor
Special-Purpose Modules Ubicom IP2022 Wireless Network Processor. In addition to products that provide a complete generic system for networking, a variety of modules and chips are available to handle specific tasks. Some products can interface to just about any CPU. If you have an existing product or a CPU that you want to use, one of these modules may provide a way to add networking capability. This section describes a selection of products. Lantronix Device Server At a glance: enables any device with an ...

2. EDTP Electronics Packet Whacker
EDTP Electronics Packet Whacker At a glance: An Ethernet interface on a circuit board with headers for connecting to a CPU. Typical use: adding Ethernet to any microcontroller circuit. Ethernet support: 10BASE-T Source: EDTP Electronics (www.edtp.com) Hardware. The Packet Whacker (Network article 3-11) from EDTP Electronics is an Ethernet interface only. The circuit board contains a Realtek RTL8019AS Ethernet controller, an RJ-45 connector, two headers that bring out the si...

3. NE2000 Compatibility
NE2000 Compatibility A term you’re likely to hear in reference to program code for network controllers is NE2000-compatible. The NE2000 was an early and popular PC network interface card from Novell. The card contained National Semiconductor’s DP8390 controller. Software for systems that use the ’8390 or a compatible chip has come to be known as NE2000-compatible code. A major feature of the ’8390 is its set of internal registers. By reading and writing to the registers, a CPU can c...

4. Using the Internet Protocol in Local and Internet Communications
The protocols in the IEEE 802.3 Ethernet standard enable the computers in a local network to exchange messages with each other. In practice, most Ethernet networks also use Internet protocols such as TCP or UDP and IP. These provide defined and well-supported methods for accomplishing common tasks such as flow control and flexible addressing and routing of messages. Messages that travel on the Internet must use IP. And because TCP and UDP are designed to work along with IP, local communications that use TCP or UDP also use...

5. There are several options for obtaining an Internet connection
Technologies for Connecting There are several options for obtaining an Internet connection. A long-popular way for home users to connect to the Internet is via dial-up connections on phone lines. For higher speeds, alternatives are a Digital Subscriber Line (DSL), an Integrated Services Digital Network (ISDN) line, or a cable modem. Satellite connections are also possible. Table 4-1 compares the capabilities of the different methods. Not every connection type is available in all locations. Depending on ...

6. Every computer that communicates over the Internet must have an IP address
Static and Dynamic IP Addresses Every computer that communicates over the Internet must have an IP address, which the computer typically receives from its ISP. The IP address may be static or dynamic. A static IP address stays the same until someone explicitly changes it, while a dynamic IP address can change on every boot up or network connect (though the address typically changes only occasionally). An embedded system may store a static IP address in non-volatile memory, either within an application...

7. Obtaining and Using a Domain Name
Obtaining and Using a Domain Name After you obtain Internet access, connect your embedded system to the Internet, and configure your firewall to enable the embedded system to communicate, the system is ready to send and receive messages on the Internet. Applications running on other computers on the Internet can access the embedded system by specifying its public IP address. For example, to view a server’s home page, in the Address text box of a Web browser, you enter http:// followed by the server&rsquo...

8. Inside the Internet Protocol
The Internet Protocol (IP) helps data find its way to its destination even if the data must travel through other networks, including the many and varied networks that make up the Internet. Although it’s called the Internet Protocol, local networks can use IP as well. Many communications in local networks use IP because they use its companion protocols, TCP and UDP. This section introduces IP, including how computers obtain IP addresses, the format of IP datagrams, how IP and the domain name system help in getti...