-
- Type the web address http://www.baidu.com/ into your browser
-
- Check whether the local computer stores the server IP address corresponding to the domain name Baidu.com. If yes, the browser directly sends a three-way handshake request to the target server. If no storage resource is available, the SERVER sends a request to the DNS server to query the server IP address of Baidu.com. After the DNS server returns the target IP address of Baidu.com, the DNS server sends a three-way connection request to the target IP address. If the connection is successful, the target IP address is backed up locally
The details of sending the request to the destination IP (why both MAC and IP addresses are necessary) : In the OSI Layer 7 protocol, the MAC address belongs to the layer 2 data link layer and the IP address belongs to the layer 3 network layer. When the browser sends a request, it sends an ARP broadcast to check whether the target IP host exists on the local network. If yes, the BROWSER directly sets the MAC address as the MAC address of the target IP host. If not, set the MAC address requested by the browser to the MAC address of Router A on the local network. Router A forwards the browser request to Router B on the other network (the requested MAC address is changed to the MAC address of Router B). If the destination host IP address exists in router B’s subnet, If the MAC address does not exist, the IP address is directly changed to the MAC address of the target host. If the MAC address does not exist, the IP address is directly changed to the MAC address of the target host
-
- When the server receives a request and sets up a reverse proxy service (such as Nginx), Nginx forwards the request to the corresponding port of the service. (For example, if Django is running on port 3309, Nginx forwards the request from port 80 to port 3309.)
-
- When Django receives the request, the middleware preprocesses it. The request matches urls.py in the home directory based on the re. Once the match is successful, the request is distributed to a separate App that also contains urls.py
-
- The view function will process the request, generate the response, pass it through the middleware, leave Django, and return it to Nginx, which will send the response back to the browser.
On the three handshakes and four waves:
Three handshakes:
- Browser initiates a connection request (browser: We will meet at 8:00 tomorrow morning, please reply when received)
- The server receives the request and returns the response (server: acknowledge receipt, let’s meet at 8am tomorrow)
- The browser sends an acknowledgement that it has received a response from the server (browser: I received your acknowledgement!).
Four waves:
- The browser makes a disconnection request **(browser: I’ve asked all the questions I need to ask, no more questions)**
- Server: I have received the message you asked for. When I finish answering your previous question, we will disconnect.
- Server: I have answered all your questions, are you sure there are no more questions? **
- The browser returns a response (the browser confirms that the server has sent the resource)(Browser: I have no further questions, just disconnect!)