设为首页 收藏本站
查看: 808|回复: 0

[经验分享] FTP传输的两种模式:binary vs ascii

[复制链接]

尚未签到

发表于 2016-6-10 08:58:50 | 显示全部楼层 |阅读模式
What is ASCII?
  ASCII: the American Standard Code for Information Interchange. It's the code by which computers have stored and exchanged text for the last 40 or more years.
  ASCII has been the mainstay of information interchange for four decades, but it has limitations. Designed during a time when computer memory (RAM) was very expensive, it used only the low 7 of the 8 bits in a standard byte. This was adequate, and allowed the leftover bit to be used (occasionally) for other purposes.
What is Binary?
  http://courses.wccnet.edu/computer/mod/na36c_f01.gifBinary is the number system based on 2. In this context, though, it refers to numeric, as opposed to text, information. While ASCII text uses only 7 of the 8 bits in a byte, numbers use all 8.
  Not only do numbers themselves use all 8 bits, but so do most other types of computerized information (all of which use numbers to represent information), including:

  • programs
  • images
  • databases
  • music
  • video
  • word processing documents
  • compressed files
  It comes as a surprise to many people that word processing documents, such as Microsoft Word and Word Perfect files, are binary rather than ASCII. That's because they store a great deal of information besides just the letters: they contain font and formatting information, images, user preferences, and many other "bells and whistles".
  
http://courses.wccnet.edu/computer/mod/rain_lin.gif
ASCII and Binary in FTP
Why Does FTP Have Both?
  FTP was developed at a time when typical modem speeds were 110 to 300 bits per second (as compared with 28,000 to 56,000 today). Since ASCII only used 7 bits, long files could be transmitted more quickly by not sending all the unused bits.
  The big drawback is that if a file that uses all 8 bits in each byte is accidentally sent using ASCII transfer, it will lose 1/8 of its information content. In most files, even the loss of one bit is enough to make it invalid, and losing 1/8 makes them totally unreadable. So ASCII transfer can be fatal to a file's health!
  With today's higher speeds, the time lost by sending all 8 bits of an ASCII file is practically unnoticeable. But FPT has incorporated features into ASCII transfer that make it useful for other reasons, so the two modes remain.
  The fact that they both remain means that FTP users need to exercise great caution in transferring files!
What Extra Services Does ASCII Transfer Have?
  What features are so useful that FTP retains ASCII transfer in spite of the risk of ruining files in transmission? There are two: end-of-line translation, and end-of-file translation.
  Although ASCII has standardized almost all aspects of text files shared between computers, there are two areas where operating systems have "agreed to disagree". One is how you symbolize the end of a line, the other is how you mark the end of a file.
  When files are transferred using ASCII mode, FTP clients and servers will translate the different symbols into the native "language" of the receiving computer. This eliminates files that appear to have "garbage" in them, or that appear to be all one long line stretching from here to the horizon. There are some programs used in making the Web interactive, that depend on having the right line-break characters.
  In case you're interested or need to know the details, here they are:
 ASCII character numbers
followed by
[Character Names]
SystemEnd-of-LineEnd-of-FileIBM, DOS, Windows, VAX-VMS13+10
[CR]+[LF]
26
[^Z]
Linux, Unix10
[LF]
04
[^D]
Macintosh OS 1-9 13
[CR]
04
[^D]
Macintosh OS X Flexible: either
[LF] or [CR]
04
[^D]
  
  
http://courses.wccnet.edu/computer/mod/rain_lin.gif
How to Set Transfer Mode
Setting Transfer Mode in Character-Based FTP Clients
http://courses.wccnet.edu/computer/mod/na36c_f02.gif
  If you use a command-line FTP client: The default mode is ASCII. Every time you intend to transfer a binary file, you need to type the command,
binary
before typing in the getor putcommand.

  FTP will stay in binary mode until you change it, so if you then transfer ASCII files, you need to type the command
ascii
before typing the getor putcommand.

How To Set Transfer Mode in a GUI-based FTP Client
  http://courses.wccnet.edu/computer/mod/na36c_f03.gif
  http://courses.wccnet.edu/computer/mod/na36c_f04.gif
  GUI-based FTP clients are each different, but since we use WS-FTP at WCC, we'll focus on that.
  WS-FTP has three controls for mode: ASCII, Binary, and Auto. Auto is a check box, and does not affect the status of the other two, while ASCII and Binary are "radio buttons", meaning you have to choose one or the other. Here's how they work:

  • If Auto is OFF(unchecked), and:

    • ASCII is ON: All transfers will be in ASCII mode.
    • Binary is ON: All transfers will be in binary mode.

  • IfAutomatic is ON(checked), files are transferred in binary mode unless the extension is listed in a table set up in WS-FTP. Details follow...
