[Computer Network - Application Layer] Domain Name System DNS, File Transfer Protocol FTP, Email

1 Domain Name System DNS

IP addresses are difficult to remember, and domain names are introduced to facilitate people's memory and identification.

Domain Name System (Domain Name System, DNS) : A system used to convert domain names (host names) into IP addresses, adopting the client/server (C/S) model, running on the UDP protocol, and the port number is 53.

Client/Server (C/S) model : There is one always-on host called the server, which serves many requests from other hosts called clients.

1.1 Domain name structure

Domain name structure : 四级域名.三级域名.二级域名.顶级域名(the domain name with the lowest level is written on the far left, and the top-level domain name with the highest level is written on the far right)

The tree structure of the domain name space is as follows:

insert image description here

  • Top Level Domain (TLD) is divided into the following three categories:
    • National top-level domain name nTLD : cn, us, uk, etc.
    • Generic top-level domain gTLD : com, net, org, int, edu, gov, mil
    • Reverse domain arpa : used for reverse domain name resolution, that is, the IP address is reversely resolved into a domain name
  • Second-level domain name : The second-level domain name registered under the country's top-level domain name is determined by the country itself.

1.2 Domain name server

The hierarchical structure of the domain name system is as follows:

insert image description here

1.2.1 Root domain name server

  • The root domain name server is the highest-level domain name server.
  • Each root domain name server knows the domain names and IP addresses of all top-level domain name servers.
  • The root domain name server usually does not directly resolve the domain name, but returns the IP address of the top-level domain name server of the top-level domain name to which the domain name belongs.
  • When the local domain name server sends a query request to the root domain name server, the router forwards the query request message to a root domain name server closest to the DNS client.

1.2.2 Top-level domain name server

  • The top-level domain name server is responsible for managing all second-level domain names registered with the top-level domain name server.
  • When receiving a DNS query request, it will give a corresponding answer, which may be the final result or the IP address of the domain name server at the next level of authority.

1.2.3 Authoritative domain name server

  • Authoritative name servers are responsible for managing domain names in a zone.
  • The domain name of each host must be registered with an authoritative domain name server. Therefore, the authoritative domain name server knows the mapping relationship between the domain name and the IP address under its jurisdiction.
  • In addition, the authoritative domain name server also knows the address of its subordinate domain name server.

1.2.4 Local domain name server

  • Local name servers do not belong to the hierarchy of name servers described above.
  • When a host sends a DNS request packet, the packet is first sent to the host's local domain name server.
  • The local domain name server acts as a proxy and forwards the message to the hierarchical structure of the above domain name server.
  • The local domain name server is relatively close to the user, generally not more than a few routers away, and may also be in the same local area network. The IP address of the local domain name server needs to be directly configured in the host that needs domain name resolution.

1.3 Domain name resolution process

insert image description here

1.3.1 Recursive query

The host (m.xyz.com) needs to look up the IP address of www.abc.uvw.com:

RTT initiate take over Issue content query type
1 Host (m.xyz.com) Local domain name server (xyz.com) DNS request message recursive query
2 Local domain name server (xyz.com) root name server DNS request message recursive query
3 root name server TLD server (com) DNS request message recursive query
4 TLD server (com) Authoritative domain name server (uvw.com) DNS request message recursive query
5 Authoritative domain name server (uvw.com) Authoritative domain name server (abc.uvw.com) DNS request message recursive query
6 Authoritative domain name server (abc.uvw.com) Authoritative domain name server (uvw.com) IP address of www.abc.uvw.com recursive query
7 Authoritative domain name server (uvw.com) TLD server (com) IP address of www.abc.uvw.com recursive query
8 TLD server (com) root name server IP address of www.abc.uvw.com recursive query
9 root name server Local domain name server (xyz.com) IP address of www.abc.uvw.com recursive query
10 Local domain name server (xyz.com) Host (m.xyz.com) IP address of www.abc.uvw.com recursive query

1.3.2 Combination of recursive and iterative queries

The host (m.xyz.com) needs to look up the IP address of www.abc.uvw.com:

RTT initiate take over Issue content query type
1 Host (m.xyz.com) Local domain name server (xyz.com) DNS request message recursive query
2 Local domain name server (xyz.com) root name server DNS resolution request message iterative query
3 root name server Local domain name server (xyz.com) The IP address of the top-level domain name server com iterative query
4 Local domain name server (xyz.com) TLD server (com) DNS resolution request message iterative query
5 TLD server (com) Local domain name server (xyz.com) The IP address of the authoritative domain name server uvw.com iterative query
6 Local domain name server (xyz.com) Authoritative domain name server (uvw.com) DNS resolution request message iterative query
7 Authoritative domain name server (uvw.com) Local domain name server (xyz.com) The IP address of the authoritative domain name server abc.uvw.com iterative query
8 Local domain name server (xyz.com) Authoritative domain name server (abc.uvw.com) DNS resolution request message iterative query
9 Authoritative domain name server (abc.uvw.com) Local domain name server (xyz.com) IP address of www.abc.uvw.com iterative query
10 local nameserver (xyz.com)) Host (m.xyz.com) IP address of www.abc.uvw.com recursive query

1.3.3 Cache of local domain name server

In order to improve DNS query efficiency, reduce the load on the root domain name server and reduce the number of DNS query messages on the Internet, cache memory is widely used in domain name servers . The cache is used to store the records of recently queried domain names and where to obtain domain name mapping information.

The host (m.xyz.com) needs to find the IP address of www.abc.uvw.com, and the IP address of www.abc.uvw.com is already stored in the cache of the local domain name server:

RTT initiate take over Issue content query type
1 Host (m.xyz.com) Local domain name server (xyz.com) TCP connection established recursive query
2 Local domain name server (xyz.com) Host (m.xyz.com) IP address of www.abc.uvw.com recursive query

