TCP/IP study notes (8)

Source: Internet
Author: User
Tags ftp commands file transfer protocol ftp protocol
TCP/IP study notes (8)

I,FTP: File Transfer Protocol

1. FTP protocol: two TCP connections are used to transmit a file.
(1) control connection:
The control connection is usually established on the client server. The control connection always waits for the customer to communicate with the server. The connection sends the command from the client to the server and returns the server's response.
(2) Data Connection:
This connection is used for data transmission.
2. Data Representation:
(1) file type:
◆ ASCII files: nvt ASCII files are transmitted by default. This requires that the sender convert the local text file to the nvt ASCII code, and the receiver restores the nvt ASCII code to the local text file. Each line transmitted with the nvt asvcii code ends with a carriage return and a line feed.
◆ Ebcdic file: both ends are required to be an ebcdic system.
◆ Binary file type: Data sends a continuous bit stream, which is usually used to transmit binary files.
◆ Local file type: Transfers binary files between hosts with different bytes.
(2) format control, which is only valid for ASCII and ebcdic file types.
◆ Non-print (default): the file does not contain vertical format information.
◆ Remote logon format control: the file contains the vertical format Control for remote logon explained to the printer.
◆ Fortran carriage return control: the first character of each line is a FORTRAN control character.
(3) structure:
◆ File structure (default): The file is considered as a continuous byte stream and does not have an internal file structure.
◆ Record structure: this structure is only used for text files.
◆ Page Structure: each page is sent with a page number so that the recipient can store each page at random.
(4) Transmission Mode
◆ Stream mode (default): The file is transmitted in byte streams. For the file structure, the sender prompts to close the data connection at the end of the file. For the record structure, a dedicated two-byte sequence code is provided to mark the end of the record and the end of the file.
◆ Block Mode: The file is transmitted in a series of blocks. Each block is preceded by one or more header bytes.
◆ Compression method:
3. FTP command:
Commands and responses are transmitted in nvt ASCII format over the control connection between the customer and the server. This requires that CR/LF be returned at the end of each line.
FTP commands are familiar to everyone.
4. FTP Response:
The response is a three-digit ASCII code with the packet option. Some typical responses:
◆ 125: data connection is enabled and transmission starts
◆200: Ready
◆ 214: help message
◆ 331: the user name is ready. enter a password.
◆ 425: data connection cannot be enabled
◆ 452: incorrect file writing
◆500: Unknown syntax error
◆ 501: Invalid Parameters
◆ 502: unimplemented mode type
5. Connection Management:
Data connection has three major uses:
(1) send a file from the client to the server
(2) send a file from the server to the customer
(3) The slave server sends a file or directory list to the customer.
Each data connection establishes a new connection for transferring a file or directory sequence.
(1) The customer issues a command to establish a data connection
(2) The customer selects a temporary port number for no data connection on the customer host.
(3) The customer uses the PORT command to send the port number to the server from the control connection.
(4) The server receives the port number on the control connection and actively opens the port on the client host. The data connection of the server uses Port 20.

II,SMTP: Simple Mail Transfer Protocol

1. SMTP protocol:

