HTTP protocol analysis experiment

1. Experimental principle

1. Introduction to HTTP protocol

  • HTTP (Hyper Text Transfer Protoco) Hypertext Transfer Protocol
  • Transfer data based on TCP/IP communication protocol
  • Applied to www (World Wild Web)

The method of accessing the www server through a browser:
http://<server address>[:port]/<path>/<file name>

2. Features of HTTP protocol

  • Based on TCP protocol

  • Single request response mode

  • No session state

  • Protocol command simple GET

  • HTML language
    3, HTTP protocol working principle

    The HTTP protocol works on a client-server architecture. As an HTTP client, the browser sends all requests to the HTTP server, ie, the WEB server, through the URL.

2. Experimental configuration

1. Experimental topology diagram
Insert picture description here

In this experiment, three clients and one HTTP server are used. This switch is used as a Layer 2 switch here, without configuration.
2. Experimental purpose
Realize the communication between client and server.
3. Experimental steps
1. Configure the IP address of the client;
2. Configure the IP address of the HTTP server;
3. Configure the file root directory of the HTTP server;
Insert picture description here
4. Test the connectivity between the client and the server;
Insert picture description here
client 1 to the HTTP server Send the ping command three times and all succeed.
5. Access the HTTP server on Client1; at
Insert picture description here
this time, we see that the connection to the server failed. Check it and found that it is because the server is not turned on.
6. Turn on the HTTP server;
7. Visit the HTTP server on Client1 again, and perform group capture on G0/0/1;
Insert picture description here
Insert picture description here

3. Experimental results

1. Packet captured by packet

Insert picture description here
2. Message analysis

1. Request message

The HTTP request message consists of 4 parts: request line, request header, blank line and request content.
1>The request line is
composed of three parts: request method field, URL field, and protocol version field, separated by spaces. Commonly used request methods are: GET, POST, HEAD, PUT, DELETE, OPTIONS, TRACE, CONNECT.
2>Request header The
request header consists of key/value pairs, each line is a pair, and the key and value are separated by a colon (:). The function of the request header is mainly used to notify the server of the request information about the client.
3>Blank line There
is a blank line after the last request header, which is used to tell the server that the following content is no longer the content of the request header. The request body is optional, and the get request does not have a request body.
4>Request content The
request content is mainly used for POST requests. The request headers that match the POST request method generally include Content-Type (identifying the type of requested content) and Content-Length (identifying the length of the requested content).
Insert picture description here

GET / HTTP/1.1: Use the get method to request an http server, the path is /, and the HTTP version is 1.1.
User-Agent: The type of browser that generated the request.
Accept: A list of response content types that can be recognized by the client; an asterisk * is used to group types by range. */* means that all types are acceptable, and type/* means that all subtypes of type are acceptable.
Accept-Language: The natural language acceptable to the client.
Accept-Encoding: The encoding and compression format acceptable to the client.
Accept-Charset: Acceptable character set.
Host: The requested host name, allowing multiple domain names to bind the same IP address.
Connection: connection mode (close or keeplive), whether tcp persistent connection is required, keep-alive means persistent connection, close means non-persistent connection.
Cookie: An extended field stored in the client.

2. Response message

The HTTP response message consists of four parts: status line, response header, blank line and response content.
1>The status line
consists of three parts: HTTP protocol version, status code, and status code description, separated by spaces.
2>Response header
Location: The server returns to the client to redirect to a new location.
Server: Contains the software information and version information used by the server to process the request.
Vary: Identifies the non-cacheable request header list.
Connection: Connection method.
3> Blank line After the
last response header, there is a blank line to tell the requester that the following content is no longer the content of the response header.
4>Response content
The text message returned by the server to the requester.
Insert picture description here
HTTP/1.1 200 OK: At the beginning of the response header, it must declare the protocol version HTTP/1.1, and return the status code and status description string.
Content-Type: Return MIME type
Content-Length: Return byte length

Guess you like

Origin blog.csdn.net/weixin_44366125/article/details/105873564