Video pre-caching method and device based on P2P
By adopting the P2P-based video pre-cache method in the P2P network, using the polling mechanism and the bitmap switching mechanism, the problems of download delay and network congestion in the existing P2P network are solved, and more efficient video data download and pre-cache are achieved. .
Patent Information
- Application Number
- CN202311029174.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-15
- Publication Date
- 2025-02-21
AI Technical Summary
The existing P2P network has problems such as large network overhead, download delay and large service space in terms of content download and content pre-store, which can easily lead to network congestion and bandwidth spikes.
By applying a P2P-based video pre-cache method on the client, using the polling mechanism to send and receive local data bitmaps and pre-download bitmaps through the P2P connection, it is determined that undownloaded and unpre-downloaded data is generated and a pre-download list is sent to the pair Wait for nodes until all nodes successfully download the complete video data.
It effectively avoids bandwidth spikes, improves the load balancing and efficiency of the network, and reduces download delay and network overhead.
Smart Images

Figure CN119496942A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of peer-to-peer networks, and in particular to a video pre-caching method and device based on P2P. Background Art
[0002] In recent years, with the explosive growth of the Internet and its users, content distribution networks CDN and peer-to-peer networks P2P have received more and more attention. The development and application of P2P technology and CDN technology have brought about a qualitative change in the way of obtaining information resources.
[0003] P2P technology is a peer-to-peer data transmission technology between Internet nodes. Computers at any node on the network can act as network servers to provide resources to other computers, and can also act as general clients to obtain resources from other computers. P2P technology has the characteristics of decentralization, scalability, privacy protection, and load balancing. Existing P2P networks have problems such as high network overhead, download delays, and large service space occupation in content downloading and content pre-storage, which can easily cause network congestion, especially during the peak period of program playback. A large number of users making requests to the CDN at the same time will cause the CDN to be overly stressed and bandwidth spikes will occur. Therefore, it is particularly important to study pre-caching methods to avoid bandwidth spikes. Summary of the invention
[0004] The present disclosure provides a P2P-based video pre-caching method, apparatus, device and storage medium.
[0005] According to a first aspect of the present disclosure, a P2P-based video pre-caching method is provided. The method is applied to a client and includes:
[0006] In polling, the local data bitmap and pre-download bitmap of the local node are sent to each peer node through the P2P connection, and the local data bitmap and pre-download bitmap of each peer node are received at the same time;
[0007] Determine the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node;
[0008] Determine the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node;
[0009] Determine the data to be downloaded based on the data not downloaded and the data not pre-downloaded;
[0010] Generate a pre-download list of each peer node according to the data to be downloaded and send it to each peer node;
[0011] Before / after / while sending the pre-download list to each peer node, determine the completion status of each peer node for the pre-download list polled last time;
[0012] Repeat the above polling operation until each peer node successfully downloads the complete video data.
[0013] In some implementations of the first aspect, the bitmap determines whether each data block of the video exists through an array; wherein,
[0014] Each binary bit of each element in the array represents the existence or non-existence of a data block, 1 represents the existence of data, and 0 represents the non-existence of data.
[0015] In some implementations of the first aspect, determining the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node includes:
[0016] A logical AND operation is performed on the local data bitmap of the local node and the local data bitmaps of each peer node. The data block corresponding to the binary bit with a value of 0 in the result M of the AND operation is the undownloaded data. The local node downloads the undownloaded data locally.
[0017] In some implementations of the first aspect, determining the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node includes:
[0018] A logical AND operation is performed on the pre-download bitmap of the local node and the pre-download bitmaps of each peer node, and the data block corresponding to the binary bit with a value of 0 in the result N of the AND operation is the non-pre-downloaded data.
[0019] In some implementations of the first aspect, determining the data to be downloaded according to the data not downloaded and the data not pre-downloaded includes:
[0020] Perform a logical OR operation on M and N. The data block corresponding to the binary bit with a value of 0 in the result R of the OR operation is the data to be downloaded;
[0021] The data to be downloaded includes the data in the pre-download list of each peer node in the previous polling that was not successfully downloaded and the data that each peer node does not have locally and has not been pre-downloaded in this polling.
[0022] In some implementations of the first aspect, generating a pre-download list of each peer node according to the data to be downloaded and sending the pre-download list to each peer node includes:
[0023] The data blocks corresponding to the binary bits with the value of 0 in R are randomly selected, a pre-download list of each peer node is generated, and the pre-download list is sent to each peer node.
[0024] In some implementations of the first aspect, before / after / while sending the pre-download list to each peer node, determining the completion status of each peer node for the pre-download list of the previous polling includes:
[0025] Before / after / while the pre-download list is sent to each peer node, the local data bitmap of the local node and the local data bitmap of each peer node are logically ORed, and the data block corresponding to the binary bit with a value of 0 in the result P of the OR operation is the data that has not been successfully downloaded locally by each peer node; the pre-download bitmap of the local node and the pre-download bitmap of each peer node are logically ORed, and the data block corresponding to the binary bit with a value of 0 in the result Q of the OR operation is the data that has not been pre-downloaded by each peer node, and the data block corresponding to the binary bit with a value of 0 in both P and Q is the data that has not been successfully downloaded by each peer node in the pre-download list of the last poll.
[0026] According to a second aspect of the present disclosure, a P2P-based video pre-caching device is provided. The device comprises:
[0027] The bitmap mutual transmission module is used to send the local data bitmap and pre-download bitmap of the local node to each peer node through the P2P connection in polling, and receive the local data bitmap and pre-download bitmap of each peer node at the same time;
[0028] The undownloaded data determination module is used to determine the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node;
[0029] A non-pre-downloaded data determination module, used to determine the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node;
[0030] A module for determining data to be downloaded, used to determine data to be downloaded based on data not downloaded and data not pre-downloaded;
[0031] A pre-download list sending module is used to generate a pre-download list of each peer node according to the data to be downloaded and send it to each peer node;
[0032] A pre-download list checking module is used to determine the completion status of the pre-download list of the last polling by each peer node before / after / while sending the pre-download list to each peer node;
[0033] The video data download module is used to repeat the above polling operation until each peer node successfully downloads the complete video data.
[0034] According to a third aspect of the present disclosure, an electronic device is provided. The electronic device includes: at least one processor; and a memory connected to the at least one processor in communication; the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the method described above.
[0035] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, where the computer instructions are used to cause a computer to execute the method as described above.
[0036] According to a fifth aspect of the present disclosure, an embodiment of the present disclosure provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it implements the method described above.
[0037] The present disclosure is applied to the client. In polling, the local data bitmap and pre-download bitmap of the local node are sent to each peer node through a P2P connection, and the local data bitmap and pre-download bitmap of each peer node are received at the same time; the undownloaded data is determined according to the local data bitmap of the local node and the local data bitmap of each peer node; the unpre-downloaded data is determined according to the pre-download bitmap of the local node and the pre-download bitmap of each peer node; the data to be downloaded is determined according to the undownloaded data and the unpre-downloaded data; the pre-download list of each peer node is generated according to the data to be downloaded and sent to each peer node; before / after / while sending the pre-download list to each peer node, the completion status of the pre-download list of the previous polling by each peer node is determined; the above polling operation is repeated until each peer node successfully downloads the complete video data. In this way, the bandwidth spike phenomenon can be avoided.
[0038] It should be understood that the contents described in the summary of the invention are not intended to limit the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The above and other features, advantages and aspects of the embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure. In the accompanying drawings, the same or similar reference numerals represent the same or similar elements, among which:
[0040] Figure 1 A flowchart of a P2P-based video pre-caching method provided by an embodiment of the present disclosure is shown;
[0041] Figure 2 A structural diagram of a P2P-based video pre-caching device provided by an embodiment of the present disclosure is shown;
[0042] Figure 3 A block diagram of an exemplary electronic device capable of implementing an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0044] In addition, the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0045] In response to the problems in the background technology, the embodiments of the present disclosure provide a P2P-based video pre-caching method and device. Specifically, it is applied to the client, and in polling, the local data bitmap and pre-download bitmap of the local node are sent to each peer node through the P2P connection, and the local data bitmap and pre-download bitmap of each peer node are received at the same time; the undownloaded data is determined according to the local data bitmap of the local node and the local data bitmap of each peer node; the unpre-downloaded data is determined according to the pre-download bitmap of the local node and the pre-download bitmap of each peer node; the data to be downloaded is determined according to the undownloaded data and the unpre-downloaded data; the pre-download list of each peer node is generated according to the data to be downloaded and sent to each peer node; before / after / while sending the pre-download list to each peer node, the completion status of the pre-download list of the previous polling by each peer node is determined; the above polling operation is repeated until each peer node successfully downloads the complete video data. In this way, the bandwidth spike phenomenon can be avoided.
[0046] The P2P-based video pre-caching method and device provided by the embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings through specific embodiments.
[0047] Figure 1 A flowchart of a P2P-based video pre-caching method provided by an embodiment of the present disclosure is shown. The method 100 includes the following steps:
[0048] S110, in polling, sending the local data bitmap and pre-download bitmap of the local node to each peer node through the P2P connection, and receiving the local data bitmap and pre-download bitmap of each peer node at the same time.
[0049] In some embodiments, the bitmap determines whether each data block of the video exists through an array; wherein,
[0050] Each binary bit of each element in the array represents the existence or non-existence of a data block, 1 represents the existence of data, and 0 represents the non-existence of data.
[0051] In some embodiments, the data blocks corresponding to the binary bits with a value of 1 in the local data bitmap are downloaded data, and the data blocks corresponding to the binary bits with a value of 0 are not downloaded data;
[0052] The data blocks corresponding to the binary bits with a value of 1 in the pre-download bitmap are the data to be pre-downloaded, and the data blocks corresponding to the binary bits with a value of 0 are the data that will not be pre-downloaded.
[0053] S120: Determine the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node.
[0054] In some embodiments, determining the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node includes:
[0055] A logical AND operation is performed on the local data bitmap of the local node and the local data bitmaps of each peer node. The data block corresponding to the binary bit with a value of 0 in the result M of the AND operation is the undownloaded data. The local node downloads the undownloaded data locally.
[0056] In some embodiments, the local node downloads the undownloaded data to the local node, including:
[0057] The local node downloads the undownloaded data to the local node through the CDN.
[0058] In some embodiments, the data block corresponding to the binary bit with a value of 1 in M is the data that has been downloaded by the local node and each peer node.
[0059] S130: Determine the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node.
[0060] In some embodiments, determining the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node includes:
[0061] A logical AND operation is performed on the pre-download bitmap of the local node and the pre-download bitmaps of each peer node, and the data block corresponding to the binary bit with a value of 0 in the result N of the AND operation is the non-pre-downloaded data.
[0062] In some embodiments, the data block corresponding to the binary bit with a value of 1 in N is the data that the local node and each peer node need to pre-download.
[0063] S140: Determine data to be downloaded according to the data not downloaded and the data not pre-downloaded.
[0064] In some embodiments, determining the data to be downloaded based on the data not downloaded and the data not pre-downloaded includes:
[0065] Perform a logical OR operation on M and N. The data block corresponding to the binary bit with a value of 0 in the result R of the OR operation is the data to be downloaded;
[0066] The data to be downloaded includes the data in the pre-download list of each peer node in the previous polling that was not successfully downloaded and the data that each peer node does not have locally and has not been pre-downloaded in this polling.
[0067] In some embodiments, the data blocks corresponding to the binary bits with a value of 1 in R are data that have been downloaded by the local node and each peer node, and data that the local node and each peer node need to pre-download.
[0068] S150: Generate a pre-download list for each peer node according to the data to be downloaded and send it to each peer node.
[0069] In some embodiments, generating a pre-download list of each peer node according to the data to be downloaded and sending it to each peer node includes:
[0070] The data blocks corresponding to the binary bits with the value of 0 in R are randomly selected, a pre-download list of each peer node is generated, and the pre-download list is sent to each peer node.
[0071] S160: Before / after / while sending the pre-download list to each peer node, determine the completion status of each peer node for the pre-download list polled last time.
[0072] In some embodiments, before / after / while sending the pre-download list to each peer node, determining the completion status of each peer node for the pre-download list of the previous polling includes:
[0073] Before / after / while the pre-download list is sent to each peer node, the local data bitmap of the local node and the local data bitmap of each peer node are logically ORed, and the data block corresponding to the binary bit with a value of 0 in the result P of the OR operation is the data that has not been successfully downloaded locally by each peer node; the pre-download bitmap of the local node and the pre-download bitmap of each peer node are logically ORed, and the data block corresponding to the binary bit with a value of 0 in the result Q of the OR operation is the data that has not been pre-downloaded by each peer node, and the data block corresponding to the binary bit with a value of 0 in both P and Q is the data that has not been successfully downloaded by each peer node in the pre-download list of the last poll.
[0074] In some embodiments, the data block corresponding to the binary bit with a value of 1 in P is data that has been downloaded by the local node or data that has been downloaded by a peer node;
[0075] The data block corresponding to the binary bit with a value of 1 in Q is the data to be pre-downloaded by the local node or the data to be pre-downloaded by a peer node.
[0076] S170, repeat the above polling operation until each peer node successfully downloads the complete video data.
[0077] The above is an introduction to the method embodiment. The following further illustrates the scheme of the present disclosure by adopting a specific embodiment of the method.
[0078] Assume that the local node is A, and the peer nodes are B, C, and D. The binary bits of A's local data bitmap are 00101010, the binary bits of B's local data bitmap are 00001101, the binary bits of C's local data bitmap are 10001000, and the binary bits of D's local data bitmap are 00001000. The binary bits of A's pre-download bitmap are 10000101, the binary bits of B's pre-download bitmap are 11100100, the binary bits of C's pre-download bitmap are 00100100, and the binary bits of D's pre-download bitmap are 10010110.
[0079] Perform the first polling, send the local data bitmap and pre-download bitmap of node A to nodes B, C, and D through the P2P connection, and receive the local data bitmap and pre-download bitmap sent by node B, the local data bitmap and pre-download bitmap sent by node C, and the local data bitmap and pre-download bitmap sent by node D;
[0080] Perform a logical AND operation on the local data bitmap of node A and the local data bitmap of nodes B, C, and D, and obtain a binary bit of the AND operation result M of 00001000. Node A downloads the data block corresponding to the binary bit with a value of 0 in M to the local; perform a logical AND operation on the pre-download bitmap of node A and the pre-download bitmap of nodes B, C, and D, and obtain a binary bit of the AND operation result N of 00000100. The data block corresponding to the binary bit with a value of 0 in N is the data that has not been pre-downloaded; perform a logical OR operation on the binary bits of M and N, and obtain an OR operation result R, the binary bit of R is 00001100. Randomly select the data block corresponding to the binary bit with a value of 0 in R, generate a pre-download list, and send the pre-download list to the peer nodes B, C, and D;
[0081] Before / after / at the same time as the pre-download list is sent to peer nodes B, C, and D, the local data bitmap of node A is logically ORed with the local data bitmap of peer nodes B, C, and D, and the pre-download bitmap of node A is logically ORed with the pre-download bitmap of peer nodes B, C, and D. Assume that at this time, the binary bits of A's local data bitmap are 11101100, the binary bits of B's local data bitmap are 10111100, the binary bits of C's local data bitmap are 11111100, and the binary bits of D's local data bitmap are 11101100. The binary bits of A's pre-download bitmap are 00010000, the binary bits of B's pre-download bitmap are 01000000, and the binary bits of C's pre-download bitmap are 01000000. The binary bit is 00000000, and the binary bit of D's pre-download bitmap is 00010000. Then the binary bit of the result P obtained by performing a logical OR operation on the local data bitmap of node A and the local data bitmaps of nodes B, C, and D is 11111100, and the binary bit of the result Q obtained by performing a logical OR operation on the pre-download bitmap of node A and the pre-download bitmap of nodes B, C, and D is 01010000. The data blocks corresponding to the binary bits with values of 0 in P and Q are the data that were not successfully downloaded by the peer nodes B, C, and D in the pre-download list of the first polling, that is, the data blocks corresponding to the last two bits in the binary bits of P and Q are the data that were not successfully downloaded by the peer nodes B, C, and D in the pre-download list of the first polling;
[0082] Perform a second poll. At this time, the binary bits of A's local data bitmap are 11101100, the binary bits of B's local data bitmap are 10111100, the binary bits of C's local data bitmap are 11111100, and the binary bits of D's local data bitmap are 11101100. The binary bits of A's pre-download bitmap are 00010000, the binary bits of B's pre-download bitmap are 01000000, the binary bits of C's pre-download bitmap are 00000000, and the binary bits of D's pre-download bitmap are 00010000. The local data bitmap and pre-download bitmap of node A are sent to nodes B, C, and D through a P2P connection. At the same time, the local data bitmap and pre-download bitmap sent by node B, the local data bitmap and pre-download bitmap sent by node C, and the local data bitmap and pre-download bitmap sent by node D are received.
[0083] Perform a logical AND operation on the local data bitmap of node A and the local data bitmap of nodes B, C, and D, and obtain the binary bit of the AND operation result M to be 10101100. Node A downloads the data block corresponding to the binary bit with a value of 0 in M to the local; perform a logical AND operation on the pre-download bitmap of node A and the pre-download bitmap of nodes B, C, and D, and obtain the binary bit of the AND operation result N to be 00000000, perform a logical OR operation on the binary bits of M and N, and obtain the OR operation result R, the binary bit of R is 10101100, randomly select the data block corresponding to the binary bit with a value of 0 in R, generate a pre-download list, and send the pre-download list to peer nodes B, C, and D;
[0084] Before / after / at the same time as the pre-download list is sent to peer nodes B, C, and D, the local data bitmap of node A is logically ORed with the local data bitmap of peer nodes B, C, and D, and the pre-download bitmap of node A is logically ORed with the pre-download bitmap of peer nodes B, C, and D. Assume that at this time, the binary bits of A's local data bitmap are 11111110, the binary bits of B's local data bitmap are 10111111, the binary bits of C's local data bitmap are 11111101, and the binary bits of D's local data bitmap are 11101111, the binary bits of A's pre-download bitmap are 00000001, and the binary bits of B's local data bitmap are 10111111. The binary bits of the pre-download bitmap are 01000000, the binary bits of C's pre-download bitmap are 00000010, and the binary bits of D's pre-download bitmap are 00010000. The binary bits of P, the result of the logical OR operation of the local data bitmap of node A with the local data bitmaps of nodes B, C, and D, are 11111111. The binary bits of Q, the result of the logical OR operation of the pre-download bitmap of node A with the pre-download bitmaps of nodes B, C, and D, are 01010011. There are no binary bits with values of 0 in P and Q. Then, the peer nodes B, C, and D have successfully downloaded the data in the pre-download list of the second polling.
[0085] By repeating the above polling operation, peer nodes B, C, and D can all successfully download the complete video data.
[0086] The embodiment of the present disclosure is applied to the client. In polling, the local data bitmap and pre-download bitmap of the local node are sent to each peer node through a P2P connection, and the local data bitmap and pre-download bitmap of each peer node are received at the same time; the undownloaded data is determined according to the local data bitmap of the local node and the local data bitmap of each peer node; the unpre-downloaded data is determined according to the pre-download bitmap of the local node and the pre-download bitmap of each peer node; the data to be downloaded is determined according to the undownloaded data and the unpre-downloaded data; the pre-download list of each peer node is generated according to the data to be downloaded and sent to each peer node; before / after / while sending the pre-download list to each peer node, the completion status of the pre-download list of the previous polling by each peer node is determined; the above polling operation is repeated until each peer node successfully downloads the complete video data. In this way, the bandwidth spike phenomenon can be avoided.
[0087] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should be aware that the present disclosure is not limited by the order of the actions described, because according to the present disclosure, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
[0088] The above is an introduction to the method embodiment. The following is a further explanation of the scheme disclosed in the present invention through an apparatus embodiment.
[0089] Figure 2 The structure diagram of a P2P-based video pre-caching device provided by an embodiment of the present disclosure is shown. The device 200 includes:
[0090] The bitmap mutual transmission module 210 is used to send the local data bitmap and pre-download bitmap of the local node to each peer node through the P2P connection during polling, and simultaneously receive the local data bitmap and pre-download bitmap of each peer node.
[0091] In some embodiments, module 210 is specifically configured to:
[0092] The bitmap uses an array to determine whether each data block of the video exists;
[0093] Each binary bit of each element in the array represents the existence or non-existence of a data block, 1 represents the existence of data, and 0 represents the non-existence of data.
[0094] The not-downloaded data determining module 220 is used to determine the not-downloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node.
[0095] In some embodiments, module 220 is specifically configured to:
[0096] Determine the undownloaded data based on the local data bitmap of the local node and the local data bitmaps of each peer node, including:
[0097] A logical AND operation is performed on the local data bitmap of the local node and the local data bitmaps of each peer node. The data block corresponding to the binary bit with a value of 0 in the result M of the AND operation is the undownloaded data. The local node downloads the undownloaded data locally.
[0098] The non-pre-downloaded data determining module 230 is used to determine the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node.
[0099] In some embodiments, module 230 is specifically configured to:
[0100] Determining the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node includes:
[0101] A logical AND operation is performed on the pre-download bitmap of the local node and the pre-download bitmaps of each peer node, and the data block corresponding to the binary bit with a value of 0 in the result N of the AND operation is the non-pre-downloaded data.
[0102] The data to be downloaded is determined by the module 240, which is used to determine the data to be downloaded based on the data not downloaded and the data not pre-downloaded.
[0103] In some embodiments, module 240 is specifically configured to:
[0104] Determine the data to be downloaded based on the data that has not been downloaded and the data that has not been pre-downloaded, including:
[0105] Perform a logical OR operation on M and N. The data block corresponding to the binary bit with a value of 0 in the result R of the OR operation is the data to be downloaded;
[0106] The data to be downloaded includes the data in the pre-download list of each peer node in the previous polling that was not successfully downloaded and the data that each peer node does not have locally and has not been pre-downloaded in this polling.
[0107] The pre-download list sending module 250 is used to generate a pre-download list of each peer node according to the data to be downloaded and send it to each peer node.
[0108] In some embodiments, module 250 is specifically configured to:
[0109] Generate a pre-download list for each peer node based on the data to be downloaded and send it to each peer node, including:
[0110] The data blocks corresponding to the binary bits with the value of 0 in R are randomly selected, a pre-download list of each peer node is generated, and the pre-download list is sent to each peer node.
[0111] The pre-download list checking module 260 is used to determine the completion status of the pre-download list of the last polling by each peer node before / after / while sending the pre-download list to each peer node.
[0112] In some embodiments, module 260 is specifically configured to:
[0113] Before / after / while sending the pre-download list to each peer node, determine the completion status of each peer node for the pre-download list of the previous poll, including:
[0114] Before / after / while the pre-download list is sent to each peer node, the local data bitmap of the local node and the local data bitmap of each peer node are logically ORed, and the data block corresponding to the binary bit with a value of 0 in the result P of the OR operation is the data that has not been successfully downloaded locally by each peer node; the pre-download bitmap of the local node and the pre-download bitmap of each peer node are logically ORed, and the data block corresponding to the binary bit with a value of 0 in the result Q of the OR operation is the data that has not been pre-downloaded by each peer node, and the data block corresponding to the binary bit with a value of 0 in both P and Q is the data that has not been successfully downloaded by each peer node in the pre-download list of the last poll.
[0115] The video data downloading module 270 is used to repeat the above polling operation until each peer node successfully downloads the complete video data.
[0116] Understandably, Figure 2 Each module / unit in the detection device 200 shown has the function of implementing each step in the detection method 100 provided in the embodiment of the present disclosure and can achieve its corresponding technical effect. For the sake of brevity, it will not be repeated here.
[0117] Figure 3 A block diagram of an exemplary electronic device capable of implementing an embodiment of the present disclosure is shown. The electronic device 300 is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device 300 may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0118] like Figure 3As shown, the electronic device 300 includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 302 or a computer program loaded from a storage unit 308 into a random access memory (RAM) 303. In the RAM 303, various programs and data required for the operation of the electronic device 300 can also be stored. The computing unit 301, the ROM 302, and the RAM 303 are connected to each other via a bus 304. An I / O interface 305 is also connected to the bus 304.
[0119] A number of components in the electronic device 300 are connected to the I / O interface 305, including: an input unit 306, such as a keyboard, a mouse, etc.; an output unit 307, such as various types of displays, speakers, etc.; a storage unit 308, such as a disk, an optical disk, etc.; and a communication unit 309, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 309 allows the electronic device 300 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0120] The computing unit 301 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 301 performs the various methods and processes described above, such as method 100. For example, in some embodiments, the method 100 may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 308. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 300 via the ROM 302 and / or the communication unit 309. When the computer program is loaded into the RAM 303 and executed by the computing unit 301, one or more steps of the method 100 described above may be performed. Alternatively, in other embodiments, the computing unit 301 may be configured to perform the method 100 in any other appropriate manner (e.g., by means of firmware).
[0121] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0122] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0123] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0124] It should be noted that the present disclosure also provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable a computer to execute method 100 and achieve the corresponding technical effect achieved by executing the method in the embodiment of the present disclosure. For the sake of concise description, they are not repeated here.
[0125] In addition, the present disclosure also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the method 100 is implemented.
[0126] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0127] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0128] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0129] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0130] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A video pre-caching method based on P2P, characterized in that: Applied to the client, including: In polling, the local data bitmap and pre-download bitmap of the local node are sent to each peer node through the P2P connection, and the local data bitmap and pre-download bitmap of each peer node are received at the same time; Determine the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node; Determine the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node; Determining the data to be downloaded according to the undownloaded data and the unpre-downloaded data; Generate a pre-download list of each peer node according to the data to be downloaded and send it to each peer node; Before / after / while sending the pre-download list to each peer node, determine the completion status of each peer node for the pre-download list polled last time; Repeat the above polling operation until each peer node successfully downloads the complete video data.
2. The method according to claim 1, characterized in that The bitmap determines whether each data block of the video exists through an array; wherein, Each binary bit of each element in the array represents the existence or non-existence of a data block, 1 represents the existence of data, and 0 represents the non-existence of data.
3. The method according to claim 1, characterized in that The determining of the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node includes: A logical AND operation is performed on the local data bitmap of the local node and the local data bitmaps of each peer node. The data block corresponding to the binary bit with a value of 0 in the result of the AND operation M is the undownloaded data. The local node downloads the undownloaded data locally.
4. The method according to claim 1, characterized in that: The determining of the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node includes: A logical AND operation is performed on the pre-download bitmap of the local node and the pre-download bitmaps of each peer node, and the data block corresponding to the binary bit with a value of 0 in the result N of the AND operation is the non-pre-downloaded data.
5. The method according to claim 1, characterized in that Determining the data to be downloaded according to the undownloaded data and the unpre-downloaded data includes: Perform a logical OR operation on M and N, and the data block corresponding to the binary bit with a value of 0 in the result R of the OR operation is the data to be downloaded; The data to be downloaded includes data that was not successfully downloaded in the pre-download list of each peer node in the previous polling and data that each peer node does not have locally and has not pre-downloaded in this polling.
6. The method according to claim 1, characterized in that The method of generating a pre-download list of each peer node according to the data to be downloaded and sending the pre-download list to each peer node includes: A data block corresponding to a binary bit with a value of 0 in the R is randomly selected to generate a pre-download list of each peer node, and the pre-download list is sent to each peer node.
7. The method according to claim 1, characterized in that Before / after / while sending the pre-download list to each peer node, determining the completion status of each peer node for the pre-download list polled last time, including: Before / after / while the pre-download list is sent to each peer node, a local data bitmap of the local node and the local data bitmap of each peer node are subjected to a logical OR operation, and the data block corresponding to the binary bit with a value of 0 in the result of the OR operation P is the data that has not been successfully downloaded locally by each peer node; a pre-download bitmap of the local node and the pre-download bitmap of each peer node are subjected to a logical OR operation, and the data block corresponding to the binary bit with a value of 0 in the result of the OR operation Q is the data that has not been pre-downloaded by each peer node, and the data block corresponding to the binary bit with a value of 0 in both P and Q is the data that has not been successfully downloaded by each peer node in the pre-download list of the last poll.
8. A P2P-based video pre-caching device, characterized in that: include: The bitmap mutual transmission module is used to send the local data bitmap and pre-download bitmap of the local node to each peer node through the P2P connection in polling, and receive the local data bitmap and pre-download bitmap of each peer node at the same time; The undownloaded data determination module is used to determine the undownloaded data according to the local data bitmap of the local node and the local data bitmaps of each peer node; A non-pre-downloaded data determination module, used to determine the non-pre-downloaded data according to the pre-download bitmap of the local node and the pre-download bitmaps of each peer node; A module for determining data to be downloaded, used for determining data to be downloaded according to the data not downloaded and the data not pre-downloaded; A pre-download list sending module is used to generate a pre-download list of each peer node according to the data to be downloaded and send it to each peer node; A pre-download list checking module, used for determining the completion status of the pre-download list of the last polling by each peer node before / after / while sending the pre-download list to each peer node; The video data download module is used to repeat the above polling operation until each peer node successfully downloads the complete video data.
9. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.