Simple understanding of computer network (easy to understand)

1. Computer network concept

  What is a computer network? Many computers will appear in my mind. That is to say, in my cognition, it is just computers connected together to form a network.
Insert picture description here

  These computers can communicate with each other in this network -share resources and transmit information. Just like a web woven by a spider, once a prey falls into the web, the spider can obtain the location information of the prey.
Insert picture description here

2. Computer network hierarchical structure

  So how does the device communicate with each other? This process is very complicated. For example, to send a file between two devices, the
Insert picture description here
  left host must send a file to the right host. This file must pass through a link before it can be sent. So it is necessary to lay the link. Just lay the link. It's complicated. With the link, a series of work must be done before sending.
  For example:
(1) The computer sending the communication must activate the data communication path. Activation is to send some commands to ensure that my files can be sent and received correctly. This step is to clean up the communication road and make sure it can communicate.
(2) Tell the network how to identify the destination host. In other words, I sent the file and sent it to the cloud. You have to tell who to send it to.
(3) It is also necessary to find out whether the destination host is turned on and whether the network connection is normal...

  These processes are very complicated, so a layered method is adopted in the computer network to decompose these complicated problems into several levels. So there are several kinds of computer network hierarchical structures. The 7-layer OSI reference model and the 4-layer TCP/IP reference model . The OSI reference model is a legal standard, but the general standard is the TCP/IP reference model. Summarizing the advantages and disadvantages of these two reference models, a 5-layer architecture is obtained.

2.1 OSI reference model, TCP/IP reference model and commonly used protocols

Insert picture description here
 ; Divide the complex process into these levels, what is each level and what is the corresponding function? What are these agreements?

2.2 Basic concepts and functions of each level

2.2.1 Application layer

  The application layer is the top layer of the computer network's hierarchical structure , which is the closest to the host or the closest to the user . That is to say, this level is user-oriented; it is the interactive interface between the user and the network; it can be understood and applied by the user.
Insert picture description here
  So what is the application layer, and what is in it? To put it insecurely and correctly: The application layer is all programs that can interact with users to generate network traffic. What is the program that generates network traffic? To put it simply, it is a program that can only be used when connected to the Internet. For example, QQ, the mailbox that can send emails.
Insert picture description here
Insert picture description here
  So here we can see that the typical application layer can provide:
    file transfer,
    email,
    World Wide Web

2.2.2 Presentation layer

  According to the literal meaning, the presentation layer is mainly responsible for what is finally displayed on the device (such as the screen).
Insert picture description here

Strictly speaking, it is used to deal with the representation of information exchanged in two communication systems, usually the processing of grammar and semantics.
  The presentation layer is mainly responsible for what is finally presented on the device. For example, if I want to send a picture to Zhang San, that picture must be displayed on the screen of Zhang San's device. We know that all data is composed of 0 and 1 in the computer. Then sending a picture is essentially sending a string of 1s and 0s. The picture must be encoded into a binary number string when sending, and the binary number string must be translated into a picture when receiving. Therefore, an important function of the presentation layer is the change of data format (data decoding and encoding) . That is, the translator in life.

2.2.3 Session layer

  Conversation refers to talk; dialogue. The conversation between the user and the system can be called communication. For example, when I enter the browser Baidu web page to search for information, a conversation is established. Then this communication process is called a conversation.
Insert picture description here

  In computer terms, a session refers to the process by which an end user communicates with an interactive system. Then the work to be completed by the session layer is to provide the presentation layer entity/user process to establish a connection and transfer data in an orderly manner on the connection.

2.2.4 Transport layer

  In fact, the real entity that communicates in a computer network is a process located in the hosts at both ends of the communication . A process is a running program. The transport layer is responsible for the communication between the two processes in the host, that is, end-to-end communication. End-to-end communication-communication between processes in two hosts. Each process will be identified by a number, this number is the port number, so it is called end-to-end communication.
Insert picture description here
  Functions of the transport layer:

    Reliable transmission, unreliable transmission,
    error control,
    flow control,
    multiplexing and demultiplexing

2.2.5 Network layer

  The main task of the network layer is to transmit packets from the source to the destination, and provide communication services (between the host and the host) for different hosts on the packet switching network. The unit of transmission is a datagram. Grouping is to cut the datagram into multiple parts, the relationship between the whole and the part.

