"Rl-tcpnet Network Tutorial" chapter 35th FTP File Transfer Protocol basics

Source: Internet
Author: User
Tags ftp file ftp client file transfer protocol ftp file transfer ftp file transfer protocol ftp protocol ftp transfer

Chapter 35th FTP File Transfer Protocol basics

This chapter explains the basic knowledge of FTP (file Transfer Protocol, document Transfer Protocol), and facilitates the actual operation of the following chapters.

(The knowledge points in this chapter are mainly organized from the network)

35.1 Important tips for beginners

35.2 FTP Basic Knowledge Reference

35.3 FTP basic Knowledge point

35.4 Summary

35.1 Important tips for beginners

FTP file Transfer Protocol in the actual project has more important practical value, the need for beginners to the basic knowledge of FTP also have an understanding.

35.2 FTP Basic Knowledge Reference

You can get the basic knowledge of FTP from the following address:

    • RFC959 Address: Ftp://ftp.rfc-editor.org/in-notes/rfc959.txt.
    • Wiki Wikipedia Chinese version ftp: Address link (this is a hyperlink)
    • Wiki Wikipedia English ftp: Address link (this is a hyperlink)
    • Baidu Wikipedia ftp: Address link (this is a hyperlink)

For beginners, learning the above three references is enough. If you have a network of books, such as "TCP/IP detailed", you can also directly read books.

35.3 FTP basic Knowledge point

(The knowledge points here are collated from the reference address above)

Tutorial here also on the basic knowledge of FTP to do an introduction, so that we have a general understanding of the first.

35.3.1 FTP Brief description

FTP (file Transfer Protocol) is used for two-way transmission of control files over the Internet. At the same time, it is also an application. There are different FTP applications based on different operating systems, and all of these applications follow the same protocol to transfer files. In the use of FTP, users often encounter two concepts: Download and upload. Downloading files is copying files from a remote host to your computer, and uploading files from your computer to a remote host. In the Internet language, users can upload (download) files to (from) a remote host through a client program.

FTP services typically run on 20 and 212 ports. Port 20 is used to transfer traffic between the client and server, while Port 21 is used to transport the control flow.

35.3.2 FTP Server/Client

Simply put, a server that supports the FTP protocol is an FTP server.

Like most Internet services, FTP is also a client/server system. The user connects to the FTP server program on the remote host through a client program that supports the FTP protocol. The user sends commands to the server program through the client program, the server executes the commands issued by the user, and returns the results to the client. For example, a user sends a command asking the server to send a copy of a file to the user, and the server responds to the command to send the specified file to the user's machine. The client program receives the file on behalf of the user and stores it in the user directory.

35.3.3 Anonymous FTP

When using FTP, you must first log in and obtain the appropriate permissions on the remote host before you can download or upload the file. That is, if you want to transfer files to the same computer, you must have the appropriate authorization for which computer. In other words, the file cannot be transferred unless there is a user ID and password. This situation violates the openness of the Internet, the FTP host on the internet is more than tens of millions, it is impossible to require each user to have an account on each host. Anonymous FTP was created to solve this problem.

Anonymous FTP is a mechanism by which a user can connect to a remote host and download files from it without becoming a registered user. The system administrator has established a special user ID, named Anonymous, that can be used anywhere on the Internet by anyone.

The FTP program to connect the anonymous FTP host is similar to the way to connect a normal FTP host, but only when providing a user ID must enter anonymous, the password of the user ID can be any string. In practice, use your own e-mail address as a password, so that the system maintenance program can record who is accessing these files.

It is important to note that anonymous FTP does not apply to all Internet hosts, it only applies to those hosts that provide the service.

When the remote host provides an anonymous FTP service, certain directories are specified to be open to the public, allowing anonymous access. The remaining directories in the system are in a stealth state. As a security measure, most anonymous FTP hosts allow users to download files from them without allowing users to upload files to them, which means that the user can copy all the files on the anonymous FTP host to their machine, but cannot copy any of the files on their machine to an anonymous FTP host. Even if some anonymous FTP hosts do allow users to upload files, users can only upload files to a specified upload directory. Then, the system administrator will check these files, he will move these files to another public download directory for other users to download, in this way, the remote host users are protected, to avoid someone uploading the problematic files, such as virus files.

35.3.4 FTP Transfer Mode

FTP There are two ways to transfer: ASCII, Binary.

    • ASCII transmission Mode

Assuming that the user is copying a file that contains simple ASCII text, if it is not UNIX running on the remote machine, FTP will usually automatically adjust the contents of the file in order to interpret the file as another computer's format for storing the text file when the file is transferred.

However, it is often the case that the files that the user is transmitting contain not text files, which may be programs, databases, or compressed files. Before copying any non-text files, use the binary command to tell FTP verbatim copies.

    • Binary transfer Mode

In binary transmission, the order of the files is saved so that the original and copy are bit-wise. Even a file of this bit sequence on the destination machine is meaningless. For example, Mac OS transfers executable files to the Windows system in binary mode, and this file cannot be executed on the other side of the system.

If the binary file is transmitted in ASCII mode, even if it is not required, it will corrupt the data (the ASCII method generally assumes that the first bit of each character is meaningless, because the ASCII character combination does not use it.) If the binary file is transferred, all the bits are important).

35.3.5 FTP-supported mode

FTP supports two modes: standard (PORT, active mode), Passive (PASV, passive mode).

    • Standard Mode

The FTP client first establishes a connection to the server's TCP 21 port, which is used to send a command that sends the port command on this channel when the client needs to receive data. The port command contains what ports the client uses to receive data. When transmitting data, the server connects to the client's specified port via its TCP 20 port to send the data. The FTP server must establish a new connection with the client to transfer the data.

    • Passive Mode

Establish a control channel similar to standard mode, but send the PASV command after establishing a connection. After the server receives the PASV command, it opens a temporary port (with a port number greater than 1023 less than 65535) and notifies the client to transmit data on this port, the client connects to the FTP server on this port, and then the FTP server transmits the data through this port.

Many firewalls are not allowed to accept externally initiated connections when they are set up, so many FTP servers behind a firewall or intranet do not support PASV mode because the client cannot open the high-end port of the FTP server through the firewall. Many clients in the intranet cannot log on to the FTP server in port mode because TCP 20 from the server cannot establish a new connection to the internal network's clients, causing it to fail to work.

35.3.6 goals and disadvantages of FTP implementation

The objectives of the FTP implementation are as follows:

    1. Promote the sharing of files (computer programs or data).
    2. Encourage the use of remote computers indirectly.
    3. The details of various file systems in different hosts are masked to the user.
    4. Reliable and efficient transfer of data.

The disadvantages of FTP are as follows:

    1. Passwords and file contents are transmitted in clear text, and eavesdropping may occur.
    2. Because a random port must be opened to create a connection, it is difficult for the client to filter FTP traffic in active mode when the firewall is present. This problem, by using the passive mode of FTP, has been largely addressed.
    3. The server may be told to connect a reserved port on a third-party computer.
    4. This is not a good performance when you need to transfer small files with a large number of files.
35.4 Summary

This chapter for everyone to explain so much, more relevant knowledge of FTP needs you to consult the relevant books to study, or online search for relevant information to learn.

"Rl-tcpnet Network Tutorial" chapter 35th FTP File Transfer Protocol basics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.