Author: vamei Source: http://www.cnblogs.com/vamei welcome reprint, please also keep this statement. Thank you!
The signal transmission must always meet certain requirements.Protocol). For example, the Great Wall is filled with Wolf smoke because the physical signal of the wolf smoke has been preset to represent the abstract signal of "enemy intrusion. Such a"Langyan = enemy intrusion"Is a simple protocol. The protocol can be more complex. For example, the Morse code uses a combination of short signals and long message numbers to represent different English letters. For example, SOS (*** --- ***, * represents a short signal, and-represents a long message number ). This way"*** = S, --- = O"It is the Protocol stipulated by the moles code. However, on the next layer, people will know that SOS is the help information because we have"SOS = distress"This protocol is in my mind. Therefore, "*** --- *** = SOS = distress" is a hierarchical communication system composed of two protocols.
An electric reporter using the Morse code
Communication between computers must also follow different protocols to implement computer communication.
Physical Layer)
The so-called physical layer refers to the physical media that actually exists, 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, high voltage represents 1 and low voltage represents 0, which constitutes a simple physical layer protocol. For a certain media, the computer can have corresponding interfaces to receive physical signals and interpret themSequence 0/1.
Link Layer)
At the connection layerFrame)Transmission in units. The so-called frame is a finite 0/1 series. The connection layer protocol is used to recognize frames contained in the 0/1 sequence. For example, the start and end of a frame are identified based on a certain 0/1 combination. In frames, there are source, SRC, destination, DST, and frame check sequence ). Of course, the most important and important thing in frames isData (payload). The data is often in line with higher-level protocols for upper-Layer Networks. It is compatible with data, and data type information is also available in frames. The connection layer protocol does not care about what is contained in the data. Frame is likeEnvelopeTo package the data.
Ethernet and WiFi are currently the most common connection layer protocols. Through the connection layer protocol, we can establish a local Ethernet or Wi-Fi LAN, and let the two computers in the same local area network communicate. The connection layer is likeCommunityOfPostmasterHe knows everyone in the community. Each person in the community can send a letter (FRAME) to him to another person in the same community.
Connection layer: Community postmaster
Network Layer)
How do different communities communicate? In other words, how can one computer on WiFi communicate with another computer on Ethernet? We need a man in the middle ". This "man-in-the-middle" must have the following features: 1. It can receive and send 0/1 sequences in two networks on the physical layer; 2. It can understand the frame formats of the two networks at the same time. A router is a translation generated for this purpose ". A vro has multiple NICs (NIC, network interface controller). Each Nic can connect to multiple networks and understand the corresponding connection layer protocol. When a frame passes through a route to another network, the route reads the frame information and changes it to another network. So the router has branches in both communities.Post Office. The postmaster of one community delivers the mail to the branch office of the Community, and the post office transfers the mail to the Postmaster of another community through its branch in another region, and the postman from another community is finally sent to the destination.
Wi-Fi and Ethernet connected through a route
The entire communication process is as follows:
On WiFiComputer 1->RoutingWiFi Interface-> RoutingEthernet Interface-> EthernetComputer 2
(BlueIndicates a Wi-Fi network,GreenIndicates the Ethernet network)
In the connection layer, only the SRC and DST addresses can be recorded in one frame. The above process requires four addresses (Computer 1, Wi-Fi interface, Ethernet interface, and computer 2 ). Obviously, the connection Layer Protocol alone cannot meet our needs. Since the connection layer protocol is developed first, we cannot change the connection layer protocol. We can only work on the data (payload) in the connection layer, that is, the internal work of the letter. The IP Protocol came into being.
Computer 1, router and computer 2 must understand the IP protocol. When computer 1 writes a letterThe beginning of the letterWrite the departure address and the final arrival address (instead of the envelope) of this letter, and write it on the envelope to send it to the post office. The wifi Postmaster sends the email to the post office. In the post office, the mail was opened, and the Post Office staff saw the final address, so they packed the mail in a new envelope and wrote the Post Office as the post office, and the place of arrival was computer 2, and sent to the Ethernet postman, which is sent to the computer 2.
(The IP Protocol also requires information such as verification and traffic conditions to protect the communication stability .)
Transfer to Post Office
On the connection layer, the postmaster is only responsible for sending messages in the community, therefore, the address on the envelope is always "the third house in the first street" or "the small house at the corner of the central Crossroads". Some local talents know the address description, which makes the post office work inconvenient. So the post office requires that,Address written on the letter paperMust be an official compliant"Zip code", That isIP address. This address is the number of every house in the world (ZIP code ). When a letter is sent to the post office, the post office can find the corresponding address Description Based on the zip code, so that the information on the envelope can be smoothly rewritten.
Each post office is generally connected to multiple communities, and one community can also have multiple post offices to access different communities. Sometimes a letter must be transferred through multiple post offices before it can reach its destination. This process is calledRoute. The post office connects the separated Local Area Network to the Internet and eventually formsGlobal coverageInternet.
Transport Layer)
The preceding layer-3 protocol allows different computers to communicate with each other. But there are actually manyProcess, Each process can have communication requirements (see Linux Process basics and Linux Process Communication ). This is like having several people (processes) in a house. How can we send emails to someone accurately? According to the same logic, we need to write new information on the letter, such as the recipient's name, to send the letter. Therefore, the transport layer writes a new"Recipient"Information. Each house is equipped with an administrator (Transport Layer Protocol ). The postmaster receives the email from the postmaster and sends it to someone in the house based on the receiver.
Administrator
The transport layer protocol, such as TCP and UDP, usesPort Number)To identify the recipient (a process ). When writing a letter, we write the destination port. When the email arrives at the destination, the Administrator identifies the port number based on the transport layer protocol and sends the email to different users.
TCP and UDP are two different transport layer protocols. UDP is similar to our communication process. TCP is like frequent communication between two lovers. A lover wants to express too much feelings, so that he has written several messages consecutively. The other party must sort these messages in order to understand all the meaning. TCP also provides functions such as network traffic control.
Application Layer)
Through the above several layers of protocols, we can already communicate between any two people (processes. However, what everyone actually does is different.Industry. Some are lawyers and some are diplomats. For example, communications between lawyers use strict legal terms to avoid disputes. For example, communications between diplomats must comply with certain diplomatic formats to avoid diplomatic misunderstanding. For example, a spy transmits encrypted information through an encrypted number. The application layer protocol further applies to the letter content.Terms and regulations. The application layer protocol includes the HTTP protocol for Web browsing, the FTP protocol for file transmission, and the IMAP protocol for email.
Diplomatic Communication
Summary
Over network layering, we abstract the original 0/1 Series
Local Address (Postman), zip code (Post Office), recipient (Administrator), recipient industry (Standard of terms)
These concepts. These concepts eventually allow two processes distributed on the Internet on two computers to communicate with each other.
The writer must encapsulate the entire envelope (encapsulation) according to the protocol of each layer, and the receiver opens the envelope in reverse order. The entire process isReadable 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 ensures the integrity of readable information throughout the conversion and transmission process.
The computer protocol itself has more details to go. This articleArticleIt only describes the functions implemented by each layer from the perspective of hierarchy.
Welcome to the "protocol Forest" Series