“This is the 8th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021”

Hello everyone, I am quick-frozen fish 🐟, a front end of water system 💦, like colorful whistle 💐, continuous sand sculpture 🌲, I am a good brother of the next door Cold grass Whale, I just started to write an article. If you like my article, you can follow ➕ to like it, inject energy into me, and grow with me

Read this article 📖

1. You will get a full view of the web by typing the URL to the browser to display the content

2. Get a big picture view of computer networks

3. To understand the computer network from a macro perspective and build a knowledge system of computer network, Yu Yu will follow the new chapter by chapter

4. I am full of interest and hobbies in basic knowledge and cultivate my interest in computer

Preface 🌵

Learning computer network for a long time, I found that the computer network is a very interesting topic, but its knowledge broad and deep, through learning I find that many books are one part of the deep to explain, is to let a person lose interest, from the URL into the browser display picture would allow us to have a comprehensive understanding to the network from zero to one

Knowledge 📒

Generate an HTTP request message

  • When we enter a URL to display the page, the first step is of course to generate an HTTP request message

HTTP is hypertext Transfer Protocol, an application-layer protocol used to transfer web data over the Internet, just like the Chinese language we usually speak, this is the protocol.

Even if the agreement, according to what to the routine, to communicate.

  • Enter the URL to start the browser first parses the URL (Uniform Resource Identifier) to indicate the location of the resource on the network. www.baidu.com/dir/a.jpg HTTP: represents the transfer protocol similar to file protocol, FTP protocol and so on. This section represents the access method the browser should use. For example, HTTP is used to access the WEB server and FTP is used to access the FTP server. www.baidu.com: This part represents the domain name, is to take a small name to the IP address of this resource, convenient memory. /dir/a.jpg: This part indicates which file to access on which level of the target computer directory, such as /dir/ omit the file name, the default is index.html

    In general, URL is a combination of access protocol + server domain name + data source path name. The purpose is to express the specific location of a resource in the network and how to access it.

  • When the browser has parsed the URL, it knows which target resource on which computer on which network we want to access

  • The HTTP protocol defines the message content and steps for interaction between a client and a server.

  • The request message is basically what to do and what to do

  • HTTP is essentially an application layer protocol, we can use this protocol to relax the request to the Web server, the server will also use HTTP protocol to respond to our request, just like I communicate with you in Chinese, you of course back to me in Chinese, we know what to say, the meaning is the same.

  • CGI programmatically defines the rules by which a Web server program calls other programs. We can either send requests for resources or execute programs on a Web server

  • The main HTTP method GET: GET POST: the customer side sends data to the server. HEAD: This method is similar to GET except that it only returns the HTTP header and does not return the data content. It is used to obtain attributes such as the last update time of the file.

    OPTIONS: OPTIONS for notifying or querying communication

    PUT: replaces the file on the server specified by the URL. If the file does not exist, create DELETE: deletes TRACE: returns the request line and request header received by the server to the client, which is used to check for rewriting requests in the environment where proxies are used. CONNETCT: Method used when transmitting encrypted messages using a proxy

After the URL is parsed and you know where to go and what to do, it’s time to generate HTTP request messages, which are strictly regulated.

You can follow this diagram roughly, in this format, which is our HTTP request/response message

It’s like when we were at war we had to agree on some Morse code, and it was the same thing to say what we wanted to say, and we had to follow that code, otherwise we didn’t know what we were talking about.

With the HTTP request message generated, we need to send our message out, so it’s time to query the DNS server for the IP address of the Web server.

Query the IP address of the Web server from the DNS server

With HTTP request messages, of course we need to send our messages out. The first thing we need is something like a DNS server to query the IP address of our target Web server

  • An IP address is on the Internet, we mean a machine connected to the Internet, a machine connected to the Internet, its address on the Internet. Just like the number of the building in our community, you can be found through this address.

  • A DNS server is a computer with a table that holds the mapping between domain names and IP addresses

  • Why do you need a domain name when you have an IP address? Because it’s easy to remember. Domain names are usually semantic

  • Who queries the IP address corresponding to the domain name? The browser does not have this function, but it can call the DNS module in the Socket of the operating system to help us query the IP address corresponding to the domain name

  • We just need to delegate the domain name to the operating system, and then it will help us to query the IP address and save it to the specified memory address, we just need to fetch the IP address from the corresponding memory address to complete the DNS resolution

  • The parser in the operating system calls the protocol stack inside the operating system to send UDP messages to get the IP address

  • Protocol stack: The internal network control software of the operating system, also called “protocol driver”, “TCP/IP” driver, etc.

  • Which server does the protocol stack use to find the IP address corresponding to the domain name? Generally, it first obtains the IP address from the internal cache of the browser, if not, it obtains the corresponding information from the operating system cache, if not, it obtains the corresponding information from the default DNS server set above