"Automatic" Mode
http://courses.wccnet.edu/computer/mod/na36c_f05.gif
  The behavior of WS-FTP in Auto mode depends on a list of file extensions it keeps.You can access that list by clicking the Options button at the bottom of the WS-FTP LE window (or the top of the WS-FTP Pro window).
http://courses.wccnet.edu/computer/mod/na36c_f06.gif  In the Options dialog, click the Extensions button. This brings you to the list of extensions. The illustration at left shows the default list of ASCII extensions - only .TXT. (This is notcase-sensitive.)
  If you're transferring Web files, HTML files could also be in this list.In addition, there are a number of other file type used on the Web that are text files and should be transferred using ASCII mode. These are listed in the table in the next section.
  
http://courses.wccnet.edu/computer/mod/rain_lin.gif
Summary: Practical Advice
WS-FTP Help offers this advice:

  • A file that is text, HTML, postscript, other ASCII format (.txt, .html, .htm, .cgi), or EBCDIC should be transferred in ASCII mode. Note: Transferring a binary file in ASCII format can damage the file.
  • A file that is a bitmap, an executable, or compressed (.bmp, .jpg, .exe, .zip) should be transferred in binary mode. (Binary mode should also be used if there is no file extension or the file extension is not registered.)
  Here's a quick overview of files and how they should be transferred:
ASCIIBinary.txtASCII text.txtUnicode text - see notebelow.htm
.html
HTML
Web page
.jpg
.jpeg
JPEG image.xmlExtensible Markup Language.gifCompuServe GIF image.cgiCommon Gateway Interface script.pngPortable Network Graphics.plPerl scrips must be transferred in ASCII.bmpWindows bitmap image.phpPHP program script.docMS Word or Word Perfect document.cfCold Fusion script.xlsMS Excel spreadsheet.svgScalable Vector Graphics image.mdbMicrosoft database file.aspMS Active Server Pages script.exe
.com
.dll
Executable programs.rtfRich Text Format.zipCompressed files.psPostscript files.pdfAdobe Acrobat Portable Document Format filesNote about Unicode
  Unicode is the system which ultimately will replace ASCII, because it has the potential to include all the characters of all human languages. It can do this because instead of 7 bits it can use 8, 16, or 32. It is still evolving, but more and more programs are coming to use it.
  Since it uses all the bits in each byte, it must be transferred in binary mode. Unfortunately, the extension .txt is routinely used for Unicode text files, making it impossible to tell from the extension whether to transfer it in ASCII or binary.
  
http://courses.wccnet.edu/computer/mod/rain_lin.gif
 About this document...
http://courses.wccnet.edu/computer/mod/review.gifClick herefor a review of this module. Audience:
This is for people who are familiar with the basics of FTP and need to distinguish between files appropriate for binary transfer, and those appropriate for ASCII transfer. Objectives:
  When you successfully complete this lesson, you will be able to...

  • Explain what is meant by "binary" files
  • Explain what is meant by "ASCII" files
  • Identify ASCII and Binary files by their extensions
  • Discuss the reasons for maintaining a distinction between ASCII and binary transfer
  • Recognize the commands for switching between ASCII and binary transfer in command-line FTP clients
  • Recognize the commands for switching between ASCII and binary transfer a GUI FTP client such as WS-FTP
  • Discuss the uses and proper setup of "automatic" mode in WS-FTP
Module NA36c:
This document is part of a modular instruction series in Computer Instruction. For more information, see the overviewor the list of modules in this series, NA: Network Applications. This document has been used in the following classes: INP 150, INP 152, INP 220. Author:
Laurence J. Krieg Institution:
Department of Computer Information Systems, Washtenaw Community College
http://courses.wccnet.edu/computer/mod/wcclogoc.gif
History:Original: 16 Oct 2002
This version posted  Thursday, 01-Jun-2006 09:37:40 EDT
Copyright:Copyright © 2002, Laurence J. Krieg, Washtenaw Community College
Instructors: You may point to this file in your Web-based materials.

Students: you may make a copy for your personal use.


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-228470-1-1.html 上篇帖子: ftp协议分析:Passive模式和Port模式 下篇帖子: 最好的ftp server 软件 Serv-U 绿色 中文
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表