The process of web page request

Process requirements for WEB page requests
insert image description here
: Computers in the school network access the web server in the Google network

1. The computer is connected to the campus network through a physical network cable

2. The computer runs the DHCP protocol and obtains an IP address from the local DHCP server (the DHCP server is generally acted by a gateway router).
The acquisition process:
1) As a DHCP client, the computer will first send a DHCP request message ----DHCP– discover packet (broadcast packet)
transport layer: SP (source port number): 68 DP: 67
network layer: SIP: 0.0.0.0 (represents no IP address) DIP: 255.255.255.255 (broadcast address)
data link layer: SM : Own MAC DMAC: All F

        数据包先通过传输介质,来到交换机上。交换机收到数据包先关注数据帧中的源MAC地址,将源MAC地址和进入接口的对应关系记录在本地的MAC地址表中。之后,再看目标MAC地址,因为目标MAC地址是广播地址,所以,交换机将执行泛洪动作,将该数据包发于所有和自己连接的设备(发送设备除外)。
        因为路由器和交换机连接,路由器将收到该广播帧。先看二层MAC地址,因为是广播帧,所以,将解二层封装看三层;因为三层的目标IP地址是255.255.255.255,所以,路由器将解三层封装,根据三层封装中的协议号(17)判定将该数据交给UDP模块进行处理,UDP解四层封装,UDP模块基于目标端口号67,判定此数据寻址的是DHCP服务,将交于DHCP服务进行后续处理。则此时DHCP服务器收到了DHCP客户端的请求。

(The DHCP transport layer uses the UDP protocol, and the UDP protocol number is 17)
2) The DHCP server will respond to the request of the DHCP client and reply the DHCP-offer packet. ----Unicast/Broadcast
This packet will carry an available IP address in the allocatable network segment (the allocatable network segment in the figure is 68.80.2.0/24, and the available IP address carried is 68.80.2.101), among which Also includes gateway 68.80.2.1 and DNS server 68.87.71.226 information.
3) The DHCP client performs reverse selection and replies to the DHCP-Request packet—the request is for the IP information in the DHCPOffer. —Broadcast packet (multiple DHCP-OFFERs may be received, in the form of broadcast packets, on the one hand, tell the DHCP server requesting IP that it needs to obtain his IP address; on the other hand, tell other DHCP servers in the broadcast domain (if any) ) The IP address requested by oneself is not theirs, and the address can be released)
Note: If the DHCP client receives multiple DHCP-offers, it will choose the first received one to make the request.
4) The DHCP server will send DHCP-ACK for final confirmation. —Unicast/broadcast (different from different manufacturers)

3. At this time, the computer has the basic network conditions to access the Google server, then enter the URL (Uniform Resource Locator) of www.google.com in the browser