2 File Transfer Protocol FTP

File Transfer Protocol (FTP) : The most widely used file transfer protocol on the Internet. It adopts the client/server (C/S) model, runs on the TCP protocol, and the port numbers are 20 and 21.

2.1 Active mode (when the data channel is established, the FTP server actively connects to the FTP client)

operate FTP client port number FTP server port number type
FTP client initiates TCP connection ephemeral port number 21 Control connection (TCP connection for transmitting control commands)
FTP server initiates TCP connection another ephemeral port number 20 Data connection (TCP connection for transferring data)

When there is data transmission, the FTP client informs the FTP server of its own temporary port number through the command channel, and the FTP server is responsible for establishing a TCP connection to establish a data channel.

Notice:

  • The control connection remains open throughout the session and is used to transmit FTP-related control commands.
  • The data connection is used for file transfer, it is established every time the file is transferred , and it is closed when the transfer is completed.

2.2 Passive mode (when the data channel is established, the FTP server passively waits for the connection of the FTP client)

operate FTP client port number FTP server port number type
FTP client initiates TCP connection ephemeral port number 21 Control connection (TCP connection for transmitting control commands)
FTP client initiates TCP connection another ephemeral port number The temporary port number notified by the client Data connection (TCP connection for transferring data)

When there is data transmission, the FTP client tells the FTP server to open a temporary port through the command channel, and the FTP client is responsible for establishing a TCP connection to establish a data channel.

Notice:

  • The control connection remains open throughout the session and is used to transmit FTP-related control commands.
  • The data connection is used for file transfer, it is established every time the file is transferred , and it is closed when the transfer is completed.

3 emails

3.1 Email system

The e-mail system adopts the client/server (C/S) model and has three main components: the user agent, the mail server, and the protocols required for e-mail.

insert image description here

  • User Agent : The user's interface with the email system, also known as email client software.
  • Mail Server : The infrastructure of the email system. All Internet service providers (ISPs) on the Internet have mail servers, whose function is to send and receive mail, and is also responsible for maintaining users' mailboxes.
  • Protocol : including mail sending protocols (such as SMTP) and mail reading protocols (such as POP3, IMAP).

3.2 Email format

  • Envelope : To(recipient, important), Subject(mail subject, important)
  • Content : including header and body
    • Header : From(sender), To(receiver, important), Subject(email subject, important)
    • Subject : message content

3.3 Email protocol

3.3.1 Simple Mail Transfer Protocol SMTP

Simple Mail Transfer Protocol (SMTP) : use TCP connection, the port number is 25. The SMTP client can notify the SMTP server through 14 SMTP commands; correspondingly, the SMTP server can respond to the SMTP client through 21 SMTP replies.

After the SMTP server and client establish a TCP connection, the working process of SMTP is as follows:

process sender content receiver Remark
connection established SMTP server 220 Service ready SMTP client Unsolicited push "service ready" response
connection established SMTP client HELLO: 163.com SMTP server Indicate your identity to the server and tell your domain name
email sending SMTP server 250 OK SMTP client If the identity is valid, send back a response code 250
email sending SMTP client MAIL FROM: [email protected] SMTP server Tell the server where the mail is coming from
email sending SMTP server 250 OK SMTP client If reasonable, send back response code 250
email sending SMTP client RCPT To: [email protected] SMTP server Tell the server where the mail is going
email sending SMTP server 250 OK SMTP client If the mailbox exists, send back the response code 250
email sending SMTP client DATA SMTP server Inform the server that it is ready to send the content of the mail
email sending SMTP server 354 Start mail input; end with . SMTP client If ready to receive, send back response code 354
email sending SMTP client <mail content> SMTP server Send email content to server
email sending SMTP client . SMTP server After sending the content of the email, the terminator is also sent
email sending SMTP server 250 OK SMTP client If the receipt is successful, send back the response code 250
connection release SMTP client QUIT SMTP server Request to the server to disconnect the TCP connection
connection release SMTP server 221 SMTP client Send back a reply code 221 and actively disconnect

【Note】Indicates carriage return and line feed.

The SMTP protocol can only transmit 7-bit ASCII code text data, but cannot transmit executable files or other binary objects.

3.3.2 Multipurpose Internet Mail Extensions MINE

Because SMTP cannot meet the needs of transmitting multimedia mail (for example, with pictures, audio or video data). And many other non-English-speaking countries' texts cannot be sent by SMTP. In addition to this, SMTP servers will reject emails that exceed a certain length.

In order to solve the problem of SMTP transmitting non-ASCII code text, the Multipurpose Internet Mail Extensions (Multipurpose Internet Mail Extensions, MIME) was proposed :

insert image description here

  • Five new message header fields have been added that provide information about the message body.
  • Defines a number of formats for email content, standardizing the representation of multimedia email.
  • The transfer encoding is defined, and any content format can be converted without being changed by the mail system.

3.3.3 Post Office Protocol POP

  • The client/server mode based on TCP connection, the port number is 110.
  • POP3, its third version, is the official Internet standard for a very simple, limited-function mail reading protocol.
  • Users can only download mail from the mail server to the user's computer in the download and delete mode or download and keep mode.
  • Users are not allowed to manage their own mail on the mail server (such as creating folders, classifying mail, etc.).

3.3.4 Internet Mail Access Protocol IMAP

  • IMAP4 is its fourth version. It is an Internet recommended standard and a mail reading protocol with more powerful functions than POP3.
  • Users can manipulate the mailboxes in the mail server on their own computers, just like locally, so IMAP is an online protocol.

Guess you like

Origin blog.csdn.net/baidu_39514357/article/details/130070728