OSI seven-layer model and TCP/IP five-layer model

write picture description here

The process of communication between two hosts, from the sender (hereinafter referred to as A) to the receiver (hereinafter referred to as B), belongs to the encapsulation from layer 7 (application layer) -> layer 1 (physical layer), and then transmitted to the remote end, and then from 1 Layer (physical layer) -> 7 layer (application layer) decapsulation process.
1. When A opens the QQ software, it will reach the application layer; because the software will mobilize the underlying hardware of the machine according to your operation.
2. When A enters information into the chat window of the QQ software, and after sending it, QQ will save the information in the local chat record file MSGEX.db (usually saved in the QQ directory with your QQ number as the folder) . Encoding/saving some kind of information in a certain format, this can be understood as the presentation layer.
3. When A opens the chat window with B, enters information, and presses the "Enter" button, the user's operation is over, and the rest is the machine's own operation. Before the actual transmission, QQ will first establish a session connection between A and B, and then really start to transmit information/data (you can understand the transmission file understanding: you send a file to the other party, and you have to wait for the other party to press the receive button before the session is established, and then transmission.) This is the session layer.
4. After the session is established, the information sent by A will be cut into pieces, such as “Have you eaten?” The transport layer chops this sentence into 6 data segments of "you", "eat", "eat", "rice", "no" and "yes", mark the port number to be used, and then prepare to send it out.
5. After connecting to the next layer, the information has not yet been sent. At this time, routing is performed at the network layer. It can be understood that, when going out from home A, you can go through one of the three networks of "Unicom", "Telecom" and "Mobile". Go to B's house. The network layer is responsible for route selection according to the routing protocol (based on the methodologies such as link quality, bandwidth, and overhead). Assuming that 2 items are selected at the end, A->Unicom->B may send 3 data segments of "you", "eat", and "have", and A->Telecom->B send 3 data segments of "rice", "no" and "yes" data segment. After routing, this layer should mark the IP packet header. The main content of the packet header is the source IP address, destination IP address, and what protocol is used. The source and destination IP are equivalent to the address and zip code of the sending and receiving when you send the letter, marking the sender and receiver. The agreement is equivalent to what language the letter is written in. (Only ensure that the two terminals use the same language to ensure communication, otherwise you write to aunt in English, how can aunt understand it?)
6. Then go to the data link layer. The data link layer is mainly responsible for the same communication within a subnet. For example, if A and B are connected to the same layer 2 switch, they belong to the same subnet, so the communication room of the data frame does not need to pass through the network layer (ie, a layer 3 switch or router), and passes directly on the layer 2 switch. . This layer is marked with the frame header of the MAC address. For the above communication process, the data frame is marked with the MAC of the machine of A and the MAC of the gateway of A. This layer of work is done.
7. The last layer is the last layer. After the above-mentioned slicing and labeling of each layer of 6 data frames, the physical layer translates the bit stream represented by 6 paragraphs 0 and 1 of the text, and then transmits it through optical fibers and copper cables. 8. When the bit stream is transmitted to the remote end, then the machine of B can run in the reverse direction according to the above steps 1~7 (that is, from the physical layer to the application layer). It is to read the labels layer by layer, transmit them to the corresponding objects marked by the labels, then remove the labels, and then read the labels of the previous layer, until the application program of B can finally read the data input by A to the application program.

write picture description here
The computer network with the five-layer model of the TCP/IP protocol first appeared. The hardware interface implements the "physical layer" and the "data link layer", and the TCP/IP protocol stack in the operating system kernel implements the "network layer" and "transport layer". All applications relying on the TCP/IP protocol stack implement the "application layer" in a broad sense. This "application layer" in a broad sense not only implements session ID, heartbeat keepalive, but also implements functions such as text, pictures, audio, video, Different representations of files. Later, there was the OSI seven-layer reference model with TCP/IP as the real material. It is hoped that the "session layer" and "presentation layer" will be separated from the application layer in a broad sense, but these two layers are difficult to maintain in practical applications. Unification, applications usually choose different encryption and decryption methods, different semantics and timing, and it is meaningless to talk about reused things as part of the protocol, so the functions of these two layers are handed over to application developers as the application layer. Part of the function development is more appropriate.
write picture description here
Different devices work at each layer, commonly used switches work at the data link layer, and general routers work at the network layer.
write picture description here
The protocols implemented by each layer are also different, that is, the services of each layer are also different.

(Security layer)
As a layer that provides secure encryption services, many people have used it, but no one has ever wanted to divide the hierarchy. Its name is SSL/TLS. With its addition, we can use TCP/IP five layers. The structure is regarded as six layers:
application layer,
security layer (TLS),
transport layer (TCP/UDP),
network layer (IP),
data link layer (ppp),
physical layer,
with the services provided by the security layer, HTTP/SMTP/ FTP, you can add an S (Security) after its name, such as HTTPS. In fact, there is no HTTPS protocol in this world, only the HTTP protocol. Adding the suffix of S just tells everyone that HTTP uses a six-layer structure. With SSL /TLS security protection.

This article refers to a number of network-related articles, combined with my own understanding.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325996061&siteId=291194637