Network six [top interface: application layer]

1. What did the application layer do?

As the uppermost layer of the network, the application layer provides many application layer protocols.

These protocols are nested in various applications we use,

Provide an interface for dealing with users and the network.

When we use various network applications, application layer protocols are built in.

For example, IE browser uses the HTTP protocol at the application layer;

The application layer protocol used by QQ is OICQ;

Outlook uses SMTP and POP3 protocols for sending and receiving emails.

One thing to note here, the software we use is an application,

These softwares are only programmed by software developers, and these application softwares are just a shell.

And the nested protocol in these software is the content of the application layer.

Programs that use the network need an integrated protocol before they can be used normally.

Here are a few common examples of how the OSI application layer interacts with us:

We have to look at the webpage, open the IE browser, enter a web address, and then enter the corresponding website, then this IE browser is my application tool for browsing the web, and it also works at the application layer. The IE browser is developed based on the HTTP protocol, which is an application layer protocol.

If we want to upload and download a file using FTP, we will first open the FTP client and then connect to the FTP server. This client is the application layer tool. The FTP client is developed based on the FTP protocol, which is also an application layer protocol.

I want to send an E-mail, I will install a Foxmail, Outlook and other mail client software on the computer, then edit the mail and send it to the corresponding person. Outlook and Foxmail are developed based on the SMTP and POP3 protocols. SMTP and POP3 are also application layer protocols.

In general: the application layer provides services for application communication.

The application layer protocol defines:

1. The type of message exchanged by the application process, is it a request or a response? (Types of)

2. The syntax of various message types, such as each field in the message and its detailed description. (grammar)

3. The semantics of the field, that is, the meaning of the information contained in the field; (semantics)

4. When and how the process sends a message, and the rules for responding to the message. (Synchronize) 

Functions of the application layer:

1. File transfer FTP and TFTP

2. Email SMTP and POP3

3. Virtual terminal HTTP

4. Query service and remote operation log in to DNS

Second, the network application model

Client/server model

server:

A host that is always on, a device that provides computing services.

He serves other host requests called clients.

work process:

1. The server is in a state of accepting requests;

2. The client sends a service request and waits for the result to be accepted;

3. After the server receives the request, it analyzes the request, performs necessary processing, and obtains the result and sends it to the client.

Client computer:

1. Communicate with the server and use the services provided by the server

2. Intermittent access to the network

3. Possibly use dynamic IP address

4. Do not communicate directly with other clients 

application:

WEB,

File transfer FTP,

Remote login,

e-mail 

P2P model

Any pair of computers is called a peer.

There is no always-on server, and each host can provide services or request services.

There can be direct communication between any end systems/nodes.

Good scalability and strong network robustness.

The disadvantage is that while obtaining services, it also provides services to other nodes, so it will take up more memory and affect the speed of the whole machine.

3. Domain Name System DNS

Domain Name System DNS is a naming system used on the Internet to convert host names that are easy for people to remember and have specific meanings into IP addresses that are easy for machines to process.

The role of DNS service: resolve domain names into IP addresses.

Domain name server 

1. Local domain name server

Every Internet service provider ISP, or a university, or even each department in a university, can have a local domain name server.

When a host sends a DNS query request, the query request message is sent to the local domain name server.

In the local connection in the WINDOWS system configuration, the DNS address filled in is the address of the local domain name server.

2. Root DNS

The root domain name server is the highest level domain name server,

All root domain name servers know the IP addresses of all top-level domain name servers .

No matter which local domain name server, if you want to resolve any domain name on the Internet,

As long as you can't resolve it yourself, you first ask for help from the root name server.

The number of root domain name servers on the Internet: 13

This is a cluster of three servers that are actually redundant servers,

Used to govern top-level domains,

Usually it does not directly convert the domain name with query into an IP address.

Instead, it tells the local domain name server which top-level domain name server to look for next.

3. Top-level domain name servers

Responsible for all second-level domain names registered under the top-level domain name server.

4. Authorized domain name server 

Each host must be registered with an authorized domain name server.

The authorized domain name server can always convert the host name under its jurisdiction into the IP address of the host.

 

Domain name resolution process

1. The query from the host to the local domain name server: recursive query

If the local domain name server asked by the host does not know the IP address of the domain name being queried,

Then the local domain name server will replace the host, acting as a DNS client,

Continue to send query request messages to the root domain name server instead of letting the host query by itself.

The next few queries are carried out in a recursive manner,

The local domain name server must give the host an accurate IP address.

2. The query from the local domain name server to the root domain name server: recursive and iterative query

