大家好,又见面了,我是你们的朋友全栈君。
Hello. Hello again. I'm your friend.
摘要:包括比特币、以太坊等在内的去中心化的区块链平台,其底层网络都是采用的P2P技术实现,每个节点都是对等的。而本文,则先通过介绍P2P技术的特点和发展历史,让大家对P2P这个技术的来龙去脉有一个初步的认识和了解。然后在下一篇文章中,我会详细介绍第三代P2P技术(DHT)—Kademlia算法的实现原理。
Abstract: Decentralized block chain platforms, including Bitcoin, Etheria, etc., the bottom network is implemented using P2P technology, each node being reciprocal. This paper, by presenting the characteristics and history of P2P technology, provides an initial understanding and understanding of the history of the P2P technology. In the next post, I will elaborate on the principles of the third generation of P2P (DHT)-Kademlia algorithms.
P2P是peer-to-peer的简称,又称为点对点技术,是没有中心服务器、依靠用户群节点进行信息交换的对等式网络。区别于传统的C/S中央服务器结构,P2P网络中每一个用户节点即是客户端又是服务端,能同时作为服务器给其他节点提供服务。
有中心服务器的中央网络系统(左)和无中心服务器的对等式网络(右) Central network systems with central servers (left) and equivalent networks without central servers (right) 在传统的C/S模式网络系统中,客户端之间的交互需要依赖中心化的服务器进行。当网络规模变得庞大时,这些中心服务器的负担就会越来越重,很容易成为网络瓶颈。而且一旦服务器崩溃,就会造成整个网络瘫痪(单点故障的风险)。而P2P网络由于没有中心服务器,不存在单点性能上的瓶颈,每个节点在充当客户端的同时,也可以作为服务端给其他相邻节点提供服务,极大地提高了资源的利用率。 In the traditional C/S model network system, client-end interaction depends on a centralized server. When the network becomes large, these central servers become more and more burdensome and can easily become network bottlenecks. And when the server collapses, the entire network is paralysed (risk of single-point failure). And the P2P network, without a central server, has no single-point performance bottlenecks, and each node, while serving as a client, can also serve as a service end to other adjacent nodes, significantly increasing resource utilization. 总结来说,P2P网络的特点如下: In summary, the P2P network is characterized by the following: (1)可扩展性。在P2P网络中,用户可以随时加入、离开网络。而且随着用户节点的加入,系统整体的服务能力也在相应的提高。例如p2p下载中,加入的用户越多,则P2P网络中提供的资源就越多,下载速度就越来越快。 (1) extensions. in the P2P network allows users to join and leave the network at any time. And with the addition of the user nodes, the overall service capacity of the system has increased accordingly. For example, the more users the P2P download, the more resources the P2P network provides, the faster it downloads. (2)健壮性。由于P2P不存在中心化服务器,天生就具备耐攻击和高容错的特点。即使网络中某个节点被攻击或下线,也不影响整个系统的正常运行。因为P2P网络中每个节点都可以充当服务端的角色。 (2) is robust. , because of the absence of a centralised P2P server, is inherently resistant to attacks and high tolerance errors. Even if a node in the network is attacked or downlined, it does not affect the normal functioning of the entire system. Because each node in the P2P network can act as a service ender. (3)高性价比。采用P2P结构的网络,可以有效地利用互联网中大量分散的普通用户节点。充分利用这些普通节点中闲散的CPU、带宽、存储资源,从而达到高性能计算和海量存储的目的。例如:迅雷旗下的星域CDN产品,就是充分利用每一个普通用户机器的闲散网络资源,从而提供一个高性价比的服务。类似的还有360共享云、国外的sia网盘等。 (3) high value for money. , using a network of P2P structures, can make effective use of a large number of widely dispersed general user nodes on the Internet. Make full use of idle CPUs, bandwidths, storage resources in these general nodes, thereby achieving high performance computing and mass storage. For example, the field CDN product under the Thunderflag is to make full use of the idle network resources of each common user machine, thus providing a high value for money service. Similar to 360 shared clouds, foreign sia web disks, etc. (4)隐私保护。在P2P网络中,由于信息的传输分散在各个节点之间,而无需经过中心服务器。这样就减少用户隐私信息被窃听和泄露的风险。 (4) privacy protection. in the P2P network reduces the risk of privacy information being tapped and leaked because the transmission of information is dispersed between nodes without going through the central server. (5)负载均衡。由于P2P网络中,资源分散存储在多个节点上,而每个节点又都可以充当服务器的角色。当某个节点需要获取资源时,只需要向相邻节点发送请求即可,很好地实现了整个网络的负载均衡。 (5) load balance. achieves a good load balance for the entire network when a node requires resources. P2P网络的主要功能可以分为如下3种: The main functions of the P2P network can be divided into the following three: (1)数据发布和传输有3中方式,分别是一对一(如即时通讯)、一对多(如群组通信和消息广播)和多对多(如内容分发应用:BT、PPS等) (1) Data are disseminated and transmitted in three medium ways, one-to-one (e.g., instant communication), one-to-one (e.g., group communication and messaging) and one-to-one (e.g., content distribution applications: BT, PPS, etc.) (2)数据存储和检索分为基于结构化的P2P网络方法和基于非结构化的P2P网络方法。结构化的P2P网络也就是基于分布式哈希表(DHT)的P2P网络,这个也是目前应用最广泛的,它的网络拓扑结构是确定的。而非结构化的P2P网络的资源存储通常与网络拓扑结构无关,例如Gnutella。 (2) Data storage and retrieval are divided into a structured P2P network approach and a non-structured P2P network approach. The structured P2P network is a distributed P2P network, which is also the most widely applied network-top structure. (3)目前,大多数分布式数据处理技术采用的是master/slave的架构。而基于P2P网络,也能够进行分布式的数据处理。 (3) At present, most distributed data-processing technologies use master/slave structures, and distributed data-processing is also possible based on the P2P network. P2P技术的发展可以分为如下三个阶段: The development of P2P technologies can be divided into the following three phases: 这种网络采用的是中心化的拓扑结构,由于文件的索引信息都是存储在中央服务器上,每个子节点都需要连接中央服务器才可以找到资源。它最大的优点是维护简单、索引速度快。但是由于整个网络严重依赖于中央服务器,容易造成性能瓶颈和单点故障的问题。 The network uses a centralized top-up structure, and since the index information for documents is stored on a central server, each sub-node needs to be connected to the central server in order to find resources. Its greatest advantage is to maintain simple, fast indexing. But because the network is heavily dependent on the central server, it is prone to performance bottlenecks and single-point malfunctions. 典型代表是:napster。 Typical representatives are: napster. 这种网络采用Flooding搜索算法,每次搜索都把要查询的消息广播给网络上的所有节点。当一个节点要下载某个文件的时候,这个节点会以文件名或者关键字生成一个查询,并把查询发送给所有跟他相连的节点。如果这些节点存在文件,则跟这个节点建立连接,如果不存在,则继续向相邻的节点转发这个查询,直到找到文件位置,过程如下图所示。 When a node is to download a file, the node generates a query by its name or keyword and sends the query to all nodes connected to it. If there is a file, connects to the node and, if it does not exist, continues to transmit the query to the adjacent node until the location of the file is found, as shown in the figure below. 可以发现,当网络规模变大以后,这种搜索方式会引发”广播风暴”,严重消耗网络带宽和节点的系统资源。虽然避免了集中式对等网络的“单点故障”问题,但是效率却很低下。 It can be found that when the network becomes larger, this search creates a "broadcasting storm" that severely consumes the system resources of network bandwidth and nodes. While the “single-point failure” of centralized peer-to-peer networks is avoided, it is very inefficient. 典型代表:Gnutella早期版本。 Typical representative: 目前采用最广泛的就是结构化的分布式网络,也就是基于DHT(分布式哈希表)的网络。DHT为了达到Napster的效率和正确性,以及Gnutella的分散性,使用了较为结构化的基于键值对的路由方法(如下图所示)。
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论