当前位置:网站首页>Whole process of web page request
Whole process of web page request
2022-06-25 11:30:00 【sermonlizhi】
Web The whole process of page request
scene :
Xiao Li has just joined the administrative staff and assigned him a working computer , Xiao Li uses a network cable to connect the computer to the switch at the station , The switch is connected to the company's router , As shown in the figure below . The company's routers and ISP Network connectivity ,CMNET For China Mobile ISP The Internet ,CMNET Provide the company with DNS service ,DNS Server resides in CMNET In the network .
hypothesis :DHCP The server runs on the company router
Request process :
IP Distribute
When the computer starts up , Operating system encapsulation DHCP Application message , The transport layer uses UDP Agreed 68 No. client port , The destination for DHCP Server's 67 Port no. , The transport layer places the source port and the target port in the header of the message segment .
So the computer has not yet IP Address , The network layer will UDP The message segment is placed in a IP In group , The purpose of this group IP It's a broadcast address 255.255.255.255, Source IP The address is 0.0.0.0.
The link layer will IP Packets are encapsulated into frames , At the head of the Ethernet frame , Source MAC The address is 0D:16:A1:68:92:8A, Because there is no IP, I don't know what to do next MAC Address , Therefore, the link layer defines the purpose of the frame MAC Address set to FF:FF:FF:FF:FF:FF( Broadcast address ), This frame will be broadcast to all devices connected to the company switch .
Switch receives Ethernet frame , Discover its purpose MAC The address is FF:FF:FF:FF:FF:FF, Then broadcast the frame at all exits , Of course, the company router will also receive this frame .
After the router receives the frame from the switch , It is concluded that IP The packets are handed over to the network layer , The network layer found this IP The purpose of the grouping header IP The address is the broadcast address , You know that it also needs to handle this request , So from the IP Extract from the group UDP Message segment , It's up to the transport layer .UDP take DHCP The request message is uploaded to the application layer 68 Port number corresponds to DHCP service , thus DHCP The server received a message from the new host DHCP Request message .
If the router does not have DHCP Server , It will record one DHCP Server address , The router acts as a relay , take DHCP The request is routed to DHCP The server .
Suppose the company router is connected to CMNET Of ISP The subnet block of the network connection is 172.168.81.0/24, Routes can be allocated within this range IP Address . All of the IP The addresses are CMNET In the address block of , hypothesis DHCP The server assigned... To Xiao Li's computer 172.168.81.24 Address .DHCP The server generation contains this IP Address 、DNS Server address (172.162.72.16)、 Default gateway router IP Address (172.168.81.1) And subnet blocks (172.168.81.0/24) Of DHCP ACK response message . The message is encapsulated in a UDP In the message segment , The destination port is 67(DHCP Client port ),UDP The message segment is placed in a IP In group , One of the sources IP The address is 172.168.81.1, Purpose IP The address is 255.255.255.255( Broadcast response ). The IP The packet is placed in an Ethernet frame , Source in frame MAC The address is the address of the interface that the router connects to the switch MAC Address 80:A3:72:F1:B2:65, Purpose MAC The address is Xiaoli's computer MAC Address 0D:16:A1:68:92:8A.
The router will contain DHCP ACK The data frame of the response message is sent to the switch , Because the switch has the ability of self-learning , When Xiao Li's computer sent frames through a switch , The switch has put Xiao Li's computer MAC The address and switch entry are stored as table entries in the forwarding table , So when the switch receives DHCP ACK Response frame of , View the target of the frame header MAC Address 0D:16:A1:68:92:8A, We know that this frame is only forwarded from the output port to Xiao Li's computer
Xiao Li's computer received DHCP ACK After the message , Extract... From the frames in turn IP grouping , from IP Group extraction UDP Message segment , Again from UDP The message segment extracts the response message , At this time DHCP The client also needs to report to DHCP The server sends a confirmation message to indicate that it has received the relevant information allocated IP Address information and select use ( Still broadcast IP),DHCP The server sends to the client again ACK Confirmation message , So far, we have successfully obtained IP Address . Computer DHCP The client records its IP Address and DNS Server address , And in the routing table (IP Forwarding table ) Fill in the address of the default routing gateway , From now on , Xiao Li will send to the default gateway the destination address is its subnet 72.168.81.0/24 Datagrams other than .
DNS and ARP
Xiao Li enters in the browser www.baidu.com, The computer needs to know the corresponding domain name IP Address , Generate a TCP Socket , Then the socket goes to www.baidu.com send out HTTP request . have access to DNS Domain name resolution system www.baidu.com The domain name corresponds to IP Address
The operating system generates a DNS Query message , Domain name www.baidu.com In the problem segment of the message . The DNS The message is placed on a destination port 53 Of UDP In the message segment ,UDP The message segment is placed in a IP In group , Source IP The address is 172.168.81.24, Purpose IP The address is 172.162.72.16(DNS The server ).IP Packets are encapsulated in Ethernet frames , Source MAC The address is 0D:16:A1:68:92:8A, The frame will be sent to the company's router , But now only know the router IP Address , But do not know the gateway router MAC Address . In order to get the router's MAC Address , Will use ARP agreement .
Xiao Li's computer will generate a purpose IP Address 172.168.81.1( The default gateway ) Of ARP Query message , The ARP The message is encapsulated in a target MAC by FF:FF:FF:FF:FF:FF( Broadcast address ) In the Ethernet frame of , And send the frame to the switch , The link layer of the switch finds that the destination address of the frame is the broadcast address , The frame is sent to all connected devices , Including gateway router .
The gateway router receives the message on the interface connected to the switch ARP Query frame , analysis ARP message , Discover the purpose of the request frame IP The address and frame are at the entrance of the router IP The address is the same , Then assemble a ARP response message , Mark it MAC Address 80:A3:72:F1:B2:65 Corresponding IP Address 172.168.81.1, Encapsulate the message in an Ethernet frame , Send to switch , Then the switch sends it to Xiao Li's computer .
Xiao Li's computer received ARP After the frame of the response , Get the gateway router from the response message MAC Address (80:A3:72:F1:B2:65), thus ,DNS Ethernet frame header for query purposes MAC There's the address .
Xiao Li's computer will DNS The query message is sent to the gateway router , The gateway router depends on the purpose IP Address , Combined with routing table ,ARP surface , The forwarding table will contain DNS The queried frames are forwarded to CMNET The router on the left side of the network .
CMNET The router on the left side of the network receives the frame , extract IP grouping , Check IP Destination address of the packet (172.162.72.16), Determine the interface according to its routing table , Through this interface, the direction is DNS The server forwards the datagram , And the reprint has passed CMNET Domain protocol of (RIP、OSPF) And inter domain protocols (BGP) Fill in .
DNS Query message IP Group arrival DNS The server , from IP Extract... From the group UDP Message segment , And then get from the message segment DNS Query message of , And then in DNS Look up the name in the server's database www.baidu.com, Find the corresponding domain name IP Address of the DNS Source record ( If there is one in the cache ). If it's time to DNS The server has no cache , Go to the authoritative domain name server (baidu.com) lookup , If not , Go to the root domain name server com lookup ( The root domain name server must have ). The DNS The server encapsulates a host name ( domain name ) To IP Address mapped DNS response message , Will be DNS The response message is encapsulated in UDP Message segment , Put in IP In group , Send datagrams to the company's router , After being sent to Xiao Li's computer through the switch , Xiao Li's computer started from DNS Get the server in the response message www.baidu.com Of IP Address 68.233.125.8.
client - Server interaction :TCP and HTTP
Xiao Li has a computer now www.baidu.com Of IP Address 68.233.125.8, Can generate TCP Socket , Send... To the server HTTP GET request- Generate TCP Socket time , It takes three handshakes , First, a random initial sequence number is generated seq = client_seq, And then in TCP The header of the message segment is filled with the destination port 80, At the same time, the SYN Set as 1, Indicates request connection . And then TCP The message segment is encapsulated in IP In group , The purpose of the head IP Address 68.233.125.8, then IP Group into the next hop MAC The address is 80:A3:72:F1:B2:65 In the Ethernet frame of , And send the frame to the switch .
- On the corporate network 、CMNET The routers in the network and Baidu network are going to www.baidu.com Server forwarding for contains TCP SYN Datagram , Use the routing table in each router .
- Final , browser-issued TCP SYN The connection request message of is sent to www.baidu.com Server for , from IP Get... In the group TCP SYN Request message for , according to TCP The destination port of the header is associated with the corresponding server socket , The server encapsulates a TCP SYNACK The corresponding message of , The header of the corresponding message contains the flag bit SYN = 1, Confirmation no. ack = client_seq( In the request header )+1, Serial number seq = server_seq( Initialization sequence number randomly generated by the server ), Will be TCP The corresponding message is put into IP grouping , then IP The packet is put into the link layer frame , Send it to Xiao Li's computer .
- Xiao Li's computer received a message from www.baidu.com Of TCP SYN ACK Response acknowledgement message , The client then encapsulates the response message to the server , The message header includes SYN=0( Connection is established ),ack=server_seq( Generated by the server )+1,seq = client_seq+1( The index of the server receiving buffer waiting to be received ), Send the first connection request , The client's response ack Send to www.baidu.com Server for . thus ,TCP The connection is fully established .
- TCP After the connection is established , Xiao Li can go to www.baidu.com The server sent a request , Browser generation HTTP GET Message and write TCP Socket ,HTTP GET The request message of is as TCP Load of message segment ( Data section ), And then according to TCP The process of requesting connection sends the request message to www.baidu.com The server 80 Socket corresponding to port number ,HTTP The server gets... From the socket HTTP GET message , Generate a HTTP response message , Will request Web The contents of the page are put into HTTP In response body , And send the message to TCP Socket .
- contain HTTP The datagram of the response message passes through Baidu network 、CMNET The Internet 、 The company's routers and switches arrive at Xiao Li's computer , The browser reads from the socket HTTP Respond to , from HTTP Get... From the response body Web Page html, By the browser according to html Draw page , thus , A complete page is displayed on the browser interface .
- Last TCP Disconnect with four waves , By the client HTTP Initiate a disconnect request , among TCP Header flag bit of message segment FIN = 1( Disconnect request ), take TCP The message is encapsulated into a frame and sent to www.baidu.com Server for , The server sends the response message of disconnection .TCP It's a full duplex connection , The server sends a connection disconnection request to the client , The message header is the same as above , Client received FIN Request message for , send out ACK Respond to , And then into TIME_WAIT(30s) The state of ,30 If no data is received from the server within seconds, the connection is officially closed , All resources of the client are released .
边栏推荐
- GaussDB 如何统计用户sql的响应时间
- Comparison between relu and SIGMOD
- Jincang KFS data centralized scenario (many to one) deployment
- 子类A继承父类B, A a = new A(); 则父类B构造函数、父类B静态代码块、父类B非静态代码块、子类A构造函数、子类A静态代码块、子类A非静态代码块 执行的先后顺序是?
- Free access to the global human settlements layer (ghsl) dataset from Gee
- GC
- Kingbasees plug-in DBMS of Jincang database_ session
- Open source invites you to participate in the openssf Open Source Security Online Seminar
- Gaussdb cluster maintenance case set - slow SQL execution
- Apache ShenYu 入门
猜你喜欢
Leetcode 1249. Remove invalid brackets (awesome, finally made)
Upload and modify the use of avatars
Research on parallel computing architecture of meteorological early warning based on supercomputing platform
金太阳教育美股上市:市值3.6亿美元 成小盘中概股
Double buffer transparent encryption and decryption driven course paper + project source code based on minifilter framework
仿真与烧录程序有哪几种方式?(包含常用工具与使用方式)
Explanation and use of kotlin syntax for Android
金仓KFS数据集中场景(多对一)部署
Idea uses the fast request interface for debugging
Niuke.com: Candy distribution
随机推荐
Ladder side tuning: the "wall ladder" of the pre training model
try-catch-finally
推荐一款M1电脑可用的虚拟机软件
CFCA Anxin sign access
金仓数据库 KingbaseES 插件force_view
Spark history server and event log details
CFCA安心签接入
Jincang KFS data centralized scenario (many to one) deployment
金仓数据库 KingbaseES 插件DBMS_UTILITY
wait()、notify()和notifyAll()、sleep()、Condition、await()、signal()
Spannable 和 Editable、SpannableString 和 SpannableString
Spark tuning tool -- detailed explanation of sparklens
牛客网:主持人调度
SQL注入漏洞(繞過篇)
SystemVerilog (XIII) - enumerate data types
GC
金仓KFS数据级联场景部署
查询法,中断法实现USART通信
GaussDB 如何统计用户sql的响应时间
Comparator (for arrays.sort)