The message exchange over TCP is completed by the message transmission proxy MTA (message transfer agent. The two MTA instances communicate with each other using nvt ASCII. The customer sends a command to the server, and the server responds with a digital response code and an optional string.
There are only five common SMTP commands for sending emails: Hello, mail, rctp, data, and quit.

HELO: Identify your own mail: Start User Agent RCPT: Identify recipient data: mail message content quit: Exit rset: Abort the current Mail transaction with an exception and reset VRFY at both ends: allows the customer to ask the sender to verify the recipient's address without sending an email to the recipient. Noop: forces the server to respond to an OK response code without doing anything.

2. envelope, header, and body

(1) envelope: it is delivered by MTA.
Mail from: xiaoj@njb.swirebev.com
Rcpt to: xiaoj@hotmail.com
(2) header: used by the user agent. There are nine fields: received, message_id, from, Data, reply-to, X-phone, X-mailer, to, and subject. Each header field contains a name followed by a colon followed by the field value.
(3) body: it is the content sent to receive user packets. When you use the data command to send a message, the first line is sent first, followed by an empty line, followed by the body. Each row sent with data must be smaller than 1000 bytes.

The user receives the body part, adds some header fields, and sends the result to the MTA. Add some header fields to the MTA, add an envelope, and send the result to another MTA. All of these are sent in nvt ASCII format.

3. Expanded SMTP:

To use ESMTP, run the EHLO command instead of the HELO command to start the session with the server. It displays extended commands such as EXPN, size, help, 8 bitmime, and xadr. The size command allows the customer to specify the packet size in bytes in the mail from command, so that the server can verify whether the server receives the packet of this length before the customer starts sending the packet. 8 bitmime allows the customer to add the keyword body to the mail from command to specify whether the body contains nvt ASCII (default) or 8-bit data. The client is prohibited from sending any non-nvt ASCII characters unless the client receives the 8bitmime keyword from the server in response to the EHLO command.

(1) first change: Non-ASCII characters

The main purpose is to allow the sender name, receiver name, and topic to use other characters.
The header field can contain a coded word in the following format:

  =?charset?encoding?encoded-text?=

Charset represents the character set. Valid values are US-ASCII and iso-8859-x.
Encoding is a single character used to specify the encoding method. It supports two values:
◆ Q: It indicates that the quotation marks are printable and used for the Latin character set. Most characters are sent as nvt ASCII. Any character to be sent is sent as three characters if the first character is 1, and the first character is "=", followed by two hexadecimal numbers, such as 0xe9, send 3 characters "= E9", and spaces are usually used as underscores or three characters "= 20.
◆ B: indicates the code based on 64. The three consecutive bytes (24 bits) in the text are encoded into 4 6 bits, which are used to represent 64 nvt ASCII characters of all possible 6 bits. When the number to be encoded is not a multiple of 3, the equal sign is used as a fill character.

(2) Body Change: Generic Internet Mail Extension can place the structure into the body, which is mime, that is, generic Internet extension. Mime does not require any extension,
However, some new headers are added to inform the recipient of the body structure. The body can still be sent using nvt ASCII, regardless of the mail content. Mime defines five new titles:
Mime-version: the current version is 1.0.
Content-tyoe: The content type is unformatted ASCII text, which is the default choice for Internet mail. It can be text, multipart, message, application, image, audio, and video.
Content-transfer-encoding: The content is encoded in 5: 7bit (nvt ASCII), quoted-printable, base64, 8bit, and binary.
Content-ID:
Content-description:

III,NFS: Network File System

1. Remote Procedure Call RPC (Remote procedue access). The main process is as follows:

(1) When the client program calls a remote process, it actually only calls a function generated by the RPC program located on the local machine. This function is called the client residual pile (stub ), the customer vulnerability encapsulates the process parameters as a network packet and sends the packet to the server program.
(2) A server residue on the server host is responsible for receiving the network packet. It extracts parameters from the network packet and then calls the server process.
(3) when the server function returns, it returns to the server. The server residual pile extracts the returned value, encapsulates the returned value into a network packet, and then sends the packet to the customer residual pile.
(4) The customer residual pile retrieves the return value from the received network packet and returns it to the customer program.

2. XDR: External Data Representation

XDR is used to encode the values in the RPC call message and response message, including the RPC header field (Xid, program number, receiving status, etc.), process parameters, and process results. XDR defines many data types and how they are transmitted in an RPC message. The sender must construct an RPC packet in XDR format, and then the receiver converts the packet in XDR format to the local format.

3. Port er

The RPC server program that contains the remote procedure uses a temporary window, which requires tracking which temporary port the RPC program uses. The port er itself must be composed of a well-known port 111, a program number (100000), and a version number (2 ). The server program uses RPC to call the port er to register itself. The client program uses RPC to call the port ER for query.
The port er provides four service processes:
(1) pmapproc_set: This process is called when the RPC server is started. register the program number, version number, and Protocol with a port number.
(2) pmapproc_unsret: the RPC server deletes a registered ing.
(3) pmapproc_getport: The registered port number is obtained based on the given program number, version number, and protocol.
(4) pmapproc_dump: returns all records in the port er database.

4. NFS Protocol

(1) Whether to access a local file or NFS file is transparent to the customer. When the file is opened, it is determined by the kernel.
(2) NFS customers send RPC requests to the NFS server through its TCP/IP module.
(3) NFS servers generally receive client requests as UDP datagram on port 2049.
(4) When the NFS server receives a customer request, it passes the request to the local file access routine, which accesses a local file on the server host.
(5) Most NFS servers are multithreading and can process multiple requests.
(6) customers can also run multiple NFS customers.

5. file handle

A file handle is an opaque object used to reference a file or directory on the server. The server creates a file handle, passes it to the customer, and then uses the handle when the customer accesses the file.

6. installation protocol

The client must use the installation protocol to install a file system before accessing files in a file system on the server. Generally, the client host is guided.

7. NFS process: prefixed with nfsproc _

(1) getattr: returns the file attributes.
(2) setattr: Set file attributes
(3) Status: returns the status of a file system.
(4) lookup: Find a file
(5) read: Read data
(6) Write: Write Data
(7) Create: create a file
(8) Remove: delete an object
(9) Rename: rename a file
(10) Link: Construct a hard link for a file
(11) symlink: constructs a symbolic link for a file
(12) readlink: Read Symbolic Link
(13) mkdir: create a directory
(14) rmdir: delete a directory
(15) readdir: Read directory.

--------- End --------

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.