Simple and easy to understand OSI Layer-7 Mode

Source: Internet
Author: User

The OSI Layer-7 model is easy to understand and can't be remembered many times. I read it again today and found that it is more logical and easier to remember to look at the problem from the perspective of historical deduction. This article is not necessarily rigorous and may be flawed. It mainly serves to help people with poor memory. In general, the OSI model is developed from the bottom layer to the top layer. This model was first introduced because Americans have the need to communicate with each other. Requirement 1: the first problem scientists need to solve is how to communicate with each other. Specifically, one server sends some bitstreams and the other server receives them. As a result, scientists invented the physical layer, which mainly defines physical equipment standards, such as the interface type of the network cable, the interface type of the optical fiber, and the transmission rate of various transmission media. Its main function is to transmit the bit stream (that is, the conversion from 1, 0 to the current strength for transmission, after reaching the destination is converted to 1, 0, that is, the digital-to-analog conversion and digital-to-analog conversion ). The data at this layer is called bits. Requirement 2: Now I can send data streams through wires, but I also want to transmit data through radio waves and other media. Then I want to ensure that the bit stream transmitted in the past is correct and the error correction function is required. As a result, the data link layer was invented, which defined how to format data for transmission and how to control access to physical media. This layer usually provides error detection and correction to ensure reliable data transmission. Requirement 3: Now I can send the correct bit stream data to another computer, but it may take a long time when I send a large amount of data, such as a video format, the network may be interrupted many times (in fact, even with the physical layer and data link layer, the network is still interrupted frequently, but the Interruption Duration is millisecond-level ). So, I also need to ensure the accuracy of the transfer of a large number of files. So I want to encapsulate the sent data. Just like sending parcels, sending them one by one. As a result, the transmission layer (the transport layer in the OSI model is on the network layer), such as TCP, is used to send a large amount of data, and I sent 10 thousand packets out, the other computer will tell me if I have received 10 thousand packets. If 3 packets are missing, it will tell me 1001,234,888 8 packets are lost, and I will send it again. In this way, the other party can ensure that the video is fully received. For example, UDP is used to send a small amount of data. I usually send 20 packets without packet loss. Therefore, no matter how many packets you receive. In multiplayer interactive games, UDP is often used, because it is usually simple information and broadcast is required. If you use TCP, the efficiency is very low, because it will keep telling the host that I have received 20 packets, or that I have received 18 packets, and then send me two more! If there are 10 thousand computers doing this at the same time, using TCP will reduce the efficiency. It would be better to use UDP. Even if the host sends it out, you can just drop a few packets and get stuck. Forget it, you can update the package again next time. TCP is a protocol that binds IP addresses and ports. The following describes the IP protocol. Requirement 4: the transport layer only solves the packaging problem. But if I have multiple computers, how can I find the one I want to send? Or, A sends A message to F, which goes through B, C, D, and E, but there are still many nodes in the middle, such as K. J.Z. Y. How can I select the optimal path? This is what routing is to do. Therefore, the network layer was invented. That is, the functions implemented by routers and switches with addressing functions. This layer defines IP addresses, which are addressed by IP addresses. The IP protocol is generated. Requirement 5: now we have ensured that the encapsulated information is correctly sent to the right computer. But is user-level experience good? Do I have to call TCP to package each time, and then call the IP protocol to find the route and send it by myself? Of course not, so we need to establish an automatic packet receiving and automatic addressing function. Therefore, the Session Layer was invented. The Session Layer is used to establish and manage communications between applications. Requirement 6: Now I can ensure that the application can automatically send and receive packets and address them. But I want to use Linux to send a package to window. The two systems have different syntaxes. Just like the installation package, exe cannot be used in linux, and shell cannot run directly in windows. Therefore, the presentation layer is required to help us solve the communication syntax problem between different systems. Requirement 7: OK. Now all the necessary conditions are ready. We can write an android program and a web program to implement the requirements. Supplement: Socket: this is not a protocol, but a communication model. In fact, it was originally invented by the UC Berkeley Software Institute, BSD for short. It is mainly used for communication between two processes of a computer, and then used for inter-process communication between two computers. Therefore, it can be simply understood as inter-process communication, not anything advanced. The main task is not to send A packet: send A request packet to A bound port (so we often access this address 182.13.15.16: 1235,1235 is the port); Receive B's permission; then, send the message. After sending the message, tell B to disconnect the link. After receiving the message, immediately disconnect the message and send the disconnected message to B. B. Collect packets: bind the port and IP address. Then listen on this port. receive A request, send the request to A, and prepare for receiving the request. The main task is to clear the cache and wait for receiving new data; then, the system receives the request. Once the request is disconnected, the system can continue to listen for other requests. It can be seen that Socket is actually an I/O operation. Socket is not limited to network communication. In network communication, it covers the network layer, transmission layer, Session Layer, presentation layer, and application layer. In fact, this does not need to be noted because IP addresses and ports are used for Socket communication, only the two indicate that it uses the network layer and the transmission layer; and it ignores the system differences of communication between multiple computers, so it involves the presentation layer; generally, the Socket is based on an application, therefore, the session layer and application layer are involved.

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.