DNS server relay around the world

Basic work of the DNS server

There’s a table in the DNS server

The message sent to DNS contains three types of information

  • The domain name
  • Class is now all IN
  • MX indicates that the domain name corresponds to the mail server. CNAME indicates the alias name of the domain name. Check the PTR type of the domain name based on the IP address and the NS type of the DNS server IP address

Generally speaking, the basic work of the DNS server is to search for related records according to the domain name and record type to be queried, and return a response message to the client

Because one DNS server cannot store all records, the DNS server needs to be layered

When querying the IP address corresponding to a domain name, we usually visit the nearest DNS server first (the DNS server address specified in TPC/IP Settings on the client). If there is no record on the server, we visit the root DNS server. The root DNS server will return its next-level DNS server IP to the nearest DNS server based on the IP address, and so on and so forth, and we can look it up, but that’s inefficient.

In fact, one DNS server can manage information of multiple domains. The DNS server has the cache function and can remember the previously queried domain name.

Delegate the protocol stack to send messages

Now that we have the HTTP request message, and the IP address for the domain name, we need to delegate our protocol stack to send our message.

When the protocol stack receives the delegate, it calls the program components in the specified order to complete the message delivery. This is our TCP/IP stack

First we need to establish a TCP connection, that is, to create a socket, socket is the equivalent of the daily life of the socket, installed at both ends of the network socket, and then the TCP connection, that is, a virtual pipe connected to the two ends of the socket, so that you can communicate.

The key to establishing the pipe lies in the data outlets at each end of the pipe, called sockets. We need to create the socket first and then connect the socket to form a pipe.

Generally good server will create a socket for connection, when a client needs to send a message, the client will create a socket, then the socket to connect to the server, once the connection is established, we can send and receive data, data transceiver is completed, we can disconnect, generally by, the socket will be removed.

The general process is

1. Create a socket

2. Pipe to a socket on the server (Connection phase)

3. Sending and receiving data (communication stage)

4. Disconnect the pipe and remove the socket (disconnect phase)

At each stage the Socket library calls different program components to perform different functions.

Create a socket

Creating a socket is when the protocol stack creates a socket on the current computer and stores the descriptor of the socket in memory. This descriptor is something inside the computer that identifies the socket

Establish a connection

Using the created socket and calling the program component Connet to establish the connection, we need to tell Connet several parameters, the SERVER IP address and port number (IP address and port number are used to identify the socket between the server and the client).

The message

After establishing the connection, call write in the program component to send data and read to receive data

disconnect

Finally, disconnect and delete the socket

Conclusion 🍁

  • Parsing the URL
  • Generate an HTTP request message
  • The DNS
  • Create a socket
  • Establish a connection
  • To send and receive messages
  • disconnect

References 📚

  • How the Web Is Connected
  • Diagram of TCP/IP
  • Illustrated HTTP
  • Computer Networking from top to Bottom
  • Lingo’s illustrated computer network

Conclusion 🌞

So I “from the URL to the web page 🌏” build a knowledge of computer network system – 02 will be over, actually very simple, the purpose of the article is the summary of daily work and output, output some feel useful to everybody, cuisine is not is not important, but love 🔥, hope everyone can like my articles, I am really very attentively in writing, Also hope to know more like-minded friends through this article, if you also like to toss, welcome to add my friend, sand sculpture, progress together.

Making 🤖 : sudongyu

Personal blog 👨💻: Frozen fish blog

Vx 👦 : sudongyuer

Write in the last

Guys, if you like my words, give 🐟🐟 a thumbs up 👍 or follow ➕ to support me the most.

Add me on wechat: Sudongyuer, invite you into the group and learning the front together, become a better engineer ~ (group of qr code here – > front to go to bed early, qr code has expired, see the links to the boiling point in the comments, I will put the latest qr code in the comments section, of course, can also add me WeChat I pull you into the group, after all, I also am interesting front end, I also not bad 🌟 ~