Insert picture description here
The function of the network layer:
    routing and packet forwarding
    heterogeneous network interconnection (in different network structures-heterogeneous)
    congestion control

2.2.6 Data Link Layer

  The main task is to assemble datagrams from the network layer into frames (frames are the transmission unit of the data link layer), and then are responsible for connecting directly from one node (host, router) to another physical link through a link Adjacent nodes transmit datagrams.
Insert picture description here
The function of the data link layer:
    to provide connection services for the network layer,
    link management
    , framing,
    flow control,
    error control

2.2.7 Physical layer

  The problem to be solved by the physical layer is: how to transmit the data bit stream on the transmission medium connecting various computers.
Insert picture description here

3. Several important agreements

  The basic concepts and functions of computer network layering and each layering have been introduced above. So how exactly can those functions be realized-the protocol. A protocol is a set of rules, standards, or agreements established for data exchange in a computer network. Everyone has to abide by the established agreement. If you play in a certain circle, you have to abide by the rules of that circle. In other words, these protocols are necessary for communication. For example, the reason why we can communicate together is because we use the same language, and this language is the agreement made by the predecessors.
Insert picture description here
  The content of the computer network is intricate and complicated. I will only select some of the more important protocols and some of the more common concepts to explain my understanding.

3.1 ip address

  Suddenly, I didn't want to work hard. I wanted to find a rich woman, so I sent a message to contact her. How does the network accurately send my information to her-through the ip address, then what is the ip address? The ip address consists of two parts, the network address and the host address. The network address indicates which network it belongs to on the Internet, and the host address indicates which host in the network it belongs to. It is equivalent to looking for someone, where is ta (network address), and what is called (host number).
Insert picture description here

3.2 TCP protocol

  Transmission Control Protocol (TCP, Transmission Control Protocol) is a connection-oriented, reliable, byte stream-based transport layer communication protocol.

To put it bluntly, TCP is a transmission protocol, just like the HTTP protocol, the purpose of HTTP is to specify what kind of message the client may send to the server and what kind of response it gets, and the purpose of TCP is to ensure the reliability of data transmission , I will give you a data packet, you must receive it, if not, then I will re-send it to you, until I give you up over time.

HTTP is built on top of TCP. After you establish a TCP connection, the data transmitted on it uses the HTTP protocol.

  So how does TCP ensure the reliability of data transmission? Adopt reliable communication connection and introduce error detection, message control and retransmission mechanism.

3.2.1 Three-way handshake

  TCP provides a reliable communication connection for applications-using a three-way handshake protocol. The three-way handshake protocol refers to three interactions between the server and the client during the preparation phase of sending data.

The first handshake: the client sends a SYN packet to the server, and enters the SYN_SEND state, waiting for the server to confirm;

The second handshake: the server receives the SYN packet and confirms it, and at the same time sends a SYN+ACK packet by itself, at this time the server enters the SYN_RECV state

The third handshake: the client receives the SYN_ACK packet from the server, and sends an acknowledgment packet ACK to the server. After the packet is sent, the client and server enter the established state and complete the three-way handshake

After the connection is established, the client and server begin safe and reliable data transmission.

Insert picture description here

To put it simply:

Client: I want to talk to you, can you hear;
Server: I can hear; And I want to talk to you, can you hear;
Client: I can hear too.

Start talking to each other
...

3.2.2 Three mechanisms

① Error detection: that is, the introduction of checksum. There is a space occupying 16 bits in the header of TCP to place the result of the checksum. When the transport layer of the source host starts to receive a piece of data passed down from the application process, it will encapsulate it into a message segment, plus at least 20 bytes of header. At the same time, the header of the message segment, the data and the pseudo header are calculated and added to the header according to the form of the inverted code sum. After being transmitted to the transport layer of the destination host, this checksum will be calculated to check whether there is a bit error.

②Control message: When a bit error is detected, it is necessary to feed back the transmission information so that it can decide whether to retransmit according to the return. Generally, in theory, there are two types of feedback ACK, which is a positive feedback. In TCP, the feedback information is the next bit of the last byte sequence number in the received sub-allow. A kind of negative feedback, but in order to reduce the number of injected packets in the network and reduce the burden, it is replaced by sending the confirmation message of the previous packet to indicate that the current packet is not received correctly.

③Retransmission: If the receiver receives a replaced ACK or the confirmation of the previous packet, it means to send the share again.

Guess you like

Origin blog.csdn.net/qq_43403759/article/details/114075025