Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”. My previous work direction was hardware, but recently I transferred to the Internet. During the testing process, I was often confused about the errors reported on the web page and always asked others to look at them. Therefore, IN order to position myself, I learned it well and made a summary today
Basic knowledge of
Simple Web knowledge review
Before in the communication industry, I was in contact with the physical layer of the network, the data link layer and the network layer, and I don’t know much about the upper layer protocol application layer except that there is this HTTP protocol in the application layer, which is based on TCP/IP communication protocol to transfer data. Physical layer — connects network devices (such as PCS and switches) through network cables and cables to transmit 0 and 1 electrical signals data link layer — on top of the physical layer, runs data layer related protocols such as Ethernet, Transmitted through network device MAC address to the network layer, through the network address (IP address) + IP address, MAC address for communication protocol is used by IP transport layer – after a MAC address and IP address, also need a parameter, said the packet to the end for which procedures, processes, use, this parameter is called ports, The function of the transport layer is to establish port-to-port communication. The protocol cluster is TCP/IP. Application layer – protocols for specific applications, such as email, SSH, FTP, etc. HTTP is in this layer
Packet transmission
From the application layer to the data layer, packets are added to each layer at the sender and then parsed again at the receiver (1) at the application layer, which is an HTTP packet (2) at the transport layer, adding a TCP header to the HTTP packet (3) at the network layer. Add an IP header to the transport layer (4) Add an Ethernet header to the network layer at the link layer and then parse HTTP packets on the receiving end. Then you can see the packets clearly through wireshark
HTTP packet capture analysis
HTTP is short for Hyper Text Transfer Protocol, which is used to Transfer hypertext from the World Wide Web server to the local browser. HTTP is a TCP/ IP-based communication protocol to transfer data (HTML files, image files, query results, etc.). There are two types of HTTP data packets: request packets and response packets. The Wireshark consists of four parts: the request line, the request header, the blank line, and the request data. Open the Wireshark to filter out HTTP request packets. In the following figure, you can view the HTTP request packets at the physical layer, data link layer, network layer, transport layer, and application layer
The details of each layer can be interesting to look at, but it’s interesting to look at HTTP request packets in detail
The same is true of response packets. If we understand HTTP from the perspective of network communication, we will have a better understanding. Finally, these requests are sent to the destination through network devices and physical devices, but we generally do not pay attention to the underlying layer, just the HTTP protocol itself.