The words written in the front

There are plenty of good articles about HTTP on the web, and this article is for documenting learning about HTTP

Recently in the development of the project, HTTP for this piece of ignorance, to supplement the basic!

While learning HTTP, it is necessary to understand the TCP/IP protocol family.

Most commonly used networks operate on the BASIS of the TCP/IP protocol family, and HTTP is a subset of TCP/IP.

TCP / IP

TCP/IP protocol family

The communication between different hardware and operating systems needs to be constrained by certain rules, so that the communication conditions can be unified. T

TCP/IP is the general name of each protocol family related to the Internet. It not only refers to TCP and IP protocols.

It has FTP, SNMP, HTTP, PPPoE…….. Constitute a protocol family.

TCP/IP layer

The TCP/IP protocol family is divided into four layers: application layer, transport layer, network layer, and data link layer

The application layer

Role: The application layer determines the activities of communication when providing application services to users.

The TCP/IP protocol family stores various common application services.

For example, FTP(File Transfer Protocol) DNS(Domain name System) HTTP

The transport layer

Purpose: Data transfer between two computers, serving the application layer.

There are two different protocols at the transport layer: TCP(Transmission Control Protocol) UDP(User Data Protocol)

The network layer

Function: Used to process packets flowing on the network and how they are transmitted to each other.

A packet is the smallest unit of data transmitted over a network.

The network layer determines how packets are delivered to each other.

The most important function of the network layer is to route packets. It selects the most appropriate route based on the IP address and network congestion to transfer data packets to each other at the fastest speed.

Data link layer

Purpose: Used to deal with the hardware part connected to the network.

Hardware categories are within the scope of the link layer

TCP/IP traffic

When using TCP/IP protocol for network communication, the client (sender) will go down from the application layer, layer by layer transmission, each layer entered, is marked with serial number and port number, when the client finished its own layer 4, will enter the server (receiver), It goes up the link layer and then up the link layer, cancelling a marker number at each layer until it reaches the top layer (the application layer), at which point the server receives the message from the client to the server

Sent request.

The server sends requests to the client in reverse order.

Server (application layer ———-> Data link layer)

Client (data link layer —————> Application layer)

HTTP related protocols

The IP protocol responsible for transport

IP: It’s the Internet protocol, it’s at the network layer.

Function: Transmits various packets to each other.

To ensure that the packet can be accurately transmitted to the other party, there are two conditions:

IP address: It identifies the IP address to be transmitted to the other party.

MAC address: it is the fixed address of the nic.

IP and MAC are key to verifying an identity

The IP address can be matched with the MAC address, and the IP address can be changed, but the MAC address cannot be changed.

When a computer communicates with another computer, it will not directly find the IP address of the other party. In the middle process, it will go through device transfer. During the transfer, it will use ARP protocol to deduce the MAC address of the IP address, and finally find the MAC address of the other party after multiple transfer. The MAC address matches the IP address, and the connection is successfully established.


ARP: It is a protocol for resolving addresses. Based on the IP address of the peer, you can find the MAC address of the peer

Ensure the reliability of TCP

TCP is located at the transport layer and provides reliable byte stream services.

Byte stream service: To facilitate transmission, it divides large chunks of data into packet segments for management.

To ensure reliable and secure data transfer to the other party, TCP adopts the three-way handshake policy.

SYN synchronization sequence Number ACK confirmation character

First handshake: The sender sends a packet with the SYN flag to the other end.

Second handshake: After receiving a SYN packet from the sender, the receiving end sends back a packet with the SYN/ACK flag to indicate that the packet is received successfully.

Third handshake: The sender sends an ACK packet to receive the handshake

Why does TCP need three handshakes?

First handshake: The client sends a request to the server

Second handshake: The server receives the request from the client and processes it.

The first two handshakes have already completed the request processing, so why establish a third handshake?

If you don’t do the third handshake, if, for the first handshake, the client delays sending the request because of network reasons, you think you’re done with the request, but after the network node is normal, it will send the request again, which is an invalid packet; On the second handshake, the server receives a delayed request from the client, but at this time the client does not send any data, and the server is still waiting for the client, resulting in a waste of resources.


The third handshake is used to prevent the invalid connection request packet segment from being sent to the server and causing an error.

Make the three handshakes more vivid

In A relationship, it’s to determine if “A” is unrequited,

If not shake hands three times, B and other boyfriend…….. And A is still waiting for B’s acceptance.

Why don't you shake hands three times

A confesses her feelings to B;

B received A’s confession, B should respond to A, I don’t like you

A received A response from B, which freed him from unrequited love

Responsible for domain name resolution DNS service

The DNS service and HTTP are both application layer protocols.

Function: Provides domain name to IP address resolution service.

The DNS protocol allows you to search for IP addresses by domain name or reverse search for domain names by IP address

The relationship between HTTP and various protocols

HTTP and the above protocols are concatenated to understand the role of each protocol.

The URI and URL

What is a URI URL

URI Uniform resource Identifier.

URI stands for Uniform Resource Identifier

Uniform format

Resource Identifies resources

Idetifier Identifies objects

Uris identify Internet resources as strings, and urls represent resource locations.


URL uniform resource locator, which I believe you are already very familiar with.

URI format


So far, we have learned the composition and layering of the TCP/IP protocol family, and the most important three-way handshake, to be a little boy who is no longer unloved; There is also some knowledge about HTTP.

This is just the beginning. I see a long way to go.

Writing this article, for the record of learning HTTP, big hand please hold hands.

Original is not easy, feel good to share praise 👍