
Editor's note: Blockchain involves many technologies, from the bottom layer of the Internet to the unknown cryptography, but there are often many people who pay attention to currency prices and few people who study technology. During the bull market, everyone will study hard to speculate in coins. During the bear market, there is nothing to do anyway, so I think we can study harder. As a liberal arts student, I certainly have a lot of questions that science students seem to think are idiotic. As a reporter, it is not difficult for me to find people who understand the industry to explain to me in human terms, and they often do not dislike me face to face.
), the second phase is cross-chain ("Xiao Ming's Study Notes | Understand the Blockchain Cross-Chain Mechanism in One Article"), the second phase is cross-chain ("Xiao Ming's Study Notes | Understand the Blockchain Virtual Machine in One Article""Xiao Ming's Study Notes | Understand the Blockchain Virtual Machine in One Article"
When you come into contact with the blockchain, you may find that people often talk about the protocol, and occasionally someone talks about the TCP/IP protocol. At first glance, it doesn't seem obvious, but after thinking about it, it seems that this is really the most common "protocol" that we use every day. Some people will compare the blockchain with the Internet, and the bottom layer of the Internet is the TCP/IP protocol; I have also heard Xu Mingxing say that the blockchain is the TCP/IP protocol that will be financial; plus the architecture of Ethereum There is also very little information on the network layer. So I want to find out. The study notes this time mainly rely on the collation of public information on the Internet. Many paragraphs may be copied from different explanation articles, which are really so-called "notes".
secondary title
What is the TCP/IP protocol
First of all, the agreement can be understood as a set of unified rules, just like industry standards. Since the primary function of the Internet is to transmit information, its protocols are generally the rules governing how systems communicate with each other.
Using offline "transportation agreements" such as postal services and logistics, we used to write postal codes, senders, recipients, and addresses when we wrote letters. Postal services also have their own standards on the way. For example, postmen in different regions collect specific areas. mail, and then collect and distribute; the logistics industry also has containers, rails, etc.In Internet communication, "how to detect the communication target, which side initiates the communication first, which language to use for communication, how to end the communication and other rules need to be determined in advance. Communication between different hardware and operating systems, all of these Everything needs a rule." (From Zhihu user "”)
Oh hoo
The full name of the TCP/IP protocol is Transmission Control Protocol and Internet Protocol. TCP and IP are two protocols respectively; at the same time, the TCP/IP protocol can refer to a group of protocol families and Internet models used in the Internet transmission process, because TCP and IP are more important in it, so they are named after them.
Since there are many steps involved in communication and the software and hardware used, it will be divided into different levels. The TCP/IP model has four levels of abstraction, describes the overall design outline, and realizes the specific protocol of network communication.
Different protocols in this model have different "divisions of labor". Mastering the required information and completing its work based on specific information is actually similar to the workflow in real life. Using the postal and courier example above again, due to the division of labor, if you ask the receiving courier where your courier is, he will definitely not know. He is only responsible for delivering your courier to the courier distribution point.
Next, we can start to understand the various important roles within this express company.
secondary title
This company can be roughly divided into four departments, that is, the TCP/IP protocol family is divided into application layer, transport layer, network layer, and network interface layer (data link layer + physical layer).
English version first
image description
Let's have another cute Chinese version
The picture above actually vividly shows the entire data transmission process. It seems simple for us to send a sentence on WeChat. In fact, every step has gone through the process from the upper layer to the lower layer, and then from the lower layer to the upper layer application. For example, Xiao Xiong sent Xiao Ming a message on WeChat, and until Xiao Ming received the message, the above process actually went through.WeChat is located in the application layer, which packs the data according to a specific format, plus the address of the sender and both parties, and its own "mark" (so that Xiao Ming knows that the message is for WeChat), etc., to the transport layer;TCP protocol at the transport layerIt will cut the file into smaller fragments to ensure that the data packets are transmitted safely;IP protocol at the network (interconnection) layer
The best path will be found; the message will be sent over networks such as fiber optics and WiFi. After arriving at the destination, the scattered data will be reorganized, and the transport layer will also know from the mark that it is for WeChat.
The above process has actually talked about the main functions of the TCP protocol and the IP protocol. These two are the most important protocols of the transport layer and the network interconnection layer, so this model is named after them. There will be many other protocols in the specific process. When different data is transmitted, the application layer will have different protocol processing. Interested babies can continue to learn the details with me.Each layer has its own functions and common protocols, sorting out the blogs of Jiguang Push on CSDN,March On BloggerOh hoo、Drake、Oh hooXiao Mingarticles, and,Summarized as follows.
Information in the Internet is transmitted in units of data packets. Different protocol layers have different names for data packets. They are called segments at the transport layer, datagrams at the network layer, and frames at the link layer. .
When the sender transmits data between layers, every time it passes through a layer, it must be marked with a header information of the layer. This method of packaging data information is called encapsulation. After the data is encapsulated into a frame, it is sent to the transmission medium. After reaching the destination host, each layer protocol strips off the corresponding header, and finally the application layer data is handed over to the application program for processing. I'll start at the bottom.
secondary title
network interface layer
Common protocols: Ethernet 802.3, Token Ring 802.5, X.25, Frame relay, HDLC, PPP ATM, etc.
One of the more famous is the Ethernet protocol. "Data is sent and received between two computers (hosts) through network cards. Each network card has a unique address, that is, a MAC address. Ethernet data is in units of frames, including headers and data parts. Ethernet sends data in the form of broadcasting in the subnet. The MAC address alone does not allow two hosts to communicate with each other. If the two hosts are not in the same subnet, the Ethernet protocol will have nothing to do. This is through the network layer To distinguish which subnet the network of each host is in. If it is in the same subnet, send data by broadcasting, otherwise send it by routing. This leads to the birth of the network layer.” (from Jiguang Push)
secondary title
network access layer
Common protocols: IP (Internet Protocol), ICMP, ARP (Address Resolution Protocol), RARP (Reverse ARP). IP is the core of the network layer, and the next IP is encapsulated and handed over to the interface layer through routing selection. ICMP is a supplement to the network layer and can echo messages. Used to check whether the network is unobstructed.
The main task of the network layer is simply to "determine the route for each data packet". This host may be in the same network or an external network, so it is necessary to distinguish whether the host is in the same subnet.This layer is where the IP protocol resides. Just like we need an address when we write a letter, we also need an address in the network world, and this network address is an IP address. (The following is from)
"Tang Qiang"
The IP address is the house number, and the IP protocol is responsible for calculating and finding the designated house number. What the courier brother has to do before going out every day is the bounden duty of the IP protocol: sorting packages and planning routes. In fact, the internal communication of a small network of three or five nodes does not need to use the IP protocol at all, because these nodes can communicate with each other in pairs, but there will be a problem: when the number of nodes increases, the network speed will be paralyzed, because the bandwidth consumption do. (Bandwidth refers to the data packets that can be transmitted within a fixed time, a bit like the width of a road.)
Therefore, a network was later split into many sub-networks, and each sub-network was handed over to a router for unified management. Nodes in the sub-network can communicate independently without IP protocol, but due to bandwidth limitations, if you want to communicate with nodes outside the network, you must use a device: a router. Most of the routers in the world are owned by a few large carriers.
As shown in the figure above, nodes 1 and 2 belong to the same subnet and can communicate based on the internal communication protocol, while the communication between nodes 1 and 5 must be based on the IP protocol and communicate through the path between routers 1 and 2.
Extend the logic of the IP protocol to the entire Internet. In the end, there are countless routers connecting our mobile client and Tencent server.
The benefits of cutting a large network into smaller ones are obvious: saving bandwidth, increasing network speed, and at the same time, the failure of one router will not affect the communication between other nodes. This is the role of the IP protocol.
There are also some protocols that "assist" the IP protocol in this layer, such as ARP and RARP. To ensure that the data is indeed transmitted to the other host, a MAC address (Media Access Control Address) is required in addition to the IP address. The Mac address, also known as the physical address, corresponds to the network card one by one, and is unique and immutable for a host. The IP address will change depending on the network you are on.
The functions of the above two protocols are simply: use the IP address to find the Mac address; and use the Mac address to find the IP address. Please see the following two paragraphs for specific functions:
"The basic function of ARP (Address Resolution Protocol) is to query the MAC address of the target device through the IP address of the target device to ensure the smooth progress of communication. The data frame in Ethernet arrives from one host to another host in the network according to The 48-bit Ethernet address (hardware address) is used to determine the interface instead of the 32-bit IP address. The kernel must know the hardware address of the destination to send data. The P2P connection does not need ARP.RARP (Reverse Address Translation Protocol) allows physical machines on a LAN to request their IP addresses from the gateway server's ARP table or cache.A table is kept in the LAN gateway router to map MACs to their corresponding IP addresses.
After reading it, you may have the same doubts as I do. Since the physical address is used to find the host, why do you need an IP address?51CTOandCSDNand
These two articles answer this question:
The structure of the MAC address is purple: a total of 48bit, divided into two parts, the first 24bit is the manufacturer's code, and the last 24bit is assigned by the manufacturer. If we think that MAC addresses can distinguish different networks, then we can only use manufacturer codes to distinguish different networks. Obviously, network cards of the same brand do not mean they are in the same network.
At the earliest time when there were not so many computers in the world, there was no such thing as routing, and the hosts were all in the same network, so they really communicated directly through the mac address. The initial link layer protocol has nothing to do with the ip address. There is no network layer setting, only the physical layer and the link layer. At first, there are only hubs, no switches and routers, and the transmission of data between servers depends entirely on the mac address. Before there was no ip address, mac address was already in use. The Layer 2 switches that are used everywhere now forward data according to the mac address. The design of the mac address does not carry the location information of the device in the network. To communicate through the mac address, we have to maintain a large table on all devices to record the next hop of all mac address routes at the current location. This is obviously unreasonable.
The MAC address is like the personal ID card of the computer, the IP address is like the room where the computer is located, and many people can live in the room, and the LAN gateway route is like a street office for registering the population.
secondary title
transport layer
With the IP protocol, data can be sent between two hosts. The next problem is that each host has different applications. How to distinguish which data packet belongs to which program? This is what the transport layer does. The main task of the transport layer is to ensure that the split units arrive correctly at the other end, which establishes port-to-port connections. The network layer establishes a host-to-host connection. As long as there is a host and port, it can determine which program the data packet belongs to. At the same time, it is also responsible for receiving data from the application layer, and then dividing them into smaller units (the header and data part are in the data part of the network layer), and transmitting them to the network layer.The port mentioned here is not a hardware port, but a software port. The port is a door for external information to enter the computer, and different information is transmitted to different applications through these doors. For a more vivid explanation, please refer to:
"Why there are ports, how to plan the ports, see below. "
"IP can lock a physical machine, corresponding to a network card, and the network card will receive the data packets sent from the outside world. But here comes the problem, the network card provides an interface for the program, you can monitor me, if there is news, I will Forward it to you. In this way, the application can receive the data. But here comes the problem. Both program A and program B need to monitor the network card to receive and send data. The network card says that I will send all the received data to you. You can see for yourself Let's do it. Okay, little A and little B are accepted. But here comes CDEF again..., no, every package is sent to all applications, every application is exhausted, and finally collapsed.
Okay, the network card said that I will add a sign to you. We can use a number as an identification between us, and I will use 1 to identify between me and Xiao A. If the outside world sends data with the number 1 identification, I will forward it to you. , When you monitor me, you have to tell me when you monitor 1, and I will forward 1 data packets to you. Well, other BCDs... all have their own identification numbers, as long as they don't repeat themselves. This saves everyone trouble.
Finally, it is designed to be safe. An identification number can only be monitored by one application program, because if the small A program and small B listen to an identification number at the same time, it will be broken. The data I transmit will be received by AB, so the data security There is no way to guarantee it. "
There are two main protocols at this layer: TCP and UDP.
TCP is a connection-oriented, reliable, byte stream-based transport layer communication protocol. UDP (User Datagram Protocol) is a connectionless transport layer protocol that provides transaction-oriented simple and unreliable information transfer services.
Although these two sentences seem to be confusing, they may make people get one reliable and the other not so reliable. Yes, that's the difference between the two.Chen BaojiaandXiao Ming):
image description
The picture comes from "Graphic HTTP"
In order to accurately deliver data to the target, before sending and receiving data, a reliable connection must be established with the other party. The TCP protocol uses a three-way handshaking strategy. The TCP flags (flag) - SYN (synchronize) and ACK (acknowledgment) are used in the handshake process:
The first handshake: the client sends a syn packet (syn=j) to the server, and enters the SYN_SEND state, waiting for the server to confirm;
The second handshake: the server receives the syn packet and must confirm the client's SYN (ack=j+1), and at the same time, it also sends a SYN packet (syn=k), that is, the SYN+ACK packet, and the server enters the SYN_RECV state;
The third handshake: the client receives the SYN+ACK packet from the server and sends an acknowledgment packet ACK (ack=k+1) to the server. After the packet is sent, the client and server enter the ESTABLISHED state and complete the three-way handshake.
Note: The packet transmitted during the handshake process does not contain data. After the three-way handshake is completed, the client and server officially begin to transmit data. In addition to the above-mentioned three-way handshake, the TCP protocol has various other means to ensure the reliability of communication.
Ideally, once a TCP connection is established, the TCP connection will be maintained until either party actively closes the connection.
When disconnecting, both the server and the client can actively initiate a request to disconnect the TCP connection, and the disconnection process requires a "four-way handshake".As for the UDP protocol, it does not establish a connection with the other party before transmitting data, and does not send a confirmation signal for the received data. The sender does not know whether the data will be received correctly, and of course there is no need to resend it. A reliable data transfer protocol.Specifically, according to the posts of the user Chen Baojia
secondary title
application layer
application layer
The application layer is the layer used by Internet programs to communicate with other programs, and it is also the layer "closest" to the user."HTTP://", which is the HTTP protocol (Hypertext Transfer ProtocolHypertext Transfer Protocol"HTTPS://", which is Hypertext Transfer Protocol Secure), which is Hypertext Transfer Protocol Secure)
. In the spring of 1982, the U.S. Department of Defense announced TCP/IP as the communication standard for military networks. In 1989, Timothy Berners-Lee developed the hypertext transfer protocol HTTP. After that, not only text can be transmitted on the Internet, but also various multimedia web pages including pictures.http://www.badidu.comWhen we usually visit a webpage, we are more accustomed to typing domain names, such as
, instead of directly typing the IP (see the screenshot of the ping command above, you will see Baidu’s IP), because it is easier to remember, but the computer doesn’t think so, so DNS (Domain Name System) is needed. DNS is used to find an IP address through a domain name, or reversely look up a domain name from an IP address.If you want to send email, you need to use SMTP (Simple Mail Transfer Protocol
I am Lu Xiaoming, editor of Odaily. I am exploring the real blockchain. Please add WeChat lohiuming for breaking news and communication. Please note your name, unit, position and reason.
I am Lu Xiaoming, editor of Odaily. I am exploring the real blockchain. Please add WeChat lohiuming for breaking news and communication. Please note your name, unit, position and reason.
Related Reading:
What is the TCP/IP protocol? What are the problems now? Why is blockchain a TCP/IP solution?
Understand the TCP/IP model in one minute
The functions and main protocols of each layer of the TCP/IP model and the OSI seven-layer reference modelWhat is the TCP/IP protocol? we'll do it in 10 minutes
(There are some cute and easy-to-understand pictures)How does Xiaobai understand the TCP/IP network protocol family (
There is the ugly picture above and some simple explanations)Detailed Explanation of Computer Network Structure Model TCP/IP
(Why this set of protocols won the international standard)
What exactly is the TCP/IP protocol talking about?
The difference between TCP and UDP