Vamei Source: Http://www.cnblogs.com/vamei Welcome reprint, Please also keep this statement. Thank you!
The transmission of the signal must always conform to a certain protocol (protocol). For example, the Great Wall put smoke signals, because people have been pre-set smoke signals this physical signal represents the "enemy invasion" this abstract signal. Such a "Smoke signals = Enemy invasion" is a simple protocol. Protocols can be more complex, such as Morse code (Morse code), using a combination of short and long signals to represent different English letters. such as SOS (* * *---* *, * represents a short signal,-represents a long signal). This "***= S,---=o" is the Morse code protocol. However, one more level, people will know that SOS is the help information, because we have "sos= for help" This agreement exists in the brain. Therefore, "* * *---***=sos= for help" is a two protocol composed of layered communication system.
Using Morse code's Telegraph
Communication between computers also follows different levels of protocol to achieve computer communication.
Physical layers (physical layer)
The so-called physical layer, refers to the optical fiber, cable or electromagnetic waves and other real physical media. These mediums can transmit physical signals, such as brightness, voltage, or amplitude. For digital applications, we only need two physical signals to represent 0 and 1, for example, a high voltage of 1, low voltage represents 0, constitutes a simple physical layer protocol. For a medium, a computer can have a corresponding interface to receive physical signals and interpret them as 0/1 sequences.
connection layer (link layers)
At the connection layer, the information is transmitted in frames (frame). The so-called frame, is a finite sequence of 0/1. The function of the connection layer protocol is to identify the frames contained in the 0/1 sequence. For example, identify the start and end of a frame based on a certain 0/1 combination. In the frame, there is a delivery address (Source, SRC) and a messenger address (Destination, DST), and a checksum sequence that detects errors (frame Check Sequence). Of course, the most important thing in the frame is the data to be transferred (payload). These data are often in line with higher-level protocols for use in the upper layers of the network. In combination with the data, there is also the type information of the data in the frame. The connection layer protocol does not care what the data contains. The frame is like an envelope that wraps up the data.
Ethernet (Ethernet) and WiFi are now the most common connection layer protocols. Through the connection layer protocol, we can establish a local Ethernet or WiFi LAN, and let the two computers located in the same local area network communicate. The connection layer is like a community postman who knows every family in the community. Everyone in the community can give a letter (frame) to him and give it to another family in the same community.
Connection layer: Community small postman
Network Layer
How do you communicate between different communities? In other words, how do you let a computer on WiFi communicate with another computer on an Ethernet network? We need an "intermediary". This "middleman" must have the following functions: 1. Can receive and send 0/1 sequences on both networks from the physical layer, 2. Can understand the frame format of both networks at the same time. The router (router) is the "translation" generated for this purpose. A router has multiple network cards (nic,network Interface Controller), each NIC can access multiple networks, and understands the corresponding connection layer protocol. When a frame is routed to another network, the route reads the frame's information and overwrites it to send to another network. So a router is like a post office that has branches in two communities . The postman of a community sends the letter to the Post Office branch of the community, and the post Office transfers the letter to the postman in another community through its branch in another region, and the postman from another community eventually delivers it to the destination.
Wi-Fi and Ethernet via routed connections
The entire communication process is as follows:
Computers on WiFi 1, routing WiFi interface, routing Ethernet interface--Ethernet Computer 2
( blue indicates WiFi network, Green indicates Ethernet network)
At the connection layer, only SRC and DST two addresses can be recorded in one of our frames. The above process needs to go through four addresses (computer 1,wifi interface, Ethernet interface, computer 2). Obviously, the connection layer protocol alone does not meet our needs. Due to the development of the connection layer protocol, we can not change the connection layer protocol, only in the connection layer data (payload), that is, stationery internal work. The IP protocol was born.
Computer 1, router, and computer 2 all know the IP protocol. When Computer 1 writes a letter, it will write the starting address and final arrival address (rather than the envelope) at the beginning of the stationery, and write it on the envelope to be sent to the post office. The postman at the WiFi network sent the letter to the Post office. At the Post office, the letter was opened, the Post office staff saw the final address, so the letter was wrapped in a new envelope, the place of origin for the post office, arrived at the computer 2, and handed over to the Ethernet postman, by the Ethernet postman sent to the computer 2.
(The IP protocol also requires such information as information such as verification, traffic conditions, etc. to protect the stability of the communication.) )
Transfer to the Post Office
At the junction, the postman is only responsible for sending letters to the community, so the address on the envelope is always "the third house on the first Street" or "a small house at the corner of the center intersection", which some locals know about the address, which inconvenience the work of the Post office. So the post Office requires that the address written on the stationery must be a "ZIP code" that complies with the official rules, which is the IP address. This address is the number of every house in the world (postcode). When the letter sent to the Post Office, the post office according to the ZIP code, you can find the corresponding address description, so that the information on the envelope can be successfully rewritten.
Each post office generally connects to multiple communities, and a community can have multiple post offices, each leading to a different community. Sometimes a letter has to be forwarded through multiple post offices to arrive at the destination, a process called route. The Post office connects the detached local area network to the Internet, and ultimately the Internet, which covers the world.
The Transport layer (transport layer)
The above layer three protocol allows communication between different computers. But there are actually many processes in the computer , each of which may have a need for communication (see Linux Process Basics and Linux interprocess communication ). It's like a house where several people live (process), how to send a letter to a person accurately? Following the same logic as before, we need to write new information on the stationery, such as the name of the addressee, before the letter can be sent. So, the transport layer is to write a new "addressee" message on the blank of the letter. Each house will be equipped with an administrator (Transport Layer protocol). The administrator receives the letter from the postman and sends the letter to someone in the house according to the "addressee".
Administrator
Transport layer protocols, such as TCP and UDP, allow the port number to be used to identify the recipient (a process). At the time of writing, we write the port of destination. When the letter arrives at the destination of the administrator, 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 communications process. The TCP protocol seems to be a frequent communication with two of lovers. A little lover has so much to say that he has written several letters in succession. The other party must arrange the letters in order to see the full meaning. The TCP protocol also has the functions of controlling network traffic.
application tier (Application layer)
With the above layers of protocols, we have been able to communicate between any two people (processes). However, everyone is actually engaged in a different industry. Some people are lawyers, some are diplomats. For example, the communication between lawyers, will use a strict legal terminology, so as not to create disputes. Communication between diplomats, for example, must conform to a certain diplomatic format in order to avoid diplomatic misunderstanding. Another example is a spy passing encrypted messages through a password. The application layer protocol is a further term specification for the content of a letter. The protocol for the Application layer includes the HTTP protocol for Web browsing, the FTP protocol for transferring files, IMAP for email, and so on.
Diplomatic communications
Summary
Always over the network hierarchy, we abstracted from the original 0/1 sequence
Local address (postman), postal Code (Post Office), recipient (Administrator), Recipient industry (terminology)
These concepts. These concepts ultimately allow two processes across the Internet to communicate with each other on two computers.
The writer must encapsulate the entire envelope (encapsulation) in accordance with the agreement of each layer, while the addressee will disassemble the envelope in reverse order. The entire process is readable information ---binary, read-only information . The computer can only understand and transmit 0/1 sequences, while the computer's users always input and output readable information. The network protocol guarantees the integrity of the readable information throughout the transformation and transfer process.
The computer protocol itself has more details to go into. This article only describes the functions that are implemented at each level from a hierarchical perspective.
Vamei of Agreement Learning Blog Series 01 Network protocol overview