The structure design of the peer-communication protocol family

Source: Internet
Author: User

In the above introduction, there are many types of structure about the communication protocol, such as Eth.peer,p2p.peer,server and so on. This may be a general solution to the structure of these peer-to communication protocol families. The structure type of the peer-communication protocol family used in Ethereum can be broadly divided into three layers:

The first layer is in pkg ETH and can be directly eth. Ethereum,eth. Protocolmanager and other top management modules are used, and the ETH is also clearly considered in the type declaration. The use of Ethereum features. Typically with eth.peer{}, eth.peerset{}, where Peerset is the collection type of peer, and Eth.peer represents the remote communication object and all of its communication operations, which encapsulate the lower P2p.peer objects and read-write channels.
The second layer belongs to the PKG peer-to-peer, it can be considered as a generalization of the communication structure, more typical structure types include the remote communication object to the peer. peer{}, which encapsulates the conn{} from the underlying connection object, communicates with the channel object protorw{}, and initiates the listener, processes the new join connection, or disconnects the server{}. In this layer, the boundaries of the various data types are clear, as far as possible without the occurrence of kneading, which is the demand of the generalization structure. It is important to focus on the peer. protocol{}, which should be deliberately developed for upper-level applications, mainly includes accommodating the callback functions required by the application, and by peer server{} is passed to the communication object peer after the new connection is established. Judging by the role of this type, it is more appropriate to name protocol, although it should not be confused with existing concepts such as the TCP/IP protocol.
The third layer is in the Golang of the network code package, can also be divided into two parts: the first part of the PKG NET, including the network connection <Conn> interface, representing the network address <Addr> and their implementation class; The second part of the Pkg syscall, Including the lower level of the network-related system call class, etc., can be considered to encapsulate the network layer (IP) and Transport Layer (TCP) protocol system implementation.
The following UML diagrams depict some of the main structures in the above three-tier peer-to communication protocol family, and hope to help understand the relevant code in Ethereum.


Image.png

Summary:
Such a de-centralized digital currency operating system, such as Ethereum, is inherently suitable for peer-communication architectures. Although the principle is simple, at the level of the system architecture, there are still many implementation details need to pay attention to.

Eth. In Protocolmanager, an active transfer of data is initiated for each remote peer, which is differentiated by data type and can be divided into transactions and chunks, and if it is differentiated by sending data, it can be divided into broadcast single data and synchronized with a set of identical types of data. This allows 22 pairs to form 4 groups of active data transfer operations.
Protocolmanager can respond to any event and status update of a remote peer by embedding a callback function in the p2p.protocol{} object. These protocol objects will be made by peer. The server passes to the remote peer on each new connection.
Ethereum is currently implemented in the peer-to communication protocol family structure type, according to function and function, can be divided into three layers: the type of the top pkg ETH directly serves the current ethereum system (Ethereum,protocolmanager and other modules), the middle layer pkg peer is a generalized structure type, The bottom layer includes pkg net, syscall and so on with Golang language package, which encapsulates the system implementation of network layer and Transport layer protocol.

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.