The client still uses the recursive method to the local domain name server,

The local domain name server sends a message to the root domain name server,

If found, the local domain name server will give the IP address to the host;

If not found, tell the local domain name server which top-level domain name server should be inquired in the next step.

Then let the local domain name server to query the top-level domain name server pointed to.

Iterate in this way until the destination IP address is found.

Four, file transfer protocol FTP

TFTP: Simple File Transfer Protocol

Suitable for small file transmission, using UDP protocol.

Focus on FTP.

FTP: File Transfer Protocol,

The details of each computer system are shielded, so it is suitable for transferring files between arbitrary computers in a heterogeneous network.

FTP is based on client/server and uses TCP protocol for transmission.

(Why do you need reliable transmission? Example: upload job)

FTP server: According to FTP, the computer that transfers files is the FTP server.

FTP client: Connect to the FTP server and follow the FTP protocol. The computer that transfers files with the server is the FTP client.

An FTP server process can provide services for multiple client processes at the same time.

The FTP server process consists of two parts:

Among them, the main process is responsible for receiving new requests,

The slave process is responsible for processing a single request.

Work steps 

1. Open the well-known port 21 so that the client process can connect.

2. Wait for the client process method to connect the request.

3. Start the slave process to handle the request sent by the client process. The master process and the slave process execute concurrently, and the slave process terminates after processing the request of the client process.

3. Return to the waiting state and continue to receive requests from other client processes.

Control connection

The server listens to port 21 and waits for client connections. The connection established on this port is called a control connection.

The control connection is used to transmit control information (such as connection request, transfer request, etc.).

The transfer request sent by the FTP client is sent to the control process of the server through the control connection,

But the control connection is not used to transfer files.

The control connection is always open throughout the session.

Data Connections 

After receiving the file transfer request from the FTP client, the control process on the server side creates a "data transfer process" and a "data connection".

The data connection is used to connect the data transfer process between the client and the server,

The data transfer process actually completes the file transfer. After the transfer is completed, the "data transfer connection" is closed and the operation ends.

5. E-mail STMP and POP3

mind Mapping:

An email is divided into envelope and content .

Among them, the mail address of the recipient is recorded in the envelope,

The content is divided into the header and the main body.

The email address and subject of the sender are recorded in the header,

The subject part is the text to be sent.

Composition structure

 

An email system should have three main components:

1. User Agent

The interface between the user and the e-mail has the mail processing function, usually a program running on the PC, such as Foxmail, Thunderbird, etc.

2. Mail server

It is the core of the e-mail system.

The function is to send and receive mails, but also to report the mail delivery to the sender

The C/S method is adopted, but a mail server can be either a client or a server.

When mail server A sends mail to mail server B, A will act as an SMTP client and B will act as an SMTP server;

The opposite is the opposite.

3. Mail sending protocol and reading protocol

User agent → sender mail server

Sender's mail server → Receiver's mail server

All use SMTP protocol (push);

Recipient User Agent → Recipient Mail Server

Use POP3 protocol or IMAP protocol (pull).

SMTP protocol (Simple Mail Transfer Protocol)

The SMTP protocol specifies how information should be exchanged between two SMTP processes that communicate with each other.

The SMTP process responsible for sending mail is the SMTP client, and the process responsible for receiving mail is the SMTP server.

1. 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 there is an email, it uses the well-known SMTP port number 25 to establish a TCP connection with the SMTP server of the recipient's mail server.

After the connection is established, the receiver SMTP server sends 220 service ready (service ready).

Then, the sender sends the hello command and attaches the host name of the sender.

SMTP does not use an intermediate mail server. No matter how far away it is, it is directly established between the two mail servers, the sender and the receiver.

If it fails, wait.

2. Mail delivery

 

3. Connection release

After the email is sent, the SMTP client sends a QUIT command, and the SMTP server returns "221", indicating that it agrees to release the TCP connection.

 

Disadvantages of SMTP:

1. Cannot transfer executable files or other binary objects.

2. It is limited to the transmission of seven-bit ASCII codes, and cannot transmit other non-English languages.

3. The SMTP server will reject emails that exceed a certain length.

So we extend the protocol MIME through Internet mail.

 

MIME protocol (Internet mail extension protocol)

He increased the structure of the mail body and defined the encoding rules for transmitting non-ASCII codes.

The e-mail system can support sound, image, video, multiple national languages, etc.

POP3 protocol (post office protocol)

Post Office Protocol: When the user reads the mail, the user agent sends a request to the mail server to pull the mail in the user's mailbox.

POP uses TCP connection, the port number is 110, client-server mode.

