Computer network top-down-web page request process

1. Getting Ready: DHCP, UDP, IP, and Ethernet
Suppose Bob starts up his laptop and then connects it with an Ethernet cable to the school's Ethernet switch, which is connected to the school's router. The school's router is connected to an ISP, in this case comcast.net, which provides DNS service to the school; therefore, the DNS server resides on the comcast.net network and not on the school's network. We will assume the DHCP server is running on the router.
When Bob first connects his laptop to the network, he can't do anything without an IP address. So, one network-related action that Bob's laptop takes is to run the DHCP protocol to obtain an IP address and other information from the local DRHP server.
The operating system on Bob's laptop generates a DHCP request message and puts the message in a UDP segment with destination port 67 (DHCP server) and source port 68, which is placed in a UDP segment with broadcast IP destination address (255.255.255.255 ) and source IP address 0. 0. 0.0 in the IP datagram, because Bob's laptop does not yet have an IP address.
The lP datagram containing the DHCP request message is placed in the Ethernet frame. This ethernet frame has a destination MAC address of FF: FF: FF: FF: FF: FF, so that the frame will be broadcast to all devices connected to the switch (including the DHCP server if all goes well), and the source MAC address of the frame is Bob The MAC address of the laptop
The broadcast Ethernet frame containing the DHCP request is the first frame sent by Bob's laptop to the Ethernet switch. The switch broadcasts incoming frames on all outgoing ports, including ports connected to the router
The router receives the broadcast Ethernet frame on its interface with MAC address 00:22:6B:45:1F, which contains the DHCP request, and extracts the IP datagram from the frame, whose payload is disassembled Up to UDP, the DHCP request message is extracted from this UDP message segment. At this time, the DHCP server has a DHCP request message.
Assume a DHCP server running on a router is able to assign IP addresses with CIDR block 68.85.2.0/24. So in this example, all IP addresses used within the school are in Comcast's address block. Suppose the DHCP server assigns the address 68.85.2.101 to Bob's laptop. The DHCP server generates an IP address containing this IP address along with the DNS server's IP address (68.87.71.226), the default gateway router's IP address (68.85.2.1), and the subnet block (68.85.2.0/24) (equivalent to "netmask") for a DHCP ACK message. The DHCP message is put into a UDP segment, IP datagram, and Ethernet frame. The source MAC address of this Ethernet frame is the MAC address of the interface when the router is connected to the home network (00:22:6B:45:1F:1B), and the destination MAC address is the MAC address of Bob's laptop (00:16:D3 :23:68:8A) .
An Ethernet frame containing a DHCP ACK is sent by the router to the switch. Because the switch is self-learning and has previously received an Ethernet frame (containing a DHCP request) from Bob's laptop, the switch knows that frames addressed to 00:16:D3:23:68:8A are only sent from Bob's Output port forwarding for laptops
Bob's laptop receives the Ethernet frame containing the DHCP ACK, and finally extracts the DHCP ACK message layer by layer from the Ethernet frame. Bob's DHCP client records his IP address and the IP address of his DNS server. It also installs the address of the default gateway in its IP forwarding table. Bob's laptop will send all datagrams to this default gateway with a destination address other than its subnet 68.85.2.0/24.
2. Still in the works: DNS and ARP
When Bob types the URL of www.google.com into his web browser, Bob's web browser starts the process by creating a TCP socket, which is used to communicate to www.google.com .google.com sends an HTTP request. In order to create this socket, Bob's laptop will need to know the IP address of www.google.com, using the DNS protocol to provide this name-to-IP address translation service.
The operating system on Bob's laptop therefore generates a DNS query message, appending the string www.google.com to the question field of the DNS message. The DNS message is placed in a UDP message segment with a destination port number 53 (DNS server), and then placed in a UDP message segment with an IP destination address of 68.87.71.226 (the DNS server address returned by the DHCP ACK in step 5). ) and source IP address 68.85.2.101 in
Bob's laptop puts the datagram into an Ethernet frame. The frame will be sent (addressed at the link layer) to the gateway router in the school network. However, even though Bob's laptop knows the IP address (68. 85. 2. 1) of the gateway router of the school through the DHCP ACK message in step 5 above, it still does not know the MAC address of the gateway router. In order to obtain the MAC address of the gateway router, Bob's laptop will need to use the ARP protocol
Bob's laptop generates an ARP query message with a destination IP address of 68.85.2.1 (default gateway), places it in an Ethernet frame with a broadcast destination address, and sends it to the switch, and the switch delivers the original frame to all connected devices. Including gateway routers.
The gateway router receives the frame containing the ARP query message on the interface leading to the school network, and finds that the destination IP address in the ARP message matches the IP address of its interface. So prepare an ARP reply indicating that its MAC address 00:22:6B:45:1F:1B corresponds to IP address 68.85.2.1. It puts the ARP reply in an Ethernet frame with a destination address of (Bob's laptop) and sends the frame to the switch, which delivers the frame to Bob's laptop.
Bob's laptop receives the frame containing the ARP reply message, extracts the gateway router's MAC address from the ARP reply message
Bob's laptop can now address Ethernet frames containing DNS queries to the gateway router's MAC address. Note that the IP datagram in this frame has IP destination address 68.87.71.226 (DNS server), while the frame has destination 00:22:6B:45:1F:1B (gateway router). Bob's laptop sends the frame to the switch, which delivers the frame to the gateway router.
3. Still in preparation: intra-domain routing to DNS server
The gateway router receives the frame and extracts the IP datagram containing the DNS query. The router looks up the destination address of the datagram (68.87.7 1. 226). Based on its forwarding table, it decides that the datagram should be sent to the leftmost router in the Comcast network. The lP datagram is placed in the link layer frame suitable for connecting the school router to the leftmost Comcast router, and the frame is sent over this link.
The leftmost router in the Comcast network receives the frame, extracts the IP datagram, checks the destination address of the datagram, determines the outgoing interface according to its forwarding table, and forwards the datagram to the DNS server through this interface, and the forwarding table has been based on Comcast's intra-domain protocols (RIP, OSPF) and the Internet's inter-domain protocol BGP fill in the
final IP datagram containing the DNS query and arrive at the DNS server. The DNS server extracts the DNS query message and searches for the name www. google.com, find the DNS source record containing the IP address (64.233.169.105) corresponding to www.google.com, (assuming it is currently cached in the DNS server) This cache data originates from the authoritative DNS server of google.com. The DNS server forms a DNS answer message containing this hostname-to-IP address mapping, puts the DNS answer message in a UDP segment addressed to the Boh laptop (68.85. 2. 101) in the IP datagram. The datagram will be forwarded back through the Comcast network to the school's router, and from there through the Ethernet switch to Bob's laptop.
Bob's laptop extracts the IP address of the server www.google.com from the DNS packet. Finally, Bob's laptop is now ready to contact the www.google.com server!
4. Web Client-Server Interaction: TCP and HTTP
Bob's laptop has an IP address for www.google.com, and it can create a TCP socket that will be used to send HTTP GET messages to www.google.com. When Bob creates a TCP socket, the TCP on Bob's laptop must first perform a three-way handshake with the TCP on www.google.com. Bob's laptop therefore first generates a TCP SYN segment with destination port 80 (for HTTP), places the TCP segment in the IP data server with destination IP address 64.233.169.105 (www.google.com) , place the datagram in a frame with MAC address 00:22:6B:45:1F:1B (gateway router) and send the frame to the switch.
Routers on the school's network, Comcast's network, and Google's network forward datagrams containing TCP SYNs toward www.google.com, using forwarding tables in each router. As mentioned above, the router forwarding table entry that governs the forwarding of packets through the inter-domain link between Comcast and Google networks is determined by the BGP protocol.
Finally, the datagram containing the TCP SYN arrives at www.googole.com. The TCP SYN message is extracted from the datagram and parsed into the welcome socket associated with port 80. A connection socket is created for the TCP connection between the Google HTTP server and Bob's laptop. Generates a TCP SYNACK segment, puts it in a datagram addressed to Bob's laptop, and finally puts it in a link-layer frame suitable for connecting www.google.com to its first-hop router.
The datagram containing the TCP SYNACK segment travels through Google, Comcast, and the school's network to finally reach the Ethernet card on Bob's laptop. The datagram is decomposed into the TCP socket generated in step 18 in the operating system, thus entering the connection state
Now ready to send bytes to www.google.com via the socket on Bob's laptop, Bob's browser generates an HTTP GET message containing the URL to fetch. The HTTP GET message is written to the socket, where the GET message becomes the payload of a TCP segment. The TCP segment is placed into a datagram and delivered to www.google.com, as described in steps 18-20 above.
The HTTP server at www.google.com reads the HTTP GET message from the TCP socket, generates an HTTP response message, puts the requested Web page content into the HTTP response body, and sends the message into the TCP socket The datagram containing the HTTP reply message in the word
is forwarded through Google, Comcast, and the school network to Bob's laptop. Bob's web browser program reads the HTTP response from the socket, extracts the html of the web page from the HTTP response body, and finally displays the web page.
The above examples seem to be as exhaustive as possible, but we have ignored some possible additional protocols (for example, NAT running in the school gateway router, wireless access to the school network, access to the school network or to the packet or data security protocols for packet encryption, network management protocols), and considerations that one would encounter in the public Internet (Web caching, DNS hierarchy).
 

Guess you like

Origin blog.csdn.net/qq_65838372/article/details/132692564