Top-Down---application layer

Source: Internet
Author: User

I. Architecture of network applications

A. client-server architecture

Servers with fixed IP addresses are always turned on to serve many customers who do not communicate directly with each other. Large sites need to be equipped with a large number of data centers to meet a large number of requests

B. Peer Architecture

In this system, there is minimal (or no) dependency on dedicated servers located in the data center. The peer can communicate directly.

Self-Extensibility: Each peer can request and distribute files to and from other peers, increasing the system's ability to service.

Ii. Process Communication

Processes on two different end systems communicate with each other by exchanging messages across a computer network.

A. Client and server processes

Network applications are made up of paired processes that send messages to and from each other over the network. In a communication session scenario between a given pair of processes, the process that initiates the communication (that is, initiates a contact with another process at the beginning of the session) is identified as a client , waiting for the process to be contacted at the beginning of the session server .

B. Interface between the process and the computer network

The process sends messages to the network and receives messages from the network through a software interface called a socket. sockets are interfaces between the application layer and the transport layer within the same host

c. Process addressing

The receiving process needs to have an address in order to receive the grouping. To identify the receiving process, you need to define two kinds of information:

(1) Address of host-IP address

(2) Identifier of the receiving process defined in the destination host- port number

III. transport services available for use by applications

Select the protocol that meets the application requirements by studying the services available in the Transport Layer protocol

Common Web Application Service requirements

A. Reliable data transfer

Data is able to reach the receiving process without error. Address e-mail, file transfer and other applications.

B. Throughput

Provide guaranteed throughput at a specific rate. Meet bandwidth-sensitive applications.

C. Timing and timing guarantee

Meet applications that require strict time limits for data delivery for effectiveness.

D. Security

Provides confidentiality, data integrity, and endpoint authentication between sending and receiving processes.

Iv. transport services provided by the Internet

A.TCP Service

TCP services include connection-oriented services and reliable data transfer services

  Connection-oriented services

TCP allows the client and server to Exchange Transport-layer control information-the handshake process -before the application-layer data packets begin to flow. The connection is removed after the message is sent.

Reliable Data transfer Service

The communication process can rely on TCP to deliver all transmitted data in the proper order, without error.

congestion control mechanism 

Suppress the sending process during network congestion and relieve network pressure

B.UDP Service

Lightweight transport protocol, providing minimal service only. No connection, unreliable data transfer, no congestion control.

V. Application layer Protocol

Defines how application processes running on different end systems pass messages to each other. The Common Application layer protocol is defined by the RFC document and has a dedicated application layer protocol.

It defines the following:

1. Types of messages exchanged, such as request messages and response messages

2. Syntax for various message types, such as the various fields in the message and how these fields are described

3. The semantics of the fields, that is, the meaning of the information contained in these fields

4. Rules for responding to messages when and how a process is sent

1. HTTP

HTTP is an abbreviation for Hypertext Transfer Protocol, or Hypertext Transfer Protocol, and is one of the Web application layer protocols.

The HTTP protocol is implemented by a two-part program: AClient Programsand aServer Programs, they run on different end systems and run sessions by exchanging HTTP messages.   HTTP defines how a Web client requests a Web page from a Web server and how the server delivers the Web page to the client. HTTP uses TCP as its support transport protocol. The HTTP client initiates a TCP connection to the server, and once the connection is established, the browser (client) and server processes can access TCP through the socket interface.   The HTTP protocol that uses TCP as its support does not have to worry about data loss or how TCP recovers from data loss and sequence failures in the network, because that is the work of TCP and protocol stack underlying protocols. HTTP is aStateless ProtocolSowhen the server sends the requested file to the client, it does not store any state information about the client。   For example, if a particular client requests the same object two times in just a few seconds, the server does not respond because it has just provided the object for that user, as if the server had completely forgotten what it had done before. Finally, we add that the Web pages we normally request are made up of objects. objects, in simple terms, are files, such as HTML files, JPG images, videos, and other files that can be addressed through a URL address. When we request a page, we usually get an HTML file and several reference objects, and then load the object based on the URL address of the object in the HTML file.

Non-persistent connections and persistent connections

When the client/server interaction runs on the TCP protocol, each request/response pair for the application isvia a separate TCP connection, the application uses thenon-persistent connections, and when each request/response pair of the application isthe same TCP connection is sent, the application uses thePersistent Connections。 non-persistent connectionsIn the case of a non-persistent connection, the server closes the TCP connection after the response is sent. We define the time taken for a roundtrip time RTT to be a small grouping from the client to the server and back to the customer. So RTT includespacket propagation delay, permutation delay and packet processing delay。 In the case of a non-persistent connection, access to a Web page (assuming that there are other static resources referenced in the page, such as css,js,img, etc.), follows several steps:

