The whole process of accessing a Web page

Source: Internet
Author: User
Tags ack get ip

Introduction

Open the browser, enter the URL in the Address bar, enter, the page content appears. What happened to the whole process? What is the principle? The following are collated and summarized.

The whole process can be summed up in several sections:

1. The domain name resolves to an IP address;

2. TCP connection to the destination host (three handshake);

3. Send and receive data (browser and destination host start HTTP access process);

4. Disconnect the TCP connection (four waves) from the destination host;

Here is a detailed description of the principle of 1. Domain name resolved to IP address

There are two ways of accessing the destination address:

① is accessed using the destination IP address. Because the IP address is a bunch of numbers inconvenient memory, so there is a domain name of this character type identification.

② use domain name access. Domain name resolution is the conversion process of domain name to IP address, the resolution of the domain name is done by the DNS server.

DNS domain names are resolved using the UDP protocol. The entire domain name resolution process is as follows:
    1. The browser issues a DNS request to the native DNS module, and the DNS module generates the relevant DNS packets;
    2. The DNS module passes the generated DNS messages to the UDP Protocol unit of the Transport layer;
    3. The UDP protocol unit encapsulates the data into a UDP datagram, which is passed to the IP Protocol unit of the Network layer;
    4. The IP protocol unit encapsulates the data as an IP packet with the destination IP address of the DNS server IP address;
    5. The encapsulated IP packet is transmitted to the Protocol unit of the data link layer;
    6. When sending in the ARP cache to query the relevant data, if not, send an ARP broadcast (containing the IP address to be queried, the host that received the broadcast to check their IP, the eligible host will contain its own MAC address of the ARP packets sent to the ARP broadcast host) request, waiting for the ARP response;
    7. After receiving the ARP response, the IP address is written to the ARP cache table with the information corresponding to the next hop MAC address of the route;
    8. After the cache is written, the destination MAC address is populated with the address of the next hop to be routed and forwarded as a data frame;
    9. Forwarding may be carried out several times;

The DNS request arrives at the Data Link Layer Protocol unit of the DNS server;

The Data Link Layer Protocol unit of the DNS server resolves the data frame, passing the internal IP packet to the Network Layer IP Protocol unit;

The IP protocol unit of the DNS server resolves the IP packet and transmits the internal UDP datagram to the Transport Layer UDP Protocol unit;

The UDP protocol unit of the DNS server resolves the received UDP datagram, passing the internal DNS message to the DNS service unit;

The DNS Service unit resolves the domain name to the corresponding IP address and generates a DNS response message;

The DNS response message->udp->ip->mac-> my host;

My host receives the data frame and->ip->udp-> the data frame to the browser;

Writes the result of the domain name resolution to the DNS cache table in the form of a domain name and IP address.

TCP connection to the destination host (three-time handshake) to the destination host to send TCP connection request messages;

The SYN flag bit in this TCP message is set to 1, which indicates the connection request;

The TCP packet is via IP (DNS)->mac (ARP)-------the destination host;

The destination host receives the data frame and responds to the request reply message through the IP->TCP,TCP Protocol Unit;

The SYN and ACK flags in this message are set to 1, indicating the connection request response;

This TCP message is via IP (DNS)->mac (ARP)----my host;

My host receives a data frame and responds to the request acknowledgement message via the IP->TCP,TCP Protocol Unit;

The TCP packet is via IP (DNS)->mac (ARP)-------the destination host;

The destination host receives the data frame, through the ip->tcp, the connection establishment completes.

Send and receive data (browser and destination host start HTTP access process)

The browser sends a GET method message (HTTP request) to the domain name;

The Get method message is via Tcp->ip (DNS)->mac (ARP), gateway-and-host;

The destination host receives the data frame, and the Ip->tcp->http,http Protocol unit responds to the HTTP protocol format to encapsulate the HTML form data (HTTP response); [Gets the host name that the client wants to access from the request information.] Get the web app that the client wants to access from the request information (the Web application refers to a program that provides browser access, referred to as a web app). Gets the Web resource that the client wants to access from the request information. (Web resources, i.e. various files, pictures, videos, text, etc.) read the Web application under the corresponding host, Web resources. Creates an HTTP response with the Read Web resource data. ]

This HTML data is via TCP->IP (DNS)->mac (ARP)---my host;

My host receives data frames, and the browser displays HTML content as a Web page via the Ip->tcp->http-> browser.

Disconnect TCP connection to destination host (four waves) TCP Connection Release Process

The browser sends a TCP connection end request message to the destination host, at which point the fin wait state is entered;

The FIN flag bit of this message is set to 1, which indicates the end of the request "first time";

TCP End Request Packet via IP (DNS)->mac (ARP)---gateway---host;

The destination host receives the data frame and responds to the end response message "second time" through the IP->TCP,TCP Protocol Unit;

The current only response, because the destination host may have data to be transmitted, not in a hurry to disconnect;

The ACK flag bit in the message is set to 1, indicating that the end request was received;

After the destination data has been sent out, the TCP connection end request message to my host is "the third time";

The FIN flag bit of this message is set to 1, which indicates the end request;

TCP End Request message via IP (DNS)->mac (ARP)-I host;

My host received a data frame, through the IP->TCP,TCP Protocol unit response to end the response message, at this time to enter the status of the wait, because do not believe that the network is reliable, if the destination host confiscated can also be re-issued;

The FIN flag bit in the message is set to 1, indicating the end response;

The TCP response message is "fourth time" through the IP (DNS)->mac (ARP), gateway-to-destination host;

Destination host closed connection;

After the time wait has ended, no reply has been received, stating that the purpose is closed properly and my host is also shutting down the connection.

Summarize:

URL the whole process of network transmission when visiting a website can be summed up as:

first find IP by domain name If there is no request for DNS in the cache server; Get IP after starting a three handshake with the destination host to establish TCP Connect, make HTTP after connection is established access, transmit and retrieve the content of the webpage; four waves with the destination host to disconnect TCP connection.

The whole process of accessing a Web page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.