当前位置:网站首页>[how to connect the network] Chapter 1: the browser generates messages
[how to connect the network] Chapter 1: the browser generates messages
2022-06-26 13:15:00 【Currybeefer】
1. What happens after entering the URL
At the very beginning , If we want to visit a web page , You need to enter the web address in the input box of the browser . for example www.baidu.com Things like that . But actually when you press enter , The content of the place we input changes , It will become https://www.baidu.com/ Such things . This thing is actually called URL.
We can find out URL It is added in front of the URL we entered ”http”,”ftp:”,”file:“ Such things . actually URL The first words indicate the access method that the browser should use . visit web The server should use HTTP agreement , visit FTP The server should use FTP Protocol, etc . So we can take ”http:”,”ftp:”,”file:“ It is understood as the protocol type used during access .
2. Browser parsing URL
When we press enter , The first step of the browser is to say URL To analyze . We visit web Service as an example :
Browser resolution completed URL I'll understand later , Oh , So I'm going to this web Find a file in the directory under the server , Or start a program in this directory .
3. Generate HTTP The request message
complete URL After the analysis of , The browser has determined web Server and filename , The next step is to generate HTTP A message has been requested .HTTP The protocol specifies that the request message has a specific format , The browser must generate the request message in the specified format .
HTTP The protocol specifies the contents and steps of message interaction between client and server , The basic idea is that the client needs to send a request message to the server , The message content must include “ What to ” and “ How to operate ” These two parts .
Operations such as obtaining information (GET), To transmit data (POST), Replace the server file (PUT), Delete file (DELETE) wait .
The format of the request message is about this :
The first line stores the access method , Access specific locations ( Such as a file address ). The header stores some browser information , For example, the current browser uses HTTP Version of the agreement and other information . The entity stores the data that needs to be sent , For example, we fill in a receiving address and send it to , In that entity, there are data such as our harvest address .
alike , The server also needs to send a response message in a certain format , The response message also has certain format requirements . Including the status code at the beginning of the message ( It is used to tell whether the execution result of the request message is successful or failed ). for example 404 Is one of the status codes .
Then the format of the response message is about this :
If everything goes well , Then the browser can get the information such as the web page to be displayed from the response message , And then on our screen . It's all done .
By the way , The request message and response message we just mentioned actually have names , be called HTTP Request message and HTTP response message .
4. towards DNS Server query IP Address
Browsers can generate HTTP message , The next step should have been to delegate the operating system to send messages to Web The server . In fact, the browser does not know the specific location of the server to send the message to , That is, the browser doesn't know Web Server's IP What's the address . So we need to do more : Ask about the latest DNS The server “ The current URL www.baidu.com” Corresponding IP What's the address .
This step needs to call the operating system Socket Only the parser in the library can realize . The parser will send the current latest DNS The server sends the query request , obtain DNS After the server replies, it will IP The address is written to the memory address specified by the browser , In this way, the browser can extract from the memory address after parsing IP Address .
5.DNS The query process of the server
DNS The server knows the address corresponding to the domain name by checking the server information , And then back to the client .DNS The workflow of is roughly as shown in the figure
But not all domain names correspond to IP Information is stored in one DNS Server ? So obviously , these IP The information is distributed in multiple stations DNS In the server .
So if the browser is pointing to the nearest DNS When querying , This DNS The server does not save the corresponding domain name IP What about information ? The answer is multiple DNS Server relay cooperation , To complete the query .
How can I find it ? There are tens of thousands of computers on the Internet DNS The server , Certainly I can't find what I want one by one IP Address ? The answer is DNS All information in the server is saved in a hierarchical structure according to the domain name .DNS The domain names in are separated by periods , Such as “www.lab.galsscom.com” It represents many levels , Each level becomes a domain . therefore ,com The next level of the domain is glasscom Domain , And then there was lab Domain . These hierarchical domain name information will be registered to DNS Server , Each domain is treated as a whole .
Of child domains DNS The server will send its own IP The address is registered to its parent domain DNS Server , In this way, you can pass the superior DNS The server , Find what we want to query layer by layer IP Address .
Be careful ,com Domain ,cn Domain is not the top-level domain , There is also a root domain on top of this DNS The server , This server's IP There is only 13 individual ( Of course, there are more than physical nodes 13 individual ). be-all DNS The servers all save the root domain servers IP Address , such , Any one DNS Servers can access the root domain server . Then we can feel things through the root domain server , Query all the way to any domain DNS The server .
One DNS The specific process of query :
Of course not every query IP It's so troublesome to inquire one by one ,DNS Cached information in server . It is similar to the fast table in memory management . Save the latest query IP Address , In this way, you can quickly return the required information .
6. Delegate the protocol stack of the operating system to send messages
Get what you need to visit Web Server's IP After the address , The browser can entrust the protocol stack of the operating system to send messages . It will be called at this time Socket A series of components of the library , Establish a channel between the client and the server , Then transmit the data we need . The specific steps are as follows :
- Create socket
- Connect the pipe to the socket of the server
- Sending and receiving data
- Disconnect pipe and remove socket
边栏推荐
- HDU 3709 Balanced Number
- Biff TwinCAT can quickly detect the physical connection and EtherCAT network through emergency scan
- B - Bridging signals
- Learning Processing Zoog
- scrapy——爬取漫画自定义存储路径下载到本地
- H - Sumsets POJ 2229
- 倍福PLC选型--如何看电机是多圈绝对值还是单圈绝对值编码器
- Summary of wechat applet test points
- Power Designer - Custom Comment button
- Zoomeeper sets ACL permission control (only specific IP access is allowed to enhance security)
猜你喜欢
原型模式(prototype)
Arcpy - - utilisation de la fonction insertlayer (): ajout de calques dans un document de carte
Electron official docs series: Processes in Electron
倍福CX5130换卡对已有的授权文件转移操作
Beifu PLC based on NT_ Shutdown to realize automatic shutdown and restart of controller
Enjoy element mode (flyweight)
10秒内完成火灾预警,百度智能云助力昆明官渡打造智慧城市新标杆
First knowledge - Software Testing
Decorator
Processing polyhedron change
随机推荐
P2393 yyy loves Maths II
Electron official docs series: Testing And Debugging
倍福NC轴状态转移图解析
C language: Exercise 2
Appearance mode (facade)
MySQL数据库讲解(五)
Power Designer - Custom Comment button
Processing function translate (mousex, mousey) learning
PostGIS geographic function
Biff TwinCAT can quickly detect the physical connection and EtherCAT network through emergency scan
Electron official docs series: Processes in Electron
Electron official docs series: Get Started
中国剩余定理模板题 互质与非互质
First pass! Baidu AI Cloud Xiling platform has obtained the authoritative certification of digital human ability evaluation from the Institute of information technology
Processsing function random
QT . Establishment and use of pri
E - Apple Catching
HDU1724[辛普森公式求积分]Ellipse
Word document export (using fixed template)
橋接模式(Bridge)