Translation of an entry-level article on the Textile project blog from November 19, 2019.
The first steps to building a decentralized application can be difficult. Changing the way we think about centralized application development is not easy, because distributed design breaks most of the assumptions in our brains (and the software tools we use). To illustrate how our team envisions peer-to-peer communication, we are releasing a two-part series on the libp2p protocol stack. In this first article, we reflect on some of the complexities involved in building decentralized applications and find out how a network protocol layer abstraction like libp2p can help us. In the next article (coming soon), we will use these same concepts to create a simple example written in Go to understand how the various components,which we are talking about here are related to each other.
Rapidly increasing complexity
Implementing distributed (p2p) communication in any application is not an easy task. Imagine just a couple of minutes how your creation should work - and everything starts to get complicated right before your eyes. Let's look at two main issues for p2p applications: application state and communication infrastructure... Managing the current state of the system is not trivial. There is no central authority to determine it. System state is a derivative of the states of many other nodes, which is explosively complex in unreliable networks and complex protocols. In terms of communication infrastructure, your application must communicate with many peers, so you have to face a fair amount of problems. Consider the following topics regarding remote nodes:
They have unreliable hardware and network.
They have undefined technical parameters such as processing power and available long-term memory.
Firewalls can block them or they can be on NAT networks.
They can use older versions of applications.
, , - , . , - - ? , , ?!
Libp2p !
Libp2p - , Protocol Labs IPFS. , , ! p2p- , , , - , . , . , libp2p , - -. ! , libp2p - p2p-, .
Libp2p
libp2p (Host), p2p. :
, .
, .
: , , . .
.
Muxer, ( ).
libp2p - . (Stream) - . Stream "", "" ("raw") , TCP UDP - libp2p: - . , TCP, UDP . , , ; .
Stream - , . , , ( ), . , /sumtwointegers/v1.0.0. Stream - . , , . .
, TCP UDP - , , p2p- ( ). - , , , ( Stream). . , . ? , libp2p. p2p? , !
, p2p libp2p . TCP- . , . Streams . Libp2p ("Muxers") . - ( ) . , .
, Muxer, () . , , . , "" , , . , , ( ) (, , QUIC). ...
, , , libp2p . () , . , . Stream.
libp2p , , . , , . , !
, libp2p, , , . , .
? , p2p- , , NAT . , , , ! p2p, , libp2p , .
!
Libp2p . . , - - , . , p2p. , . , .
, libp2p , , , . , (TCP, UDP, QUIC, Websockets), (/myprotocol/v1.0.0, /myprotocol/v1.1.0), , , . . , libp2p p2p-, :
NAT: p2p-
: , ?
Pubsub: -
, !
: Libp2p , , . , p2p , libp2p . , JS, - Go Rust.
, . , libp2p . , libp2p , -.
, . ยซยป, . , p2p- , , ! ยซยป , libp2p , iOS, Android / . , , ... , !
: (StarVer)