This article mainly introduces the overview of the network protocol: physical layer, link layer, network layer, transport layer, and application layer. This article uses the mailman and post office in life to help understand complex network protocols. It is easy to understand and humorous. Is a rare good article, need friends can refer to
The transmission of signals always meets a certain protocol.For example, the Wolf is placed on the Great Wall because people have pre-set the physical signal of Wolf Smoke to represent the abstract signal of “enemies invasion”.Such a "wolf smoke = enemy invasion" is a simple agreement.The protocol can be more complex, such as Morse Code, using a combination of short and long signals to represent different English alphabets.For example, SOS (***---***, * for short signals, - for long signals).This "***= S, ---=O" is the agreement of the Morse code.However, one more level, people will know SOS is for help information, because we have "SOS = help" agreement exists in the mind.So "***---***=SOS=help" is a layered communication system consisting of two protocols. Telegraph using Morse Code Communication between computers also follows different levels of protocols to achieve computer communications.
The so-called physical layer refers to physical media such as optical fibers, cables, or electromagnetic waves.These media can transmit physical signals such as brightness, voltage, or amplitude.For digital applications, we only need two physical signals to represent 0 and 1, respectively. For example, 1 is represented by a high voltage and 0 is a low voltage, which constitutes a simple physical layer protocol.For a medium, the computer can have a corresponding interface for receiving physical signals and interpreting it as a 0/1 sequence.
At the link layer, information is transmitted in units of frames.The so-called frame is a limited 0/1 sequence.The function of the link layer protocol is to identify the frames included in the 0/1 sequence.For example, the start and end of a frame are identified based on a certain 0/1 combination.In the frame, there is a source (SRC) and a destination (Destination, DST), as well as a frame check sequence capable of detecting an error.Of course, the most important and important part of a frame is the data to be transmitted.These data are often consistent with higher-level protocols for use by the upper layers of the network.In conjunction with data, there is also data type information in the frame.The link layer protocol does not care what exactly the data contains.The frame is like an envelope, wrapping the data. Ethernet and WiFi are the most common link layer protocols.Through the link layer protocol, we can establish a local Ethernet or WiFi LAN and let two computers in the same local area network communicate.The link layer is like a postman in a community. He knows everyone in the community.Everyone in the community can give him a letter (frame) for him to send to another family in the same community. Link layer: community postman
How do different communities communicate? In other words, how does one computer on WiFi communicate with another computer on Ethernet?We need a "middleman."This "middleman" must have the following features:
- 1. Receive and send 0/1 sequence from the physical layer on both networks,
- 2. Can understand the frame format of both networks at the same time.A router is a "translator" for this purpose.
A router has multiple Network Interface Controllers (NICs). Each NIC can access multiple networks and understand the corresponding link layer protocol.When a frame is routed to another network, the route reads the frame's information and overwrites it for transmission to another network.So the router is like a post office with branches in both communities.A postman in a community sends the letter to the post office branch of the community, and the post office passes the branch in another area to the postman in another community, and the postman in another community finally sends it to the destination. The entire communication process of WiFi and Ethernet connected via routing is as follows:
- WiFi on Computer 1 -> Routing WiFi Interface -> Routing Ethernet Interface -> Computer on Ethernet 2
(Blue indicates WiFi network, green indicates Ethernet network) At the link layer, we can only record two addresses, SRC and DST, in one frame.The above process requires four addresses (Computer 1, WiFi, Ethernet, Computer 2).Obviously, link-level protocols alone cannot meet our needs.Because the link layer protocol was developed earlier, we could not change the link layer protocol. We could only work on the link layer data payload, that is, letter paper.The IP protocol came into being. Computer 1, router and computer 2 must understand the IP protocol. When the computer 1 writes, it writes the letter's starting address and final address (not the envelope) at the beginning of the letter, and writes on the envelope to go to the post office.The WiFi network postman sent the letter to the post office. At the post office, the letter was opened and the post office staff saw the final address. The letter was then packaged in a new envelope, written at the departure post office, arrived at the computer 2, and handed over to the Ethernet postman, Ethernet. The postman sent to computer 2. (The IP protocol also requires the writing of information such as checksums and traffic conditions to protect the stability of communications.) Transferred to the post office at the link level, postmen are only responsible for sending letters in the community, so the address on the envelope is always "the third house on the first street" or the "small house at the corner of the central crossroads" The address description, which brings inconvenience to the work of the post office.Therefore, the post office requires that the address written on the letter must be a "ZIP" that complies with official regulations, that is, the IP address.This address is numbered for each house in the world (zip code).When the letter arrives at the post office, the post office can find the corresponding address description according to the postal code, so that the information on the envelope can be successfully rewritten. Each post office generally connects multiple communities, and a community can also have multiple post offices leading to different communities.Sometimes a letter needs to be handed over through multiple post offices before it can finally reach its destination. This process is called route.The post office connected the separated local area network to the internet and eventually formed a global coverage network.
The above three-tier protocol allows different computers to communicate with each other.However, there are actually many processes in the computer, and each process may have communication needs.It's like there are several people (processes) in a house. How can one send letters to someone?In accordance with the same logic before, we need to write new information on letterhead, such as the name of the recipient, before sending the letter.Therefore, the transport layer writes new "recipient" information on the stationery blank.Each house will be equipped with an administrator (Transport Layer Protocol).The administrator took the letter from the postman and sent the letter to someone in the house according to the "addressee." Administrators Transport layer protocols, such as TCP and UDP, use a port number to identify the recipient (a process).When writing a letter, we wrote the port of the destination.When the letter reaches the administrator of the destination, he will identify the port number according to the transport layer protocol and send the letter to different people. The TCP and UDP protocols are two different transport layer protocols.The UDP protocol is similar to our letter exchange process.The TCP protocol is like the frequent communication between two lovers.A little lover has to express so much emotion that he has written several letters in a row.The other party must arrange these letters in order to understand the full meaning.The TCP protocol also controls network traffic and other functions.
With the above layers of protocols, we can already communicate between any two people (processes).However, everyone actually engages in different industries.Some are lawyers and some are diplomats.For example, communications between lawyers use strict lawyer terms to avoid disputes.For another example, communication between diplomats must meet certain diplomatic formats so as to avoid diplomatic misunderstandings.For another example, spies send encrypted information through a secret code.The application layer protocol is a further specification of the content of the letter.Application layer protocols include the HTTP protocol for Web browsing, the FTP protocol for transferring files, IMAP for Email, and so on.
to sum up
Over the network layer, we abstracted from the original 0/1 sequence: the concept of local address (postman), zip code (post office), recipient (administrator), and recipient industry (term specification).These concepts ultimately allow two processes on the Internet that are distributed across two computers to communicate with each other. The writer must encapsulate the entire envelope according to the agreements of all layers; and the recipients open the envelope in reverse order.The whole process is readable information -> binary -> readable information.Computers can only understand and transmit 0/1 sequences, while computer users always input and output readable information. The network protocol guarantees the integrity of the readable information throughout the conversion and transmission process. The computer protocol itself has more details that need to be deepened.This article only describes the functions implemented by various levels from a hierarchical perspective.
Originally transferred from script home, the ultimate source is unknown.This article links to https://wangbaiyuan.cn/en/the-article-summarizes-network-level-2.html. If you feel that this article is useful to you, you can click on "Sponsored Author" below the article to reward the author!