当前位置:网站首页>History of web page requests

History of web page requests

2022-07-05 04:33:00 What should I do if I can't afford my beloved cat

Suppose I start my Huawei laptop , Then connect it to the school Ethernet switch with an Ethernet cable , The switch is connected to the school router , This router in the school is connected with a ISP(comcast. net) Connect . In this case ,comcast. net Provide the school with DNS service ; hypothesis DHCP The server runs in the router .

First, connect Huawei notebook to the network , No, IP He can't do anything ( For example, download a Web Webpage ). therefore , A network related action taken by notebooks is to run DHCP agreement , From the local DHCP The server gets a IP Address and other information .

  • 1) The operating system of the notebook generates a DHCP Request message (DHCP agreement ), And put this message into the port with destination 67(DHCP The server ) And source port 68(DHCP Customer ) Of UDP Message segment , The UDP The message segment is placed in a broadcast IP Destination address (255.255.255.255) And the source IP Address 0.0.0.0 Of IP In the datagram , Because notebooks don't have one IP Address .

  • 2) contain DHCP Requesting a message IP Datagrams are placed in Ethernet frames . The Ethernet frame has a purpose MAC Address FF:FF:FF:
    FF:FF:FF, Cause the frame to be broadcast to all devices connected to the switch ; The source of the frame MAC The address is notebook MAC Address

  • 3) contain DHCP The requested broadcast Ethernet frame is the first frame sent by my laptop to the Ethernet switch . The switch broadcasts in frames at all out ports , Including the port connected to the router .

  • 4) An interface of the router receives the broadcast Ethernet frame , And extract it from the Ethernet frame P The datagram . The broadcast of the datagram IP The destination address indicates this IP Datagrams should be processed by the high-level protocol at the node , Therefore, the load of the datagram ( One UDP Message segment ) Be broken up to
    UDP,DHCP The request message from UDP Extracted from the message segment . here DHCP The server has DHCP Request message .

  • 5) hypothesis
    DHCP Server assigned address 67.88.24.101 The notebook .DHCP The server generation contains itself IP Address and DNS Server's IP Address 、 Default gateway router IP One of address and subnet block
    DHCP ACK message . The DHCP The message is put into a
    UDP In the message segment ,UDP The message segment is put into one IP In the datagram ,IP The datagram is then put into an Ethernet frame . The source of this Ethernet frame MAC The address is the address of the interface when the router is connected to the home network MAC Address , Purpose MAC The address is notebook MAC Address .

  • 6) contain DHCP ACK The Ethernet frame of is sent to the switch by the router . Because the switch is self-learning ( Link layer switches ), And previously received Ethernet frames sent from notebooks , So the switch knows the addressing destination of this frame , Forward only from the output port to the notebook .

  • 7) Notebook received containing DHCP ACK Ethernet frame , Extract from frame IP The datagram , from IP Extract... From datagrams UDP Message segment , from UDP Segment extraction DHCPACK message .DHCP The customer records its IP The address and its DNS Server's P Address . It's still there IP The address of the default gateway installed in the forwarding table ( Router LAN Interface default IP Address ).

  • take www. google. com Of URL Type it Web Browser time ,Web The browser will generate a TCP Socket , Used to direct to www.google.com send out HTTP request . To generate the socket , Notebook needs will need to know www.google.com Of IP Address .

  • 8) The operating system therefore generates a DNS Query message ( About DNS), Include string www.google.com. The DNS The message is placed in a with 53 Number (DNS The server ) Of the destination port UDP In the message segment . The UDP The message segment is put into a message with IP The destination address is 5 In step DHCPACK Back to DNS Server address and source IP Address IP In the datagram .

  • 9) The notebook will contain DNS The datagram of the request message is put into an Ethernet frame . The frame will be sent ( Addressing at the link layer ) To the gateway router in the school network . However , After the above paragraph 5 In step DHCP ACK The message knows the of the school gateway router IP Address , But I still don't know the of the gateway router MAC Address . In order to obtain the MAC Address , Need to use ARP agreement ( Address resolution protocol ARP).

  • 10)Bob A portable computer generates a program with a purpose IP Address ( The default gateway ) Of ARP Query message , Will be ARP The message is placed in an address with broadcast destination (FF:FF:FF:FF:FF:FF) In the Ethernet frame of , And send the Ethernet frame to the switch , The switch delivers the frame to all connected devices , Including gateway router .

  • 11) The gateway router receives this... On the interface to the school network ARP Query message frame , stay ARP Target in message IP The address matches its interface IP Address . The gateway router therefore prepares a ARP answer , Containing it MAC Address 、IP Address . It will ARP The answer is in an Ethernet frame , Its destination address is notebook MAC, And send the frame to the switch , Then the switch delivers the frame to the notebook .

  • 12) Notebook reception contains ARP Frame of reply message , And from ARP In the reply message, extract the MAC Address .

  • 13) Notebooks can now contain DNS The queried Ethernet frame is addressed to the gateway router's MAC Address . Notice the... In this frame IP Datagram has IP The destination address is DNS The server , And this frame has the destination address gateway router MAC. The laptop sends this frame to the switch , The switch delivers the frame to the gateway router .

  • 14) The gateway router receives the frame and extracts the contents DNS Of the query P The datagram . The router looks up the destination address of the datagram , And decide which router the datagram should be sent to according to its forwarding .

  • 15) Select the most appropriate router to receive the frame , extract IP The datagram , Check the destination address of the datagram , And determine the interface according to its forwarding table , Go through the interface towards DNS The server forwards the datagram .

  • 16) It eventually includes DNS Of the query IP The datagram has arrived DNS The server .DNS Server extraction DNS Query message , In its DNS Look up the name in the database www. google. com , Find the corresponding www. google. com Of IP Address of the DNS Source record .( Suppose it is currently cached in DNS Server ) This cached data comes from google.com The authority of the DNS The server . The DNS The server forms a host name that contains this to IP Address mapped DNS Answer message , Will be DNS The reply message is put into UDP In the message segment , This message segment is placed in the IP In the datagram . The datagram will be forwarded to the school router , And through the switch to the notebook .

  • 17) Notebook from DNS Message extraction server www. google. com Of IP Address . Final ,Bob The laptop is now ready to contact www.google.com The server !

  • 18) Given the www. google. com Of IP Address , It can generate TCP Socket , The socket will be used to www. google. com send out HTTP GET message . When generated TCP Socket , Must first be with www. google.com Medium TCP Perform three handshakes .Bob The laptop therefore first generates a port with a destination 80( in the light of HTTP Of ) Of TCP SYN Message segment , Will be TCP Message segments are placed with purpose IP Address 64.233.169.105(www. google.com) Of IP In the datagram , Place the datagram in the gateway router with the destination address MAC In the frame of , And send the frame to the switch .

  • 19) In the school network 、ISP The router in the web and Google Web is facing www. google. com Forwarding contains TCP SYN
    Datagram , Use the forwarding table in each router .

  • 20) Final , contain TCP SYN The datagram of arrived www. googole. com. Extract from datagram TCP SYN The message is decomposed to and port 80 Associated welcome socket . For Google HTTP Between server and notebook TCP Connection generates a connection socket . Produce a TCP SYN ACK Message segment , Put it into a datagram , Finally put it into the link layer frame .

  • 21) contain TCP SYNACK The segment's datagram goes through Google 、ISP And the school network , Finally arrive at the Ethernet card of the notebook . Datagrams are broken down into steps in the operating system 18 Generated TCP Socket , To enter the connection state .

  • 22) With the help of the generated socket , Now I'm ready to go to www. google.com Bytes sent , Browser generation contains the URL Of HTTP CET message .HTTP GET The message is written to the socket , among GET The message becomes a TCP Load of message segment . The TCP Put the message segment into a datagram , And deliver to www. google.com, As in the previous steps 18~20 Described .

  • 23) stay www. google. com Of HTTP Server slave TCP Socket read HTTP GET message , Generate a HTTP
    response message , Will request Web Put the page content in HTTP In response body , And send the message to TCP Socket .

  • 24) contain HTTP Answer the datagram of the message through Google 、ISP And school network forwarding , Arrive at the notebook .Web Browser program reads from socket HTTP Respond to , from HTTP Extract... From the response body Web Web page html, And finally showed Web Webpage .

原网站

版权声明
本文为[What should I do if I can't afford my beloved cat]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140636205922.html