The TCP/IP Guide - Version 3.0 (Contents) ` 1333 _ © 2001-2005 Charles M. Kozierok. All Rights Reserved.
sender's internal representation to the neutral ASCII representation used by the Telne t
protocol (“NETASCII”) with each line ending in “CR+LF”. The receiving device then converts
from this neutral representation to the internal format used by the recipient file system.
For example, when using FTP to move a text file from a Macintosh to a UNIX system, each
line would have the “CR” changed to a “CR+LF” for transmission over the FTP data
channel. The receiving UNIX system would change each “CR+LF” to just “LF”, so UNIX
programs would read it properly.
Note that this actually does mean the resulting file can be bigger or smaller than the
original, if it is transferred between systems using ASCII mode. Also, since FTP works by
converting to a neutral representation for universality, sending an ASCII file from a UNIX
system to a UNIX system means each “LF” is changed to “CR+LF” for transmission, then
changed back to just “LF” by the recipient. Slightly inefficient, but not that big a deal.
It's very important that when FTP is used, the correct data type be specified with the appro-
priate user command. Sending a text file between dissimilar systems without setting ASCII
mode will result in either a file that cannot be properly read on the destination, or one that
has stray characters in it. Conversely, binary files must be sent in binary mode. If you send
something like a ZIP file or a JPG graphic in ASCII mode, the FTP software will think it is a
text file. It will treat the file as if it were text, and each time it encounters bytes in the file that
look like “CR”, “LF” or “CR+LF” it will convert them, which you do not want. (Having the
wrong data type set is a leading cause of corrupted files when using FTP to move files
between PCs and UNIX systems. I know from experience!)
Key Concept: FTP defines four data types: ASCII, EBCDIC, image and local. ASCII
and EBCDIC are used for text files in the ASCII and EBCDIC character sets, respec-
tively; the image type is used for files with no specific structure, and the local type for
local representation. The ASCII type is important because it allows text files to be trans-
ferred successfully between file systems that may use different methods of indicating the
end of a line of text. The image type, also called binary, is used for files that must be sent
and received byte-for-byte with no transformation, such as executable files, graphics and
files with arbitrary formats.
FTP Format Control
For the ASCII and EBCDIC types, FTP defines an optional parameter called format control.
This allows a user to specify a particular representation for how vertical formatting is used
to describe a file. The three options are:
☯ Non Print: The default, indicating no vertical formatting.
☯ Telnet Format: Indicates that vertical format control characters, as specified in the
Telnet protocol, are used in this file.
☯ Carriage Control / FORTRAN: The file uses format control characters given as the
first character of each line, as specified for the FORTRAN programming language.