- TCP/IP protocol
The purpose of Internet construction is to share information. In the process of information transmission, the computer inevitably needs to generate communication. Just as we talk to others need to understand each other's language to understand the meaning of each other's expression, the computer communication also needs a constraint, called the protocol. For example, the file transfer uses the TCP protocol, and the DNS protocol is used by the domain Name System. With the existence of these protocols, various data streams are routed according to constraints, which constitutes the communication of the computer. The TCP/IP protocol is a collection of these many protocols.
Architecture of the TCP/IP protocolThe architecture of the TCP/IP protocol is only four layers.
- Network interface layer: a physical device (network card, etc.) used to handle network connections
- Internetwork: Handles packets that flow over the network.
- Transport Layer: responsible for providing a common data transfer Service (TCP protocol, UDP protocol) to communication between two host processes
- Application layer: Through the application process simple interaction to complete the specific network application. (HTTP protocol, DNS protocol)
HTTP (Hypertext Transfer Protocol) protocol parsing HTTP Protocol introduction
Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet. All WWW documents must comply with this standard. It can make the browser more efficient and reduce the network transmission. It not only ensures that the computer transmits hypertext documents correctly and quickly, but also determines which part of the document is being transmitted, and which content is displayed first (such as text before graphics), and so on.
Domain name resolved to IP address
- Enter the domain name
Here we use the official website of Jiaotong University as an experimental example ~
- Locate the IP
Fiddler interface, a lot of requests are very intuitive display in front of us.
When we enter the domain name and press ENTER, the browser will query the DNS server to the IP corresponding to this domain name.
We ping
check the correctness of the IP by command.
In the console we can see that the IP address is the same as the fiddler display. Send requests requestThe client sends an HTTP request to the server for a request message that includes the following format:
- Request Line
- Request Header (header)
- Blank Line
- Request data
Specific format:
We can view the specific information of a request via Fiddler Raw
GET http:www.ecjtu.jx.cn/HTTP/1.1Host:Www.Ecjtu.Jx.cnConnection:Keep-AlivePragma: No-CacheCache-Control: No-CacheUpgrade-Insecure-Requests: 1User-Agent: Mozilla/5.0 (WindowsNt10.0; Win64;x64) AppleWebKit/537.36 (Khtml,LikeGecko) Chrome/57.0.2987.98 safari/537.36accept: Text/html ,application/xhtml+< Span class= "PLN" >xml,application/xml< Span class= "pun" >; q=0.9,image /webp,*/*;q=0.8accept-encoding:gzip, Deflate, sdchaccept-language:zh-cn,zh;q=0.8cookie:um_distinctid= 15abb4abc1777b-01b1e80c9d3c39-67f1a39-1fa400-15abb4abc189b7
- A request line that describes the type of request, the resource to access, and the HTTP version used.
GET http://www.ecjtu.jx.cn/ HTTP/1.1
Description The request type is get, the resource accessed is http://www.ecjtu.jx.cn/, and the HTTP version used is GTTP1.1
- The request header, followed by the section after the request line (i.e. the first row), is used to describe additional information that the server will use
- Host will indicate the destination of the request.
- User-agent, both server-side and client script access to it, is an important basis for browser type detection logic. This information is defined by your browser and is automatically sent in each request
- Cookies, cookies that are carried by the browser.
- Other references: The header information of the HTTP protocol is detailed
- Blank line, a blank line behind the request header is required
- Request data, request data is also called the principal, you can add any other data.
such as some login information.
Responding to requests response
Typically, the server returns an HTTP response message after it receives and processes a request from the client. A response is also made up of four parts.
- Status line
- Message header
- Blank Line
- Response body
We can view the specific information of a response via fiddler Raw
HTTP/1.1 200OkDate: Tue, 28 Mar 2017 13:30:59GmtServer: Apache/2.2.31 (Unix)DAV/2Mod_jk/1.2.23Accept-Ranges:bytesKeep-Alive:Timeout=5, Max=100 connection: keep-alivetransfer- encoding: Chunkedcontent -type: Text/ html15b0<! DOCTYPE html><HEAD>
- The status line consists of the HTTP protocol version number, the status code, and the status message.
http/1.1 OK, indicates the use of the HTTP1.1 protocol, the response status is 200, indicating a successful response
- The message header, which describes some additional information that the client will use
- Date Time
- Server type
- Keep-alive whether to keep the connection
- Content-type braking MIME-type HTML
- Blank Line
- Response body, the text information that the server returns to the client.
is HTML information.
HTTP status Code
The status code consists of three digits, and the first number defines the category of the response, divided into five categories:
1XX: Indication information--Indicates that the request has been received and continues processing
2XX: Success-Indicates that the request has been successfully received, understood, accepted
3XX: Redirect--further action is required to complete the request
4XX: Client Error--Request syntax error or request not implemented
- 5XX: Server-side error-the server failed to implement a legitimate request
Common Status Codes:
200OkClient request succeeded400 Bad Request Client requests have syntax errors and cannot be understood by the server60s Unauthorized Request is not authorized, this status code must be used with the Www-authenticate header field403 Forbidden //server receives the request, but refuses to provide service 404 not Found//request resource does not exist, Eg: entered the wrong URL Internal Server error //server Unexpected error occurred 503 Server unavailable //Servers are currently unable to process client requests and may return to normal after a period of time
HTTP request method
HTTP requests can use a variety of request methods, depending on the HTTP standard.
HTTP1.0 defines three methods of request: GET, POST, and head.
HTTP1.1 has five new request methods: Options, PUT, DELETE, TRACE, and CONNECT methods.
- The GET request specifies the page information and returns the entity principal.
- HEAD is similar to a GET request, except that there is no specific content in the returned response to get the header
- POST submits data to the specified resource for processing requests (such as submitting a form or uploading a file). The data is included in the request body. A POST request may result in the creation of new resources and/or modification of existing resources.
- PUT replaces the contents of the specified document with the data that the client transmits to the server.
- The delete request server deletes the specified page.
- The Connect http/1.1 protocol is reserved for proxy servers that can change connections to pipelines.
- The OPTIONS allows clients to view server performance.
- TRACE echoes the requests received by the server, primarily for testing or diagnostics.
Summarize
RELATED links:
- An article on the HTTP protocol is enough.
- HTTP protocol explanation (really classic)
- An explanation of the header information of the HTTP protocol
- Fiddler how to set up a display IP
Fiddler is a very useful HTTP protocol capture tool, the network has a lot about his usage, interested students can go to check the relevant information.
The article may be similar to other articles, there are errors are also welcome to correct!
Thank you, everyone.
My Heart
Links: https://www.imooc.com/article/17272
Source: MU-Class Network
Computer Network--http Protocol