区块链:P2P技术是什么

资讯 2024-06-22 阅读:59 评论:0
大家好,又见面了,我是你们的朋友全栈君。Hello. Hello again. I'm your friend.摘要:包括比特币、以太坊等在内的去中心化的区块链平台,其底层网络都是采用的P2P技术实现,每个节点都是对等的。而本文,则先通过介...

大家好,又见面了,我是你们的朋友全栈君。

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.

区块链:P2P技术是什么
区块链:P2P技术是什么

这种网络采用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的分散性,使用了较为结构化的基于键值对的路由方法(如下图所示)。

The most widely used distributed network is the network based on

目前实现了DHT协议的有Kademlia和Chord算法,其中Kad算法由于简单易用而被广泛使用,其中比特币和以太坊网络中的P2P网络采用的就是Kad算法。这个也是我们下一篇文章要重点将的内容,这里我们就不展开讲解,留到下一篇文章。

The DHT agreement has now been achieved with the Kademlia and Chord algorithms, which are widely used because they are simple and easy to use, with the P2P network in Bitcoin and Etheria using the kad algorithm. This is also what we will focus on in our next article, and we will leave it to the next one.


利用P2P技术可以使计算机之间不通过服务器直接进行内容共享和数据分发,使得互联网上任意两台机器间共享数据成为可能。例如Napster、Gnutella、eDonkey、eMule、Maze、BT,以及现在PPS、腾讯视频客户端等采用的P2P流媒体技术,使得播放速度更加流畅。

The use of P2P technology makes it possible for computers to share content and data directly without using a server, making it possible for any two machines on the Internet to share data between them. For example, Napster, Gnutella, eDonkey, eMule, Maze, BT, as well as the current P2P-flow media technology, such as the PPS, the telecommunications video client, and so on, make the broadcast more fluid.

基于P2P网络的分布式结构构造出分布式的存储系统实现存储共享,提供高效率、高性价比、负载均衡的文件存取功能,例如国外的Sia、Storj等分布式云存储平台,不依赖第三方的大型集中存储空间,避免了数据泄露、保证了安全性。同时由于任何人的主机都可以提供存储服务,降低了门槛,大幅降低了存储的成本。如下,采用分布式存储的Storj价格是每个月0.015而亚马逊提供的AWS价格是0.023。

The distributional structure of the P2P network creates distributed storage systems that achieve storage sharing by providing efficient, high-value, load-balanced document access, such as the foreign distributed cloud storage platform Sia, Stotj, etc., which does not rely on a large centralized storage space for third parties, avoids data leakage and ensures security. At the same time, as anyone's mainframe can provide storage services, it reduces the threshold and significantly reduces the cost of storage.

同时也可以共享CPU处理能力。例如360的共享云计划和星域CDN等,充分利用每个人机器的闲散计算资源来提供计算服务。

CPU processing capabilities can also be shared. For example, 360 shared nebula plans and domain CDNs make full use of the idle computing resources of each machine to provide computing services.

例如目前的Skype通话软件就是从连接建立和数据传输都采用P2P实现,保证了良好的通话质量。

The current Skype call software, for example, is implemented using P2P for both connection creation and data transmission, which ensures a good quality of calls.

常见的协同处理有视频会议、共享白板、协同协作等,而基于P2P技术的同样也可以实现上述功能,不同的是,这种实现方式不需要中心服务器,参与协同工作的计算机之间可以直接建立点对点的连接。例如被微软收购的Groove协同软件平台。

Common synthesizing processes include videoconferencing, sharing of whiteboards, teamwork, etc., while the same functionality can be achieved with P2P-based technologies, unlike central servers, where direct point-to-point connections can be established between computers involved in teamwork. For example, the Groove platform for synergizing software acquired by Microsoft.

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/150726.html原文链接:https://javaforall.cn

Published by: Chief of the Whole House Programmer, referenced in https://javaforall.cn/150726.html. Link to original text: https://javaforall.cn

文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

发表评论
热门文章
  • 以太坊区块链浏览器的搭建

    以太坊区块链浏览器的搭建
    环境;Ubuntu 首先需要下载git 参考链接:?http://www.360bchain.com/article/156.html??Environment; Ubuntu first needs to download git reference link: ˂a rel="noformlow" href="http://www.360bchai.com/article/156.html"? http://www.360bchai.com/article/156.htm...
  • 百度元宇宙希壤app官方下载

    百度元宇宙希壤app官方下载
    希壤元宇宙是一款非常好玩的休闲手游,这款游戏采用了元宇宙的游戏概念,超级自由的游戏玩法,在这里没有什么标准限定,你可以自由的在这里进行着一切你想做的事情,游戏比较的休闲和放松,没有什么操作难度,感兴趣的小伙伴们可以来007游戏网下载这款非常有趣的希壤元宇宙吧!˂a href=http://m.yx007.com/key/xxsy" target="_blank" , a game that uses the concept of meta-cosm, super-free p...
  • 【CoinCentral 合作內容】加密貨幣 Decred 正式推出 2018 發展路段線圖

    【CoinCentral 合作內容】加密貨幣 Decred 正式推出 2018 發展路段線圖
    早些時候,加密貨幣Decred發表了一篇博客文章,概述了他們2018年的正式發展路線圖。Earlier, encrypt currency Decred published a blog article outlining their official road map for development in 2018.在這個路線圖中,團隊在為他們制定營銷宣傳之前,明確地表明他們於建立和發布可交付物品的成果,同時將他們的營銷集中在項目的核心組成部分。Decred團隊正在研究一些...
  • 跨接在两个网络间的语音记录仪设计

    跨接在两个网络间的语音记录仪设计
      摘  要: 设计了语音记录仪。该语音记录仪桥接在通信设备之间,同时提供3种桥接接口:以太网接口,支持在IP通信方式下的各通话组的直通及录音功能;二线接口,支持模拟二线方式下的直通及录音功能;音频接口,支持模拟音频方式下的直通及录音功能。同时话音记录仪提供FTP服务器,可以通过局域网对语音记录仪保存的语音文件进行下载和管理。此外,该设备支持语音回放功能。 extracts & nbsp; to : The voice record...
  • 元宇宙概念股有哪些 元宇宙概念股一览表

    元宇宙概念股有哪些 元宇宙概念股一览表
    元宇宙概念股排行精选 元宇宙概念股一览表(2022/11/08),下文就随小蔡来简单的了解一下吧。The contours of the meta-cosmology unit are in the list of the meta-cosmological concept units (2022/11/08), so let's get to the bottom of this with Little Choi. 元宇宙概念股龙头有:The contou...
标签列表