Overview from browser to server


A journey of discovery from browser to server

Everyone often browses the web to get the knowledge they need, but few people have delved into the wonderful process that happened. From the user's input of a web address (URL) to the successful visit to a web page, what happened? This This is what this column will explain to you. Everyone as a programmer knows that a web application is divided into a client and a server . Browsing a web page is an interaction between the client and the server. From the browser to the server, the most The main interaction is equivalent to the following dialogue:

  • Browser: ×× server, I want to perform ×× operations on your ×× resources
  • Server: ×× browser, I did not/have fulfilled your request, the result/cause is ××.

Although it is just a small interaction, it has to go through a very complicated process. There are many issues that we need to consider, such as:

  1. How does the browser know where the server corresponding to the URL you entered is?
  2. How can the message sent by the browser be recognized by the server?
  3. How can the sent message reach the destination (server) successfully?
  4. In the face of numerous messages, how does the server judge whether the incoming message is safe?

Therefore, in response to these problems, the articles in the column will introduce the process of the browser to the server and the problems on the way as clues to introduce the network in the computer.

The following is the overall overview from the browser to the server (the picture comes from <<How is the network connected>>):

Insert picture description here

According to this process, I also divided this column into several parts.

In order to deepen my understanding, I will use express delivery as an example in life to compare the process in the network. We (sender) are equivalent to a browser, and the recipient is equivalent to a server.

(1) Web browser

This part will explore how the browser works. Because we browse a webpage by entering a URL in the browser. For example, we can enter https://blog.csdn.net/qq_44823898 in the browser. The browser will follow Certain rules are used to analyze this URL and generate a message. But the browser does not send the message, but entrusts the operating system to send the message . This process is equivalent to what we (browser) want to send (message) Get ready and then entrust the courier (operating system) in the area to send the package.

(2) Protocol stack, network card

In this part, we will explore the mechanism of moving data.

The protocol stack (network control software) that comes out first . It will package the data received in the browser, and add some necessary information such as: destination address, etc. This process is equivalent to a regional courier (riding a three-wheeled courier Brother) deliver the received package to the courier point (protocol stack), the courier point packs the things and pastes the courier slip, which contains the basic information of the sender and the address and information of the consignee (plus necessary information).

Next, the protocol stack will deliver the packet to the network card (the hardware responsible for Ethernet or wireless communication) . Then the network card will convert the packet into an electrical signal and send it out through the network cable. This way the packet enters the network. This process is equivalent At the courier point (protocol stack), the package (package) is delivered to the transportation courier (the courier who drives a large truck full of packages, which is equivalent to a network card). Then the transportation courier drove the large truck and entered the main traffic road ( Network)

(3) Hubs, switches, routers

The following items will be different according to the different forms of Internet access. The client computer can access the Internet through the home or company LAN, or directly access the Internet. This process is equivalent to many types of express delivery. , Some are railway transportation and some are shipping. Our exploration journey will be in the most typical scenario: the client connects to the home and company's local area network, and then connects to the Internet through broadband lines such as ADSL and optical fiber .

In such a scenario, the packet sent by the network card will pass through the switch and other devices to the router used to access the Internet. Behind the router is the Internet, and the network operator will be responsible for delivering the packet to the destination.

(4) Access network, network operator

Next, the data starts from the router used to access the Internet and enters the inside of the Internet. The entrance line of the Internet is called the access network . Generally speaking, we can access the Internet through optical fiber, cable TV, etc., these are access networks .

Numerous access networks will connect to the contracted network operators and access devices called Point of Presence (PoP) . This access point is managed by the operator, and the operator will The message is transmitted to the Internet. Then it is sent to the world. You will find that at this stage there are devices (access points) that are not related to our use of individuals. This is also the reason for the emergence of operators. They provide special services To enable us to connect to the Internet and charge a fee. A common operator is China Unicom Mobile Telecom.

(5) Firewall, buffer server

After a series of transmissions on the Internet, the package finally enters the local area network where the web server is located. Then it will encounter a firewall to check it. This process is equivalent to the package sent by the community security to the courier brother Perform a basic inspection to ensure the safety of the head of household.

If you check the network packet, you may encounter a cache server next . This is because a considerable part of the web page data can be reused. These reusable data are stored in the cache server. If the web page data to be accessed is just right Can be found in the cache server, then there is no need to trouble the server, just read the data from the cache server and return it

(6) Web server

When the network packet arrives at the server, the data will be unpacked and restored to the original request data, and then handed over to the web server. Like the client, this process is also completed by the protocol stack (network controller). Next, the web server will analyze the meaning of the request and make a corresponding answer. Then transfer the data into the response message and send it back to the client. The process of returning the response message to the client is exactly the opposite of the process we introduced before.
When the response reaches the client After that, the browser will read the data of the webpage from it and display it on the screen. At this point, a series of operations to access the web server are all completed, and our journey of exploration has also reached the end.

This is the outline of all the knowledge that this column will introduce, how you are interested in this part of the content. You are welcome to bookmark and like, your support is the biggest motivation for my writing . Thank you .

Guess you like

Origin blog.csdn.net/qq_44823898/article/details/112299065