A node election method, apparatus, device, and storage medium based on IPFS
By acquiring the download speed and performance information of IPFS nodes, and selecting target nodes for data download, the problem of slow download speeds in local area networks is solved, achieving more efficient bandwidth utilization and download monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-30
- Publication Date
- 2026-04-03
AI Technical Summary
In a local area network environment, under the IPFS-based edge-cloud architecture, the concurrent download speed of the terminal is slow and the number of nodes cannot be perceived, resulting in a slowdown when multiple users download concurrently.
By obtaining the download speed information of each node in IPFS, the total download speed and average download speed are determined. A preset number of target nodes are selected for data download based on node performance, and the default routing and multicast protocols are disabled to optimize the node selection process.
It effectively utilizes router bandwidth, avoids slowdowns caused by too many nodes, and can sense and monitor the download process to improve download efficiency.
Smart Images

Figure CN115834607B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a node selection method, apparatus, device, and storage medium based on IPFS. Background Technology
[0002] Currently, in a local area network (LAN) environment, the concurrent download speed of terminals in an IPFS-based edge-cloud architecture is too slow, and it's difficult to know the number of connected nodes. Therefore, a method to recommend nodes is needed. IPFS (InterPlanetary File System) is a network transport protocol designed to create persistent and distributed storage and sharing of files. It is a content-addressable peer-to-peer hypermedia distribution protocol, and nodes in an IPFS network constitute a distributed file system. Edge-cloud, as a terminal-edge-cloud collaborative architecture, organically integrates cloud computing and edge computing.
[0003] In existing technologies, IPFS file download nodes are obtained through the Kad network. Kad is short for Kademlia, a peer-to-peer (P2P) overlay network protocol used to build distributed P2P computer networks. However, in local area networks (LANs), limited by routers, the more nodes there are, the slower the download speed becomes for concurrent downloads by multiple users, and it's impossible to detect which node a user is downloading from. Summary of the Invention
[0004] In view of this, the purpose of this invention is to provide a node selection method, apparatus, device, and medium based on IPFS, which can maximize the utilization of router bandwidth, sense the nodes downloading data, and provide nodes to perform download tasks. The specific solution is as follows:
[0005] Firstly, this application discloses a node election method based on IPFS, including:
[0006] Obtain node information, including download speed, for each node within IPFS;
[0007] The total download rate is determined based on the download rate of each node. The number of nodes is determined based on the total download rate and the average total download rate obtained based on historical download rates. The available nodes for download are then determined from the nodes that have already downloaded the target data based on the number of nodes.
[0008] Based on the node performance of each of the downloadable nodes, a predetermined number of target nodes are selected from all the downloadable nodes;
[0009] The target node is used to execute the target data download task of the node to be downloaded, and the identification information of the target node is sent to the node to be downloaded.
[0010] Optionally, obtaining the node information containing the download rate for each node within IPFS includes:
[0011] Obtain node information for each node within IPFS; the node information includes node identification information, download speed, and upload speed.
[0012] A configuration file is sent to the node; the configuration file is used to disable IPFS routing and multicast protocols.
[0013] Optionally, the IPFS-based node election method further includes:
[0014] If no node has already downloaded the target data, the target data download task is executed on the node to be downloaded using the cloud.
[0015] Optionally, the step of selecting a preset number of target nodes from all the downloadable nodes based on the node performance of each downloadable node includes:
[0016] Based on the node performance parameters corresponding to each downloadable node, the node performance corresponding to each downloadable node is determined according to a preset performance calculation formula; the node performance parameters include memory size, average download time, and number of connections.
[0017] The downloadable nodes are sorted in descending order according to their performance, and the first preset number of downloadable nodes are selected as the target nodes.
[0018] Optionally, the step of selecting a preset number of target nodes from all the downloadable nodes based on the node performance of each downloadable node includes:
[0019] The operation of selecting a preset number of target nodes from all available download nodes is performed using a loop thread in order to select the current optimal available download node.
[0020] Optionally, the step of using the target node to execute the target data download task of the node to be downloaded includes:
[0021] Determine the current number of connections that each target node can support to obtain the current total number of connections that can be supported; the number of connections that can be supported is the difference between the maximum total number of connections and the number of connections already connected.
[0022] Based on the total number of supported connections, the same number of nodes to be downloaded are taken from the queue to be downloaded, and the target nodes are used to execute the target data download task of the nodes to be downloaded.
[0023] Optionally, determining the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determining available download nodes from the nodes that have already downloaded the target data based on the number of nodes, includes:
[0024] Based on the numerical relationship between the total download rate and the average total download rate, and the numerical relationship between the current number of target nodes and the preset target node number threshold, the node number adjustment method is determined in conjunction with the judgment rules; the node number adjustment method includes no adjustment, adding a first preset number of nodes, and adding a second preset number of nodes;
[0025] The number of nodes available for download is adjusted according to the node number adjustment method described above.
[0026] Secondly, this application discloses a node election device based on IPFS, comprising:
[0027] The node information acquisition module is used to acquire node information, including download speed, for each node in IPFS.
[0028] The module for determining available download nodes is used to determine the total download rate based on the download rate of each node, determine the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determine available download nodes from the nodes that have already downloaded the target data based on the number of nodes.
[0029] The target node determination module is used to select a preset number of target nodes from all the downloadable nodes based on the node performance of each downloadable node.
[0030] The download module is used to execute the target data download task of the node to be downloaded using the target node, and to send the identification information of the target node to the node to be downloaded.
[0031] Thirdly, this application discloses an electronic device, comprising:
[0032] Memory, used to store computer programs;
[0033] A processor is used to execute the computer program to implement the aforementioned IPFS-based node election method.
[0034] Fourthly, this application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned IPFS-based node election method.
[0035] In this application, node information including download speed for each node within IPFS is obtained; the total download speed is determined based on the download speed of each node; the number of nodes is determined based on the total download speed and the average total download speed obtained based on historical download speeds; and available download nodes are determined from the nodes that have already downloaded target data based on the number of nodes; a preset number of target nodes are selected from all available download nodes based on the node performance of each available download node; the target nodes are used to execute the target data download task of the node to be downloaded, and the identification information of the target nodes is sent to the node to be downloaded. It is evident that by controlling the number of available download nodes for target data download based on the total download speed and the average total download speed, the problem of slower download speeds due to a larger number of nodes and concurrent downloads by multiple users within the local area network is avoided, maximizing the utilization of router bandwidth. Furthermore, by combining the obtained node information with the target node that last executed the target data download task, it is possible to identify which nodes are downloading data and from which target nodes, thus facilitating better monitoring of the entire download process. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0037] Figure 1 A flowchart of a node election method based on IPFS provided in this application;
[0038] Figure 2 A flowchart illustrating a specific IPFS-based node election method provided in this application;
[0039] Figure 3 A schematic diagram of a node election device based on IPFS provided in this application;
[0040] Figure 4 This application provides a structural diagram of an electronic device. Detailed Implementation
[0041] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0042] In existing technologies, IPFS file download nodes are obtained through the Kad network, short for Kademlia, a peer-to-peer (P2P) overlay network protocol used to build distributed P2P computer networks. However, in local area networks (LANs), limited by routers, the more nodes there are, the slower the download speed becomes for multiple concurrent users, and it's impossible to detect which node a user is downloading from. To overcome these technical problems, this application proposes an IPFS-based node selection method that can maximize the use of router bandwidth, detect the nodes from which download data is being downloaded, and identify the nodes that provide download data to perform download tasks.
[0043] This application discloses a node election method based on IPFS, see [link to relevant documentation]. Figure 1 As shown, for a controller applied to a local area network architecture, the method may include the following steps:
[0044] Step S11: Obtain node information, including download speed, for each node in IPFS.
[0045] In this embodiment, the node information, including the download rate, corresponding to each node in IPFS is first obtained. It can be understood that this solution can be applied to concurrent downloads of terminal nodes based on IPFS in an edge-cloud architecture. After the terminal node starts, IPFS starts accordingly. Each node connects to the controller in the local area network architecture. The controller obtains the node information reported by each terminal node, including the download rate (rateIn).
[0046] In this embodiment, obtaining node information including download speed for each node within IPFS can include: obtaining node information for each node within IPFS; the node information includes node identification information, download speed, and upload speed; issuing a configuration file to the node; the configuration file is used to disable IPFS routing and multicast protocols. That is, the node information reported by the node includes, but is not limited to, node identification information and bandwidth information, where the node identification information includes the node ID and the corresponding IP address, and the bandwidth information includes the download speed and upload speed. Simultaneously, issuing a configuration file to nodes within the IPFS system to disable IPFS routing and multicast protocols (MDNS, Multicast DNS protocol) is understood because IPFS has built-in default routing and multicast protocols. Routing is used for node addressing and object addressing. If this default configuration is used, node data download detection cannot be achieved. Therefore, in this embodiment, by disabling these configurations and defining new node selection rules combined with node information, node data download detection is achieved.
[0047] Step S12: Determine the total download rate based on the download rate of each node, determine the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determine the nodes available for download from the nodes that have already downloaded the target data based on the number of nodes.
[0048] In this embodiment, after obtaining node information, the total download rate for all nodes is obtained by summing the download rates of all nodes based on the download rate of each node. The number of nodes is then determined based on the total download rate and the average total download rate obtained from historical download rates. The average total download rate can be the average rate of the previous download in the system, or an empirical value defined based on multiple historical download rates. The aforementioned number of nodes is a parameter used to adjust the number of available download nodes. It is understood that after initialization, there may not be any available download nodes in the entire system that can provide the target data. Therefore, each node that has already downloaded the target data can be considered a available download node. However, once a certain number of available download nodes are reached, further increasing the number of available download nodes will consume network bandwidth and actually reduce the concurrent download rate. For example, if the total download rate is 15M, with three available download nodes and an average download rate of 5M per node, the total download rate is 12M. With four available download nodes and an average download rate of 3M per node, the total download rate can reflect the download rate of a single available download node.
[0049] Therefore, to maximize bandwidth utilization, this embodiment controls the number of available download nodes based on the total download rate and the average total download rate. Specifically, when the total download rate is greater than the average total download rate, some nodes that are not currently available for download but possess the target data are selected as available download nodes in addition to the existing available download nodes, thereby increasing the number of available download nodes. Of course, if the current number of nodes that are not currently available for download but possess the target data is less than the number that needs to be increased, then all nodes that are not currently available for download but possess the target data are added as available download nodes. If the total download rate is less than or equal to the average total download rate, then the current number of available download nodes remains unchanged.
[0050] In this embodiment, determining the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determining the available download nodes from the nodes that have already downloaded the target data based on the number of nodes, may include: determining a node number adjustment method based on the numerical relationship between the total download rate and the average total download rate, and the numerical relationship between the current number of target nodes and a preset target node number threshold, combined with judgment rules; the node number adjustment method includes not adjusting, adding a first preset number of nodes, and adding a second preset number of nodes; and adjusting the number of currently available download nodes according to the node number adjustment method.
[0051] In this embodiment, to prevent the number of available download nodes from increasing too rapidly, which in turn slows down the download speed, a preset target node number threshold is used to control the growth rate of nodes. Specifically, the node number adjustment method is determined based on the numerical relationship between the total download speed and the average total download speed, and the numerical relationship between the current number of target nodes and the preset target node number threshold, combined with judgment rules. This can include the following situations:
[0052] Case 1: If the total download speed is greater than the average total download speed, and the number of current target nodes is less than the preset target node number threshold, then the number of available download nodes will be increased by a first preset number.
[0053] Case 2: If the total download speed is greater than the average total download speed, and the number of current target nodes is greater than the preset target node number threshold, then the number of available download nodes will be increased by a second preset number; the second preset number is less than the first preset number, that is, in case 1, the number of available download nodes will be increased rapidly, and in case 2, the number of available download nodes will be increased slowly.
[0054] Scenario 3: If the total download speed is less than or equal to the average total download speed, keep the number of available download nodes unchanged.
[0055] Step S13: Based on the node performance of each downloadable node, select a preset number of target nodes from all downloadable nodes.
[0056] In this embodiment, a preset number of target nodes are selected from all available downloadable nodes based on the node performance of each available downloadable node. This selection of the preset number of target nodes based on the node performance of each available downloadable node can include: using a loop thread to perform the operation of selecting the preset number of target nodes from all available downloadable nodes, so as to select the currently optimal available downloadable node. That is, by starting a loop thread at preset intervals, the target node recommendation operation is repeatedly executed to select the currently best-performing available downloadable node as the target node to provide data download services, further improving the efficiency of data download.
[0057] In this embodiment, selecting a preset number of target nodes from all available downloadable nodes based on the node performance of each available downloadable node may include: determining the node performance corresponding to each available downloadable node according to a preset performance calculation formula based on the node performance parameters corresponding to each available downloadable node; the node performance parameters include memory size, average download time, and number of connections; sorting the available downloadable nodes in descending order according to node performance, and selecting the top preset number of available downloadable nodes as the target nodes. In this embodiment, the preset performance calculation formula is used to calculate the weighted sum of all performance parameters based on each performance parameter and the weight corresponding to each performance parameter, and using this weighted sum as the node performance. The top preset number of available downloadable nodes with higher node performance are selected as the target nodes. Alternatively, target nodes can be selected from available downloadable nodes based on a performance scoring threshold to avoid using nodes with poor performance for data delivery, thus reducing efficiency. Define a node performance score, `score`, which is calculated by allocating points to the node's memory size (in milliseconds) and the average download time (average time for successful downloads). The weights for the current node's connection count (`con`), `ms`, `score`, and `average` are `w1`, `w2`, and `w3`, respectively. Therefore, `score = (w1 * ms) + (w2 * (average_max - average) / average_max) + (w3 * (con_max - con) / con_max)`. `average_max` represents the maximum average download time among all available download nodes, and similarly, `con_max` represents the maximum number of connections. The score range is limited by the ratio of the maximum value of each parameter to the current node's value.
[0058] Step S14: Use the target node to execute the target data download task of the node to be downloaded, and send the identification information of the target node to the node to be downloaded.
[0059] In this embodiment, after determining the target node, the target node is used to execute the target data download task of the node to be downloaded, and the identification information of the target node is sent to the node to be downloaded, so that the node to be downloaded can perceive which node the data is being downloaded from.
[0060] In this embodiment, the step of using the target node to execute the target data download task of the node to be downloaded may include: determining the current number of connections that each target node can currently support, thus obtaining the current total number of connections that can be supported; the number of connections that can be supported is the difference between the maximum total number of connections and the number of connections already connected; retrieving the same number of nodes to be downloaded from the queue based on the total number of connections that can be supported, and using the target node to execute the target data download task of the node to be downloaded. That is, based on the number of connections that the target node can currently support, a corresponding number of nodes to be downloaded are retrieved from the queue. The queue is used to temporarily store nodes waiting to be downloaded in sequence. After the download begins, these nodes to be downloaded are stored in the downloading queue, and after the download is completed, they are saved to the downloaded queue.
[0061] The IPFS-based node selection method described in this embodiment further includes: if no node has already downloaded the target data, executing the target data download task for the node to be downloaded using the cloud. That is, after system initialization, it is possible that no terminal node has the target data in its memory; in this case, the initial download task can be executed using the cloud.
[0062] As can be seen from the above, this embodiment obtains node information including download speed for each node within IPFS; determines the total download speed based on the download speed of each node; determines the number of nodes based on the total download speed and the average total download speed obtained based on historical download speeds; and determines available download nodes from the nodes that have already downloaded the target data based on the number of nodes. Based on the node performance of each available download node, a preset number of target nodes are selected from all available download nodes. The target nodes are used to execute the target data download task for the node to be downloaded, and the identification information of the target nodes is sent to the node to be downloaded. Therefore, by controlling the number of available download nodes for target data download based on the total download speed and the average total download speed, the problem of slower download speeds due to a larger number of nodes and concurrent downloads by multiple users within the local area network is avoided. This maximizes the utilization of router bandwidth. Furthermore, by combining the obtained node information with the target node that last executed the target data download task, it is possible to identify which nodes are downloading data and from which target nodes, thus facilitating better monitoring of the entire download process.
[0063] For example Figure 2 As shown, a specific IPFS-based node selection method disclosed in this embodiment may include the following steps:
[0064] Step 1: Start the terminal node of the edge-cloud architecture. IPFS is started on the terminal and connected to the controller of the local area network architecture, and then the node ID and IP address are reported. The controller saves or updates the parameters and issues a configuration file to disable the routing selection and MDNS of IPFS. The node reports the current bandwidth information using TCP long connection or http short connection. The bandwidth information includes the download rate (rateIn) and upload rate.
[0065] Step 2: Initialize each queue and thread. First, create a waiting download queue waitingQueue, a downloading queue downloadingQueue, and a set of nodes available for download providers. Start a cyclic thread a with an interval time t to start the node recommendation process.
[0066] Step 3: Calculate the number of nodes, that is, determine the number of nodes available for download. Define the current target number of nodes as s, with an initial value of 0. If providers is empty, the target node is the cloud. As the objects in providers increase, the target node can be taken from it. Statistically record the current total download rate rateIn_total, and define the value that increases rapidly in the calculation method as i and the value that increases slowly as j. To prevent the download from being too slow due to excessive rapid growth, a state variable of the target node quantity threshold slow_threhold is also set. After reaching this threshold, the growth changes from i to j. The specific implementation steps of the calculation are as follows:
[0067] Step 1: Calculate rateIn_total=(rateIn1 + rateIn2 + rateInN), and define the average total download rate rateIn_total_before of the previous download;
[0068] Step 2: When rateIn_total>rateIn_total_before and s<slow_threhold, increase the number of nodes by i. When rateIn_total>rateIn_total_before and s>slow_threhold, increase the number of nodes by j. When rateIn_total <= rateIn_total_before, keep the number of nodes unchanged.
[0069] Step 4: Node Selection. Based on the number of nodes, select the appropriate nodes and their corresponding downloadable nodes from the available node set `providers`. Calculate the node performance score. Sort the providers in descending order of their scores and select the top `s` nodes.
[0070] Step 5: Node Distribution. Each node supports a total of c connections. Loop through nodes m (s), retrieve at least c-con nodes to be downloaded from the waiting queue, add them to the downloading queue, and assign them to the corresponding nodes. The Distributor distributes the corresponding node information list to the nodes to be downloaded. The nodes to be downloaded automatically connect and download based on the node information returned by the cloud detection system, and report the download status back to the controller at time intervals t2.
[0071] Step Six: Download Complete. Once the download is complete, the terminal changes its role to that of a node that has downloaded the target data and is removed from the downloading queue. The controller records the download completion time.
[0072] Accordingly, this application also discloses an IPFS-based node election device, applied to a controller in a local area network architecture, see [link to relevant documentation]. Figure 3 As shown, the device includes:
[0073] The node information acquisition module 11 is used to acquire node information, including download speed, for each node in IPFS;
[0074] The available download node determination module 12 is used to determine the total download rate based on the download rate of each node, determine the number of nodes based on the total download rate and the average total download rate obtained based on the historical download rate, and determine the available download nodes from the nodes that have already downloaded the target data based on the number of nodes.
[0075] The target node determination module 13 is used to select a preset number of target nodes from all the downloadable nodes based on the node performance of each downloadable node.
[0076] Download module 14 is used to execute the target data download task of the node to be downloaded using the target node, and send the identification information of the target node to the node to be downloaded.
[0077] As can be seen from the above, this embodiment obtains node information including download speed for each node within IPFS; determines the total download speed based on the download speed of each node; determines the number of nodes based on the total download speed and the average total download speed obtained based on historical download speeds; and determines available download nodes from the nodes that have already downloaded the target data based on the number of nodes. Based on the node performance of each available download node, a preset number of target nodes are selected from all available download nodes. The target nodes are used to execute the target data download task for the node to be downloaded, and the identification information of the target nodes is sent to the node to be downloaded. Therefore, by controlling the number of available download nodes for target data download based on the total download speed and the average total download speed, the problem of slower download speeds due to a larger number of nodes and concurrent downloads by multiple users within the local area network is avoided. This maximizes the utilization of router bandwidth. Furthermore, by combining the obtained node information with the target node that last executed the target data download task, it is possible to identify which nodes are downloading data and from which target nodes, thus facilitating better monitoring of the entire download process.
[0078] In some specific embodiments, the node information acquisition module 11 may specifically include:
[0079] The node information acquisition unit is used to acquire node information corresponding to each node in IPFS; the node information includes node identification information, download speed, and upload speed.
[0080] The configuration file distribution unit is used to distribute configuration files to the nodes; the configuration files are used to disable IPFS routing and multicast protocols.
[0081] In some specific embodiments, the IPFS-based node election device may specifically include:
[0082] The download task execution unit is used to execute the target data download task of the node to be downloaded using the cloud if there is no node that has already downloaded the target data.
[0083] In some specific embodiments, the target node determination module 13 may specifically include:
[0084] A node performance determination unit is used to determine the node performance of each downloadable node according to a preset performance calculation formula based on the node performance parameters corresponding to each downloadable node; the node performance parameters include memory size, average download time, and number of connections.
[0085] The target node determination unit is used to sort the downloadable nodes in descending order according to their performance and select the first preset number of downloadable nodes as the target nodes.
[0086] In some specific embodiments, the target node determination module 13 may specifically include:
[0087] The node selection unit is used to perform the operation of selecting a preset number of target nodes from all the downloadable nodes using a loop thread, so as to select the current optimal downloadable node.
[0088] In some specific embodiments, the download module 14 may specifically include:
[0089] A unit for determining the total number of supported connections is used to determine the current number of supported connections for each target node, thereby obtaining the current total number of supported connections; the number of supported connections is the difference between the maximum total number of connections and the number of connections already connected.
[0090] The download unit is used to retrieve the same number of nodes to be downloaded from the queue of nodes to be downloaded according to the total number of supported connections, and to use the target nodes to execute the target data download task of the nodes to be downloaded.
[0091] In some specific embodiments, the downloadable node determination module 12 may specifically include:
[0092] The node number adjustment method determination unit is used to determine the node number adjustment method based on the numerical relationship between the total download rate and the average total download rate, and the numerical relationship between the current number of target nodes and the preset target node number threshold, combined with judgment rules; the node number adjustment method includes no adjustment, adding a first preset number of nodes, and adding a second preset number of nodes;
[0093] The node adjustment unit is used to adjust the number of currently available download nodes according to the node number adjustment method.
[0094] Furthermore, this application also discloses an electronic device, see [link to relevant documentation]. Figure 4 As shown, the content in the figure should not be considered as any limitation on the scope of use of this application.
[0095] Figure 4 This is a schematic diagram of the structure of an electronic device 20 provided in an embodiment of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the IPFS-based node election method disclosed in any of the foregoing embodiments.
[0096] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0097] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored on it include operating system 221, computer program 222 and data 223 including node information, etc., and the storage method can be temporary storage or permanent storage.
[0098] The operating system 221 manages and controls the various hardware devices on the electronic device 20 and the computer program 222 to enable the processor 21 to perform calculations and processing on the massive amounts of data 223 in the memory 22. The operating system 221 can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the IPFS-based node election method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0099] Furthermore, this application also discloses a computer storage medium storing computer-executable instructions. When the computer-executable instructions are loaded and executed by a processor, they implement the steps of the IPFS-based node election method disclosed in any of the foregoing embodiments.
[0100] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0101] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0102] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0103] The present invention provides a detailed description of a node election method, apparatus, device, and medium based on IPFS. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A node election method based on IPFS, characterized in that, Controllers used in local area network architectures include: Obtain node information, including download speed, for each node within IPFS, and send a configuration file to the node; the configuration file is used to disable IPFS routing and multicast protocols. The total download rate is determined based on the download rate of each node. The number of nodes is determined based on the total download rate and the average total download rate obtained based on historical download rates. The number of nodes available for download is determined from the nodes that have already downloaded the target data based on the number of nodes. The number of nodes is a parameter used to adjust the number of nodes available for download. Based on the node performance of each of the downloadable nodes, a predetermined number of target nodes are selected from all the downloadable nodes; The target node is used to execute the target data download task of the node to be downloaded, and the identification information of the target node is sent to the node to be downloaded; The step of determining the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determining available download nodes from the nodes that have already downloaded the target data based on the number of nodes, includes: If the total download rate is greater than the average total download rate, select some nodes from those nodes that are not available for download but have the target data as available nodes for download. If the total download rate is less than or equal to the average total download rate, then the number of available download nodes remains unchanged.
2. The node election method based on IPFS according to claim 1, characterized in that, The process of obtaining node information, including download speed, for each node within IPFS includes: Obtain the node information corresponding to each node in IPFS; the node information includes node identification information, download speed and upload speed.
3. The node election method based on IPFS according to claim 1, characterized in that, Also includes: If no node has already downloaded the target data, the target data download task is executed on the node to be downloaded using the cloud.
4. The node election method based on IPFS according to claim 1, characterized in that, The step of selecting a preset number of target nodes from all downloadable nodes based on the node performance of each downloadable node includes: Based on the node performance parameters corresponding to each downloadable node, the node performance corresponding to each downloadable node is determined according to a preset performance calculation formula; the node performance parameters include memory size, average download time, and number of connections. The downloadable nodes are sorted in descending order according to their performance, and the first preset number of downloadable nodes are selected as the target nodes.
5. The node election method based on IPFS according to claim 1, characterized in that, The step of selecting a preset number of target nodes from all downloadable nodes based on the node performance of each downloadable node includes: The operation of selecting a preset number of target nodes from all available download nodes is performed using a loop thread in order to select the current optimal available download node.
6. The node election method based on IPFS according to claim 1, characterized in that, The step of using the target node to execute the target data download task of the node to be downloaded includes: Determine the current number of connections that each target node can support to obtain the current total number of connections that can be supported; the number of connections that can be supported is the difference between the maximum total number of connections and the number of connections already connected. Based on the total number of supported connections, the same number of nodes to be downloaded are taken from the queue to be downloaded, and the target nodes are used to execute the target data download task of the nodes to be downloaded.
7. The node election method based on IPFS according to any one of claims 1 to 6, characterized in that, The process of determining the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determining available download nodes from the nodes that have already downloaded the target data based on the number of nodes, includes: Based on the numerical relationship between the total download rate and the average total download rate, and the numerical relationship between the current number of target nodes and the preset target node number threshold, the node number adjustment method is determined in conjunction with the judgment rules; the node number adjustment method includes no adjustment, adding a first preset number of nodes, and adding a second preset number of nodes; The number of nodes available for download is adjusted according to the node number adjustment method described above.
8. A node election device based on IPFS, applied to a controller in a local area network architecture, characterized in that, include: The node information acquisition module is used to acquire node information, including download speed, for each node in IPFS, and to send a configuration file to the node; the configuration file is used to disable IPFS routing and multicast protocols. The module for determining available download nodes is used to determine the total download rate based on the download rate of each node, determine the number of nodes based on the total download rate and the average total download rate obtained based on historical download rates, and determine available download nodes from the nodes that have already downloaded the target data based on the number of nodes; the number of nodes is a parameter used to adjust the number of available download nodes. The target node determination module is used to select a preset number of target nodes from all the downloadable nodes based on the node performance of each downloadable node. The download module is used to execute the target data download task of the node to be downloaded using the target node, and send the identification information of the target node to the node to be downloaded; The downloadable node determination module is used to select a portion of nodes as downloadable nodes from nodes that are not downloadable nodes but have the target data if the total download rate is greater than the average total download rate. If the total download rate is less than or equal to the average total download rate, then the number of available download nodes remains unchanged.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the IPFS-based node election method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store computer programs; wherein the computer programs, when executed by a processor, implement the IPFS-based node election method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Cloud-assisted cooperative downloading method of mobile P2P network
CN104158904A
Load balancing method and system
CN110247983A
File multi-node transmission method based on capability negotiation
CN113873045A
Monitoring video downloading method, server, client and readable storage medium
CN114666324A