Way of working:

IMAP protocol (Internet Message Access Protocol)

Allow users to create folders, and also allow only a certain part of the message to be read (for example, read the body first, and then download the attachment when WiFi is available)

Web-based e-mail

6. The World Wide Web and HTTP Protocol

The World Wide Web WWW is a large-scale, online data space, a collection of countless web sites and web pages.

The core of the World Wide Web consists of three standards:

1. Uniform Resource Locator URL

Responsible for identifying various documents on the World Wide Web, and making each document have a unique identifier URL in the entire World Wide Web.

2. Hypertext Transfer Protocol HTTP

An application layer protocol that uses TCP for reliable transmission. HTTP is a protocol that must be strictly followed between client programs and server programs on the World Wide Web.

3. Hypertext Markup Language HTML

A markup language for document structure, which uses some convention markup to describe various information on the page.

 

URL-Uniform Resource Locator

URL is equivalent to an extension of a file name on the Internet.

Uniquely identify resources by him

General form:

<protocol>: //<host>: <port>/<path>

Common protocols are HTTP, FTP, etc.,

The host is the domain name of the host that stores the resources in the Internet, or it can be an IP address,

Port and path can be omitted if something is wrong,

The URL is not case sensitive.

About WWW

The World Wide Web works in C/S mode,

The browser is a World Wide Web client program on the user’s computer,

The computer where the World Wide Web document resides runs the server program, and this computer is called the World Wide Web server.

The client program sends a request to the server program,

The server program sends back the documents required by the client to the client program.

The process is as follows:

1. WEB Firefox uses the browser to enter the specified URL, establish a connection with the WEB server, and send a browsing request.

2. The WEB server converts the URL into a file path and returns the information to the WEB browser.

3. After the communication is complete, close the connection.

 

Hypertext Transfer Protocol HTTP

The HTTP protocol defines how the browser (web client process) requests web documents from the web server,

And how the server delivers the document to the browser.

 

HTTP has two types of messages:

1. HTTP request message: Send a service request from the web client to the web server.

2. HTTP response message: the response from the web server to the web client request.

 

Take the website of Tsinghua University as an example:

1. The browser analyzes the URL address

2. The browser requests DNS to resolve the IP address of www.tsinghua.edu.cn

3. DNS resolves the IP address of Tsinghua University server

4. The browser establishes a TCP connection with the server (the default port number is 80, and the server process will continuously monitor TCP port 80)

5. The browser sends an HTTP request message: GET/chn/index.htm

6. The server sends the file index.htm to the browser via an HTTP response message.

7. The TCP connection is released.

8. The browser interprets the file index.htm and displays the web page to the user.

 

Features of HTTP protocol

The HTTP protocol is stateless , that is, the server does not remember a certain user that has been visited, nor does it remember how many times it has served the client.

This simplifies the design of the server and makes it easier for the server to handle highly concurrent HTTP requests.

But in practical applications, we usually use cookies plus a database to record user activities.

Cookie is a text file stored in the user's host, which contains a string of identification codes, used for WEB services to identify users.

This can provide personalized services, such as recommending new products to users based on previously viewed products on e-commerce platforms.

 

HTTP uses the TCP protocol, but itself is connectionless.

In other words, HTTP does not have to consider the problem of errors in the data transmission process.

And there is no need to establish an HTTP connection before exchanging HTTP insulation, just establish a TCP connection.

The connection method is divided into:

Non-persistent connection

The transmission of each web page element object (such as JPEG graphics, FLASH, etc.) requires a separate TCP connection.

In other words, the practice required to request a World Wide Web document is the transmission time of the document plus twice the round-trip time RTT.

One of them is used to establish a TCP connection,

The other RTT is used to receive HTTP request messages and response messages.

Persistent connection

It means that the web server still maintains this link after sending the response, so that the same client and server can continue to transmit subsequent HTTP request and response messages on this connection.

Non-pipelined

The customer can send out the next request after receiving the previous response.

Assembly line

The client immediately issues a request every time it encounters an object reference.

Therefore, the client can successively issue requests for each referenced object one by one.

If all requests and responses are sent continuously,

Then all referenced objects experience a total of RTT delay, instead of non-pipelined, each reference must have an RTT delay.

 

HTTP message structure

Common methods in HTTP request messages:

1. GET request to read the information identified by the URL

2. HEAD request to read the header of the information identified by the URL

3. POST to add information to the server (such as comments)

4.CONNECT is used for proxy server

 

Guess you like

Origin blog.csdn.net/Kukeoo/article/details/114856450