Hypertext Transfer Protocol (Http,hypertext Transfer Protocol) is one of the most widely used network protocols on the Internet. HTTP is also a subset of the TCP/IP protocol family, and to learn HTTP, you need to understand TCP/IP first.
Hierarchical management of 1-TCP/IP
The important point in the TCP/IP protocol family is the layering, which is divided into the following 4 layers: application layer, Transport layer, network layer, Data link layer .
The benefit of layering is that the protocol changes between layers can be mutually exclusive and need to be programmed according to the interface.
Includes HTTP,FTP(file Transfer Protocol, Files Transfer Protocol),DNS(domain Name System, nameservers) services.
There are two protocols of different nature:TCP(transmission Control Protocol, transmission Protocol) and UDP(user data Protocol, Subscriber Datagram Protocol)
When transferring from one computer or network device to another, the network layer's role is to select a transmission route within a multitude of options.
2-TCP/IP Communication Transport Stream
As shown in 1, when transmitting data between layers and layers, each layer is bound to be hit with the header information that the layer belongs to. Conversely, the receiving end in the layer and layer transfer data, each pass through a layer will be the corresponding header elimination.
This wrapping of data information becomes encapsulated.
Figure 1-http Communication Transmission process3-protocols that are closely related to HTTP: IP, TCP, and DNS
-
3.1 is responsible for transmitting the IP protocol
ip (Internet Protocol) Internet Protocol is located at the network layer IP address and MAC address . The IP address can be paired with the MAC address, the IP address can be transformed, but the MAC address will not change.
on the network, the two sides of the communication on the same local area network (LAN) are rare, usually through multiple computers and network devices to connect to each other. While in transit, the next relay device's MAC address is used to search for the next transit target. At this point, the ARP (Address Resolution Protocol) protocol is used. ARP is a protocol to resolve the address, according to the IP address of the communication party can be used to detect the corresponding MAC address.
3.2 TCP protocol to ensure reliability
TCP is located in the transport layer, providing a reliable byte stream service . a byte-stream service is a packet that divides chunks of data into packet segments (segment) for management
To ensure accuracy, the TCP protocol employs a three-time handshake (Three-way handshaking) strategy. The TCP flag--syn (Synchronize), ACK (acknowledgement), and FIN (finish) are used during the handshake.
TCP establishes a connection-three handshake : the sending side first sends a packet with a SYN flag to the other. When received, a packet with a syn/ack flag is sent back to convey the confirmation message. Finally, the sender sends back a packet with an ACK flag, representing the end of the handshake, as shown in Figure 2.
Figure 2-tcp Establishing a connection-three-time handshake
TCP Release connection-four handshake : The sending side first sends a packet with a FIN flag to the other, then enters the fin-wait-1 state. The receiving end can not immediately disconnect (prevent data loss), send a packet with an ACK flag, at this time the sending side into the fin-wait-2 state. Then the receiving end will not transmit the data to continue to pass, after the transmission of a packet with an ACK and FIN flag, notify the sending side. The sending side sends the ACK flag packet to the receiving end and enters the time-wait state, waiting for 2MSL to disconnect.
Figure 3-tcp Release connection-four-time handshake
- 3.3 DNS Service for Domain name resolution
The DNS (Domain Name System) service is an application-level protocol that is the same as the HTTP protocol. It provides the parsing service between the domain name and the IP address. Users typically visit each other's computers via their host name or domain name, and the computer queries the server via an IP address. So DNS provides the domain name lookup IP address and the service to reverse the domain name from the IP address.
The functions of the above three protocols in the HTTP communication process can be represented by a graph:
Figure 4-http The functions of each protocol in the communication process
HTTP need to master the knowledge Point (i)