The process of entering a URL into a browser to access a web site
- When entering a URL, the browser, as the client, first requests the DNS server to obtain the corresponding domain name and IP address (application layer).
- Locate the server using the IP address and establish a TCP connection
- The browser sends HTTP request packets to the server (application layer -> Transport Layer -> Network layer -> Data link layer)
- After receiving the HTTP request packet, the server starts to process the request packet (data link layer > Network layer > Transport layer > Application layer).
- After the server receives the request, the server invokes its own service and returns the response package
- The browser receives the response and begins rendering the page
Network communication
The communication between network devices on the Internet follows the TCP/IP protocol. When the TCP/IP protocol family is used for network communication, the devices communicate with each other in hierarchical order.
The layers in descending order are application layer, transport layer, network layer, and data link layer. The sending end goes down from the application layer, and the receiving end goes down from the data link layer. As shown evernotecid: / / e1 fd3 e80 F9E7509D – 5-4-87 – A1340229FCB4 / appyinxiangcom / 27675019 / ENResource/p34
Enter the URL in your browser
The URL entered in the browser cannot be used to connect directly, so DNS address resolution is used to convert the entered URL into an IP address.
The browser first looks at the browser cache, system cache, and router cache. If there is one in the cache, the page content is directly displayed on the screen. If no, domain name resolution (DNS resolution) is required to obtain the corresponding IP address before sending the HTTP request
Establishing a TCP Connection
In THE TCP/IP protocol,TCP provides reliable connection service, using the three-way handshake to establish a connection.
First handshake: When establishing a connection, the client sends a SYN packet to the server
Second handshake: After receiving a SYN packet from the client, the server replies with an ACK packet. The server also sends a SYN packet. So the server replies with ACK + SYN
Third handshake: After receiving a SYN + ACK packet from the server, the client uses ack to confirm the SYN packet
The three-way handshake is complete, and the TCP connection is established between the client and server
The browser (the application-layer client) sends the HTTP request
An HTTP request consists of three parts: Request method URI Protocol/version
- GET/POST/PUT/DELETE/OPTIONS
Request Header
- User-Agent
- content-type
- content-length
- content-encoding
- cache-contro
Request body
- queryString
- form
- application/json
TCP Transport Packet (Transport Layer)
TCP at the transport layer provides reliable byte stream service for transmitting packets. To facilitate transmission, it divides large data packets into packet segments for management and numbers them so that the server can accurately restore packet information (MTU) when receiving packets.
TCP protocol confirmation a method of ensuring secure and reliable transmission:
- Ack to confirm
- Timeout retransmission
- Connection management
The server returns the corresponding file
After receiving an HTTP response, the client uses HTTP to parse the HTTP response:
- Response Header
- Content_Type: html/css/js/img/mp3/mp4/m3u8
- Response Body
HTML builds a DOM tree -> parses CSS builds a rendering tree -> loads JS -> Client and server interact via Ajax