Summary of 408 network application layer

Network application model

    ■Client/server model (C/S): The client is the service requester, and the server is the service provider.
    ■P2P model: Each host is both a client and a server (any pair of computers is called a peer)

Note:
    1. The client must know the address of the server in advance, but the server does not need to know the address of the client in advance. 2. The client mainly
    implements how to display information and collect user input, while the server mainly implements data processing. 
    3. The browser displays The content comes from the server 
    4. The client is the requester. After the connection is established, the server can actively send data (such as error notification)
    5. P2P network refers to an overlay network composed of peer nodes in the Internet (Overlay Network) , is a dynamic logical network, not a physical network.
    6. When sending a file to multiple users, the P2P model usually takes less time than the C/S model.
 

Domain Name System DNS

Hierarchical domain name space
    ●Top-level domain name (.com)
    ●Second-level domain name (baidu)
    ●Third-level domain name (www)

Domain name server
    1. Root domain name server (all root domain name servers know the IP address of the top-level domain name server)
    2. Top-level domain name server
    3. Authority domain name server
    4. Local domain name server

Domain name resolution process
    ● Recursive query (almost never used in practice)
    ● Query that combines recursion and iteration

Note:
    1. Multiple MAC addresses, IP addresses, and hosts can correspond to one domain name.
    2. The host provided on the Internet must have an IP address, not necessarily a domain name.
    3. During the domain name resolution process, the host requests domain name resolution. The software needs to know the IP of the local domain name server. (Under normal circumstances, the client only needs to send the domain name resolution request to the local domain name server, and other things are completed by the local domain name server, and the final result is returned to the client. So the host only needs to know the IP of the local server) 4.
    Every Each host must be registered with an authorized domain name server. The authorized domain name server must be able to convert the host name under its jurisdiction into the IP address of the host.
    5.DNS uses UDP to transmit data. UDP is a connectionless protocol.

Text Transfer Protocol (FTP)

FTP
    ●Control connection (21)
    ●Data connection (20)
 

Note:
    1. The control connection uses TCP port 21, and the data connection uses TCP port 20.
    2. The port number of the client process is provided by the client process itself.
    3. http uses port number 80, and SMTP uses port number 25.
    4. Allowed The type and format of the file specified by the customer
    5. The data from the FTP server must pass through the application layer, transport layer, network layer, data link layer and physical layer, which correspond to data, data segments, datagrams, data frames, and bits.
    6. When transferring FTP commands between the FTP client and the server, the connection used is: a control connection established on TCP.
    7. The control connection exists throughout the FTP session. The data connection is only established each time the file is transferred, and the transfer ends. Just close.

e-mail

Email format: username@domain name of the host where the mailbox is located ([email protected])

SMTP: C/S processing method, using TCP connection, port number is 25
    ●Connection establishment
    ●Mail transmission
    ●Connection release

POP3 and IMAP :
    ●POP3 is C/S, TCP, the port number is 110
    ●POP3 is a reliable data transmission with a connection

Note:
    1. With the popularity of the World Wide Web, the sending or receiving of emails between the user's browser and the mail server of Hotmail or Gmail HTTP is used (such as [email protected]), while SMTP is only used when transferring mail between different mail servers.
    2. SMTP can only transmit ASCII code emails of a certain length, and only supports the transmission of 7-bit ASCII code content. 3. The
    POP3 protocol is based on ASCII code. If you want to transmit non-ACSII code data, you must use MIME to convert the data into ASCII code form. .
    4.MIME (Multipurpose Internet Mail Extensions) can transmit a variety of information such as text, voice, images and videos.
    5.POP3 protocol uses plain text to transmit passwords at the transport layer and does not encrypt passwords.
 

world wide web

The core of the World Wide Web consists of three parts:
    ●Uniform Resource Locator (URL)
    ●Hypertext Transfer Protocol (HTTP)
    ●Hypertext Markup Language (HTML)

URL:
URL format: <Protocol>://<Host>:<Port>/<Path>
For example: https://yzb.cust.edu.cn/ssszs/index.htm

Characteristics of HTTP:
    ●HTTP uses TCP as the transport layer protocol to ensure reliable transmission of data.
    ● HTTP does not have to consider how data is retransmitted after being discarded during transmission.
    ●HTTP itself is connectionless.
    ●Although HTTP uses a TCP connection, the communicating parties do not need to establish an HTTP connection before exchanging HTTP messages. 
    ●HTTP is stateless. The server does not remember the customer it has visited before, nor does it remember how many times it has served this customer.
    ●It can be a non-persistent connection or a persistent connection.
 

import requests	# 导入requests模块
url = 'http://www.baidu.com/s?wd=你是我的神'
headers = {
        'Content-Type': 'text/html;charset=utf-8',
        'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36'
    }
r = requests.get(url,headers=headers)
print(r.headers)

HTTP message structure
    ●Request message
    ●Response message

 

Note:
    1. Cookies can be used in HTTP to save the status information passed between the HTTP server and the client.
    2. Cookies are generated by the server and are text files stored in the user's host computer.
    3. Connection: connection mode. Close indicates a non-persistent connection mode. , keep-alive indicates continuous connection mode.

 

Guess you like

Origin blog.csdn.net/weixin_53197693/article/details/133563079