The "1" HTTP client process initiates a TCP connection to the server. There is one socket on the client and server associated with the connection.

The "2" HTTP client sends an HTTP request message to the server via its socket.

The "3" HTTP Server process receives the request message through its socket, retrieves the request object from its memory, encapsulates the object in an HTTP corresponding message, and sends a response message to the client through its socket.

The "4" HTTP server process notifies TCP to disconnect the TCP connection (until TCP confirms that the client has fully received the response message before it actually interrupts the connection).

The "5" HTTP client accepts a response message and the TCP connection is closed .

"6" repeats the previous steps for all other resources

The HTTP protocol is based on the TCP protocol as the Transport layer, using HTTP to establish a connection to the server, a TCP connection to the server is initiated, and TCP establishes a connection that involves a "three-time handshake" process. After completing the first two parts of the three handshake, the client combines the third part of the three handshake (acknowledgment) with an HTTP request message to send to the TCP connection. Once the request message arrives at the server, the server sends an HTML file to the TCP connection. From the above description, it can be known that for a non-persistent connection, the total time required to request an HTTP request/response is two rtt+ the time that the server transmits the HTML file. Persistent ConnectionsIn the case of a persistent connection, the server keeps the TCP connection open after the response is sent. Subsequent requests and response messages between the same client and server are routed through the same connection. In particular, a complete Web page, including multiple objects, can be delivered using a single persistent TCP connection.   If a connection has not been used for a certain time interval, the HTTP server shuts down the connection. Multiple web pages located on the same server can be made on a single persistent TCP connection when sent from the server to the same client, so that the object request can be sent one after another without waiting for the answer of the pending request, which is calledpipelined, persistent connections, which is the persistent connection used by HTTP by default. Disadvantages of non-persistent connectionsFirst, a non-persistent connection must establish and maintain a completely new connection for each requested object. For each such connection, both the client and the server are assigned TCPBuffers and Variables, which poses a serious burden to the server. Second, the transmission delay for each object is two Rtt, which is aa RTT is used to establish TCP, and the other RTT is used to request and receive an object。 2. HTTP message FormatHTTP request message Format,as shown in the following:The first line is the request line, the request line has 3 fields, the Method field, the URL field, and the HTTP version field.  Method fields can take values of Get, POST, HEAD, put, and delete, and most requests use the Get method.  The following line is called the first row.     When you use the Get method, the entity body is usually empty, and when you use the Post method, the entity body is usually the content that needs to be post to the server, for example, the data that we enter on the Web page. Below, a real HTTP request message is given, as follows:
get/xxx/page.html http/1.1Host:www.xxx.comConnection:closeUser-agent:mozilla/4.0  Accept-language:fr
With correspondence, the first line of this message represents the request line, the browser requests an object from the server, uses the Get method, its address in the URL field, is/xxx/page.html, and the HTTP version used is 1.1.  The rest of the behavior is the header line, preceded by the first field name, followed by the value of the field.  Host:www.xxx.com defines the host on which the target resides, and the information provided by the header row is required by the Web Proxy cache.  Connection:close it tells the server that it does not want to use persistent connections, it requires the server to close the connection after the requested object has been sent.  User-agent:mozilla/4.0 is used to define the user agent, the type of browser that sends requests to the server, which is the Netscape browser.   ACCEPT-LANGUAGE:FR indicates that the user wants the French version of the object. HTTP Response message Formatas shown in the following:We can see that it is also made up of three parts, the first behavior state line, followed by the leading line, and finally the entity body to be sent. The entity body part is the body of the message, that is, it contains the requested object itself. Here's a look at a real HTTP response message, as follows: First take a look at the first line, it corresponds to the status line, in the message, the status line indicates that the server uses the protocol is http/1.1, the status code is 200, the phrase is OK, indicating everything is normal, the information is included in the returned response message.
 http/1.1  200   OKConnection:closeData:Thu,  03 , Jul, 2013  00 : 00 : 00   Gmtserver:apache /1.3 . 0  -modified:sun, 6 , May 2007   : 23 : 24   gmtcontent -type:text/html (data ...)  
The 2nd to 5th behavior is the first line, Connection:close tells the client to close the TCP connection after the message is sent.   The Data header line indicates the date and time that the server generated and sent the response message, which is the time that the server retrieved the object from its file system and inserted it into the response message.  The server header line indicates that the message was generated by an Apache web server, similar to the User-agent header line in the request message.  The Last-modified header line indicates the time and date when the object was created or last modified. The Content-type header row indicates the file type of the object in the entity body, and the object type should be used formally instead of the file extension, because in some systems (such as Linux), the file type is not distinguished by the extension. The Content-length header row indicates the number of bytes of the object being sent.

Top-Down---application layer

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.