Illustration: What happened to the sentence "I like you" on the Internet

Write in front

Speaking of computer networks, I must give everyone the impression that they are protocols. If you learn them, you can forget them. In fact, I am the same, but its importance is very worth learning. Whether you are learning Java, Python, C++, etc. , this network course is all It is necessary to learn. Recently, through reading some books, articles, etc., I have made a systematic summary of the calculation network. I hope it can help everyone. It will continue to be updated in the future.

Computer network architecture

Before explaining the network system structure, let's talk about a question. Why should the network system structure be managed by layers? What are the benefits of layering? In fact, layering is for good management. Each layer only needs to be responsible for the affairs of the layer, and only one interface needs to be provided between layers. This not only improves scalability, but also reduces maintenance costs. We have three common architectures, namely OSI architecture, TCP/IP architecture and five-tier architecture.

So the question is, there are so many architectures, which one is better? First, let me talk about the OSI architecture . The architecture is a standard developed by the International Organization for Standardization. It can only be said that they are quite detailed, but too Complex and impractical. Let’s talk about the TCP/IP architecture . In order to interconnect different network interfaces, the network interface layer does not specify any specific content, so it is not suitable for learning, so a combination of OSI and TCP/IP is here. ——Five - tier system structure , he combines the advantages of the two. Before explaining the five-layer system structure, let's explain the three commonly used exchange methods in the network.

Exchange method

First of all, we need to understand how the communication between computers realizes data exchange. In fact, there are three common exchange methods. 1. Circuit switching , 2. Message switching , and 3. Packet switching .

Speaking of circuit switching, we must first talk about telephones. If 2 telephones need to communicate, one telephone line is needed, while 5 telephones need 20 telephone lines for pairwise communication. With the increase of telephone sets, telephone lines It increases exponentially (n*(n-1)/2). It is for this reason that circuit switching has been introduced to solve this problem.

The forwarding is carried out through a telephone exchange, which reduces a lot of telephone lines. Of course, not all calls are forwarded through one switch. In fact, calls are made through the cooperation of multiple switches.

Among them, circuit switching requires three processes. The first is to establish a connection, followed by data transmission, and finally to release the connection (the switches are connected by trunk lines and are public). A seemingly simple call, but experienced a lot of progress in the middle, so I can't easily hang up when I hear the ringing.

For message exchange , there is no need to establish a connection. It is directly sent to the switch of the neighboring node in the form of a message until the destination node. The destination node is forwarded by looking up the table. The size of the message is unlimited, so each The node has a larger cache space.

However, packet switching can just solve the problem of large buffer space required by packet switching. A message is forwarded in packets, so that each node does not need too much buffer space, and after grouping, data can be transmitted through different routes. To improve transmission efficiency, fish and bear's paws cannot have both, and it also introduces a new problem, that is, when a message is grouped, how to splice it after receiving it, so it is necessary to add a header identifier to the group. In this way, The amount of data transmitted has increased, but relative to its advantages, this disadvantage is still acceptable.

send messages

Three exchange methods are introduced. Let’s talk about the highlight below, that is, A sends a sentence "I like you" to B as an example , A represents the browser, and B represents the server. When A sends a request, it first passes through the application layer. The application layer encapsulates the information into an HTTP request message and delivers it to the transport layer.

The above picture is the general format of HTTP request message. The format when transmitting in our Internet is generally as follows.

The transport layer adds the TCP header , encapsulates it into a TCP message segment (which can be used to distinguish application processes and achieve reliable transmission), and hand it over to the network layer.

The network layer adds an IP header to the TCP message segment , encapsulates it into an IP datagram (which can be transmitted on the Internet, that is, it is forwarded by a router), and handed over to the data link layer.

Add the data link layer header and trailer, it encapsulates the frame (the destination host may be received, and check), the data link layer to the physical layer frame.

The physical layer regards the frame as a bit stream, adds a preamble, and then converts it into a corresponding signal for transmission on the transmission medium.

When encountering a router, the physical layer first removes the preamble and delivers it to the data link layer. The data link layer removes the header and tail of the frame and delivers it to the network layer. The network layer parses the header of the IP datagram. Analyze its destination address and forward it. The network layer delivers the IP datagram to the data link layer. The data link layer adds headers and trailers and encapsulates them into frames. The data link layer passes the frames to the physical layer, and the physical layer The frame is treated as a bit stream, and a preamble is added.

Then it arrives at the server, and the server starts to parse from the physical layer. First remove the preamble, then remove the header and tail, then remove the IP header, then remove the TCP header, and finally receive the HTTP request message at the application layer.

The application layer parses the HTTP request message, and then sends a response message, the message content: we are not suitable(The process is similar to the sending process).

After all, one person will carry everything. . .
References
[1] Computer network top-down method. Translated by Chen Ming. Machinery Industry Press
[2] Huoke University Teachers. Computer Network Micro Classroom. Bilibili

Write at the back

Here, through the sentence "I like you", I describe the process of data transmission on the network. Some details will be introduced in the following chapters. See you next time~

Guess you like

Origin blog.csdn.net/HeZhiYing_/article/details/113822686