4. Because the input is domain name information, but access to the server requires IP address information, so the computer will trigger a DNS request and send it to the DNS server.
DNS: Domain Name Resolution Protocol
DNS protocol request search method:
1. Recursive search—the computer sends a search request to the local DNS server (the computer requests Baidu’s IP address from the local DNS server, and the local DNS searches for Baidu’s IP address in its own address table , if there is, it will directly reply to Baidu's IP address; if not, the local DNS server will continue to search for other DNS, if there is no DNS, then this DNS will continue to search until it is found, and then find another layer The first layer is transmitted upwards, and the original route is returned until the local DNS receives Baidu’s IP address, and the local DNS server then sends Baidu’s IP address to the computer.) (Local recursive search generally uses UDP port 53) 2.
Iteration Search—the search request sent by the local DNS server (for example, the computer requests Baidu's IP address from the local DNS server, and the local DNS searches for Baidu's IP address in its own address table. If there is, it will directly reply to Baidu's IP address. If not, At this time, the local DNS returns an IP address to the computer, but this IP address is not Baidu's IP, but another DNS server. This DNS server then checks whether there is Baidu's IP address in the local address table, and if so, it will reply To the computer, if not, then reply to the computer the IP address of another DNS server......) (Iterative search uses TCP port 53)
Transport layer: UDP DP: 53
Network layer: SIP: 68.85. 2.101 DIP: 68.87.71.226
Data Link Layer: SM: own MAC target MAC: ? ? ? (I don’t know yet) (The target MAC is the gateway MAC, because the computer and the DNS server are not in the same broadcast domain, so the gateway router is required to help forward the information)

5. In order to obtain the MAC address of the gateway, the computer needs to send an ARP request packet with the gateway IP: 68.85.2.1 as the request IP.
Source IP: 68.85.2.101 Destination IP: 68.85.2.1
Source MAC: Your own MAC Destination MAC: All F (broadcast form)
Working process:
First, the host sends an ARP request in the form of broadcast, and requests the MAC address through the IP address. Because it is a broadcast frame, all devices in the broadcast domain will receive this request. After receiving the request, the device first records the corresponding relationship between the source IP and source MAC in the data packet in its local ARP cache table. Then, look at the requested IP address. If the requested IP address is not your own, the data packet will be discarded directly. If the request is for its own IP address, it will be answered. Afterwards, when communicating again, the local ARP cache table will be checked first. If there is a record, it will be added according to the MAC address in the record; if there is no record, it will send an ARP request to obtain it.
Through the ARP request, the computer will obtain the MAC address of the gateway

6. The DNS request packet will be encapsulated normally
Transport layer: UDP DP: 53
Network layer: SIP: 68.85.2.101 DIP: 68.87.71.226
Data link layer: SM: own MAC Target MAC: MAC of the gateway

7. When the gateway receives the DNS request packet sent by the computer, it first checks the MAC address. If the target MAC is its own MAC, it will unencapsulate the second layer and look at the third layer. Check the local routing table based on the Layer 3 destination IP address. If there is a matching routing entry, it will be forwarded according to the routing entry. If not present, the datagram will simply be discarded. (However, in the current scenario, the gateway will send it to the ISP in the public network through the default route)

**8. Through the forwarding of the router, the request packet will come to the local DNS server. **If the IP address corresponding to the domain name exists in the cache of the local DNS server, it will be returned directly to the computer. If not, it will initiate an iterative search request to the DNS root server, and finally obtain the IP address corresponding to the domain name, and return it to the computer. (TCP port 53 is used for iterative search)

9. The computer will obtain the IP address information corresponding to www.google.com through the DNS protocol. Afterwards, the establishment of an HTTP relationship from the local computer to the target server will be triggered.
Because the HTTP protocol works based on the TCP protocol, it is necessary to complete the TCP session connection between the computer and the target server first. (Three-way handshake)
When the TCP session is established, the client (computer) and the server will establish a two-way session channel, and will be able to send information to each other.

10. Client----server: send Http request----obtain web page information----send GET request

11. Server----Client: After receiving the GET request, the server will return the web page information (200 OK) to the client----At this point, Xiao Ming's computer will obtain the page information of the Google web server.

If the three-way handshake is not established, the two parties cannot transmit data. The three-way handshake and reliable data transmission are two different things. It is necessary to ensure that there is no problem with the connection-oriented, so that the data can be transmitted reliably.
If the two parties are client (C) and server (S) models—CS model, generally the client first sends a synchronous request packet for the first handshake.
If the two ends are not client or server models, it doesn’t matter who sends data first. Only after one party sends, the other party suppresses the first handshake ability

Three-way handshake:
the first handshake: the host sends a synchronization request packet (syn+req) to the server (syn mark position 1)
synchronization request: both ends of the request are in the same state (A host is ready to send data to B, and B server is ready Received state) (the host requests the port of the server to be opened)
the second handshake: the server replies to the host (ACK+syn+req, (ACK mark position 1) (ACK confirmation mark bit) ACK means confirmation) (while confirming Another synchronization request packet is sent) (the server requests the port of the host to be opened)
the third handshake: the host replies to the server with an ACK packet (the ACK mark position is 1, because the communication is two-way, so the SYN request mark position is also set to 1)

Guess you like

Origin blog.csdn.net/xiaoxiaoxyxz/article/details/128541136