application layer
Web Application Model
client/server model
In the client/server (Client/Server, CS) model, there is an always-on host called the server, which serves many requests from other hosts called clients. Its workflow is as follows:
The server is in the state of accepting requests
The client makes a service request and waits to receive the result
After receiving the request, the server analyzes the request, performs necessary processing, gets the result and sends it to the client
The main characteristics of the client/server model are: the client is the service requester, and the server is the service provider.
P2P model
The performance of the server in the CS model determines the performance of the entire system. When a large number of users request services, the server will inevitably become the bottleneck of the system. The idea of the P2P model is that the transmission content in the entire network is no longer stored on the central server, and each node has the function of downloading and uploading at the same time, and its rights and obligations are roughly equal
Domain Name System [DNS]
Hierarchical Namespace
The Internet adopts a hierarchical tree structure naming method. With this naming method, any host or router connected to the Internet has a unique hierarchical structure name, that is, a domain name . A domain is a manageable division of a namespace
The following points should be noted about the label in the domain name:
The English in the label is not case-sensitive
Punctuation marks other than the hyphen ((-) cannot be used in labels
Each label shall not exceed 63 characters, and the maximum length of a complete domain name composed of multiple labels shall not exceed 255 characters
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
domain name server
The domain name system of the Internet is designed as an online distributed database system and adopts the client/server model. The resolution of the domain name to the P address is completed by the program running on the domain name server
domain name resolution process
Domain name resolution refers to the process of mapping domain names to IP addresses or mapping IP addresses to domain names . The former is called forward analysis , and the latter is called reverse analysis. When the client needs domain name resolution, it constructs a DNS request message through the local DNS client and sends it to the local domain name server in the form of UDP datagram
There are two ways of domain name resolution: recursive query and query combining recursion and iteration
File transfer protocol [FTP]
working principle
File Transfer Protocol is the most widely used file transfer protocol on the Internet. FTP provides interactive access, allows customers to specify the type and format of files, and allows files to have access rights
FTP adopts the working method of client/server
FTP adopts the working method of client/server, and it uses TCP reliable transmission service. An FTP server process can provide services for multiple client processes at the same time. The server process of FTP consists of two parts: a main process , which is responsible for receiving new requests; and several slave processes , which are responsible for processing individual requests
Its working steps are as follows
Open the well-known port 21 (control port), so that the client process can connect
Wait for the client process to send a connection request.
Start the slave process to handle the request sent by the client process. The master process and the slave process are executed concurrently, and the slave process terminates after processing the request of the client process
Return to the waiting state and continue to receive requests from other client processes
Use two parallel TCP connections
control connection and data connection
FTP uses two parallel TCP connections at work: one is a control connection (port number 21) and the other is a data connection (port number 20)
Control connection: The control connection is used to transmit control information (such as connection requests, transfer requests, etc.), and remains open during the entire session (port 21)
Data connection: There are two transmission modes, the active mode transmits data is the port where the "server" connects to the "client"; the passive mode transmits data is the port where the "client" connects to the "server" (port 20)
The structure of the e-mail system
An e-mail system should have three main components, namely user agent, mail server and protocol used by e-mail
Mail sending protocol and reading protocol: mail sending protocol is used by user agents to send mail to or between mail servers, such as SMTP; mail reading protocol is used by user agents to read mail from mail servers, such as POP3
SMTP uses the "Push" communication method, and POP3 uses the "Pull" communication method
MIME (Multipurpose Internet Mail Extensions)
Since SMTP can only transmit ASCII codes of a certain length, many other non-English-speaking countries (such as Chinese, Russian, and even French or German with accent marks) cannot be transmitted, and executable files and other binary objects cannot be transmitted, so the use of network mail extensions is proposed.
SMTP
SMTP uses a TCP connection with a port number of 25 . SMTP communication has the following three stages of connection establishment: after the sender's mail is sent to the mail cache of the sender's mail server, the SMTP client scans the mail cache at regular intervals. If mail is found, establish a TCP connection.
Mail transmission: After the connection is established, the mail can be sent. The transmission of the mail starts from the MAIL command, and there is the sender's address after the MAIL command.
Connection release: After the mail is sent, the SMTP client should send the QUIT command. The information returned by the SMTP server is 221 (service closed), indicating that SMTP agrees to release the TCP connection
POP3
POP also uses the working method of client/server, uses TCP at the transport layer, and the port number is 110 .
POP works in two ways:
"Download and keep" and "Download and delete"
World Wide Web [WWW]
concept
The World Wide Web (World Wide Web, www) is a distributed, online information storage space, in this space: the same useful thing is called a "resource", and is identified by a global "Uniform Resource Locator" (URL). These resources are transmitted to the user via Hypertext Transfer Protocol (HTTP), and the latter obtains the resource by clicking on the link
The core part of the World Wide Web is made up of three standards:
Uniform Resource Locator (URL) . Responsible for identifying various documents on the World Wide Web and making each document have a unique identifier URL within the scope of the entire World Wide Web
Hypertext Transfer Protocol (HTTP) . An application layer protocol that uses TCP connections for reliable transmission, HTTP is a protocol that must be strictly followed for interactions between World Wide Web client programs and server programs
Hypertext Markup Language (HTML) . A markup language for document structure, which uses some agreed tags to describe various information (including text, sound, image, video, etc.) and formats on the page
work process:
The web user uses a browser (specified URL) to establish a connection with the web server and sends a browsing request; the web server converts the URL into a file path and returns the information to the web browser; the communication is completed and the connection is closed
Composition
HTTP
Hypertext Transfer Protocol (HTTP) HTTP operation process
The sequence of events that occur after the user clicks the mouse is as follows
- The browser analyzes the URL of the page the link points to
- Browser requests DNS to resolve IP address
- Domain Name System DNS resolves the IP address of the website server
- The browser establishes a TCP connection with the server
- The browser makes an HTTP request
- The server sends the file to the browser via an HTTP response
- release TCP connection
Features of HTTP
HTTP uses TCP as the transport layer protocol to ensure reliable data transmission. HTTP does not have to consider how data is retransmitted after being discarded during transmission
HTTP is stateless. That is to say, when the same client visits the page on the same server for the second time, the server's response is the same as when it was visited for the first time.
HTTP can use both non-persistent connections and persistent connections.
For non-persistent connections, the transmission of each web element object (such as JPEG graphics, 'Flash, etc.) needs to establish a separate TCP connection.
A persistent connection means that the World Wide Web server still maintains this connection after sending a response, so that the same client (browser) and the server can continue to transmit subsequent HTTP requests and response messages on this connection.
Summary of common application layer protocols
https://www.bilibili.com/video/BV1Ha411r745?p=6&spm_id_from=pageDriver