CN109561137A - Establish method, apparatus, terminal device and the medium of P2P network - Google Patents
Establish method, apparatus, terminal device and the medium of P2P network Download PDFInfo
- Publication number
- CN109561137A CN109561137A CN201811354513.7A CN201811354513A CN109561137A CN 109561137 A CN109561137 A CN 109561137A CN 201811354513 A CN201811354513 A CN 201811354513A CN 109561137 A CN109561137 A CN 109561137A
- Authority
- CN
- China
- Prior art keywords
- nodes
- node
- network
- live broadcast
- client
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 44
- 230000011664 signaling Effects 0.000 claims description 10
- 238000004590 computer program Methods 0.000 claims description 5
- 230000005540 biological transmission Effects 0.000 description 10
- 238000010586 diagram Methods 0.000 description 8
- 230000004044 response Effects 0.000 description 8
- 238000005516 engineering process Methods 0.000 description 6
- 230000006870 function Effects 0.000 description 5
- 230000003993 interaction Effects 0.000 description 2
- 230000008569 process Effects 0.000 description 2
- 229920006395 saturated elastomer Polymers 0.000 description 2
- 230000000903 blocking effect Effects 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 238000010276 construction Methods 0.000 description 1
- 238000007796 conventional method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000005538 encapsulation Methods 0.000 description 1
- 230000006872 improvement Effects 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 239000007787 solid Substances 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/14—Session management
- H04L67/141—Setup of application sessions
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L65/00—Network arrangements, protocols or services for supporting real-time applications in data packet communication
- H04L65/80—Responding to QoS
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/104—Peer-to-peer [P2P] networks
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/56—Provisioning of proxy services
- H04L67/568—Storing data temporarily at an intermediate stage, e.g. caching
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Multimedia (AREA)
- Information Transfer Between Computers (AREA)
Abstract
This application discloses a kind of method, apparatus for establishing P2P network, terminal device and storage medium, the method includes the steps: after entering a direct broadcasting room, other nodes in the corresponding P2P network of Xiang Suoshu direct broadcasting room send connection request;Connection is established with the node for responding the request;The number of nodes that record has connected with this live streaming client;When the number of nodes having connected with this live streaming client is less than preset value, the node into the corresponding P2P network of the direct broadcasting room sends connection request again.The problem of aiming to solve the problem that the P2P network for how establishing suitable live scene.
Description
Technical Field
The application relates to the internet field, especially relates to the live broadcast field.
Background
Peer-to-Peer (P2P) is a distributed network where participants in the P2P network share a portion of their own hardware resources (processing power, storage power, network connectivity, printers, etc.) that need to be served and content by the network, and that can be accessed directly by other Peer nodes (peers) without going through intermediate entities. The participants in the network are both the resource (service and content) provider (the number of nodes acquiring the resource from the node is called the actual output number of the node) and the resource acquirer (the number of nodes providing the resource to the node is called the actual input number of the node).
Live broadcast can quickly and accurately transmit live information, and more people can watch live broadcast through websites, computers or mobile phones due to strong telepresence. Real-time live data streams are typically actively distributed by a server to various viewer clients for viewing by users. Under general conditions, hundreds of thousands or even millions of users watch the same live data stream in real time, and if the live data stream is distributed in a P2P mode, the pressure of a server can be greatly reduced, and the data distribution efficiency is improved. However, since the scenes in which the live broadcast and the conventional P2P technology are applied are very different, and the conventional P2P technology is mainly applied to scenes in which video or audio data are shared (for example, video resource downloading of websites such as video on demand), compared with the above scenes, the live broadcast has the characteristic that a large number of users can enter and exit the live broadcast room at every moment, so that the live broadcast-based P2P network dynamically changes at any moment and changes at a very fast frequency, but the live broadcast scene has real-time performance and the characteristic of extremely low tolerance to delay blocking, and if the conventional P2P technology is used for establishing the P2P network, the real-time performance requirement of the live broadcast is hardly met, and therefore how to establish the P2P network suitable for the live broadcast scene becomes an urgent problem to be solved.
Disclosure of Invention
In order to solve the technical problem, the present application provides a method, an apparatus, a terminal device and a medium for establishing a P2P network.
In a first aspect of the present application, there is provided a method for establishing a P2P network, comprising the steps of:
after entering a live broadcast room, sending a connection request to other nodes in a P2P network corresponding to the live broadcast room;
establishing a connection with a node responding to the request;
recording the number of nodes connected with the live broadcast client;
and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
In some examples, the recording of the number of nodes connected to the live client specifically includes the steps of:
storing the node identification connected with the live broadcast client to a cache region;
periodically interacting signaling information with the connected nodes, and if the signaling information of the connected nodes does not meet the preset requirement, releasing the node identifiers stored in the cache region;
and periodically recording the number of the node identifications stored in the cache region.
In some examples, the returning a connection request to another node in the P2P network corresponding to the live broadcast room includes:
requesting a node list from a server, wherein the node list carries address information of nodes meeting preset conditions;
and after receiving the node list, sending a connection request to the nodes in the node list.
In some examples, the preset condition is determined according to location information of a device where the live client is located, uplink capabilities of sections in the P2P network, a connection condition, a network condition, and/or a hardware configuration of the device where the live client is located.
In some examples, the number of other nodes to which any node is actively connected in the P2P network is not greater than a first set threshold, the number of other nodes to which any node is actively connected is not greater than a second set threshold, and the first set threshold is greater than the second set threshold.
In some examples, the live resources include packets, the packets are split from a live data stream acquired by a server from an anchor client and are encapsulated by the server in a customized format, the customized format includes a first identifier, the first identifier is used for describing uniqueness of each packet, and the packets are acquired by nodes in a P2P network directly or indirectly from the server.
In some examples, after establishing the connection with the node responding to the request, the method further includes:
negotiating a subscription with the connected node;
after the negotiation is successful, when the subscribed node acquires the data packet from the server through other nodes, the data packet subscribed by the live broadcast client is pushed to the live broadcast client.
In a second aspect of the present application, there is provided an apparatus for establishing a P2P network, comprising:
the request module is used for sending a connection request to other nodes in a P2P network corresponding to a live broadcast room after entering the live broadcast room;
a processing module for establishing a connection with a node responding to the request; recording the number of nodes connected with the live broadcast client; and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
In a third aspect of the present application, there is provided a terminal device, comprising:
a processor; and
a memory configured to store a computer program configured to be executed by the processor to perform operations according to any one of the methods of the first aspect.
In a fourth aspect of the present application, there is provided a computer readable storage medium having stored thereon a computer program for execution by a processor of operations according to any one of the methods of the first aspect.
The number of the nodes connected with the live broadcast client is recorded; when the number of the nodes connected with the live broadcast client is less than a preset value, a connection request is sent to the nodes in the P2P network corresponding to the live broadcast room again to maintain that the number of the nodes connected with the live broadcast client is not less than the preset value, so that the live broadcast client can quickly acquire live broadcast streaming media data from the connected nodes when the live broadcast streaming media data cannot be acquired, the time for reestablishing the connection is shortened, the problems of delay and blockage caused by the traditional P2P network construction mode when the live broadcast streaming media is played are solved, and the live broadcast scene with higher real-time requirement is excellently adapted.
Drawings
Fig. 1 is a network architecture of a live broadcast system according to an embodiment of the present application;
fig. 2 is a flowchart of a method for establishing a P2P network according to an embodiment of the present application;
fig. 3a is a flowchart of another method for establishing a P2P network according to the embodiment of the present application;
fig. 3b is a flowchart of another method for establishing a P2P network according to the embodiment of the present application;
FIG. 4 is a diagram illustrating a conventional P2P network setup;
FIG. 5a is a schematic diagram of a P2P network according to an embodiment of the present invention;
FIG. 5b is a schematic diagram of another P2P network proposed in the embodiment of the present application;
fig. 6 is a flowchart of another method for establishing a P2P network according to an embodiment of the present application;
FIGS. 7 a-7 c are diagrams of networks constructed under three different server architectures according to embodiments of the present application;
fig. 8 is a flowchart of another method for establishing a P2P network according to an embodiment of the present application;
fig. 9 is a schematic diagram of an apparatus for establishing a P2P network according to an embodiment of the present application;
fig. 10 is a schematic diagram of a terminal device exemplarily shown in the embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
Referring to fig. 1, which is a schematic view of a live broadcast scene based on a P2P network exemplarily shown in an embodiment of the present application, a first viewer client, a second viewer client, a third viewer client, and an anchor client are respectively installed on terminal devices 110, 120, 130, and 140, the anchor client may produce live broadcast streaming media data through screen capture and by using other methods such as recording video and taking photos with a camera, and the live broadcast streaming media data includes a frame of image frame and audio data, and then send the produced live broadcast streaming media data to a server 100 through the network. The server 100 is configured to provide a live background service, for example, store a corresponding relationship between each anchor client and each viewer client, manage the P2P network, segment live streaming media data into a plurality of data packets, package the data packets according to a customized format, and distribute the packaged data packets, and when the first viewer client, the second viewer client, and the third client are in the same live broadcasting room as the anchor client, the server 100 may notify the first viewer client, the second viewer client, and the third viewer client to establish a P2P network, and the first viewer client, the second viewer client, and the third viewer client in the P2P network may interact with each other to exchange data packets, so as to reduce the pressure of the server and improve the efficiency of each live client obtaining live streaming media data. The live clients in the P2P network are also referred to as nodes.
The embodiment of the application refers to a social network platform, an instant messaging platform and the like which are aggregated together, a user enters a live broadcast room by logging in a client side, the user exists in the live broadcast room in the identity of the member, and the member with various identities, such as audience, anchor broadcast and the like, is contained in the same live broadcast room. The user can arbitrarily join or quit the live broadcast room. For users with certain authority, the users can add or delete members in the live broadcast room, and can also create or separate the live broadcast room, and the identities of the users with the authority are taken as the anchor broadcast. In the live broadcast room, any plurality of members can carry out interaction such as chatting, talking, video or pushing electronic gifts.
The "anchor client" and the "viewer client" described in the embodiments of the present application may refer to software installed on a terminal device, and in some cases, the live client and the viewer client are integrated on one piece of software, and when the identity of the user is the anchor, the client may be referred to as the anchor client, and when the identity of the user is the viewer, the client may be referred to as the viewer client. The live client in the present specification is either an anchor client or a viewer client.
Because the scenes in which the live broadcast and the conventional P2P technology are applied are greatly different, the conventional P2P technology is mainly applied to scenes in which video or audio data are shared (for example, video resource downloading of websites such as video on demand), and compared with the scenes in which live broadcast exists, the characteristics that a large number of users can enter and exit the live broadcast room at any moment exist, so that the live broadcast-based P2P network dynamically changes at any moment, and the change frequency is very fast, but the live broadcast has real-time performance and extremely low tolerance to delay jamming, and how to establish the P2P network suitable for the live broadcast scene becomes an urgent problem to be solved.
In order to solve the foregoing technical problem, embodiments of the present application provide a method, an apparatus, a device, and a storage medium for establishing a live broadcast-based P2P network. Fig. 2 is a flowchart illustrating an exemplary method for establishing a P2P network according to an embodiment of the present application, where the method includes the steps of:
the live client performs S210: after entering a live broadcast room, sending a connection request to other nodes in a P2P network corresponding to the live broadcast room;
s220: establishing a connection with a node responding to the request;
s230: recording the number of nodes connected with the live broadcast client;
s240: and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
In some examples, the entering into a live broadcast room may specifically be: and after clicking the control for entering the live broadcast room, the user enters the live broadcast room.
In some examples, after the live broadcast client sends a connection request to other nodes in the P2P network, the other nodes receiving the request select to return a response or not to respond according to their own conditions, if the live broadcast client receives the response returned by the node, the connection is successfully established, and if the live broadcast client does not receive a response within a specified time, the connection is considered to be failed.
In a specific example, the method for establishing the live broadcast-based P2P network described in fig. 2 may be: a live broadcast room a has a plurality of audience clients, and the audience clients mutually establish a P2P network to push live broadcast streaming media data. When logging in, a live broadcast client 1 registers with a server, and sends a connection request to a node in a P2P network corresponding to a live broadcast room a after entering the live broadcast room a, and certainly, after entering the live broadcast room a, the live broadcast client 1 requests the server for address information of each node in the live broadcast room a, so that the live broadcast client 1 can send the connection request to the node in the P2P network corresponding to the live broadcast room a; after receiving the response of the node, the live broadcast client 1 establishes a connection with the node, and then updates the recorded number of nodes connected to the live broadcast client 1, and certainly, if there is a node to which the connection has been established is disconnected, also updates the number of connected nodes, and when the number of nodes connected to the live broadcast client 1 is less than a preset value, sends a connection request to the node in the P2P network corresponding to the live broadcast room a again, so that the number of nodes kept connected to the live broadcast client a is not less than a first preset value, for example: the preset value is 2, the live broadcast client 1 and 3 nodes are connected, and are respectively node 1, node 2, and node 3, and the live broadcast streaming media data is acquired from node 1, but because network jitter or two of nodes 2 and 3 exit the live broadcast room, the number of connected nodes is equal to 1 and is less than 2, at this time, if no processing is performed, if node 1 also exits the live broadcast room or cannot receive the live broadcast streaming media data due to network jitter, the live broadcast client needs to request connection to a node in the P2P network again, so that the live broadcast streaming media data cannot be received for a period of time, and a live broadcast client a has pause or a screen when playing the live broadcast streaming media data, but in the embodiment of the present application, by maintaining the number of nodes connected with the live broadcast client a to be not less than the preset value, it can be ensured that when the live broadcast streaming media client a cannot acquire the live broadcast streaming media data, the live streaming media data are quickly acquired from the connected nodes, so that the time for reestablishing the connection is reduced, the time delay and the time delay are reduced, and the method is excellently suitable for live scenes with higher real-time requirements.
In some examples, referring to fig. 3a, step S230 described in fig. 2 may specifically include:
s231: and storing the node identification connected with the live broadcast client to a cache region.
S232: and periodically interacting signaling information with the connected nodes, and if the signaling information of the connected nodes does not meet the preset requirement, releasing the node identifiers stored in the cache region.
S233: and periodically recording the number of the node identifications stored in the cache region.
The buffer may be a queue for maintaining the stored node identifiers. The node identification is used to characterize the uniqueness of the node in the P2P network, such as the IP number of the node or others.
The signaling information includes: the information such as the network speed, the time delay, the packet loss rate, and/or the uplink bandwidth of the connected node may be one or more signaling message comprehensive scores, and the meeting of the preset requirement means that the comprehensive score is smaller than a preset score. Of course, except for scoring, the live broadcast client may also find that when the live broadcast client interacts signaling information with a connected node, the connection may be interrupted and the identifier of the node may be released from the cache region when the time delay is extremely long, or the packet loss rate is extremely low, or the uplink bandwidth of the connected node is small.
The embodiment shown in fig. 3a records the number of nodes connected to the live client in a queue manner, so that the nodes connected to the live client can be better maintained and managed.
In some examples, the number of connected nodes may also be cached in the cache region, and after the connection is disconnected, the number of connected nodes in the cache region is reduced, and after the connection is newly established, the number of connected nodes in the cache region is increased. In other examples, the number of connected nodes may be periodically detected, and the number of connected nodes with the live client may be recorded. The number of the nodes connected with the live client can be recorded in other modes, and the method for recording the number of the nodes connected with the live client is not limited in the application.
The number of nodes in the P2P network corresponding to one live broadcast room is huge, and if each live broadcast client entering the live broadcast room needs to send a connection request to all the nodes, excessive occupation of bandwidth is caused. In order to solve the technical problem, in some examples, referring to fig. 3b, step S210 in fig. 2 may specifically include:
s211: after a live client (e.g., live client a) enters a live room, a node list is requested from the server.
And the server sends the node list to the live client a according to the related information of the live client.
The node list carries address information of nodes meeting preset conditions, such as IP addresses and the like.
The preset conditions are determined according to the position information of the device where the live client a is located, the uplink capacity of each section in the P2P network, the connection condition, the network condition and/or the hardware configuration of the device where the live client a is located. In a specific example, the server records a certain number of nodes closer to the live client in a node list according to the location information of the device where the live client is located, where the number may be forty to fifty.
S212: and after receiving the node list, the live broadcast client sends a connection request to the nodes in the node list.
In some examples, the live client a may send a connection request to all or part of the nodes in the node list according to the address information carried in the node list.
According to the method and the device, the node list which is in accordance with the preset conditions and aims at the live client a is obtained from the server, so that the number of the nodes which send the connection requests by the live client a is controlled, and meanwhile, the connection quality is considered.
In practical application, it is found that the existing P2P network is prone to saturation, so that a newly-accessed node cannot obtain resource data from other nodes. For example, referring to fig. 4, two nodes 1, 2 and 3 are each a resource data provider and a resource data acquirer, and if each node serves as a resource data provider for at most two nodes, when a new node enters, the nodes 1, 2 and 3 cannot provide resource data for the newly entering node. In view of this problem, in the P2P network provided in the embodiment of the present application, the number of other nodes actively connected to any node is not greater than a first set threshold, the number of other nodes actively connected to any node is not greater than a second set threshold, and the first set threshold is greater than the second set threshold.
Referring to fig. 5a, which is a schematic diagram of a P2P network shown in this embodiment of the present application, in the P2P network shown in fig. 5a, it is set that the number of other nodes actively connected to any node is not greater than a first set threshold, the number of other nodes actively connected to any node is not greater than a second set threshold, and the first set threshold is greater than the second set threshold, for example, the first set threshold is 3, the second set threshold is 2, node 1 actively establishes connection with 2 nodes, and is actively connected by 3 nodes, then the number of other nodes actively connected to node 1 is 3, which is equal to the first set threshold, and the number of other nodes actively connected to node 1 is 2, which is equal to the second set threshold, at this time, node 1 cannot actively connect to other nodes, and cannot be successfully actively connected by other nodes; node 2 is actively connected to 1 node and actively connected to 2 nodes, so that the number of other nodes actively connected to node 2 is 2, which is smaller than a first set threshold, the number of other nodes actively connected to node 2 is 1, which is smaller than a second set threshold, at this time, node 2 may also be actively connected to 2-1 ═ 1 nodes, and node 2 is also allowed to be actively connected to 3-2 ═ 1 other nodes.
Therefore, unlike the conventional method for building the P2P network, in the P2P network proposed in the embodiment of the present application, the number of other nodes to which any node is actively connected is not greater than a first set threshold, the number of other nodes to which any node is actively connected is not greater than a second set threshold, and the first set threshold is greater than the second set threshold. That is to say, in the embodiment of the present application, the number of nodes allowed to be actively connected (the first set threshold) of each node is greater than the number of nodes allowed to be actively connected (the second set threshold), so that, according to the method of the embodiment of the present application, no matter how the whole P2P network is constructed, there must be an opportunity of being actively connected by other nodes, so that the P2P network constructed by the embodiment of the present application is unlikely to be saturated, and finally, a newly joined node can be more easily accessed into the P2P network. For example, referring to fig. 5b, taking 3 nodes in a P2P network as an example, which are node 1, node 2 and node 3, respectively, in the P2P network, the first set threshold is 2, the second set threshold is 1, that is, the number of other nodes allowed to be actively connected by each node is 1, and the number of other nodes allowed to be actively connected by each node is 2. If the node 1 is actively connected with the node 2, the node 1 reaches a second set threshold value, and the node 1 cannot be actively connected with other nodes but can be actively connected by 1 node; at this time, the node 3 may actively connect to the node 1 or the node 2, since the node 3 actively connects to the node 1 or the node 2, and for the sake of no repeated description, it is exemplified in fig. 5b that the node 3 actively connects to the node 1, at this time, both the nodes 1 and 3 reach the second set threshold, and cannot actively connect to other nodes, but can be actively connected by 1 node, at this time, in the P2P network, the node 2 may actively connect to 1 other node, since the nodes 1 and 2 have already established a connection, the node 2 actively sends a connection request to the node 3, and by this time, the nodes 1 to 3 complete the establishment of the P2P network, in the P2P network, none of the nodes can actively send a connection request to other nodes, and all of the 3 nodes can be actively connected by other nodes. When the node 4 enters the P2P network, since none of the nodes 1-3 in the P2P network can actively connect to other nodes, a connection request is sent from the node 4 newly entering the P2P network to any of the nodes 1-3 (e.g., the node 4 shown in fig. 5b actively connects to the node 2) to establish a new P2P network. As can be seen from the example of fig. 5b, by the method of the embodiment of the present application, and no matter how the connection relationship between the nodes 1-3 is, there are 3 opportunities allowed to be actively connected by other nodes in the whole P2P network, and the network is not saturated; in addition, in the new P2P network after the node 4 joins, the node 1 and the node 3 can be allowed to be actively connected by 1 node, the node 4 is allowed to be actively connected by 2 nodes, and the new P2P network has 4 opportunities of being allowed to be actively connected by other nodes, and saturation does not occur.
Based on that the number of other nodes actively connected with any node in the P2P network is not greater than a first set threshold, the number of other nodes actively connected with any node is not greater than a second set threshold, and the first set threshold is greater than the second set threshold. In some examples, after receiving the node list, the live broadcast client may send a connection request to all or some of the nodes on the node list according to address information on the node list, and the node that receives the request determines whether the node itself is allowed to be actively connected by other nodes, and if the number of other nodes that the node is actively connected to is less than a first set threshold, returns a response to the live broadcast client, the connection is successful, and if the number of other nodes that the node is actively connected to is equal to the first set threshold, the response is not returned, and the live broadcast client does not receive a feedback within a specified time, and then considers that the connection is failed.
Referring to fig. 6, a flowchart of another method for establishing a P2P network schematically illustrated in this embodiment of the present application includes the specific steps of:
s610: and the anchor client sends the collected live broadcast streaming media data to the server.
S620: the server cuts the received live broadcast streaming media data into a plurality of data packets, and encapsulates each data packet according to a self-defined format, wherein the self-defined format comprises a first identifier, and the first identifier is used for describing the uniqueness of each data packet.
S630: after a P2P network is established with a spectator client in the same live broadcast room as the anchor client, the server distributes the encapsulated data packets to nodes of a subscription server in the P2P network.
S210: and the live broadcast client enters the live broadcast room and sends a connection request to other nodes in the P2P network corresponding to the live broadcast room.
In some examples, in the P2P network, the number of other nodes to which any node is actively connected is not greater than a first set threshold, the number of other nodes to which any node is actively connected is not greater than a second set threshold, and the first set threshold is greater than the second set threshold;
s220: the live client establishes a connection with the node responding to the request to update the P2P network.
S230: the live broadcast client records the number of nodes connected with the live broadcast client;
s240: and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
The method illustrated in fig. 6 differs from the conventional P2P mode in that live streaming media data is first cut into packets instead of file blocks, the size of the file blocks may be hundreds of KB, and the cuttable granularity of the packets is smaller relative to the file blocks, and the packets can be transmitted in the network as smaller transmission units, for example, when the size of the cut packets is considered, the packets can be designed by combining the transmission characteristics of the internet network, so that the size of the packets matches the transmission bandwidth of each connection channel in the P2P network. For example, the channel established between each pair of peer nodes may be a UDP channel, and the size of each packet may be about 1KB, which is slightly smaller than MTU (maximum transmission unit of internet network layer), so that each packet may be transmitted by 1 IP packet without unpacking based on the IP packet, which is more efficient than the way of cutting a file, thereby having a wider application scenario.
The server provided by the embodiment of the application can be assumed by various entities, which depends on the role division of different network devices by designers. For example, fig. 7a, 7b, and 7c are network architectures in three different scenarios, and it can be seen that, in different service modes, due to different requirements of service or device management, different types of server devices may assume the functions of the server. In fig. 7a, a first server plays a role of collecting live streaming media data, a second server plays a role of cutting data packets, and a third server plays a role of distributing data packets to a peer node. In fig. 7b, the first server integrates the functions of collecting streaming media data and cutting data packets, and the second server serves as the server for distributing the data packets. In fig. 7c, the server integrates the functions of collecting streaming media data, cutting data packets, and distributing data packets. It is noted that other forms of network architecture or server functionality than the examples listed in fig. 7a, 7b and 7c are not excluded.
It should be noted that, in the data packet encapsulation stage, in order to enable the cut data packets to be orderly assembled after being received by the clients and to enable the data packets to be interacted after peer nodes are formed between the clients, the server may number each data packet as a field describing a unique identifier of each data packet, where the unique identifier is a first identifier, in some examples, the purpose may be achieved by customizing a format of the data packet, and a specific field may be specified in the customized format as the unique identifier. In some examples, the first identifier proposed in the present application may be a unique identifier for distinguishing other data packets in the same shared resource data. Of course, other ways of achieving this are not excluded.
In some examples, referring to fig. 8, after step S220 "establishing connection with the node responding to the request" in fig. 2, the method may further include the steps of:
s810: negotiating a subscription with the connected node.
In this step, the live broadcast client may partially negotiate and subscribe with a connected node, and it should be noted that, in the P2P network described in this embodiment of the present application, the node positions for establishing connection are equal, and if a node a actively requests a node b for connection, after the node a and the node b establish connection, the two nodes may subscribe with each other, that is, the node a may obtain live broadcast streaming media data from the node b, and at this time, the node b is a subscribed node with respect to the node a, or the node b may obtain live broadcast streaming media data from the node a.
S820: after the negotiation is successful, when the subscribed node acquires the data packet from the server through other nodes, the data packet subscribed by the live broadcast client is pushed to the live broadcast client.
It should be noted that fig. 2, fig. 3a, fig. 3b, fig. 6, and fig. 8 may be arbitrarily combined to form another method for establishing a P2P network, and details are not repeated herein.
In the embodiment shown in fig. 8, by first negotiating subscription with the connected node, after the negotiation is successful, when the subscribed node acquires a data packet from the server through another node, the data packet subscribed by the live broadcast client is pushed to the live broadcast client, so that delay caused by too much request and response information interaction and occupation of network bandwidth due to a stream pulling mode of each node in the existing P2P technology are avoided, and the real-time performance of playing live broadcast streaming media data by the live broadcast client is ensured.
To further improve the efficiency of data transmission in the P2P network, in some examples, different data packets are divided into a plurality of groups according to the first identifier, and the specific data packets pushed by the subscribed different nodes respectively belong to different groups.
Specifically, in some examples, the first identifier may be a number of a predetermined number of bits, and the number of packets may be complemented by the number of each data packet, and the packet of each data packet may be determined according to a remainder of the complementation. For example: the method includes the steps that the live streaming media data are cut into data packets with the numbers of 1-20, the number of the packets is 5, the number of each data packet is used for complementing the number of 5, for example, the number of the remainder is 1, 1/5 is 1, the remainder of 1 belongs to a first group, so that the data packets with the number of 1 belong to the first group, and so on, the grouping situation of each data packet can be determined, the data packets of each group of packets form a sub-stream, for example, the data packet with the remainder of 0 belongs to a sub-stream with the number of 0, the data packet with the remainder of 1 belongs to a sub-stream with the number of 1, and so on. In some examples, the number of packets may be determined according to a code rate or a resolution of the live streaming media data or a number of servers that undertake a task of distributing the data packets, and a specific redundancy strategy is not limited. After the data packets are grouped, the server may distribute the data packets to nodes in the P2P network based on the grouping, for example, a plurality of servers may respectively send data packets of different groups to nodes in the P2P network that obtain resource data from the server, so as to improve data transmission efficiency and increase the play-out speed of the nodes for playing the streaming media data. Of course, in some examples, after the data packets are grouped, each node may obtain the data of different groups from different nodes, which may further improve the data transmission efficiency in the P2P network.
The effect of the above embodiment can also be achieved by classifying the nodes. In a specific example, each node in the P2P network may maintain or record different types of nodes, where the types of nodes include: candidate nodes, active nodes, transmission nodes, obsolete nodes or/and dead nodes. Wherein,
the candidate node refers to a node in a node list acquired from the server, or a node which sends a connection request by the node, but connection is not established yet.
And the active node refers to a node which establishes a connection with the node and maintains a connection state from the candidate nodes. Signaling information, such as packet loss rate, delay, network speed and/or uplink bandwidth, can be periodically exchanged between the active node and the node.
And a transmitting node refers to a node which can be used for acquiring resource data in the active nodes.
And the obsolete node refers to a node which has poor quality in the active node and is actively abandoned by the node.
The dead nodes can be divided into two types, wherein one type is a node which requests connection but is not successfully connected in the candidate nodes; the other is a node which cannot transmit resource data in the transmission node, and the condition can be caused by dead halt or network disconnection.
Of course, if the data packets are grouped according to numbers, in some examples, the transmission nodes in the P2P network may include subscription nodes, for example, node 1 acquires sub-flow No. 1 from node 2, node 2 is a subscription node of node 1 corresponding to sub-flow No. 1, node 1 acquires sub-flow No. 0 from node 3, and node 3 is a subscription node of node 1 corresponding to sub-flow No. 0.
Of course, in some examples, step S230 of fig. 2 may also be implemented by maintaining a queue for recording active nodes, removing eliminated nodes and dead nodes from the active nodes when eliminated nodes and dead nodes exist, and requesting the node list again from the server when the node finds that the number of active nodes is less than the preset value, and sending a connection request to candidate nodes in the node list, so that the number of active nodes corresponding to each node is not less than the preset value. It will be appreciated that in some examples, each of the above types of nodes may be maintained in a queue.
Referring to fig. 9, an apparatus for establishing a P2P network is provided, including:
a request module 910, configured to send a connection request to another node in a P2P network corresponding to a live broadcast room after entering the live broadcast room;
a processing module 920, configured to establish a connection with a node responding to the request; recording the number of nodes connected with the live broadcast client; and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
The embodiment of the apparatus for establishing a P2P network in fig. 9 can be applied to a terminal device. The device embodiments may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and as a logical device, the device is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor of the terminal device where the device is located. From a hardware aspect, as shown in fig. 10, for a hardware structure diagram of a terminal device where a device for establishing a P2P network is located in the present application, except for the processor, the memory, the network interface, and the nonvolatile memory shown in fig. 10, a client device where the device is located in the embodiment may also include other hardware according to an actual function of the device, which is not described again. The processor is configured to perform:
after entering a live broadcast room, sending a connection request to other nodes in a P2P network corresponding to the live broadcast room;
establishing a connection with a node responding to the request;
recording the number of nodes connected with the live broadcast client;
and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
In the embodiments of the present application, the computer readable storage medium may be in various forms, such as, in different examples: a RAM (random Access Memory), a volatile Memory, a non-volatile Memory, a flash Memory, a storage drive (e.g., a hard drive), a solid state drive, any type of storage disk (e.g., an optical disk, a dvd, etc.), or similar storage medium, or a combination thereof. In particular, the computer readable medium may be paper or another suitable medium upon which the program is printed. Using these media, the programs can be electronically captured (e.g., optically scanned), compiled, interpreted, and processed in a suitable manner, and then stored in a computer medium.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only exemplary of the present application and should not be taken as limiting the present application, as any modification, equivalent replacement, or improvement made within the spirit and principle of the present application should be included in the scope of protection of the present application.
Claims (10)
1. A method for establishing a P2P network, comprising the steps of:
after entering a live broadcast room, sending a connection request to other nodes in a P2P network corresponding to the live broadcast room;
establishing a connection with a node responding to the request;
recording the number of nodes connected with the live broadcast client;
and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
2. The method according to claim 1, wherein the recording of the number of nodes connected to the live client specifically includes the steps of:
storing the node identification connected with the live broadcast client to a cache region;
periodically interacting signaling information with the connected nodes, and if the signaling information of the connected nodes does not meet the preset requirement, releasing the node identifiers stored in the cache region;
and periodically recording the number of the node identifications stored in the cache region.
3. The method as claimed in claim 1, wherein the step of returning connection requests to other nodes in the P2P network corresponding to the live broadcast room comprises the steps of:
requesting a node list from a server, wherein the node list carries address information of nodes meeting preset conditions;
and after receiving the node list, sending a connection request to the nodes in the node list.
4. The method according to claim 3, wherein the preset condition is determined according to location information of a device where the live client is located, uplink capabilities of sections in the P2P network, connection conditions, network conditions, and/or hardware configuration of the device.
5. The method of claim 1, wherein the number of other nodes actively connected to any node in the P2P network is not greater than a first threshold, the number of other nodes actively connected to any node is not greater than a second threshold, and the first threshold is greater than the second threshold.
6. The method according to claim 1, wherein after establishing the connection with the node responding to the request, further comprising the steps of:
negotiating a subscription with the connected node;
after the negotiation is successful, when the subscribed node acquires live streaming media data from the server through other nodes, the live streaming media data subscribed by the live client is pushed to the live client.
7. The method of claim 6, wherein the live streaming media data comprises data packets obtained by the server from the anchor client, and the data packets are packaged by the server in a customized format, the customized format comprising a first identifier, the first identifier being used for describing uniqueness of each data packet, and the data packets are obtained by nodes in the P2P network directly or indirectly from the server.
8. An apparatus for establishing a P2P network, comprising:
the request module is used for sending a connection request to other nodes in a P2P network corresponding to a live broadcast room after entering the live broadcast room;
a processing module for establishing a connection with a node responding to the request; recording the number of nodes connected with the live broadcast client; and when the number of the nodes connected with the live broadcast client is less than a preset value, sending a connection request to the nodes in the P2P network corresponding to the live broadcast room again.
9. A terminal device, comprising:
a processor; and
a memory configured to store a computer program configured to be executed by the processor to perform operations of any of the methods of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, characterized in that the program is executed by a processor for performing the operations of the method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811354513.7A CN109561137B (en) | 2018-11-14 | 2018-11-14 | Method, device, terminal equipment and medium for establishing P2P network |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811354513.7A CN109561137B (en) | 2018-11-14 | 2018-11-14 | Method, device, terminal equipment and medium for establishing P2P network |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109561137A true CN109561137A (en) | 2019-04-02 |
CN109561137B CN109561137B (en) | 2021-08-24 |
Family
ID=65866156
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811354513.7A Active CN109561137B (en) | 2018-11-14 | 2018-11-14 | Method, device, terminal equipment and medium for establishing P2P network |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109561137B (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110489484A (en) * | 2019-07-11 | 2019-11-22 | 视联动力信息技术股份有限公司 | Method of data synchronization, device, readable storage medium storing program for executing and electronic equipment |
CN111225242A (en) * | 2020-01-17 | 2020-06-02 | 广州酷狗计算机科技有限公司 | Video playing disaster tolerance method and device and computer storage medium |
CN111479170A (en) * | 2020-03-13 | 2020-07-31 | 杭州火烧云科技有限公司 | Method and system based on video interaction and screen sharing live broadcast |
CN115865941A (en) * | 2023-02-15 | 2023-03-28 | 花瓣云科技有限公司 | Packet loss retransmission method, packet determination method, device, equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080140780A1 (en) * | 2006-11-07 | 2008-06-12 | Tiversa, Inc. | System and method for enhanced experience with a peer to peer network |
US20090116430A1 (en) * | 2007-11-07 | 2009-05-07 | Motorola, Inc. | System for enabling mobile coverage extension and peer-to-peer communications in an ad hoc network and method of operation therefor |
CN101720136A (en) * | 2009-11-27 | 2010-06-02 | 成都市华为赛门铁克科技有限公司 | Method for controlling number of neighbor nodes of client and device and cache system thereof |
CN101945129A (en) * | 2010-09-10 | 2011-01-12 | 北京易视腾科技有限公司 | P2P (Peer to Peer) stream media live-broadcast low-delay transmission method and system thereof |
CN101969448A (en) * | 2009-06-17 | 2011-02-09 | 中国移动通信集团公司 | Method, system and equipment for searching active node in P2P streaming media system |
CN103312824A (en) * | 2013-07-10 | 2013-09-18 | 亿览在线网络技术(北京)有限公司 | Peer-to-peer (P2P) network intelligent speed governing method, device and system |
CN103355008A (en) * | 2010-09-16 | 2013-10-16 | 电话有限公司 | Method and single radio station for fair aggregation of internet backhaul throughput using multiple access points |
US20150381675A1 (en) * | 2012-02-16 | 2015-12-31 | Telefonaktiebolaget L M Ericsson (Publ) | P2p streaming support |
-
2018
- 2018-11-14 CN CN201811354513.7A patent/CN109561137B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080140780A1 (en) * | 2006-11-07 | 2008-06-12 | Tiversa, Inc. | System and method for enhanced experience with a peer to peer network |
US20090116430A1 (en) * | 2007-11-07 | 2009-05-07 | Motorola, Inc. | System for enabling mobile coverage extension and peer-to-peer communications in an ad hoc network and method of operation therefor |
CN101969448A (en) * | 2009-06-17 | 2011-02-09 | 中国移动通信集团公司 | Method, system and equipment for searching active node in P2P streaming media system |
CN101720136A (en) * | 2009-11-27 | 2010-06-02 | 成都市华为赛门铁克科技有限公司 | Method for controlling number of neighbor nodes of client and device and cache system thereof |
CN101945129A (en) * | 2010-09-10 | 2011-01-12 | 北京易视腾科技有限公司 | P2P (Peer to Peer) stream media live-broadcast low-delay transmission method and system thereof |
CN103355008A (en) * | 2010-09-16 | 2013-10-16 | 电话有限公司 | Method and single radio station for fair aggregation of internet backhaul throughput using multiple access points |
US20150381675A1 (en) * | 2012-02-16 | 2015-12-31 | Telefonaktiebolaget L M Ericsson (Publ) | P2p streaming support |
CN103312824A (en) * | 2013-07-10 | 2013-09-18 | 亿览在线网络技术(北京)有限公司 | Peer-to-peer (P2P) network intelligent speed governing method, device and system |
Non-Patent Citations (2)
Title |
---|
KYOUNGSOO BOK,JONGHYEON YOON,JONGTAE LIM,JAESOO YOO: ""Load Balancing with Load Threshold Adjustment in Structured P2P"", 《2018 IEEE INTERNATIONAL CONFERENCE ON BIG DATA AND SMART COMPUTING》 * |
李雯,梁刚: "基于网络流量的P2P动态检测方法", 《四川大学学报 自然科学版》 * |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110489484A (en) * | 2019-07-11 | 2019-11-22 | 视联动力信息技术股份有限公司 | Method of data synchronization, device, readable storage medium storing program for executing and electronic equipment |
CN111225242A (en) * | 2020-01-17 | 2020-06-02 | 广州酷狗计算机科技有限公司 | Video playing disaster tolerance method and device and computer storage medium |
CN111479170A (en) * | 2020-03-13 | 2020-07-31 | 杭州火烧云科技有限公司 | Method and system based on video interaction and screen sharing live broadcast |
CN115865941A (en) * | 2023-02-15 | 2023-03-28 | 花瓣云科技有限公司 | Packet loss retransmission method, packet determination method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN109561137B (en) | 2021-08-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109474684B (en) | Method, device, terminal equipment and storage medium for acquiring live video stream | |
CN109560901B (en) | Data retransmission method, device, terminal equipment and storage medium | |
CN109561137B (en) | Method, device, terminal equipment and medium for establishing P2P network | |
CN109889543B (en) | Video transmission method, root node, child node, P2P server and system | |
JP6612355B2 (en) | Client node, virtual broadcast server and method | |
CN109151497B (en) | Live wheat-connecting method and device, electronic equipment and storage medium | |
WO2017088383A1 (en) | Method, apparatus and system for playing live video | |
CN108924609B (en) | Streaming media data transmission method, electronic equipment, device and storage medium | |
WO2017088381A1 (en) | Method, apparatus and system for playing live video | |
US9497035B2 (en) | Method, device, and system for playing media based on P2P | |
RU2647654C2 (en) | System and method of delivering audio-visual content to client device | |
US8176192B2 (en) | Networked transmission system and method for stream data | |
US7525965B1 (en) | Trick play for multicast streams | |
CN108833591B (en) | method, electronic equipment, device and network architecture for data transmission in P2P network | |
Paul | Digital video distribution in broadband, television, mobile and converged networks: Trends, challenges and solutions | |
CN109348257B (en) | Pull stream control method and device and live broadcast system | |
EP3471421A1 (en) | Live broadcast video replay method, server, and system | |
CN109510868B (en) | Method, device, terminal equipment and storage medium for establishing P2P network | |
CN110191315B (en) | Monitoring and checking method and device based on video network | |
CN113727144A (en) | High-definition live broadcast system and streaming media method based on mixed cloud | |
CN114501052B (en) | Live broadcast data processing method, cloud platform, computer equipment and storage medium | |
Kumar et al. | Cloud enabled media streaming using Amazon Web Services | |
WO2023061060A1 (en) | Audio and video code stream scheduling method, system, medium and electronic apparatus | |
Zhang et al. | MMCSACC: A multi-source multimedia conference system assisted by cloud computing for smart campus | |
WO2017182815A1 (en) | Media data streaming method and apparatus |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |