WO2023035660A1 - Resource request method, system and apparatus, and device and storage medium - Google Patents

Resource request method, system and apparatus, and device and storage medium Download PDF

Info

Publication number
WO2023035660A1
WO2023035660A1 PCT/CN2022/093659 CN2022093659W WO2023035660A1 WO 2023035660 A1 WO2023035660 A1 WO 2023035660A1 CN 2022093659 W CN2022093659 W CN 2022093659W WO 2023035660 A1 WO2023035660 A1 WO 2023035660A1
Authority
WO
WIPO (PCT)
Prior art keywords
electronic device
resource
connection
information
management server
Prior art date
Application number
PCT/CN2022/093659
Other languages
French (fr)
Chinese (zh)
Inventor
董阳
单卫华
Original Assignee
华为云计算技术有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 华为云计算技术有限公司 filed Critical 华为云计算技术有限公司
Publication of WO2023035660A1 publication Critical patent/WO2023035660A1/en

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/251Translation of Internet protocol [IP] addresses between different IP versions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • H04L61/256NAT traversal
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/146Markers for unambiguous identification of a particular session, e.g. session cookie or URL-encoding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Definitions

  • the present application relates to the technical field of network communication, and in particular to a resource request method, system, device, equipment and storage medium.
  • Peer-to-peer (P2P) network technology is a network technology used for resource sharing.
  • a P2P network includes a P2P server and multiple electronic devices. Each electronic device communicates with the P2P server to learn about other electronic devices.
  • the stored resources can establish a P2P network by establishing a connection between electronic devices, thereby realizing resource sharing among multiple electronic devices. Since the electronic devices in the P2P network are often located in the local area network, they need to communicate with the P2P server located in the wide area network through a network address translation (network address translation, NAT) device.
  • network address translation network address translation
  • the P2P server sends the address and port of the peer to the two electronic devices, and the two electronic devices perform NAT penetration based on their respective NAT devices, addresses and ports of the peer. , so that two electronic devices located in different local area networks can communicate with each other through their respective NAT devices, thereby establishing a connection between the two electronic devices.
  • an electronic device is often installed with multiple applications. For each application, NAT penetration needs to be performed based on different ports, and a connection between electronic devices is established to build a P2P network corresponding to each application. Realize the resource sharing of different applications among multiple electronic devices.
  • embodiments of the present application provide a resource request method, system, device, device, and computer-readable storage medium.
  • the technical solution is as follows:
  • a resource request method includes:
  • the first electronic device sends a first resource acquisition request to the management server, where the first resource acquisition request carries an identifier of the first application and an identifier of the first resource;
  • the management server receives the first resource acquisition request, determines the second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource, and sends the second device information to the first electronic device , the second electronic device stores the first resource of the first application;
  • the first electronic device receives the second device information, multiplexes the established connection between the first electronic device and the second electronic device, and requests the first resource from the second electronic device.
  • the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, so as to be able to multiplex with the second electronic device
  • the established connection requests the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat The corresponding NAT penetration is performed multiple times, thereby achieving the purpose of saving network resources and reducing the time-consuming of establishing a connection.
  • determining the second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource includes:
  • the management server Based on the identifier of the first application and the identifier of the first resource, the management server queries the resource topology of the peer-to-peer network to obtain the second device information of the second electronic device, and the resource topology is used to record multiple resources in the peer-to-peer network.
  • the second device information of the second electronic device is obtained, thereby obtaining the address of the second electronic device that stores the resources requested by the first electronic device, so that the first electronic device can request resources from the second electronic device .
  • the multiplexing the established connection between the first electronic device and the second electronic device, and requesting the first resource from the second electronic device includes:
  • the first electronic device determines the target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection information is used to indicate that the first electronic device is connected to The established connection between the second electronic device; the first electronic device requests the first resource from the second electronic device based on the target connection information.
  • the method before the first electronic device sends the first resource acquisition request to the management server, the method further includes:
  • the first electronic device sends a second resource acquisition request to the management server, and the second resource acquisition request carries the identifier of the second application and the identifier of the second resource; the management server receives the second resource acquisition request, and based on the second The identification of the application and the identification of the second resource, determining the second device information of the second electronic device, sending the second device information to the first electronic device, and the second electronic device stores the information of the second application Second resource: the first electronic device receives the second device information, establishes the connection with the second electronic device based on the first device information and the second device information, and stores the target connection information.
  • the first electronic device can reuse the connection with the second electronic device when requesting resources from the second electronic device.
  • the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the second device information includes an address of the second electronic device. At least one of IPv6 address and IPv4 address;
  • Establishing the connection with the second electronic device based on the first device information and the second device information includes:
  • the first electronic device establishes the connection with the second electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device ; If at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device communicates with the first electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device. The two electronic devices establish the connection.
  • the first electronic device and the second electronic device can intelligently choose to establish a connection based on an IPv4 address or an IPv6 address.
  • the first electronic device establishing the connection with the second electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device includes:
  • the first electronic device performs NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and sends a traversal message to the management server, where the traversal message is used to indicate that the second electronic device Perform NAT penetration based on the first device information; the management server forwards the penetration message to the second electronic device; the second electronic device receives the penetration message, based on the NAT device of the second electronic device, the first The IPv4 address of the electronic device performs NAT penetration, and sends a penetration response to the first electronic device, and the penetration response is used to indicate that NAT penetration has been completed; the first electronic device receives the penetration response, based on the second The IPv4 address of the electronic device and the IPv4 address of the first electronic device establish the connection with the second electronic device.
  • the management server forwarding the penetration message and penetration response, the first electronic device and the second electronic device complete NAT penetration, so that the connection between the two electronic devices can be established
  • the method before the first electronic device sends the first resource acquisition request to the management server, the method further includes:
  • the first electronic device sends a notification message to the management server, the notification message is used to indicate that the first electronic device has enabled the connection multiplexing function;
  • the management server receives the notification message, sends a connection establishment message to the first electronic device,
  • the connection establishment message is used to indicate to establish a connection with at least one electronic device, and the at least one electronic device enables the connection multiplexing function;
  • the first electronic device receives the connection establishment message, establishes a connection with the at least one electronic device, and the at least one
  • the electronic device includes the second electronic device, and stores connection information of a connection between the first electronic device and the at least one electronic device.
  • the electronic device can directly use the established connection when making a resource request, thereby improving resource request efficiency.
  • a network system in a second aspect, includes: a first electronic device, a second electronic device, and a management server, configured to execute corresponding steps in the resource request method provided in the first aspect.
  • the first electronic device can send a resource acquisition request to the management server, and obtain the device information of the second electronic device that stores the requested resource, so that it can reuse the established connection with the second electronic device, and send The second electronic device requests the required resources, so that the first electronic device and the second electronic device can request resources without re-establishing a connection. Since the first electronic device and the second electronic device are located in different local area networks, they need to first Only through NAT traversal can a connection be established. Therefore, when the first electronic device requests resources from the second electronic device, there is no need to re-perform NAT traversal, thereby achieving the purpose of saving network resources and reducing time-consuming connection establishment.
  • a resource requesting device which is used in the above-mentioned first electronic device, and the device includes a sending module and a multiplexing module.
  • a sending module configured to send a first resource acquisition request to the management server, where the first resource acquisition request carries the identifier of the first application and the identifier of the first resource;
  • a connection multiplexing module configured to receive the second device information, multiplex the established connection between the first electronic device and the second electronic device, and request the first resource from the second electronic device.
  • the connection multiplexing module is configured to determine the target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection information It is used to indicate the established connection between the first electronic device and the second electronic device; based on the target connection information, request the first resource from the second electronic device.
  • the sending module is further configured to send a second resource acquisition request to the management server, where the second resource acquisition request carries the identifier of the second application and the identifier of the second resource;
  • the unit also includes:
  • a connection establishing module configured to receive the second device information, establish the connection with the second electronic device based on the first device information and the second device information, and store the target connection information.
  • the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the second device information includes an address of the second electronic device. At least one of IPv6 address and IPv4 address;
  • the connection establishment module is configured to, if both the first electronic device and the second electronic device support IPv6 communication, the first electronic device communicates with the first electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device The second electronic device establishes the connection; if at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device based on the IPv4 address of the second electronic device and the first electronic device The IPv4 address of the second electronic device to establish the connection.
  • the connection establishment module is configured to perform NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and send a traversal message to the management server, the traversal message It is used to instruct the second electronic device to perform NAT traversal based on the first device information; receive a traversal response from the second electronic device, the traversal response is used to indicate that NAT traversal has been completed, based on the second electronic device's IPv4 address and the IPv4 address of the first electronic device, and establish the connection with the second electronic device.
  • the sending module is configured to send a notification message to the management server, where the notification message is used to indicate that the first electronic device has enabled the connection multiplexing function;
  • the connection establishment module is configured to receive the connection establishment message, establish a connection with the at least one electronic device, the at least one electronic device includes the second electronic device, and store the connection between the first electronic device and the at least one electronic device connection information.
  • the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, thereby being able to reuse the established connection with the second electronic device, Request the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat the corresponding NAT traversal, so as to achieve the purpose of saving network resources and reducing the time-consuming connection establishment.
  • a computer device in a fourth aspect, includes a communication bus, at least one network interface, a memory, and at least one processor, the communication bus is used to transmit information between the above components, and the at least one network interface is used for In communication with other devices or communication networks, the memory stores program codes, and the at least one processor realizes any step of the resource request method in the first aspect above by reading and executing the program codes stored in the memory.
  • the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, so that it can reuse the established connection with the second electronic device, and send The second electronic device requests the required resources, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat the corresponding NAT multiple times. Penetration, so as to achieve the purpose of saving network resources and reducing the time-consuming connection establishment.
  • a computer-readable storage medium is provided.
  • the program code in the computer-readable storage medium is executed by the processor of the computer device, the computer device can execute any one of the resource request methods in the above-mentioned first aspect. step.
  • the first electronic device obtains the device information of the second electronic device that stores the requested resources by sending a resource acquisition request to the management server, so that it can reuse the established relationship with the second electronic device. Connection, to request the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat multiple The corresponding NAT penetration achieves the purpose of saving network resources and reducing the time-consuming of establishing connections.
  • FIG. 1 is a schematic diagram of a network system provided by an embodiment of the present application.
  • FIG. 2 is a schematic diagram of a network system provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of a computer device 300 provided in an embodiment of the present application.
  • FIG. 4 is a flow chart of the steps of a resource request method provided by an embodiment of the present application.
  • FIG. 5 is a schematic diagram of a resource request method provided by an embodiment of the present application.
  • FIG. 6 is a schematic diagram of a resource topology provided by an embodiment of the present application.
  • FIG. 7 is a schematic diagram of a resource request method provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a CDN network based on P2P technology provided by an embodiment of the present application.
  • Fig. 9 is a schematic structural diagram of a resource request device provided by an embodiment of the present application.
  • Peer-to-peer network (peer to peer, P2P) is a peer-to-peer network technology that relies on user group nodes for information exchange.
  • the P2P network does not need to rely on dedicated centralized servers or workstations.
  • Each electronic device in the network can act as a resource requester to obtain resources from other electronic devices, or as a resource provider to send stored resources to other electronic devices.
  • these resources include video resources, audio resources, computing resources (such as CPU computing resources), storage resources (such as cache memory and disk space), and the like.
  • Grid is a kind of resource (including computer system, storage system, communication system, file, database, program, etc.) that is used to integrate or share geographical distribution, making it an organic whole, and jointly accomplishing various needs.
  • the task network technology, P2P network is a kind of grid.
  • the content delivery network is an intelligent virtual network built on the basis of the existing network, relying on the edge servers deployed in various places, through the load balancing, content distribution, scheduling and other functional modules of the central platform, so that users Obtain required content from adjacent edge servers, reduce network congestion, and improve user access response speed and hit rate.
  • Network address translation also known as network masking, Internet protocol (internet protocol, IP) masking
  • IP Internet protocol
  • IP address technology is commonly used in local area networks that have multiple electronic devices but only access the Internet through a public IP address.
  • NAT traversal also known as intranet traversal, is a technology that enables electronic devices in different local area networks using NAT technology to communicate with each other.
  • NAT traversal technology is the basis for realizing P2P networks.
  • FIG. 1 is a schematic diagram of a network system provided by an embodiment of the present application.
  • the network system includes multiple first electronic devices 101 , multiple second electronic devices 102 and a management server 103 .
  • the first electronic device 101 and the second electronic device 102 may be smart phones, tablet computers, notebook computers, desktop computers, hosts, etc., but are not limited thereto.
  • the management server 103 can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, and can also provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud Cloud servers for basic cloud computing services such as communications, middleware services, domain name services, security services, CDN networks, and big data and artificial intelligence platforms.
  • the first electronic device 101 and the second electronic device 102 may be located in a wide area network, communicate with the management server 103 located in the wide area network through a wired or wireless network, and the first electronic device 101 and the second electronic device 102 may also be located in a local area network,
  • the NAT device communicates with the management server 103 located in the wide area network.
  • the first electronic device 101 and the second electronic device 102 can be located in the same local area network or in different levels of local area networks.
  • the local area network can be a telecom operator (Internet service provider (ISP), which is not limited in this embodiment of the present application.
  • ISP Internet service provider
  • the plurality of first electronic devices 101 can establish connections with the plurality of second electronic devices 102, so that the plurality of first electronic devices 101, the plurality of second electronic devices 102 and the management server 103 form a P2P network, and the P2P A network is also called a grid, and the network system is also called a wormhole mesh.
  • the first electronic device 101 and the second electronic device 102 are installed with multiple applications, and the multiple applications provide multiple types of resources, including video resources, audio resources and text resources.
  • the first electronic device 101 can request resources from the second electronic device 102 based on the function of the P2P network. For example, as shown in FIG. 2 , if both the first electronic device 101 and the second electronic device 102 are installed with application 1 and application 2, the first electronic device 101 can connect to the second electronic device 102 to send The second electronic device 102 requests the resource of application 1 and the resource of application 2 .
  • first electronic device 101 can also send stored resources to other devices based on resource acquisition requests of other electronic devices, and the second electronic device 102 can also request resources from other electronic devices, which is not discussed in this embodiment of the present application. limited.
  • the hardware structure of the first electronic device 101 , the second electronic device 102 and the management server 103 in the above system architecture will be introduced below with reference to FIG. 3 .
  • FIG. 3 is a schematic structural diagram of a computer device 300 provided by an embodiment of the present application.
  • the computer device 300 shown in FIG. 3 can be configured as the first electronic device 101 , the second electronic device 102 or the management server 103 , and the computer device 300 is used to execute the operations involved in the resource request method.
  • the computer device 300 includes at least one processor 301, a communication bus 302, a memory 303, and at least one network interface 304.
  • the processor 301 is, for example, a general-purpose central processing unit (central processing unit, CPU), a network processor (network processor, NP), a graphics processing unit (graphics processing unit, GPU), a neural network processor (neural-network processing units, NPU) ), a data processing unit (data processing unit, DPU), a microprocessor, or one or more integrated circuits for implementing the solution of this application.
  • the processor 301 includes an application-specific integrated circuit (application-specific integrated circuit, ASIC), a programmable logic device (programmable logic device, PLD) or a combination thereof.
  • the PLD is, for example, a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a general array logic (generic array logic, GAL) or any combination thereof.
  • complex programmable logic device complex programmable logic device, CPLD
  • field-programmable gate array field-programmable gate array
  • GAL general array logic
  • the communication bus 302 is used to transfer information between the aforementioned components.
  • the communication bus 302 is optionally divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 3 , but it does not mean that there is only one bus or one type of bus.
  • the memory 303 is, for example, a read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, or a random access memory (random access memory, RAM) or a memory that can store information and instructions.
  • Other types of dynamic storage devices such as electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc Storage (including Compact Disc, Laser Disc, Optical Disc, Digital Versatile Disc, Blu-ray Disc, etc.), magnetic disk storage medium, or other magnetic storage device, or is capable of carrying or storing desired program code in the form of instructions or data structures and capable of Any other medium accessed by a computer, but not limited to.
  • the memory 303 exists independently, for example, and is connected to the processor 301 through the communication bus 302 . Or optionally, the memory 303 and the processor 301 are integrated together.
  • Network interface 304 uses any transceiver-like device for communicating with other devices or a communication network.
  • the network interface 304 includes a wired network interface, and optionally also includes a wireless network interface.
  • the wired network interface is, for example, an Ethernet interface.
  • the Ethernet interface is, for example, an optical interface, an electrical interface or a combination thereof.
  • the wireless network interface is, for example, a wireless local area network (wireless local area networks, WLAN) interface, a cellular network interface or a combination thereof.
  • the processor 301 includes one or more CPUs, such as CPU0 and CPU1 as shown in FIG. 3 .
  • computer device 300 optionally includes multiple processors, such as processor 301 and processor 305 as shown in FIG. 3 .
  • processors such as processor 301 and processor 305 as shown in FIG. 3 .
  • Each of these processors is, for example, a single-core processor, or a multi-core processor.
  • a processor herein alternatively refers to one or more devices, circuits, and/or processing cores for processing data such as computer program instructions.
  • the computer device 300 also includes output devices and input devices.
  • Output devices optionally display information in a variety of ways.
  • the output device is optionally a liquid crystal display (liquid crystal display, LCD), a light emitting diode (light emitting diode, LED) display device, a cathode ray tube (cathode ray tube, CRT) display device or a projector (projector) wait.
  • the input device communicates with the processor 301 and optionally receives user input in a variety of ways.
  • the input device is optionally a mouse, a keyboard, a touch screen device, or a sensing device, among others.
  • the processor 301 implements the methods in the following embodiments by reading the program code 310 stored in the memory 303, or, the processor 301 implements the methods in the following embodiments through internally stored program codes.
  • the processor 301 implements the method in the following embodiments by reading the program code 310 stored in the memory 303
  • the memory 303 stores the program code for implementing the resource request method provided by the embodiment of the present application.
  • the embodiment of the present application also provides a computer-readable storage medium including program codes, such as the memory 303 including program codes.
  • the above-mentioned program codes can be executed by the processor 301 of the computer device 300 to complete the resource request method.
  • the computer-readable storage medium may be a read-only memory (read-only memory, ROM), a random access memory (random access memory, RAM), a compact-disc read-only memory (CD-ROM) ), tapes, floppy disks, and optical data storage devices, etc.
  • Fig. 4 is a flow chart of the steps of a resource request method provided by the embodiment of the present application.
  • the resource request method is applied to the system architecture shown in Fig. 1, and the first electronic device in the system architecture is used below 101 , the interaction between the second electronic device 102 and the management server 103 is taken as an example, and the resource request method is described, and the resource request method includes the following steps 401 to 409 .
  • the first electronic device sends a resource acquisition request M1 to the management server, where the resource acquisition request M1 carries an identifier of the application P1 and an identifier of the resource D1.
  • the first electronic device is installed with the application P1, and the first electronic device requests the resource D1 provided by the application P1 by sending a resource request M1, for example, the first electronic device requests a video application by sending a resource request M1 or, the first electronic device requests audio resources of the music program by sending a resource request M1, which is not limited in this embodiment of the present application.
  • the identifier of the application P1 may be the identifier configured in the configuration file of the application P1, or may be a virtual IP address and port number, which is not limited in this embodiment of the present application.
  • the first electronic device first enables the connection multiplexing function, and then sends a resource acquisition request M1 to the management server based on the connection multiplexing function.
  • the connection multiplexing function can be any electronic device Multiple applications in the device provide a unified network communication function, thereby realizing resource sharing among multiple applications.
  • the connection multiplexing function is enabled by default when the first electronic device is powered on, or enabled based on invoking by any application of the first electronic device, which is not limited in this embodiment of the present application.
  • connection multiplexing function is realized based on a peer-to-peer network toolkit (peer software development kit, Peer-SDK).
  • the application provides the connection multiplexing function, or the Peer-SDK can be installed in the first electronic device as an independent application, and based on the call of any application, it provides the connection multiplexing function for the application in the first electronic device,
  • This method is called the sidecar mode, which enables the developers of each application to directly call the Peer-SDK without having to make a lot of modifications to the program code of the application, so as to realize the resource sharing of multiple applications.
  • the management server receives the resource acquisition request M1, determines the second device information of the second electronic device based on the identifier of the application P1 and the identifier of the resource D1, and sends the second device information to the first electronic device, and the second electronic device stores There is resource D1 with application P1.
  • the second device information includes the port number and the second IP address of the second port of the second electronic device, and the second IP address includes a second Internet protocol version 6 (internet protocol version 6, IPv6) address and a second Internet At least one of the protocol version 4 (internet protocol version 4, IPv4) addresses.
  • the second port and the second IPv4 address are the port and the IPv4 address of the wide area network allocated by the second NAT device for the second electronic device, that is, the port and the IPv4 address of the second NAT device, for communication with the management located in the wide area network
  • the server communicates, and the second NAT device is the NAT device of the second electronic device.
  • the second device information further includes other information of the second electronic device, such as device identification, device status, device location, etc., which is not limited in this embodiment of the present application.
  • the above "determining the second device information of the second electronic device based on the identification of the application P1 and the identification of the resource D1" includes: the management server queries the resources of the P2P network based on the identification of the application P1 and the identification of the resource D1 Topology, to obtain the second device information of the second electronic device, the resource topology is used to record the device information of multiple electronic devices in the P2P network, the identification of applications on each electronic device, and the identification of resources stored in each electronic device Correspondence between.
  • An example of the form of the resource topology above is as follows, as shown in Figure 6, if the device information of electronic device 1 is 10.182.100.1:80, resource 1 of application 1 is stored in electronic device 1, the identifier of application 1 is aaaa, and the resource 1 of resource 1 If the ID is ZY1, the management server records the corresponding relationship between the device information of the electronic device 1, the ID of the application 1, and the ID of the resource 1 (10.182.100.1:80, aaaa, ZY1), if the device information of the electronic device 2 10.182.100.2:80, resource 2 of application 2 is stored in electronic device 2, the identifier of application 2 is bbbb, and the identifier of resource 2 is ZY2, then the device information of electronic device 2 and the identifier of application 2 are recorded in the management server The corresponding relationship with the identifier of resource 2 (10.182.100.2:80, bbbb, ZY2).
  • the first electronic device receives the second device information, establishes a connection with the second electronic device based on the first device information and the second device information, and stores target connection information, where the target connection information is used to indicate that the first electronic device is connected to the second device. An established connection between electronic devices.
  • the first device information includes the port number and the first IP address of the first port of the first electronic device, and the first IP address includes at least one of the first IPv6 address and the first IPv4 address of the first electronic device.
  • the first port and the first IPv4 address are the port and the IPv4 address of the wide area network allocated by the first NAT device for the first electronic device, that is, the port and the IPv4 address of the first NAT device, for communicating with the management server located in the wide area network
  • the first NAT device is the NAT device of the first electronic device.
  • the first device information further includes other information of the first electronic device, such as device identification, device status, device location, etc., which is not limited in this embodiment of the present application.
  • the target connection information includes the corresponding relationship between the addresses and ports used by the first electronic device and the second electronic device to establish a connection.
  • the target connection information also includes other information, such as connection status, connection maintenance time etc., which are not limited in this embodiment of the present application.
  • both the first electronic device and the second electronic device support IPv6 communication, that is, both the first device information and the second device information include an IPv6 address
  • the first electronic device based on the first IPv6 address and The second IPv6 address establishes a connection with the second electronic device through the connection multiplexing function, and stores target connection information.
  • the first electronic device based on The first IPv4 address and the second IPv4 address establish a connection with the second electronic device through the connection multiplexing function, and store target connection information.
  • connection between the first electronic device and the second electronic device is a transmission tunnel, which can support efficient transmission of data under multiple different protocols, such as User Datagram Protocol (UDP) , high-speed UDP internet connection protocol (quick UDP internet connection, QUIC), fast and reliable protocol (KCP), etc.
  • UDP User Datagram Protocol
  • QUIC high-speed UDP internet connection protocol
  • KCP fast and reliable protocol
  • the first electronic device sends the target connection information to the management server, and the management server stores the target connection information.
  • the management server manages the P2P network by storing the connection information sent by the electronic device to record the connection established between the electronic devices in the P2P network.
  • the two electronic devices first allocate a LAN port for communication to the opposite end, that is, the port of the electronic device itself, and transfer the allocated LAN port The port number of the port and its own local area network IPv4 address are notified to the opposite end, and then the connection is established.
  • the first electronic device and the second electronic device may allocate idle ports to opposite ends based on the principle of random allocation.
  • the first electronic device and the second electronic device can respectively allocate a LAN port to the opposite end, and establish a connection based on an IPv6 address or an IPv4 address.
  • the first electronic device allocates a third port to the second electronic device, and the third port is a LAN port of the first electronic device, that is, a port of the first electronic device itself, and is used for communicating with the second electronic device.
  • the electronic device sends the port number of the third port to the second electronic device through the management server, and the second electronic device receives the port number of the third port, and allocates a fourth port to the first electronic device, and the fourth port is the
  • the LAN port of the device is the port of the second electronic device itself, and the second electronic device sends the port number of the fourth port to the first electronic device through the management server.
  • the management server will store the port numbers of the LAN ports of the two electronic devices corresponding to the corresponding device information.
  • Process 2 Establish a connection.
  • the first electronic device sends a connection establishment request to the second IPv6 address and the fourth port based on the first IPv6 address and the third port, and the second electronic device receives the connection establishment request based on the second IPv6 address and the fourth port, and sends the connection establishment request to the second IPv6 address and the fourth port.
  • the first IPv6 address and the third port send a connection establishment response, the first electronic device receives the connection establishment response based on the first IPv6 address and the third port, sends a confirmation message to the second IPv6 address and the fourth port, and completes the establishment of the connection process.
  • the first electronic device stores the correspondence between the first IPv6 address, the port number of the third port, the second IPv6 address, and the port number of the fourth port, and obtains a target connection record.
  • Process 1 Assign LAN ports.
  • the first electronic device assigns a third port to the second electronic device, and sends the port number of the third port and the third IPv4 address to the second electronic device through the management server, and the third IPv4 address is the local area network IPv4 address of the first electronic device
  • the second electronic device receives the port number and the third IPv4 address of the third port, assigns the fourth port to the first electronic device, and sends the port number and the fourth IPv4 address of the fourth port to the first electronic device through the management server.
  • the fourth IPv4 address is the local area network IPv4 address of the second electronic device.
  • the management server will store the local area network IPv4 addresses and the port numbers of the local area network ports of the two electronic devices in correspondence with the corresponding device information.
  • Process 2 Establish a connection.
  • the first electronic device and the second electronic device can establish a connection based on the IPv4 address of the local area network, or establish a connection based on the IPv4 address of the wide area network. The above two cases will be described respectively below.
  • the first electronic device determines that the first electronic device and the second electronic device are located in the same local area network based on the third IPv4 address and the fourth IPv4 address, then the first electronic device and the second electronic device are based on the IPv4 address of the local area network.
  • the address establishes a connection, that is, the first electronic device establishes a connection with the second electronic device based on the third IPv4 address, the third port, the fourth IPv4 address, and the fourth port, and stores the third IPv4 address, the third port's
  • the corresponding relationship among the port number, the fourth IPv4 address and the port number of the fourth port is used to obtain the target connection information.
  • the process of establishing a connection is the same as the above process of establishing a connection based on an IPv6 address, and will not be repeated here.
  • the first electronic device determines that the first electronic device and the second electronic device are located in different local area networks based on the third IPv4 address and the fourth IPv4 address, the first electronic device and the second electronic device first separately Perform NAT penetration, and then establish a connection based on the WAN IPv4 address.
  • the above process is that the first electronic device performs NAT traversal based on the first NAT device, the second IPv4 address and the second port, and sends a traversal message to the management server, and the traversal message is used to instruct the second electronic device to A piece of equipment information performs NAT traversal, the management server forwards the traversal message to the second electronic device, and the second electronic device receives the traversal message based on the NAT device of the second electronic device and the IPv4 address of the first electronic device , perform NAT penetration, and send a penetration response to the first electronic device, the penetration response is used to indicate that NAT penetration has been completed, the first electronic device receives the penetration response, based on the first IPv4 address, the first port, The second IPv4 address and the second port, establishing the connection with the second electronic device, storing the correspondence between the first IPv4 address, the port number of the first port, the second IPv4 address and the port number of the second port, Get target connection information.
  • the process of establishing a connection is the
  • the first electronic device Based on its local area network address, the first electronic device sends the first message to the wide area network address of the second electronic device through the first NAT device, that is, the first electronic device sends the first message based on the third IPv4 address and the third port through the first NAT
  • the device sends a first message to the second IPv4 address and the second port, the first message carries the third IPv4 address, the third port, the second IPv4 address and the second port, and the first NAT device receives the first message, Record the first entry, thereby completing NAT penetration, the first entry includes the correspondence between three IPv4 addresses and the third port, the second IPv4 address and the second port, through the first entry, the first NAT
  • the device is capable of forwarding data from the wide area network address of the second electronic device to the first electronic device.
  • the second electronic device can complete NAT traversal through the same method as the first electronic device, so that the second NAT device records the second entry, the second entry includes the fourth IPv4 address and the fourth port, the first IPv4
  • the correspondence between the address and the first port, through the second entry, the second NAT device can forward the data from the WAN address of the first electronic device to the second electronic device.
  • the two electronic devices can communicate through the wide area network IPv4 address, thereby establishing a connection between the two electronic devices.
  • any electronic device in the P2P network can learn its own NAT type by communicating with the management server based on the NAT session traversal protocol (session traversal utilities for NAT, STUN), and can perform multiple types of NAT.
  • NAT penetration including full cone NAT, restricted cone NAT, port restricted cone NAT and symmetric NAT.
  • the first electronic device needs to request resource D1 from the second electronic device by sending multiple resource acquisition requests, the first electronic device will trigger a communication with the second electronic device when sending the first resource acquisition request. After the connection is established, the first electronic device can reuse the connection with the second electronic device to send other resource acquisition requests for the resource D1, thereby requesting the resource D1 from the second electronic device.
  • step 401 to step 403 triggers a connection establishment process between the first electronic device and the second electronic device when the first electronic device requests resources from the second electronic device for the first time.
  • the first electronic device can establish a connection with other electronic devices before sending the resource acquisition request.
  • this embodiment of the present application further includes:
  • the first electronic device After the first electronic device activates the connection multiplexing function, for example, starts the corresponding application, and sends a first notification message to the management server, the first notification message is used to indicate that the first electronic device has enabled the connection multiplexing function, and the management server receives
  • the first notification message sends a connection establishment message to the first electronic device, the connection establishment message is used to indicate the establishment of a connection with at least one electronic device, and the at least one electronic device enables the connection multiplexing function;
  • the first electronic device receives the connection Establishing a message, establishing a connection with the at least one electronic device, the at least one electronic device including the second electronic device, and storing connection information of the connection between the first electronic device and the at least one electronic device.
  • the process of establishing a connection between the first electronic device and at least one electronic device is the same as step 403, and will not be repeated here.
  • the first electronic device can directly request the resource D1 from the second electronic device based on the established connection with the second electronic device. For example, as shown in FIG. 7 , the first electronic device receives a connection establishment message from the management server, and establishes a connection with the second electronic device and the third electronic device, and both the second electronic device and the third electronic device enable the connection multiplexing function.
  • the electronic device can directly use the established connection when making a resource request, thereby improving resource request efficiency.
  • the first electronic device requests the resource D1 from the second electronic device.
  • the first electronic device sends the resource acquisition request M1 to the second electronic device based on the connection with the second electronic device, including the following three situations:
  • the first electronic device if the first electronic device establishes a connection with the second electronic device based on the IPv6 address, the first electronic device sends a resource acquisition request M1 to the second IPv6 address and the fourth port based on the first IPv6 address and the third port . It should be noted that the embodiment of the present application does not limit the format of the resource acquisition request.
  • the first electronic device if the first electronic device establishes a connection with the second electronic device based on the local area network IPv4 address, the first electronic device sends the resource to the fourth IPv4 address and the fourth port based on the third IPv4 address and the third port Get request M1.
  • the first electronic device if the first electronic device establishes a connection with the second electronic device based on the wide area network IPv4 address, the first electronic device sends the second IPv4 address to the second IPv4 address through the first NAT device based on the first IPv4 address and the first port. Send a resource acquisition request M1 to the second port.
  • step 404 further includes: the first electronic device sends a second notification message to the management server, and the second notification message uses In order to notify the management server that the first electronic device requests the resource D1 of the application P1 from the second electronic device, the management server receives the second notification message and records the first resource request information.
  • the first resource request information is used to indicate that the first electronic device Based on the connection with the second electronic device, request the resource D1 of the application P1 from the second electronic device, the first resource request information includes the target connection information, the identifier of the application P1 and the identifier of the resource D1, optionally, the first resource request information
  • the resource request information also includes other information, such as bandwidth and time occupied by the first electronic device requesting the resource D1 from the second electronic device, which is not limited in this embodiment of the present application.
  • the second electronic device sends a resource acquisition response R1 to the first electronic device, where the resource acquisition response R1 carries the resource D1.
  • the second electronic device receives the resource acquisition request M1 of the first electronic device, obtains the stored resource D1 based on the identification of the application P1 and the identification of the resource D1, and sends the resource carrying the resource D1 to the first electronic device Get the response R1.
  • the embodiment of the present application further includes: the management server receives the resource request M1, and if the electronic device storing the resource D1 of the application P1 cannot be found in the resource topology, the management server sends the address of the first application server to the first electronic device,
  • the first application server is a server of the application P1, and the first electronic device receives the address of the first application server, and requests the resource D1 from the first application server.
  • the first electronic device sends a resource acquisition request M2 to the management server, where the resource acquisition request M2 carries the identifier of the application P2 and the identifier of the resource D2.
  • step 406 is the same as step 401, which will not be repeated here.
  • the management server receives the resource acquisition request M2, determines the second device information of the second electronic device based on the identifier of the application P2 and the identifier of the resource D2, and sends the second device information to the first electronic device, and the second electronic device
  • the device stores a resource D2 of the application P2.
  • the management server determines the second device information of the second electronic device based on the same method as step 402, and sends the second device information to the first electronic device.
  • the management server also stores the fourth IPv4 address of the second device and the port number of the fourth port, the fourth IPv4 address, the port number of the fourth port and the second device information are sent to first electronic device.
  • the first electronic device receives the second device information, multiplexes the established connection between the first electronic device and the second electronic device, and requests the resource D2 from the second electronic device.
  • the first electronic device receives the second device information, determines the target connection information stored in the first electronic device based on the first device information and the second device information, and sends the target connection information to the second device based on the target connection information.
  • the second electronic device requests the resource D2.
  • the first electronic device can reuse the connection with the second electronic device, request resources from the second electronic device, realize saving network resources and reduce time-consuming connection establishment Purpose.
  • this step 408 includes: the first electronic device receives the second device information , the fourth IPv4 address and the port number of the fourth port, based on the first device information, the second device information, the third IPv4 address and the port number of the third port, the fourth IPv4 address and the port number of the fourth port, determine the Based on the target connection information stored in the first electronic device, the resource D2 is requested from the second electronic device.
  • the fourth IPv4 address of the second electronic device and the port number of the fourth port it is possible to more accurately determine the connection information stored in the first electronic device, thereby multiplexing the connection with the second electronic device and sending the second The electronic device requests a resource.
  • the above process of determining the target connection information and requesting the resource D2 based on the target connection information is divided into the following three situations:
  • the first electronic device determines the target connection information based on the first IPv6 address, the port number of the third port, the second IPv6 address, and the port number of the fourth port, and the first electronic device determines the target connection information based on the first IPv6 address and the third port, sending a resource acquisition request M2 to the second IPv6 address and the fourth port.
  • the first electronic device determines the target connection information based on the first IPv4 address, the port number of the first port, the second IPv4 address, and the port number of the second port, and the first electronic device passes through the first NAT device , based on the first IPv4 address and the first port, send a resource acquisition request M2 to the second IPv4 address and the second port.
  • the first electronic device determines the target connection information based on the third IPv4 address, the port number of the third port, the fourth IPv4 address, and the port number of the fourth port, and the first electronic device determines the target connection information based on the third IPv4 address and the third port, and send a resource acquisition request M2 to the fourth IPv4 address and the fourth port.
  • the second electronic device sends a resource acquisition response R2 to the first electronic device, where the resource acquisition response R2 carries the resource D2.
  • step 409 is the same as step 405, which will not be repeated here.
  • the embodiment of the present application further includes: the management server receives the resource request M2, and if the electronic device storing the resource D2 of the application P2 cannot be found in the resource topology, the management server sends the address of the second application server to the second electronic device,
  • the second application server is a server of the application P2, and the first electronic device receives the address of the second application server and requests the resource D2 from the second application server.
  • the management server can delete the relevant information of the offline electronic device, so as to realize the dynamic shrinkage of the P2P network.
  • the embodiment of the present application further includes: Sending a third notification message, the third notification message is used to notify the management server that the device is online, if the management server does not receive the third notification message from the first electronic device within the target time period, it is determined that the first electronic device is offline, and the management The server deletes relevant data of the first electronic device, including first device information, connection information of connections established between the first electronic device and other electronic devices, and the like.
  • the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, so as to be able to multiplex with the second electronic device
  • the established connection requests the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat The corresponding NAT penetration is performed multiple times, thereby achieving the purpose of saving network resources and reducing the time-consuming of establishing a connection.
  • the resource request method provided in this application can be combined with a CDN network to implement a P2P technology-based CDN network.
  • the network architecture of the P2P technology-based CDN network will be introduced below.
  • the CDN network based on P2P technology includes cloud, edge, access, device and CDN origin.
  • the cloud includes CDN central nodes and management servers.
  • the CDN central node is used to respond to the resource acquisition request of the CDN edge node, and the wormhole grid management plane is deployed on the management server.
  • the management server is used to provide related services of the P2P network, including recording multiple electronic devices and multiple CDNs. Resource topology of edge nodes, assisting multiple electronic devices to perform NAT penetration, controlling and verifying shared resources, etc.
  • the edge end includes multiple CDN edge nodes, and the multiple CDN edge nodes can provide various types of resources, including file resources, video resources, audio resources, and so on.
  • the access terminal includes multiple devices that provide network communication services, such as routing equipment, 5G base stations, 4G base stations, etc.
  • the access terminal is used to provide network communication services for multiple electronic devices at the device end, so that multiple electronic devices at the device end can communicate with The cloud and the edge communicate.
  • the device side includes multiple electronic devices, which can form a P2P network with the management server. Multiple types of resources are stored in the multiple electronic devices, and any electronic device can send to the nearest CDN edge node and other electronic Devices request required resources and can also share resources with other electronic devices.
  • the CDN origin site is used to store all resources in the CDN network.
  • the process of requesting resources by electronic devices will be described below.
  • the first CDN edge node is the CDN edge node storing the resources D1 and D2 closest to the first electronic device
  • the process of the first electronic device requesting the resource D1 and the resource D2 includes the following two processes.
  • Process 1 Request resource D1 of application P1.
  • the first electronic device sends a resource acquisition request M1 to the management server, the management server determines the address of the first CDN edge node based on the scheduling service, and sends the address of the first CDN edge node to the first electronic device, and the management server based on the above steps 402 is the same method, determine the second device information of the second electronic device, and send the second device information to the first electronic device, and the first electronic device requests resource D1 from the first CDN edge node, and based on steps 403 to 405 In the same way, establish a connection with the second electronic device, and request the resource D1 from the second electronic device.
  • the first electronic device sends a resource acquisition request M2 to the management server, the management server determines the address of the first CDN edge node based on the scheduling service, and sends the address of the first CDN edge node to the first electronic device, and the management server based on the above steps 406 In the same way, determine the second device information of the second electronic device, and send the second device information to the first electronic device, and the first electronic device requests the resource D2 from the first CDN edge node, and based on steps 407 to 409 In the same way, multiplex the connection with the second electronic device, and request the resource D2 from the second electronic device.
  • the management server inquires from the resource topology that there are multiple second electronic devices storing the resources requested by the first electronic device, then send the second device information of the multiple second electronic devices to the first electronic device.
  • the first electronic device can request required resources from the plurality of second electronic devices.
  • the first electronic device if the resource requested by the first electronic device does not exist in the plurality of CDN edge nodes at the edge end and the plurality of electronic devices at the device end, the first electronic device requests the required resource from any CDN edge node, the The CDN edge node can request the required resource from the source station through the CDN central node, and return the resource to the first electronic device.
  • a CDN network based on P2P technology is realized, so that electronic devices can request required resources from CDN edge nodes and other electronic devices at the same time, improving the efficiency of resource requests, and, When two electronic devices request resources from different applications, the connection established between the two devices can be reused, thereby achieving the purpose of saving network resources.
  • FIG. 9 is a schematic structural diagram of a resource requesting device provided by an embodiment of the present application.
  • the resource requesting device is used in the above-mentioned first electronic device to perform the steps of the above-mentioned resource requesting method.
  • the resource requesting device It includes: a sending module 901 and a connection multiplexing module 902 .
  • a sending module 901 configured to send a first resource acquisition request to a management server, where the first resource acquisition request carries the identifier of the first application and the identifier of the first resource;
  • the connection multiplexing module 902 is configured to receive the second device information, multiplex the established connection between the first electronic device and the second electronic device, and request the first resource from the second electronic device.
  • connection multiplexing module 902 is configured to determine the target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection The information is used to indicate the established connection between the first electronic device and the second electronic device; based on the target connection information, request the first resource from the second electronic device.
  • the sending module 901 is further configured to send a second resource acquisition request to the management server, where the second resource acquisition request carries the identifier of the second application and the identifier of the second resource;
  • the unit also includes:
  • a connection establishing module configured to receive the second device information, establish the connection with the second electronic device based on the first device information and the second device information, and store the target connection information.
  • the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the second device information includes an address of the second electronic device. At least one of IPv6 address and IPv4 address;
  • the connection establishment module is configured to, if both the first electronic device and the second electronic device support IPv6 communication, the first electronic device communicates with the first electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device The second electronic device establishes the connection; if at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device based on the IPv4 address of the second electronic device and the first electronic device The IPv4 address of the second electronic device to establish the connection.
  • the connection establishment module is configured to perform NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and send a traversal message to the management server, the traversal message It is used to instruct the second electronic device to perform NAT traversal based on the first device information; receive a traversal response from the second electronic device, the traversal response is used to indicate that NAT traversal has been completed, based on the second electronic device's IPv4 address and the IPv4 address of the first electronic device, and establish the connection with the second electronic device.
  • the sending module 901 is configured to send a notification message to the management server, where the notification message is used to indicate that the first electronic device has enabled the connection multiplexing function;
  • the connection establishment module is configured to receive the connection establishment message, establish a connection with the at least one electronic device, the at least one electronic device includes the second electronic device, and store the connection between the first electronic device and the at least one electronic device connection information.
  • the resource request device provided in the above embodiment requests resources, it only uses the division of the above functional modules as an example. In practical applications, the above function allocation can be completed by different functional modules according to needs. That is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
  • the resource requesting device provided in the above embodiments is based on the same idea as the resource requesting method embodiments, and its specific implementation process is detailed in the method embodiments, and will not be repeated here.
  • the program can be stored in a computer-readable storage medium.
  • the above-mentioned The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The present application belongs to the technical field of network communications. Disclosed are a resource request method, system and apparatus, and a device and a computer-readable storage medium. In the method provided in the present application, a first electronic device acquires, by means of sending a resource acquisition request to a management server, device information of a second electronic device which stores a requested resource, so as to request the required resource from the second electronic device by means of reusing a connection which is already established between the first electronic device and the second electronic device, such that the first electronic device can request the resource from the second electronic device without the need to establish a plurality of connections. Since there is no need to establish a plurality of connections, corresponding NAT traversal also does not need to be repeated many times, thereby achieving the goal of saving on network resources and reducing the time used for establishing a connection.

Description

资源请求方法、系统、装置、设备及存储介质Resource request method, system, device, equipment and storage medium
本申请要求于2021年09月07日提交的申请号为202111045623.7、发明名称为“资源请求方法、系统、装置、设备及存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with the application number 202111045623.7 and the title of the invention "resource request method, system, device, equipment and storage medium" submitted on September 07, 2021, the entire contents of which are incorporated herein by reference Applying.
技术领域technical field
本申请涉及网络通信技术领域,特别涉及一种资源请求方法、系统、装置、设备及存储介质。The present application relates to the technical field of network communication, and in particular to a resource request method, system, device, equipment and storage medium.
背景技术Background technique
对等(peer to peer,P2P)网络技术是一种用于资源分享的网络技术,一个P2P网络包括P2P服务器和多个电子设备,每个电子设备通过与P2P服务器通信,来获知其他电子设备上所存储的资源,通过在电子设备之间建立连接,构建P2P网络,从而实现多个电子设备之间的资源共享。由于P2P网络中的电子设备往往位于局域网中,需要通过网络地址转换(network address translation,NAT)设备与位于广域网中的P2P服务器通信。因此,在构建P2P网络的过程中,对于任意两个设备,P2P服务器向两个电子发送对端的地址和端口,两个电子设备分别基于各自的NAT设备、对端的地址和端口,进行NAT穿透,使得位于不同局域网的两个电子设备能够通过各自的NAT设备相互通信,从而建立两个电子设备之间的连接。Peer-to-peer (P2P) network technology is a network technology used for resource sharing. A P2P network includes a P2P server and multiple electronic devices. Each electronic device communicates with the P2P server to learn about other electronic devices. The stored resources can establish a P2P network by establishing a connection between electronic devices, thereby realizing resource sharing among multiple electronic devices. Since the electronic devices in the P2P network are often located in the local area network, they need to communicate with the P2P server located in the wide area network through a network address translation (network address translation, NAT) device. Therefore, in the process of building a P2P network, for any two devices, the P2P server sends the address and port of the peer to the two electronic devices, and the two electronic devices perform NAT penetration based on their respective NAT devices, addresses and ports of the peer. , so that two electronic devices located in different local area networks can communicate with each other through their respective NAT devices, thereby establishing a connection between the two electronic devices.
在相关技术中,一个电子设备往往安装有多个应用,对于每个应用,都需要基于不同的端口进行NAT穿透,并建立电子设备之间的连接,以构建每个应用对应的P2P网络,实现多个电子设备之间不同应用的资源共享。In related technologies, an electronic device is often installed with multiple applications. For each application, NAT penetration needs to be performed based on different ports, and a connection between electronic devices is established to build a P2P network corresponding to each application. Realize the resource sharing of different applications among multiple electronic devices.
上述技术中,任一电子设备向另一个电子设备进行不同应用的资源请求时,需要进行多次NAT穿透并建立多个连接,导致网络资源的浪费,建立连接的耗时长。In the above technology, when any electronic device requests resources of different applications from another electronic device, it needs to perform multiple NAT penetrations and establish multiple connections, which leads to waste of network resources and takes a long time to establish connections.
发明内容Contents of the invention
为了解决电子设备之间进行资源请求时,需要进行多次NAT穿透并建立多个连接的问题,本申请实施例提供了一种资源请求方法、系统、装置、设备及计算机可读存储介质。该技术方案如下:In order to solve the problem that multiple NAT traversals and multiple connections need to be established when resource requests are made between electronic devices, embodiments of the present application provide a resource request method, system, device, device, and computer-readable storage medium. The technical solution is as follows:
第一方面,提供了一种资源请求方法,该方法包括:In the first aspect, a resource request method is provided, and the method includes:
第一电子设备向管理服务器发送第一资源获取请求,该第一资源获取请求携带第一应用的标识和第一资源的标识;The first electronic device sends a first resource acquisition request to the management server, where the first resource acquisition request carries an identifier of the first application and an identifier of the first resource;
该管理服务器接收该第一资源获取请求,基于该第一应用的标识和该第一资源的标识,确定第二电子设备的第二设备信息,将该第二设备信息发送至该第一电子设备,该第二电子设备存储有该第一应用的该第一资源;The management server receives the first resource acquisition request, determines the second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource, and sends the second device information to the first electronic device , the second electronic device stores the first resource of the first application;
该第一电子设备接收该第二设备信息,复用该第一电子设备与该第二电子设备之间已建立的连接,向该第二电子设备请求该第一资源。The first electronic device receives the second device information, multiplexes the established connection between the first electronic device and the second electronic device, and requests the first resource from the second electronic device.
本申请实施例所提供的资源请求方法,第一电子设备通过向管理服务器发送资源获取请求,获取存储有所请求资源的第二电子设备的设备信息,从而能够复用与第二电子设备之间已建立的连接,向第二电子设备请求所需的资源,使得第一电子设备与第二电子设备无需建立多个连接,就能够进行资源的请求,由于无需建立多个连接,也就无需重复多次进行相应的NAT穿透,从而达到了节约网络资源并减少建立连接的耗时的目的。In the resource request method provided by the embodiment of the present application, the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, so as to be able to multiplex with the second electronic device The established connection requests the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat The corresponding NAT penetration is performed multiple times, thereby achieving the purpose of saving network resources and reducing the time-consuming of establishing a connection.
在一些实施例中,该基于该第一应用的标识和该第一资源的标识,确定第二电子设备的第二设备信息包括:In some embodiments, determining the second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource includes:
该管理服务器基于该第一应用的标识和该第一资源的标识,查询对等网络的资源拓扑,得到该第二电子设备的第二设备信息,该资源拓扑用于记录该对等网络中多个电子设备的设备信息、每个该电子设备上应用的标识和每个该电子设备所存储资源的标识之间的对应关系。Based on the identifier of the first application and the identifier of the first resource, the management server queries the resource topology of the peer-to-peer network to obtain the second device information of the second electronic device, and the resource topology is used to record multiple resources in the peer-to-peer network. The corresponding relationship between the device information of an electronic device, the identification of each application on the electronic device, and the identification of the resources stored in each electronic device.
通过查询资源拓扑,获取了第二电子设备的第二设备信息,从而获取了存储有第一电子设备所请求资源的第二电子设备的地址,使第一电子设备能够向第二电子设备请求资源。By querying the resource topology, the second device information of the second electronic device is obtained, thereby obtaining the address of the second electronic device that stores the resources requested by the first electronic device, so that the first electronic device can request resources from the second electronic device .
在一些实施例中,该复用该第一电子设备与该第二电子设备之间已建立的连接,向该第二电子设备请求该第一资源包括:In some embodiments, the multiplexing the established connection between the first electronic device and the second electronic device, and requesting the first resource from the second electronic device includes:
该第一电子设备基于该第一电子设备的第一设备信息和该第二设备信息,确定该第一电子设备中已存储的目标连接信息,该目标连接信息用于指示该第一电子设备与该第二电子设备之间已建立的连接;该第一电子设备基于该目标连接信息,向该第二电子设备请求该第一资源。The first electronic device determines the target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection information is used to indicate that the first electronic device is connected to The established connection between the second electronic device; the first electronic device requests the first resource from the second electronic device based on the target connection information.
通过复用第一电子设备与第二电子设备已建立的连接,使第一电子设备向第二电子设备进行不同应用的资源请求时,无需进行多次NAT穿透并建立多个连接,从而能够达到节约网络资源并减少建立连接的耗时的目的。By multiplexing the established connection between the first electronic device and the second electronic device, when the first electronic device requests resources of different applications from the second electronic device, it is not necessary to perform multiple NAT penetrations and establish multiple connections, thereby enabling The purpose of saving network resources and reducing time-consuming connection establishment is achieved.
在一些实施例中,该第一电子设备向管理服务器发送第一资源获取请求之前,该方法还包括:In some embodiments, before the first electronic device sends the first resource acquisition request to the management server, the method further includes:
该第一电子设备向该管理服务器发送第二资源获取请求,该第二资源获取请求携带第二应用的标识和第二资源的标识;该管理服务器接收该第二资源获取请求,基于该第二应用的标识和该第二资源的标识,确定该第二电子设备的第二设备信息,将该第二设备信息发送至该第一电子设备,该第二电子设备存储有该第二应用的该第二资源;该第一电子设备接收该第二设备信息,基于该第一设备信息和该第二设备信息,与该第二电子设备建立该连接,存储该目标连接信息。The first electronic device sends a second resource acquisition request to the management server, and the second resource acquisition request carries the identifier of the second application and the identifier of the second resource; the management server receives the second resource acquisition request, and based on the second The identification of the application and the identification of the second resource, determining the second device information of the second electronic device, sending the second device information to the first electronic device, and the second electronic device stores the information of the second application Second resource: the first electronic device receives the second device information, establishes the connection with the second electronic device based on the first device information and the second device information, and stores the target connection information.
通过存储目标连接信息,使得第一电子设备在向第二电子设备请求资源时,能够复用与第二电子设备之间的连接。By storing the target connection information, the first electronic device can reuse the connection with the second electronic device when requesting resources from the second electronic device.
在一些实施例中,该第一设备信息包括该第一电子设备的互联网协议第6版IPv6地址和互联网协议第4版IPv4地址中至少一项,该第二设备信息包括该第二电子设备的IPv6地址和IPv4地址中至少一项;In some embodiments, the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the second device information includes an address of the second electronic device. At least one of IPv6 address and IPv4 address;
该基于该第一设备信息和该第二设备信息,与该第二电子设备建立该连接包括:Establishing the connection with the second electronic device based on the first device information and the second device information includes:
若该第一电子设备和该第二电子设备均支持IPv6通信,该第一电子设备基于该第二电子设备的IPv6地址和该第一电子设备的IPv6地址,与该第二电子设备建立该连接;若该第一电子设备和该第二电子设备中至少一个电子设备不支持IPv6通信,该第一电子设备基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接。If both the first electronic device and the second electronic device support IPv6 communication, the first electronic device establishes the connection with the second electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device ; If at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device communicates with the first electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device. The two electronic devices establish the connection.
通过设备信息,第一电子设备和第二电子设备能够智能选择基于IPv4地址或IPv6地址建立连接。Through the device information, the first electronic device and the second electronic device can intelligently choose to establish a connection based on an IPv4 address or an IPv6 address.
在一些实施例中,该第一电子设备基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接包括:In some embodiments, the first electronic device establishing the connection with the second electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device includes:
该第一电子设备基于该第一电子设备的NAT设备和该第二电子设备的IPv4地址,进行NAT穿透,向该管理服务器发送穿透消息,该穿透消息用于指示该第二电子设备基于该第一设备信息进行NAT穿透;该管理服务器向该第二电子设备转发该穿透消息;该第二电子设备接收该穿透消息,基于该第二电子设备的NAT设备、该第一电子设备的IPv4地址,进行NAT穿透,向该第一电子设备发送穿透响应,该穿透响应用于表示已完成NAT穿透;该第一电子设备接收该穿透响应,基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接。The first electronic device performs NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and sends a traversal message to the management server, where the traversal message is used to indicate that the second electronic device Perform NAT penetration based on the first device information; the management server forwards the penetration message to the second electronic device; the second electronic device receives the penetration message, based on the NAT device of the second electronic device, the first The IPv4 address of the electronic device performs NAT penetration, and sends a penetration response to the first electronic device, and the penetration response is used to indicate that NAT penetration has been completed; the first electronic device receives the penetration response, based on the second The IPv4 address of the electronic device and the IPv4 address of the first electronic device establish the connection with the second electronic device.
通过管理服务器转发穿透消息与穿透响应,使第一电子设备与第二电子设备完成NAT穿透,从而能够建立两个电子设备之间的连接Through the management server forwarding the penetration message and penetration response, the first electronic device and the second electronic device complete NAT penetration, so that the connection between the two electronic devices can be established
在一些实施例中,该第一电子设备向管理服务器发送第一资源获取请求之前,该方法还包括:In some embodiments, before the first electronic device sends the first resource acquisition request to the management server, the method further includes:
该第一电子设备向该管理服务器发送通知消息,该通知消息用于表示该第一电子设备已启用连接复用功能;该管理服务器接收该通知消息,向该第一电子设备发送连接建立消息,该连接建立消息用于指示与至少一个电子设备建立连接,该至少一个电子设备启用该连接复用功能;该第一电子设备接收该连接建立消息,与该至少一个电子设备建立连接,该至少一个电子设备包括该第二电子设备,存储该第一电子设备与该至少一个电子设备之间的连接的连接信息。The first electronic device sends a notification message to the management server, the notification message is used to indicate that the first electronic device has enabled the connection multiplexing function; the management server receives the notification message, sends a connection establishment message to the first electronic device, The connection establishment message is used to indicate to establish a connection with at least one electronic device, and the at least one electronic device enables the connection multiplexing function; the first electronic device receives the connection establishment message, establishes a connection with the at least one electronic device, and the at least one The electronic device includes the second electronic device, and stores connection information of a connection between the first electronic device and the at least one electronic device.
通过在电子设备进行资源请求之前提前建立连接,能够使电子设备在进行资源请求时直接使用已建立好的连接,从而能够提升资源请求的效率。By establishing a connection in advance before the electronic device makes a resource request, the electronic device can directly use the established connection when making a resource request, thereby improving resource request efficiency.
第二方面,提供了一种网络系统,该系统包括:第一电子设备、第二电子设备和管理服务器,用于执行如第一方面所提供的资源请求方法中对应的步骤。In a second aspect, a network system is provided, and the system includes: a first electronic device, a second electronic device, and a management server, configured to execute corresponding steps in the resource request method provided in the first aspect.
通过该网络系统,第一电子设备能够向管理服务器发送资源获取请求,获取存储有所请求资源的第二电子设备的设备信息,从而能够复用与第二电子设备之间已建立的连接,向第二电子设备请求所需的资源,使得第一电子设备与第二电子设备无需重新建立连接,就能够进行资源的请求,由于第一电子设备与第二电子设备位于不同局域网时,需要先进行NAT穿透才能建立连接,因此,第一电子设备向第二电子设备请求资源时,也无需重新进行NAT穿透,从而达到了节约网络资源并减少建立连接的耗时的目的。Through this network system, the first electronic device can send a resource acquisition request to the management server, and obtain the device information of the second electronic device that stores the requested resource, so that it can reuse the established connection with the second electronic device, and send The second electronic device requests the required resources, so that the first electronic device and the second electronic device can request resources without re-establishing a connection. Since the first electronic device and the second electronic device are located in different local area networks, they need to first Only through NAT traversal can a connection be established. Therefore, when the first electronic device requests resources from the second electronic device, there is no need to re-perform NAT traversal, thereby achieving the purpose of saving network resources and reducing time-consuming connection establishment.
第三方面,提供了一种资源请求装置,该装置用于上述第一电子设备中,该装置包括发送模块和复用模块。According to a third aspect, a resource requesting device is provided, which is used in the above-mentioned first electronic device, and the device includes a sending module and a multiplexing module.
发送模块,用于向管理服务器发送第一资源获取请求,该第一资源获取请求携带第一应用的标识和第一资源的标识;A sending module, configured to send a first resource acquisition request to the management server, where the first resource acquisition request carries the identifier of the first application and the identifier of the first resource;
连接复用模块,用于接收该第二设备信息,复用该第一电子设备与该第二电子设备之间已建立的连接,向该第二电子设备请求该第一资源。A connection multiplexing module, configured to receive the second device information, multiplex the established connection between the first electronic device and the second electronic device, and request the first resource from the second electronic device.
在一些实施例中,该连接复用模块,用于基于该第一电子设备的第一设备信息和该第二设备信息,确定该第一电子设备中已存储的目标连接信息,该目标连接信息用于指示该第一电子设备与该第二电子设备之间已建立的连接;基于该目标连接信息,向该第二电子设备请求该第一资源。In some embodiments, the connection multiplexing module is configured to determine the target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection information It is used to indicate the established connection between the first electronic device and the second electronic device; based on the target connection information, request the first resource from the second electronic device.
在一些实施例中,该发送模块,还用于向该管理服务器发送第二资源获取请求,该第二资源获取请求携带第二应用的标识和第二资源的标识;In some embodiments, the sending module is further configured to send a second resource acquisition request to the management server, where the second resource acquisition request carries the identifier of the second application and the identifier of the second resource;
该装置还包括:The unit also includes:
连接建立模块,用于接收该第二设备信息,基于该第一设备信息和该第二设备信息,与该第二电子设备建立该连接,存储该目标连接信息。A connection establishing module, configured to receive the second device information, establish the connection with the second electronic device based on the first device information and the second device information, and store the target connection information.
在一些实施例中,该第一设备信息包括该第一电子设备的互联网协议第6版IPv6地址和互联网协议第4版IPv4地址中至少一项,该第二设备信息包括该第二电子设备的IPv6地址和IPv4地址中至少一项;In some embodiments, the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the second device information includes an address of the second electronic device. At least one of IPv6 address and IPv4 address;
该连接建立模块,用于若该第一电子设备和该第二电子设备均支持IPv6通信,该第一电子设备基于该第二电子设备的IPv6地址和该第一电子设备的IPv6地址,与该第二电子设备建立该连接;若该第一电子设备和该第二电子设备中至少一个电子设备不支持IPv6通信,该第一电子设备基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接。The connection establishment module is configured to, if both the first electronic device and the second electronic device support IPv6 communication, the first electronic device communicates with the first electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device The second electronic device establishes the connection; if at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device based on the IPv4 address of the second electronic device and the first electronic device The IPv4 address of the second electronic device to establish the connection.
在一些实施例中,该连接建立模块,用于基于该第一电子设备的NAT设备和该第二电子设备的IPv4地址,进行NAT穿透,向该管理服务器发送穿透消息,该穿透消息用于指示该第二电子设备基于该第一设备信息进行NAT穿透;接收第二电子设备的穿透响应,该穿透响应用于表示已完成NAT穿透,基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接。In some embodiments, the connection establishment module is configured to perform NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and send a traversal message to the management server, the traversal message It is used to instruct the second electronic device to perform NAT traversal based on the first device information; receive a traversal response from the second electronic device, the traversal response is used to indicate that NAT traversal has been completed, based on the second electronic device's IPv4 address and the IPv4 address of the first electronic device, and establish the connection with the second electronic device.
在一些实施例中,该发送模块,用于向该管理服务器发送通知消息,该通知消息用于表示该第一电子设备已启用连接复用功能;In some embodiments, the sending module is configured to send a notification message to the management server, where the notification message is used to indicate that the first electronic device has enabled the connection multiplexing function;
该连接建立模块,用于接收该连接建立消息,与该至少一个电子设备建立连接,该至少一个电子设备包括该第二电子设备,存储该第一电子设备与该至少一个电子设备之间的连接的连接信息。The connection establishment module is configured to receive the connection establishment message, establish a connection with the at least one electronic device, the at least one electronic device includes the second electronic device, and store the connection between the first electronic device and the at least one electronic device connection information.
通过该资源请求装置,第一电子设备通过向管理服务器发送资源获取请求,获取存储有所请求资源的第二电子设备的设备信息,从而能够复用与第二电子设备之间已建立的连接,向第二电子设备请求所需的资源,使得第一电子设备与第二电子设备无需建立多个连接,就能够进行资源的请求,由于无需建立多个连接,也就无需重复多次进行相应的NAT穿透,从而达到了节约网络资源并减少建立连接的耗时的目的。Through the resource requesting device, the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, thereby being able to reuse the established connection with the second electronic device, Request the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat the corresponding NAT traversal, so as to achieve the purpose of saving network resources and reducing the time-consuming connection establishment.
第四方面,提供了一种计算机设备,该计算机设备包括通信总线、至少一个网络接口、存储器以及至少一个处理器,该通信总线用于在上述组件之间传送信息,该至少一个网络接口用于与其它设备或通信网络通信,该存储器保存有程序代码,该至少一个处理器通过读取并执行该存储器中保存的程序代码实现上述第一方面中资源请求方法的任一步骤。In a fourth aspect, a computer device is provided, the computer device includes a communication bus, at least one network interface, a memory, and at least one processor, the communication bus is used to transmit information between the above components, and the at least one network interface is used for In communication with other devices or communication networks, the memory stores program codes, and the at least one processor realizes any step of the resource request method in the first aspect above by reading and executing the program codes stored in the memory.
通过该计算机设备,第一电子设备通过向管理服务器发送资源获取请求,获取存储有所请求资源的第二电子设备的设备信息,从而能够复用与第二电子设备之间已建立的连接,向 第二电子设备请求所需的资源,使得第一电子设备与第二电子设备无需建立多个连接,就能够进行资源的请求,由于无需建立多个连接,也就无需重复多次进行相应的NAT穿透,从而达到了节约网络资源并减少建立连接的耗时的目的。Through the computer device, the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, so that it can reuse the established connection with the second electronic device, and send The second electronic device requests the required resources, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat the corresponding NAT multiple times. Penetration, so as to achieve the purpose of saving network resources and reducing the time-consuming connection establishment.
第五方面,提供了一种计算机可读存储介质,当该计算机可读存储介质中的程序代码由计算机设备的处理器执行时,使得计算机设备能够执行上述第一方面中资源请求方法的任一步骤。In the fifth aspect, a computer-readable storage medium is provided. When the program code in the computer-readable storage medium is executed by the processor of the computer device, the computer device can execute any one of the resource request methods in the above-mentioned first aspect. step.
通过该计算机可读存储介质,第一电子设备通过向管理服务器发送资源获取请求,获取存储有所请求资源的第二电子设备的设备信息,从而能够复用与第二电子设备之间已建立的连接,向第二电子设备请求所需的资源,使得第一电子设备与第二电子设备无需建立多个连接,就能够进行资源的请求,由于无需建立多个连接,也就无需重复多次进行相应的NAT穿透,从而达到了节约网络资源并减少建立连接的耗时的目的。Through the computer-readable storage medium, the first electronic device obtains the device information of the second electronic device that stores the requested resources by sending a resource acquisition request to the management server, so that it can reuse the established relationship with the second electronic device. Connection, to request the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat multiple The corresponding NAT penetration achieves the purpose of saving network resources and reducing the time-consuming of establishing connections.
附图说明Description of drawings
图1是本申请实施例提供的一种网络系统的示意图;FIG. 1 is a schematic diagram of a network system provided by an embodiment of the present application;
图2是本申请实施例提供的一种网络系统的示意图;FIG. 2 is a schematic diagram of a network system provided by an embodiment of the present application;
图3是本申请实施例提供的一种计算机设备300的结构示意图;FIG. 3 is a schematic structural diagram of a computer device 300 provided in an embodiment of the present application;
图4是本申请实施例提供的一种资源请求方法的步骤流程图;FIG. 4 is a flow chart of the steps of a resource request method provided by an embodiment of the present application;
图5是本申请实施例提供的一种资源请求方法的示意图;FIG. 5 is a schematic diagram of a resource request method provided by an embodiment of the present application;
图6是本申请实施例提供的一种资源拓扑的示意图;FIG. 6 is a schematic diagram of a resource topology provided by an embodiment of the present application;
图7是本申请实施例提供的一种资源请求方法的示意图;FIG. 7 is a schematic diagram of a resource request method provided by an embodiment of the present application;
图8是本申请实施例提供的一种基于P2P技术的CDN网络的示意图;FIG. 8 is a schematic diagram of a CDN network based on P2P technology provided by an embodiment of the present application;
图9是本申请实施例提供的一种资源请求装置的结构示意图。Fig. 9 is a schematic structural diagram of a resource request device provided by an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请实施方式作进一步地详细描述。In order to make the purpose, technical solution and advantages of the present application clearer, the implementation manners of the present application will be further described in detail below in conjunction with the accompanying drawings.
在介绍本申请实施例体提供的技术方案之前,下面先对本申请涉及的关键技术语进行介绍。Before introducing the technical solutions provided by the embodiments of the present application, the key technical terms involved in the present application will be introduced below.
对等网络(peer to peer,P2P),是依靠用户群节点进行信息交换的对等式网络技术。P2P网络无需依赖专用的集中服务器或工作站,网络中的每个电子设备既能作为资源请求者,从其他电子设备中获资源,也能作为资源提供者,将存储的资源发送给其他的电子设备。通常,这些资源包括视频资源、音频资源、计算资源(如中央处理器计算资源)、存储资源(如缓存和磁盘空间)等。Peer-to-peer network (peer to peer, P2P) is a peer-to-peer network technology that relies on user group nodes for information exchange. The P2P network does not need to rely on dedicated centralized servers or workstations. Each electronic device in the network can act as a resource requester to obtain resources from other electronic devices, or as a resource provider to send stored resources to other electronic devices. . Usually, these resources include video resources, audio resources, computing resources (such as CPU computing resources), storage resources (such as cache memory and disk space), and the like.
网格,是一种用于集成或共享地理上分布的各种资源(包括计算机系统、存储系统、通信系统、文件、数据库、程序等),使之成为有机的整体,共同完成各种所需任务的网络技术,P2P网络是网格的一种。Grid is a kind of resource (including computer system, storage system, communication system, file, database, program, etc.) that is used to integrate or share geographical distribution, making it an organic whole, and jointly accomplishing various needs. The task network technology, P2P network is a kind of grid.
内容分发网络(content delivery network,CDN),是构建在现有网络基础之上的智能虚拟网络,依靠部署在各地的边缘服务器,通过中心平台的负载均衡、内容分发、调度等功能模 块,使用户从临近的边缘服务器获取所需内容,降低网络拥塞,提高用户访问响应速度和命中率。The content delivery network (CDN) is an intelligent virtual network built on the basis of the existing network, relying on the edge servers deployed in various places, through the load balancing, content distribution, scheduling and other functional modules of the central platform, so that users Obtain required content from adjacent edge servers, reduce network congestion, and improve user access response speed and hit rate.
网络地址转换(network address translation,NAT),又称网络掩蔽、互联网协议(internet protocol,IP)掩蔽,在计算机网络中是一种在IP数据包通过路由器或防火墙时重写来源IP地址或目的IP地址的技术,被普遍使用在有多个电子设备但只通过一个公有IP地址访问互联网的局域网中。Network address translation (network address translation, NAT), also known as network masking, Internet protocol (internet protocol, IP) masking, is a method of rewriting the source IP address or destination IP address when an IP packet passes through a router or firewall in a computer network. IP address technology is commonly used in local area networks that have multiple electronic devices but only access the Internet through a public IP address.
NAT穿透(NAT traversal),也称为内网穿透,是一种让使用了NAT技术的处于不同局域网中的电子设备能够相互通信的技术,NAT穿透技术是实现P2P网络的基础。NAT traversal, also known as intranet traversal, is a technology that enables electronic devices in different local area networks using NAT technology to communicate with each other. NAT traversal technology is the basis for realizing P2P networks.
下面结合图1对本申请所提供的方法的系统架构进行介绍。The system architecture of the method provided by the present application will be introduced below with reference to FIG. 1 .
图1是本申请实施例提供的一种网络系统的示意图,该网络系统包括多个第一电子设备101、多个第二电子设备102和管理服务器103。FIG. 1 is a schematic diagram of a network system provided by an embodiment of the present application. The network system includes multiple first electronic devices 101 , multiple second electronic devices 102 and a management server 103 .
第一电子设备101和第二电子设备102可以是智能手机、平板电脑、笔记本电脑、台式计算机、主机等,但并不局限于此。该管理服务器103可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、CDN网络、以及大数据和人工智能平台等基础云计算服务的云服务器。The first electronic device 101 and the second electronic device 102 may be smart phones, tablet computers, notebook computers, desktop computers, hosts, etc., but are not limited thereto. The management server 103 can be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, and can also provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud Cloud servers for basic cloud computing services such as communications, middleware services, domain name services, security services, CDN networks, and big data and artificial intelligence platforms.
其中,第一电子设备101和第二电子设备102可以位于广域网中,通过有线或无线网络与位于广域网中的管理服务器103通信,第一电子设备101和第二电子设备102也可以位于局域网中,通过NAT设备与位于广域网中的管理服务器103进行通信,第一电子设备101和第二电子设备102可以位于同一个局域网中,也可以位于不同层级的局域网中,该局域网可以是电信运营商(internet service provider,ISP)提供的网络,本申请实施例对此不作限定。该多个第一电子设备101能够与该多个第二电子设备102建立连接,从而使该多个第一电子设备101、多个第二电子设备102和管理服务器103构成一个P2P网络,该P2P网络也称为网格,该网络系统也称为虫洞网格系统(wormhole mesh)。Wherein, the first electronic device 101 and the second electronic device 102 may be located in a wide area network, communicate with the management server 103 located in the wide area network through a wired or wireless network, and the first electronic device 101 and the second electronic device 102 may also be located in a local area network, The NAT device communicates with the management server 103 located in the wide area network. The first electronic device 101 and the second electronic device 102 can be located in the same local area network or in different levels of local area networks. The local area network can be a telecom operator (Internet service provider (ISP), which is not limited in this embodiment of the present application. The plurality of first electronic devices 101 can establish connections with the plurality of second electronic devices 102, so that the plurality of first electronic devices 101, the plurality of second electronic devices 102 and the management server 103 form a P2P network, and the P2P A network is also called a grid, and the network system is also called a wormhole mesh.
在本申请实施例中,该第一电子设备101和第二电子设备102安装有多个应用,该多个应用提供有多种类型的资源,包括视频资源、音频资源和文本资源等。第一电子设备101能够基于P2P网络的功能,向第二电子设备102进行资源请求。例如,如图2所示,若第一电子设备101和第二电子设备102均安装有应用1和应用2,则第一电子设备101能够通过与第二电子设备102之间的连接,向第二电子设备102请求应用1的资源和应用2的资源。In the embodiment of the present application, the first electronic device 101 and the second electronic device 102 are installed with multiple applications, and the multiple applications provide multiple types of resources, including video resources, audio resources and text resources. The first electronic device 101 can request resources from the second electronic device 102 based on the function of the P2P network. For example, as shown in FIG. 2 , if both the first electronic device 101 and the second electronic device 102 are installed with application 1 and application 2, the first electronic device 101 can connect to the second electronic device 102 to send The second electronic device 102 requests the resource of application 1 and the resource of application 2 .
应理解,上述第一电子设备101也能够基于其他电子设备的资源获取请求,向其他设备发送所存储的资源,第二电子设备102也能够向其他电子设备请求资源,本申请实施例对此不作限定。It should be understood that the above-mentioned first electronic device 101 can also send stored resources to other devices based on resource acquisition requests of other electronic devices, and the second electronic device 102 can also request resources from other electronic devices, which is not discussed in this embodiment of the present application. limited.
下面结合图3,对上述系统架构中的第一电子设备101、第二电子设备102和管理服务器103的硬件结构进行介绍。The hardware structure of the first electronic device 101 , the second electronic device 102 and the management server 103 in the above system architecture will be introduced below with reference to FIG. 3 .
图3是本申请实施例提供的一种计算机设备300的结构示意图。图3所示的计算机设备300能够配置为上述第一电子设备101、第二电子设备102或管理服务器103,该计算机设备300用于执行资源请求方法所涉及的操作。如图3所示,该计算机设备300包括至少一个处 理器301、通信总线302、存储器303以及至少一个网络接口304。FIG. 3 is a schematic structural diagram of a computer device 300 provided by an embodiment of the present application. The computer device 300 shown in FIG. 3 can be configured as the first electronic device 101 , the second electronic device 102 or the management server 103 , and the computer device 300 is used to execute the operations involved in the resource request method. As shown in FIG. 3 , the computer device 300 includes at least one processor 301, a communication bus 302, a memory 303, and at least one network interface 304.
处理器301例如是通用中央处理器(central processing unit,CPU)、网络处理器(network processer,NP)、图形处理器(graphics processing unit,GPU)、神经网络处理器(neural-network processing units,NPU)、数据处理单元(data processing unit,DPU)、微处理器或者一个或多个用于实现本申请方案的集成电路。例如,处理器301包括专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或其组合。PLD例如是复杂可编程逻辑器件(complex programmable logic device,CPLD)、现场可编程逻辑门阵列(field-programmable gate array,FPGA)、通用阵列逻辑(generic array logic,GAL)或其任意组合。The processor 301 is, for example, a general-purpose central processing unit (central processing unit, CPU), a network processor (network processor, NP), a graphics processing unit (graphics processing unit, GPU), a neural network processor (neural-network processing units, NPU) ), a data processing unit (data processing unit, DPU), a microprocessor, or one or more integrated circuits for implementing the solution of this application. For example, the processor 301 includes an application-specific integrated circuit (application-specific integrated circuit, ASIC), a programmable logic device (programmable logic device, PLD) or a combination thereof. The PLD is, for example, a complex programmable logic device (complex programmable logic device, CPLD), a field-programmable gate array (field-programmable gate array, FPGA), a general array logic (generic array logic, GAL) or any combination thereof.
通信总线302用于在上述组件之间传送信息。通信总线302可选地分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。The communication bus 302 is used to transfer information between the aforementioned components. The communication bus 302 is optionally divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 3 , but it does not mean that there is only one bus or one type of bus.
存储器303例如是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其它类型的静态存储设备,又如是随机存取存储器(random access memory,RAM)或者可存储信息和指令的其它类型的动态存储设备,又如是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、只读光盘(compact disc read-only memory,CD-ROM)或其它光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其它磁存储设备,或者是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其它介质,但不限于此。存储器303例如是独立存在,并通过通信总线302与处理器301相连接。或者可选地存储器303和处理器301集成在一起。The memory 303 is, for example, a read-only memory (read-only memory, ROM) or other types of static storage devices that can store static information and instructions, or a random access memory (random access memory, RAM) or a memory that can store information and instructions. Other types of dynamic storage devices, such as electrically erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc Storage (including Compact Disc, Laser Disc, Optical Disc, Digital Versatile Disc, Blu-ray Disc, etc.), magnetic disk storage medium, or other magnetic storage device, or is capable of carrying or storing desired program code in the form of instructions or data structures and capable of Any other medium accessed by a computer, but not limited to. The memory 303 exists independently, for example, and is connected to the processor 301 through the communication bus 302 . Or optionally, the memory 303 and the processor 301 are integrated together.
网络接口304使用任何收发器一类的装置,用于与其它设备或通信网络通信。网络接口304包括有线网络接口,可选地还包括无线网络接口。其中,有线网络接口例如为以太网接口。以太网接口例如是光接口、电接口或其组合。无线网络接口例如为无线局域网(wireless local area networks,WLAN)接口,蜂窝网络接口或其组合等。 Network interface 304 uses any transceiver-like device for communicating with other devices or a communication network. The network interface 304 includes a wired network interface, and optionally also includes a wireless network interface. Wherein, the wired network interface is, for example, an Ethernet interface. The Ethernet interface is, for example, an optical interface, an electrical interface or a combination thereof. The wireless network interface is, for example, a wireless local area network (wireless local area networks, WLAN) interface, a cellular network interface or a combination thereof.
在一些实施例中,处理器301包括一个或多个CPU,如图3中所示的CPU0和CPU1。In some embodiments, the processor 301 includes one or more CPUs, such as CPU0 and CPU1 as shown in FIG. 3 .
在一些实施例中,计算机设备300可选地包括多个处理器,如图3中所示的处理器301和处理器305。这些处理器中的每一个例如是一个单核处理器,又如是一个多核处理器。这里的处理器可选地指一个或多个设备、电路、和/或用于处理数据(如计算机程序指令)的处理核。In some embodiments, computer device 300 optionally includes multiple processors, such as processor 301 and processor 305 as shown in FIG. 3 . Each of these processors is, for example, a single-core processor, or a multi-core processor. A processor herein alternatively refers to one or more devices, circuits, and/or processing cores for processing data such as computer program instructions.
在一些实施例中,该计算机设备300还包括输出设备和输入设备。输出设备可选地以多种方式来显示信息。例如,输出设备可选地是液晶显示器(liquid crystal display,LCD)、发光二级管(light emitting diode,LED)显示设备、阴极射线管(cathode ray tube,CRT)显示设备或投影仪(projector)等。输入设备和处理器301通信,可选地以多种方式接收用户的输入。例如,输入设备可选地是鼠标、键盘、触摸屏设备或传感设备等。In some embodiments, the computer device 300 also includes output devices and input devices. Output devices optionally display information in a variety of ways. For example, the output device is optionally a liquid crystal display (liquid crystal display, LCD), a light emitting diode (light emitting diode, LED) display device, a cathode ray tube (cathode ray tube, CRT) display device or a projector (projector) wait. The input device communicates with the processor 301 and optionally receives user input in a variety of ways. For example, the input device is optionally a mouse, a keyboard, a touch screen device, or a sensing device, among others.
可选地,处理器301通过读取存储器303中保存的程序代码310实现下述实施例中的方法,或者,处理器301通过内部存储的程序代码实现下述实施例中的方法。在处理器301通过读取存储器303中保存的程序代码310实现下述实施例中的方法的情况下,存储器303中保存实现本申请实施例提供的资源请求方法的程序代码。Optionally, the processor 301 implements the methods in the following embodiments by reading the program code 310 stored in the memory 303, or, the processor 301 implements the methods in the following embodiments through internally stored program codes. When the processor 301 implements the method in the following embodiments by reading the program code 310 stored in the memory 303, the memory 303 stores the program code for implementing the resource request method provided by the embodiment of the present application.
处理器301实现上述功能的更多细节请参考下面各个方法实施例中的描述,在这里不再重复。For more details on implementing the above functions by the processor 301, please refer to the descriptions in the various method embodiments below, which will not be repeated here.
本申请实施例还提供了一种包括程序代码的计算机可读存储介质,例如包括程序代码的存储器303,上述程序代码可由计算机设备300的处理器301执行以完成资源请求方法。可选地,计算机可读存储介质可以是只读内存(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、只读光盘(compact-disc read-only memory,CD-ROM)、磁带、软盘和光数据存储设备等。The embodiment of the present application also provides a computer-readable storage medium including program codes, such as the memory 303 including program codes. The above-mentioned program codes can be executed by the processor 301 of the computer device 300 to complete the resource request method. Optionally, the computer-readable storage medium may be a read-only memory (read-only memory, ROM), a random access memory (random access memory, RAM), a compact-disc read-only memory (CD-ROM) ), tapes, floppy disks, and optical data storage devices, etc.
在介绍了本申请的系统架构的基础上,下面结合图4,对本申请所提供的资源请求方法进行说明。On the basis of introducing the system architecture of the present application, the resource request method provided by the present application will be described below with reference to FIG. 4 .
图4是本申请实施例提供的一种资源请求方法的步骤流程图,如图4所示,该资源请求方法应用于如图1所示的系统架构中,下面以系统架构中第一电子设备101、第二电子设备102以及管理服务器103之间的交互为例,对该资源请求方法进行说明,该资源请求方法包括以下步骤401至步骤409。Fig. 4 is a flow chart of the steps of a resource request method provided by the embodiment of the present application. As shown in Fig. 4, the resource request method is applied to the system architecture shown in Fig. 1, and the first electronic device in the system architecture is used below 101 , the interaction between the second electronic device 102 and the management server 103 is taken as an example, and the resource request method is described, and the resource request method includes the following steps 401 to 409 .
401、第一电子设备向管理服务器发送资源获取请求M1,该资源获取请求M1携带应用P1的标识和资源D1的标识。401. The first electronic device sends a resource acquisition request M1 to the management server, where the resource acquisition request M1 carries an identifier of the application P1 and an identifier of the resource D1.
其中,该第一电子设备安装有该应用P1,该第一电子设备通过发送资源请求M1,来请求应用P1所提供的资源D1,例如,该第一电子设备通过发送资源请求M1,请求视频应用的视频资源,或者,该第一电子设备通过发送资源请求M1,请求音乐程序的音频资源,本申请实施例对此不作限定。该应用P1的标识可以是应用P1的配置文件中配置的标识,也可以是虚拟的IP地址和端口号,本申请实施例对此不作限定。Wherein, the first electronic device is installed with the application P1, and the first electronic device requests the resource D1 provided by the application P1 by sending a resource request M1, for example, the first electronic device requests a video application by sending a resource request M1 or, the first electronic device requests audio resources of the music program by sending a resource request M1, which is not limited in this embodiment of the present application. The identifier of the application P1 may be the identifier configured in the configuration file of the application P1, or may be a virtual IP address and port number, which is not limited in this embodiment of the present application.
在一些实施例中,如图5所示,第一电子设备先启用连接复用功能,然后基于该连接复用功能,向管理服务器发送资源获取请求M1,该连接复用功能能够为任一电子设备中的多个应用提供统一的网络通信功能,从而实现多个应用的资源共享。可选地,该连接复用功能在该第一电子设备上电启动时默认启用,或者基于该第一电子设备的任一应用的调用启用,本申请实施例对此不作限定。In some embodiments, as shown in FIG. 5, the first electronic device first enables the connection multiplexing function, and then sends a resource acquisition request M1 to the management server based on the connection multiplexing function. The connection multiplexing function can be any electronic device Multiple applications in the device provide a unified network communication function, thereby realizing resource sharing among multiple applications. Optionally, the connection multiplexing function is enabled by default when the first electronic device is powered on, or enabled based on invoking by any application of the first electronic device, which is not limited in this embodiment of the present application.
在本申请实施例中,该连接复用功能基于对等网络工具包(peer software development kit,Peer-SDK)实现,该Peer-SDK运行于设备系统中,例如以插件的形式,为该多个应用提供连接复用功能,或者,该Peer-SDK能够作为一个独立的应用安装在第一电子设备中,基于任一应用的调用,来为该第一电子设备中的应用提供连接复用功能,这种方式被称为边车(sidecar)模式,能够使得各个应用的开发人员无需对应用的程序代码进行大量修改,就能够直接调用该Peer-SDK,实现多个应用的资源共享。In the embodiment of the present application, the connection multiplexing function is realized based on a peer-to-peer network toolkit (peer software development kit, Peer-SDK). The application provides the connection multiplexing function, or the Peer-SDK can be installed in the first electronic device as an independent application, and based on the call of any application, it provides the connection multiplexing function for the application in the first electronic device, This method is called the sidecar mode, which enables the developers of each application to directly call the Peer-SDK without having to make a lot of modifications to the program code of the application, so as to realize the resource sharing of multiple applications.
402、管理服务器接收资源获取请求M1,基于应用P1的标识和资源D1的标识,确定第二电子设备的第二设备信息,将该第二设备信息发送至第一电子设备,第二电子设备存储有应用P1的资源D1。402. The management server receives the resource acquisition request M1, determines the second device information of the second electronic device based on the identifier of the application P1 and the identifier of the resource D1, and sends the second device information to the first electronic device, and the second electronic device stores There is resource D1 with application P1.
其中,第二设备信息包括第二电子设备的第二端口的端口号和第二IP地址,该第二IP地址包括第二互联网协议第6版(internet protocol version 6,IPv6)地址和第二互联网协议第4版(internet protocol version 4,IPv4)地址中至少一项。其中,第二端口和第二IPv4地址为第二NAT设备为该第二电子设备分配的广域网的端口和IPv4地址,也即是第二NAT设备的 端口和IPv4地址,用于与位于广域网的管理服务器通信,该第二NAT设备为第二电子设备的NAT设备。可选地,该第二设备信息还包括第二电子设备的其他信息,如设备标识、设备状态、设备位置等,本申请实施例对此不作限定。Wherein, the second device information includes the port number and the second IP address of the second port of the second electronic device, and the second IP address includes a second Internet protocol version 6 (internet protocol version 6, IPv6) address and a second Internet At least one of the protocol version 4 (internet protocol version 4, IPv4) addresses. Wherein, the second port and the second IPv4 address are the port and the IPv4 address of the wide area network allocated by the second NAT device for the second electronic device, that is, the port and the IPv4 address of the second NAT device, for communication with the management located in the wide area network The server communicates, and the second NAT device is the NAT device of the second electronic device. Optionally, the second device information further includes other information of the second electronic device, such as device identification, device status, device location, etc., which is not limited in this embodiment of the present application.
在一些实施例中,上述“基于应用P1的标识和资源D1的标识,确定第二电子设备的第二设备信息”包括:管理服务器基于应用P1的标识和资源D1的标识,查询P2P网络的资源拓扑,得到第二电子设备的第二设备信息,该资源拓扑用于记录该P2P网络中多个电子设备的设备信息、每个电子设备上应用的标识和每个电子设备所存储资源的标识之间的对应关系。In some embodiments, the above "determining the second device information of the second electronic device based on the identification of the application P1 and the identification of the resource D1" includes: the management server queries the resources of the P2P network based on the identification of the application P1 and the identification of the resource D1 Topology, to obtain the second device information of the second electronic device, the resource topology is used to record the device information of multiple electronic devices in the P2P network, the identification of applications on each electronic device, and the identification of resources stored in each electronic device Correspondence between.
上述资源拓扑的形式示例如下,如图6所示,若电子设备1的设备信息为10.182.100.1:80,电子设备1中存储有应用1的资源1,应用1的标识为aaaa,资源1的标识为ZY1,则管理服务器中记录该电子设备1的设备信息、应用1的标识和资源1的标识之间的对应关系(10.182.100.1:80,aaaa,ZY1),若电子设备2的设备信息为10.182.100.2:80,电子设备2中存储有应用2的资源2,应用2的标识为bbbb,资源2的标识为ZY2,则管理服务器中记录该电子设备2的设备信息、应用2的标识和资源2的标识之间的对应关系(10.182.100.2:80,bbbb,ZY2)。An example of the form of the resource topology above is as follows, as shown in Figure 6, if the device information of electronic device 1 is 10.182.100.1:80, resource 1 of application 1 is stored in electronic device 1, the identifier of application 1 is aaaa, and the resource 1 of resource 1 If the ID is ZY1, the management server records the corresponding relationship between the device information of the electronic device 1, the ID of the application 1, and the ID of the resource 1 (10.182.100.1:80, aaaa, ZY1), if the device information of the electronic device 2 10.182.100.2:80, resource 2 of application 2 is stored in electronic device 2, the identifier of application 2 is bbbb, and the identifier of resource 2 is ZY2, then the device information of electronic device 2 and the identifier of application 2 are recorded in the management server The corresponding relationship with the identifier of resource 2 (10.182.100.2:80, bbbb, ZY2).
403、第一电子设备接收第二设备信息,基于第一设备信息和第二设备信息,与第二电子设备建立连接,存储目标连接信息,该目标连接信息用于指示第一电子设备与第二电子设备之间已建立的连接。403. The first electronic device receives the second device information, establishes a connection with the second electronic device based on the first device information and the second device information, and stores target connection information, where the target connection information is used to indicate that the first electronic device is connected to the second device. An established connection between electronic devices.
其中,第一设备信息包括第一电子设备的第一端口的端口号和第一IP地址,该第一IP地址包括第一电子设备的第一IPv6地址和第一IPv4地址中的至少一项。其中,第一端口和第一IPv4地址为第一NAT设备为第一电子设备分配的广域网的端口和IPv4地址,也即是第一NAT设备的端口和IPv4地址,用于与位于广域网的管理服务器进行通信,该第一NAT设备为第一电子设备的NAT设备。可选地,该第一设备信息还包括第一电子设备的其他信息,如设备标识、设备状态、设备位置等,本申请实施例对此不作限定。Wherein, the first device information includes the port number and the first IP address of the first port of the first electronic device, and the first IP address includes at least one of the first IPv6 address and the first IPv4 address of the first electronic device. Wherein, the first port and the first IPv4 address are the port and the IPv4 address of the wide area network allocated by the first NAT device for the first electronic device, that is, the port and the IPv4 address of the first NAT device, for communicating with the management server located in the wide area network For communication, the first NAT device is the NAT device of the first electronic device. Optionally, the first device information further includes other information of the first electronic device, such as device identification, device status, device location, etc., which is not limited in this embodiment of the present application.
其中,该目标连接信息包括第一电子设备与第二电子设备用于建立连接的地址和端口之间的对应关系,可选地,该目标连接信息还包括其他信息,如连接状态、连接保持时间等,本申请实施例对此不作限定。Wherein, the target connection information includes the corresponding relationship between the addresses and ports used by the first electronic device and the second electronic device to establish a connection. Optionally, the target connection information also includes other information, such as connection status, connection maintenance time etc., which are not limited in this embodiment of the present application.
在一些实施例中,若第一电子设备和第二电子设备均支持IPv6通信,也即是,第一设备信息和第二设备信息均包括IPv6地址,则第一电子设备基于第一IPv6地址和第二IPv6地址,通过连接复用功能,与第二电子设备建立连接,并存储目标连接信息。若第一电子设备和第二电子设备中至少一个电子设备不支持IPv6通信,也即是,第一设备信息和第二设备信息中至少一个设备信息中不包括IPv6地址,则第一电子设备基于第一IPv4地址和第二IPv4地址,通过连接复用功能,与第二电子设备建立连接,并存储目标连接信息。可选地,该第一电子设备与第二电子设备之间的连接为传输隧道,该传输隧道能够支持多种不同协议下的数据进行高效传输,如用户数据报协议(user datagram protocol,UDP)、高速UDP互联网连接协议(quick UDP internet connection,QUIC)、快速可靠协议(KCP)等等。In some embodiments, if both the first electronic device and the second electronic device support IPv6 communication, that is, both the first device information and the second device information include an IPv6 address, then the first electronic device based on the first IPv6 address and The second IPv6 address establishes a connection with the second electronic device through the connection multiplexing function, and stores target connection information. If at least one of the first electronic device and the second electronic device does not support IPv6 communication, that is, at least one of the first device information and the second device information does not include an IPv6 address, the first electronic device based on The first IPv4 address and the second IPv4 address establish a connection with the second electronic device through the connection multiplexing function, and store target connection information. Optionally, the connection between the first electronic device and the second electronic device is a transmission tunnel, which can support efficient transmission of data under multiple different protocols, such as User Datagram Protocol (UDP) , high-speed UDP internet connection protocol (quick UDP internet connection, QUIC), fast and reliable protocol (KCP), etc.
在一些实施例中,第一电子设备将目标连接信息发送给管理服务器,管理服务器存储该目标连接信息。管理服务器通过存储电子设备发送的连接信息,以记录该P2P网络中电子设备之间建立的连接,从而对P2P网络进行管理。In some embodiments, the first electronic device sends the target connection information to the management server, and the management server stores the target connection information. The management server manages the P2P network by storing the connection information sent by the electronic device to record the connection established between the electronic devices in the P2P network.
需要说明的是,第一电子设备与第二电子设备建立连接之前,两个电子设备首先分别为 对端分配一个用于通信的局域网端口,也即是电子设备自身的端口,并将分配的局域网端口的端口号以及自身的局域网IPv4地址告知对端,然后建立连接。可选地,第一电子设备和第二电子设备在分配端口时,可以基于随机分配的原则,将空闲的端口分配给对端。It should be noted that before the first electronic device establishes a connection with the second electronic device, the two electronic devices first allocate a LAN port for communication to the opposite end, that is, the port of the electronic device itself, and transfer the allocated LAN port The port number of the port and its own local area network IPv4 address are notified to the opposite end, and then the connection is established. Optionally, when allocating ports, the first electronic device and the second electronic device may allocate idle ports to opposite ends based on the principle of random allocation.
在一些实施例中,第一电子设备和第二电子设备能够分别为对端分配局域网端口,并基于IPv6地址或IPv4地址建立连接,下分分别对上述两种方式进行介绍。In some embodiments, the first electronic device and the second electronic device can respectively allocate a LAN port to the opposite end, and establish a connection based on an IPv6 address or an IPv4 address. The above two methods are introduced respectively in the following section.
示例性地,对分配局域网端口并基于IPv6地址建立连接的过程进行说明,分为以下2个过程。Exemplarily, the process of allocating a LAN port and establishing a connection based on an IPv6 address is described, which is divided into the following two processes.
过程1、分配局域网端口。第一电子设备为第二电子设备分配第三端口,该第三端口为第一电子设备的局域网端口,也即是第一电子设备自身的端口,用于与第二电子设备进行通信,第一电子设备将第三端口的端口号通过管理服务器发送给第二电子设备,第二电子设备接收该第三端口的端口号,为第一电子设备分配第四端口,该第四端口为第二电子设备的局域网端口,也即是第二电子设备自身的端口,第二电子设备将该第四端口的端口号通过管理服务器发送给第一电子设备。需要说明的是,在上述过程中,管理服务器会将两个电子设备的局域网端口的端口号与对应的设备信息对应存储。Process 1. Assign LAN ports. The first electronic device allocates a third port to the second electronic device, and the third port is a LAN port of the first electronic device, that is, a port of the first electronic device itself, and is used for communicating with the second electronic device. The electronic device sends the port number of the third port to the second electronic device through the management server, and the second electronic device receives the port number of the third port, and allocates a fourth port to the first electronic device, and the fourth port is the The LAN port of the device is the port of the second electronic device itself, and the second electronic device sends the port number of the fourth port to the first electronic device through the management server. It should be noted that, in the above process, the management server will store the port numbers of the LAN ports of the two electronic devices corresponding to the corresponding device information.
过程2、建立连接。第一电子设备基于第一IPv6地址和第三端口,向该第二IPv6地址和第四端口发送连接建立请求,第二电子设备基于第二IPv6地址和第四端口,接收连接建立请求,向该第一IPv6地址和第三端口发送连接建立响应,第一电子设备基于第一IPv6地址和第三端口,接收该连接建立响应,向第二IPv6地址和第四端口发送确认消息,完成连接的建立过程。第一电子设备存储该第一IPv6地址、第三端口的端口号、第二IPv6地址和第四端口的端口号之间的对应关系,得到目标连接记录。Process 2. Establish a connection. The first electronic device sends a connection establishment request to the second IPv6 address and the fourth port based on the first IPv6 address and the third port, and the second electronic device receives the connection establishment request based on the second IPv6 address and the fourth port, and sends the connection establishment request to the second IPv6 address and the fourth port. The first IPv6 address and the third port send a connection establishment response, the first electronic device receives the connection establishment response based on the first IPv6 address and the third port, sends a confirmation message to the second IPv6 address and the fourth port, and completes the establishment of the connection process. The first electronic device stores the correspondence between the first IPv6 address, the port number of the third port, the second IPv6 address, and the port number of the fourth port, and obtains a target connection record.
示例性地,对分配局域网端口并基于IPv4地址建立连接的过程进行说明,分为以下2个过程。Exemplarily, the process of allocating a LAN port and establishing a connection based on an IPv4 address is described, which is divided into the following two processes.
过程1、分配局域网端口。第一电子设备为第二电子设备分配第三端口,将第三端口的端口号以及第三IPv4地址通过管理服务器发送给第二电子设备,该第三IPv4地址为第一电子设备的局域网IPv4地址,第二电子设备接收该第三端口的端口号和第三IPv4地址,为第一电子设备分配第四端口,将该第四端口的端口号以及第四IPv4地址通过管理服务器发送给第一电子设备,该第四IPv4地址为第二电子设备的局域网IPv4地址。需要说明的是,在上述过程中,管理服务器会将两个电子设备的局域网IPv4地址和局域网端口的端口号与对应的设备信息对应存储。Process 1. Assign LAN ports. The first electronic device assigns a third port to the second electronic device, and sends the port number of the third port and the third IPv4 address to the second electronic device through the management server, and the third IPv4 address is the local area network IPv4 address of the first electronic device , the second electronic device receives the port number and the third IPv4 address of the third port, assigns the fourth port to the first electronic device, and sends the port number and the fourth IPv4 address of the fourth port to the first electronic device through the management server. device, the fourth IPv4 address is the local area network IPv4 address of the second electronic device. It should be noted that, in the above process, the management server will store the local area network IPv4 addresses and the port numbers of the local area network ports of the two electronic devices in correspondence with the corresponding device information.
过程2、建立连接。第一电子设备和第二电子设备能够基于局域网IPv4地址建立连接,或者,基于广域网IPv4地址建立连接,下面分别对上述两种情况进行说明。Process 2. Establish a connection. The first electronic device and the second electronic device can establish a connection based on the IPv4 address of the local area network, or establish a connection based on the IPv4 address of the wide area network. The above two cases will be described respectively below.
一种实现方式中,若第一电子设备基于第三IPv4地址与第四IPv4地址,确定第一电子设备与第二电子设备位于同一局域网中,则第一电子设备与第二电子设备基于局域网IPv4地址建立连接,也即是,第一电子设备基于第三IPv4地址、第三端口、第四IPv4地址和第四端口,与第二电子设备建立连接,并存储第三IPv4地址、第三端口的端口号、第四IPv4地址和第四端口的端口号之间的对应关系,得到目标连接信息。其中,建立连接的过程与上述基于IPv6地址建立连接的过程同理,在此不再赘述。In one implementation, if the first electronic device determines that the first electronic device and the second electronic device are located in the same local area network based on the third IPv4 address and the fourth IPv4 address, then the first electronic device and the second electronic device are based on the IPv4 address of the local area network. The address establishes a connection, that is, the first electronic device establishes a connection with the second electronic device based on the third IPv4 address, the third port, the fourth IPv4 address, and the fourth port, and stores the third IPv4 address, the third port's The corresponding relationship among the port number, the fourth IPv4 address and the port number of the fourth port is used to obtain the target connection information. Wherein, the process of establishing a connection is the same as the above process of establishing a connection based on an IPv6 address, and will not be repeated here.
另一种实现方式中,若第一电子设备基于第三IPv4地址与第四IPv4地址,确定第一电子设备与第二电子设备位于不同局域网中,则第一电子设备与第二电子设备先分别进行NAT 穿透,再基于广域网IPv4地址建立连接。上述过程为,第一电子设备基于第一NAT设备、第二IPv4地址和第二端口,进行NAT穿透,向管理服务器发送穿透消息,该穿透消息用于指示该第二电子设备基于第一设备信息进行NAT穿透,管理服务器向第二电子设备转发该穿透消息,该第二电子设备接收该穿透消息,基于该第二电子设备的NAT设备、该第一电子设备的IPv4地址,进行NAT穿透,向该第一电子设备发送穿透响应,该穿透响应用于表示已完成NAT穿透,第一电子设备接收该穿透响应,基于第一IPv4地址、第一端口、第二IPv4地址和第二端口,与该第二电子设备建立该连接,存储该第一IPv4地址、第一端口的端口号、第二IPv4地址和第二端口的端口号之间的对应关系,得到目标连接信息。其中,建立连接的过程与上述基于IPv6地址建立连接的过程同理,在此不再赘述。In another implementation, if the first electronic device determines that the first electronic device and the second electronic device are located in different local area networks based on the third IPv4 address and the fourth IPv4 address, the first electronic device and the second electronic device first separately Perform NAT penetration, and then establish a connection based on the WAN IPv4 address. The above process is that the first electronic device performs NAT traversal based on the first NAT device, the second IPv4 address and the second port, and sends a traversal message to the management server, and the traversal message is used to instruct the second electronic device to A piece of equipment information performs NAT traversal, the management server forwards the traversal message to the second electronic device, and the second electronic device receives the traversal message based on the NAT device of the second electronic device and the IPv4 address of the first electronic device , perform NAT penetration, and send a penetration response to the first electronic device, the penetration response is used to indicate that NAT penetration has been completed, the first electronic device receives the penetration response, based on the first IPv4 address, the first port, The second IPv4 address and the second port, establishing the connection with the second electronic device, storing the correspondence between the first IPv4 address, the port number of the first port, the second IPv4 address and the port number of the second port, Get target connection information. Wherein, the process of establishing a connection is the same as the above process of establishing a connection based on an IPv6 address, and will not be repeated here.
示例性地,对上述进行NAT穿透的过程进行说明。第一电子设备基于自己的局域网地址,通过第一NAT设备向第二电子设备的广域网地址发送第一消息,也即是,第一电子设备基于第三IPv4地址和第三端口,通过第一NAT设备,向第二IPv4地址和第二端口发送第一消息,该第一消息携带第三IPv4地址、第三端口、第二IPv4地址和第二端口,第一NAT设备接收到该第一消息,记录第一表项,从而完成NAT穿透,该第一表项包括三IPv4地址和第三端口、第二IPv4地址和第二端口之间的对应关系,通过该第一表项,第一NAT设备能够将来自第二电子设备的广域网地址的数据转发给第一电子设备。第二电子设备能够通过与第一电子设备同理的方法,完成NAT穿透,使第二NAT设备记录第二表项,该第二表项包括第四IPv4地址和第四端口、第一IPv4地址和第一端口之间的对应关系,通过该第二表项,第二NAT设备能够将来自第一电子设备的广域网地址的数据转发给第二电子设备。第一电子设备与第二电子设备均完成NAT穿透后,两个电子设备能够通过广域网IPv4地址进行通信,从而建立两个电子设备之间的连接。By way of example, the above-mentioned process of performing NAT traversal is described. Based on its local area network address, the first electronic device sends the first message to the wide area network address of the second electronic device through the first NAT device, that is, the first electronic device sends the first message based on the third IPv4 address and the third port through the first NAT The device sends a first message to the second IPv4 address and the second port, the first message carries the third IPv4 address, the third port, the second IPv4 address and the second port, and the first NAT device receives the first message, Record the first entry, thereby completing NAT penetration, the first entry includes the correspondence between three IPv4 addresses and the third port, the second IPv4 address and the second port, through the first entry, the first NAT The device is capable of forwarding data from the wide area network address of the second electronic device to the first electronic device. The second electronic device can complete NAT traversal through the same method as the first electronic device, so that the second NAT device records the second entry, the second entry includes the fourth IPv4 address and the fourth port, the first IPv4 The correspondence between the address and the first port, through the second entry, the second NAT device can forward the data from the WAN address of the first electronic device to the second electronic device. After both the first electronic device and the second electronic device complete NAT penetration, the two electronic devices can communicate through the wide area network IPv4 address, thereby establishing a connection between the two electronic devices.
在一些实施例中,该P2P网络中的任一电子设备能够基于NAT会话穿越协议(session traversal utilities for NAT,STUN),通过与管理服务器进行通信,获知自己的NAT类型,并能够进行多种类型的NAT穿透,包括全锥形NAT、受限锥形NAT、端口受限锥形NAT和对称形NAT。In some embodiments, any electronic device in the P2P network can learn its own NAT type by communicating with the management server based on the NAT session traversal protocol (session traversal utilities for NAT, STUN), and can perform multiple types of NAT. NAT penetration, including full cone NAT, restricted cone NAT, port restricted cone NAT and symmetric NAT.
需要说明的是,若第一电子设备需要通过发送多个资源获取请求,向第二电子设备请求资源D1,则第一电子设备在发送第一个资源获取请求时,触发与第二电子设备之间的连接建立过程,连接建立完成后,第一电子设备能够复用与第二电子设备之间的连接,来发送其他的对资源D1的资源获取请求,从而向第二电子设备请求资源D1。It should be noted that if the first electronic device needs to request resource D1 from the second electronic device by sending multiple resource acquisition requests, the first electronic device will trigger a communication with the second electronic device when sending the first resource acquisition request. After the connection is established, the first electronic device can reuse the connection with the second electronic device to send other resource acquisition requests for the resource D1, thereby requesting the resource D1 from the second electronic device.
需要说明的是,上述步骤401至步骤403,是通过第一电子设备第一次向第二电子设备请求资源,触发第一电子设备与第二电子设备之间的连接建立过程。在一些实施例中,第一电子设备能够在发送资源获取请求之前,与其他电子设备建立连接,相应地,在上述步骤401之前,本申请实施例还包括:It should be noted that, the above step 401 to step 403 triggers a connection establishment process between the first electronic device and the second electronic device when the first electronic device requests resources from the second electronic device for the first time. In some embodiments, the first electronic device can establish a connection with other electronic devices before sending the resource acquisition request. Correspondingly, before the above step 401, this embodiment of the present application further includes:
第一电子设备启动连接复用功能后,例如,启动相应应用,向该管理服务器发送第一通知消息,该第一通知消息用于表示该第一电子设备已启用连接复用功能,管理服务器接收该第一通知消息,向第一电子设备发送连接建立消息,该连接建立消息用于指示与至少一个电子设备建立连接,该至少一个电子设备启用该连接复用功能;第一电子设备接收该连接建立消息,与该至少一个电子设备建立连接,该至少一个电子设备包括该第二电子设备,存储第一电子设备与该至少一个电子设备之间的连接的连接信息。其中,第一电子设备与至少一个 电子设备建立连接的过程与步骤403同理,在此不再赘述。第一电子设备完成与至少一个电子设备建立连接后,在上述步骤403中,第一电子设备能够直接基于与第二电子设备之间已建立的连接,向第二电子设备请求资源D1。例如,如图7所示,第一电子设备接收管理服务器的连接建立消息,与第二电子设备和第三电子设备建立连接,第二电子设备和第三电子设备均启用连接复用功能。After the first electronic device activates the connection multiplexing function, for example, starts the corresponding application, and sends a first notification message to the management server, the first notification message is used to indicate that the first electronic device has enabled the connection multiplexing function, and the management server receives The first notification message sends a connection establishment message to the first electronic device, the connection establishment message is used to indicate the establishment of a connection with at least one electronic device, and the at least one electronic device enables the connection multiplexing function; the first electronic device receives the connection Establishing a message, establishing a connection with the at least one electronic device, the at least one electronic device including the second electronic device, and storing connection information of the connection between the first electronic device and the at least one electronic device. Wherein, the process of establishing a connection between the first electronic device and at least one electronic device is the same as step 403, and will not be repeated here. After the first electronic device establishes a connection with at least one electronic device, in the above step 403, the first electronic device can directly request the resource D1 from the second electronic device based on the established connection with the second electronic device. For example, as shown in FIG. 7 , the first electronic device receives a connection establishment message from the management server, and establishes a connection with the second electronic device and the third electronic device, and both the second electronic device and the third electronic device enable the connection multiplexing function.
通过在电子设备进行资源请求之前提前建立连接,能够使电子设备在进行资源请求时直接使用已建立好的连接,从而能够提升资源请求的效率。By establishing a connection in advance before the electronic device makes a resource request, the electronic device can directly use the established connection when making a resource request, thereby improving resource request efficiency.
404、第一电子设备基于与该第二电子设备之间的连接,向第二电子设备请求该资源D1。404. Based on the connection with the second electronic device, the first electronic device requests the resource D1 from the second electronic device.
在一些实施例中,第一电子设备基于与第二电子设备之间的连接,向第二电子设备发送资源获取请求M1,包括以下三种情况:In some embodiments, the first electronic device sends the resource acquisition request M1 to the second electronic device based on the connection with the second electronic device, including the following three situations:
一种实现方式中,若第一电子设备与第二电子设备基于IPv6地址建立连接,第一电子设备基于第一IPv6地址和第三端口,向第二IPv6地址和第四端口发送资源获取请求M1。需要说明的是,本申请实施例对该资源获取请求的格式不做限定。In one implementation, if the first electronic device establishes a connection with the second electronic device based on the IPv6 address, the first electronic device sends a resource acquisition request M1 to the second IPv6 address and the fourth port based on the first IPv6 address and the third port . It should be noted that the embodiment of the present application does not limit the format of the resource acquisition request.
另一种实现方式中,若第一电子设备与第二电子设备基于局域网IPv4地址建立连接,则第一电子设备基于第三IPv4地址和第三端口,向第四IPv4地址和第四端口发送资源获取请求M1。In another implementation, if the first electronic device establishes a connection with the second electronic device based on the local area network IPv4 address, the first electronic device sends the resource to the fourth IPv4 address and the fourth port based on the third IPv4 address and the third port Get request M1.
另一种实现方式中,若第一电子设备与第二电子设备基于广域网IPv4地址建立连接,则第一电子设备通过第一NAT设备,基于第一IPv4地址和第一端口,向第二IPv4地址和第二端口发送资源获取请求M1。In another implementation, if the first electronic device establishes a connection with the second electronic device based on the wide area network IPv4 address, the first electronic device sends the second IPv4 address to the second IPv4 address through the first NAT device based on the first IPv4 address and the first port. Send a resource acquisition request M1 to the second port.
在一些实施例中,管理服务器会记录P2P网络中任一电子设备的资源请求操作,相应地,该步骤404还包括:第一电子设备向管理服务器发送第二通知消息,该第二通知消息用于通知管理服务器第一电子设备向第二电子设备请请求应用P1的资源D1,管理服务器接收该第二通知消息,记录第一资源请求信息,该第一资源请求信息用于表示第一电子设备基于与第二电子设备之间的连接,向第二电子设备请求应用P1的资源D1,该第一资源请求信息包括目标连接信息、应用P1的标识和资源D1的标识,可选地,该第一资源请求信息还包括其他信息,如第一电子设备向第二电子设备请求资源D1所占用的带宽、时间等,本申请实施例对此不作限定。通过记录电子设备的资源请求操作,从而对P2P网络中连接的复用情况以及资源的传输情况进行管理。In some embodiments, the management server will record the resource request operation of any electronic device in the P2P network. Correspondingly, step 404 further includes: the first electronic device sends a second notification message to the management server, and the second notification message uses In order to notify the management server that the first electronic device requests the resource D1 of the application P1 from the second electronic device, the management server receives the second notification message and records the first resource request information. The first resource request information is used to indicate that the first electronic device Based on the connection with the second electronic device, request the resource D1 of the application P1 from the second electronic device, the first resource request information includes the target connection information, the identifier of the application P1 and the identifier of the resource D1, optionally, the first resource request information The resource request information also includes other information, such as bandwidth and time occupied by the first electronic device requesting the resource D1 from the second electronic device, which is not limited in this embodiment of the present application. By recording resource request operations of electronic devices, the multiplexing of connections and the transmission of resources in the P2P network are managed.
405、第二电子设备向第一电子设备发送资源获取响应R1,该资源获取响应R1携带资源D1。405. The second electronic device sends a resource acquisition response R1 to the first electronic device, where the resource acquisition response R1 carries the resource D1.
在一些实施例中,第二电子设备接收第一电子设备的资源获取请求M1,基于应用P1的标识和资源D1的标识,获取所存储的资源D1,向第一电子设备发送携带资源D1的资源获取响应R1。In some embodiments, the second electronic device receives the resource acquisition request M1 of the first electronic device, obtains the stored resource D1 based on the identification of the application P1 and the identification of the resource D1, and sends the resource carrying the resource D1 to the first electronic device Get the response R1.
在一些实施例中,若P2P网络中的多个电子设备均没有存储第一电子设备所请求的资源D1,则第一电子设备能够向应用P1的服务器请求资源,相应地,如图7所示,本申请实施例还包括:管理服务器接收资源请求M1,若无法在资源拓扑中查询到存储有应用P1的资源D1的电子设备,则管理服务器向第一电子设备发送第一应用服务器的地址,该第一应用服务器为应用P1的服务器,第一电子设备接收该第一应用服务器的地址,向第一应用服务器请求资源D1。In some embodiments, if none of the multiple electronic devices in the P2P network stores the resource D1 requested by the first electronic device, the first electronic device can request the resource from the server of the application P1, correspondingly, as shown in FIG. 7 , the embodiment of the present application further includes: the management server receives the resource request M1, and if the electronic device storing the resource D1 of the application P1 cannot be found in the resource topology, the management server sends the address of the first application server to the first electronic device, The first application server is a server of the application P1, and the first electronic device receives the address of the first application server, and requests the resource D1 from the first application server.
406、第一电子设备向管理服务器发送资源获取请求M2,该资源获取请求M2携带应用P2的标识和资源D2的标识。406. The first electronic device sends a resource acquisition request M2 to the management server, where the resource acquisition request M2 carries the identifier of the application P2 and the identifier of the resource D2.
在一些实施例中,该步骤406与步骤401同理,在此不再赘述。In some embodiments, step 406 is the same as step 401, which will not be repeated here.
407、管理服务器接收该资源获取请求M2,基于应用P2的标识和资源D2的标识,确定第二电子设备的第二设备信息,将该第二设备信息发送至第一电子设备,该第二电子设备存储有应用P2的资源D2。407. The management server receives the resource acquisition request M2, determines the second device information of the second electronic device based on the identifier of the application P2 and the identifier of the resource D2, and sends the second device information to the first electronic device, and the second electronic device The device stores a resource D2 of the application P2.
在一些实施例中,管理服务器基于与步骤402同理的方法,确定第二电子设备的第二设备信息,并将该第二设备信息发送至第一电子设备。In some embodiments, the management server determines the second device information of the second electronic device based on the same method as step 402, and sends the second device information to the first electronic device.
在一些实施例中,若管理服务器还存储了该第二设备的第四IPv4地址和第四端口的端口号,则将该第四IPv4地址、第四端口的端口号和第二设备信息发送给第一电子设备。In some embodiments, if the management server also stores the fourth IPv4 address of the second device and the port number of the fourth port, the fourth IPv4 address, the port number of the fourth port and the second device information are sent to first electronic device.
408、第一电子设备接收第二设备信息,复用第一电子设备与第二电子设备之间已建立的连接,向第二电子设备请求资源D2。408. The first electronic device receives the second device information, multiplexes the established connection between the first electronic device and the second electronic device, and requests the resource D2 from the second electronic device.
在一些实施例中,第一电子设备接收第二设备信息,基于第一设备信息和第二设备信息,确定该第一电子设备中已存储的目标连接信息,基于该目标连接信息,向该第二电子设备请求该资源D2。通过第一电子设备中已存储的连接信息,使得第一电子设备能够复用与第二电子设备之间的连接,向第二电子设备请求资源,实现节约网络资源并减少建立连接的耗时的目的。In some embodiments, the first electronic device receives the second device information, determines the target connection information stored in the first electronic device based on the first device information and the second device information, and sends the target connection information to the second device based on the target connection information. The second electronic device requests the resource D2. Through the connection information stored in the first electronic device, the first electronic device can reuse the connection with the second electronic device, request resources from the second electronic device, realize saving network resources and reduce time-consuming connection establishment Purpose.
在一些实施例中,若在上述步骤407中,管理服务器还向第一电子设备发送了第四IPv4地址和第四端口的端口号,则该步骤408包括:第一电子设备接收第二设备信息、第四IPv4地址和第四端口的端口号,基于第一设备信息、第二设备信息、第三IPv4地址和第三端口的端口号、第四IPv4地址和第四端口的端口号,确定该第一电子设备中已存储的目标连接信息,基于该目标连接信息,向第二电子设备请求资源D2。通过第二电子设备的第四IPv4地址和第四端口的端口号,能够更加准确的确定第一电子设备中已存储的连接信息,从而复用与第二电子设备之间的连接,向第二电子设备请求资源。In some embodiments, if in the above step 407, the management server also sends the fourth IPv4 address and the port number of the fourth port to the first electronic device, then this step 408 includes: the first electronic device receives the second device information , the fourth IPv4 address and the port number of the fourth port, based on the first device information, the second device information, the third IPv4 address and the port number of the third port, the fourth IPv4 address and the port number of the fourth port, determine the Based on the target connection information stored in the first electronic device, the resource D2 is requested from the second electronic device. Through the fourth IPv4 address of the second electronic device and the port number of the fourth port, it is possible to more accurately determine the connection information stored in the first electronic device, thereby multiplexing the connection with the second electronic device and sending the second The electronic device requests a resource.
在一些实施例中,上述确定目标连接信息,并基于目标连接信息请求资源D2的过程,分为以下3种情况:In some embodiments, the above process of determining the target connection information and requesting the resource D2 based on the target connection information is divided into the following three situations:
一种实现方式中,第一电子设备基于第一IPv6地址、第三端口的端口号、第二IPv6地址和第四端口的端口号,确定目标连接信息,第一电子设备基于该第一IPv6地址和第三端口,向第二IPv6地址和第四端口发送资源获取请求M2。In one implementation, the first electronic device determines the target connection information based on the first IPv6 address, the port number of the third port, the second IPv6 address, and the port number of the fourth port, and the first electronic device determines the target connection information based on the first IPv6 address and the third port, sending a resource acquisition request M2 to the second IPv6 address and the fourth port.
另一种实现方式中,第一电子设备基于第一IPv4地址、第一端口的端口号、第二IPv4地址和第二端口的端口号,确定目标连接信息,第一电子设备通过第一NAT设备,基于该第一IPv4地址和第一端口,向第二IPv4地址和第二端口发送资源获取请求M2。In another implementation, the first electronic device determines the target connection information based on the first IPv4 address, the port number of the first port, the second IPv4 address, and the port number of the second port, and the first electronic device passes through the first NAT device , based on the first IPv4 address and the first port, send a resource acquisition request M2 to the second IPv4 address and the second port.
另一种实现方式中,第一电子设备基于第三IPv4地址、第三端口的端口号、第四IPv4地址和第四端口的端口号,确定目标连接信息,第一电子设备基于该第三IPv4地址和第三端口,向第四IPv4地址和第四端口发送资源获取请求M2。In another implementation, the first electronic device determines the target connection information based on the third IPv4 address, the port number of the third port, the fourth IPv4 address, and the port number of the fourth port, and the first electronic device determines the target connection information based on the third IPv4 address and the third port, and send a resource acquisition request M2 to the fourth IPv4 address and the fourth port.
通过复用第一电子设备与第二电子设备已建立的连接,使第一电子设备向第二电子设备进行不同应用的资源请求时,无需进行多次NAT穿透并建立多个连接,从而能够达到节约网络资源并减少建立连接的耗时的目的。By multiplexing the established connection between the first electronic device and the second electronic device, when the first electronic device requests resources of different applications from the second electronic device, it is not necessary to perform multiple NAT penetrations and establish multiple connections, thereby enabling The purpose of saving network resources and reducing time-consuming connection establishment is achieved.
409、第二电子设备向第一电子设备发送资源获取响应R2,该资源获取响应R2携带资源 D2。409. The second electronic device sends a resource acquisition response R2 to the first electronic device, where the resource acquisition response R2 carries the resource D2.
在一些实施例中,该步骤409与步骤405同理,在此不再赘述。In some embodiments, step 409 is the same as step 405, which will not be repeated here.
在一些实施例中,若P2P网络中的多个电子设备均没有存储第一电子设备所请求的资源D2,则第一电子设备能够向应用P2的服务器请求资源,相应地,如图7所示,本申请实施例还包括:管理服务器接收资源请求M2,若无法在资源拓扑中查询到存储有应用P2的资源D2的电子设备,则管理服务器向第二电子设备发送第二应用服务器的地址,该第二应用服务器为应用P2的服务器,第一电子设备接收该第二应用服务器的地址,向该第二应用服务器请求资源D2。In some embodiments, if none of the multiple electronic devices in the P2P network stores the resource D2 requested by the first electronic device, the first electronic device can request the resource from the server applying P2, correspondingly, as shown in FIG. 7 , the embodiment of the present application further includes: the management server receives the resource request M2, and if the electronic device storing the resource D2 of the application P2 cannot be found in the resource topology, the management server sends the address of the second application server to the second electronic device, The second application server is a server of the application P2, and the first electronic device receives the address of the second application server and requests the resource D2 from the second application server.
在一些实施例中,管理服务器能够删除已下线的电子设备的相关信息,实现对P2P网络的动态缩容,相应地,本申请实施例还包括:第一电子设备每隔目标时长向管理服务器发送第三通知消息,该第三通知消息用于通知管理服务器设备在线,若管理服务器在目标时长内未收到第一电子设备的第三通知消息,则确定第一电子设备已下线,管理服务器删除该第一电子设备的相关数据,包括第一设备信息、第一电子设备与其他电子设备建立的连接的连接信息等。In some embodiments, the management server can delete the relevant information of the offline electronic device, so as to realize the dynamic shrinkage of the P2P network. Correspondingly, the embodiment of the present application further includes: Sending a third notification message, the third notification message is used to notify the management server that the device is online, if the management server does not receive the third notification message from the first electronic device within the target time period, it is determined that the first electronic device is offline, and the management The server deletes relevant data of the first electronic device, including first device information, connection information of connections established between the first electronic device and other electronic devices, and the like.
本申请实施例所提供的资源请求方法,第一电子设备通过向管理服务器发送资源获取请求,获取存储有所请求资源的第二电子设备的设备信息,从而能够复用与第二电子设备之间已建立的连接,向第二电子设备请求所需的资源,使得第一电子设备与第二电子设备无需建立多个连接,就能够进行资源的请求,由于无需建立多个连接,也就无需重复多次进行相应的NAT穿透,从而达到了节约网络资源并减少建立连接的耗时的目的。In the resource request method provided by the embodiment of the present application, the first electronic device obtains the device information of the second electronic device that stores the requested resource by sending a resource acquisition request to the management server, so as to be able to multiplex with the second electronic device The established connection requests the required resources from the second electronic device, so that the first electronic device and the second electronic device can request resources without establishing multiple connections. Since there is no need to establish multiple connections, there is no need to repeat The corresponding NAT penetration is performed multiple times, thereby achieving the purpose of saving network resources and reducing the time-consuming of establishing a connection.
在一些实施例中,本申请所提供的资源请求方法能够与CDN网络相结合,实现基于P2P技术的CDN网络,下面对该基于P2P技术的CDN网络的网络架构进行介绍。如图8所示,该基于P2P技术的CDN网络包括云端、边缘端、接入端和设备端和CDN源站。In some embodiments, the resource request method provided in this application can be combined with a CDN network to implement a P2P technology-based CDN network. The network architecture of the P2P technology-based CDN network will be introduced below. As shown in Figure 8, the CDN network based on P2P technology includes cloud, edge, access, device and CDN origin.
云端包括CDN中心节点和管理服务器。其中,CDN中心节点用于响应CDN边缘节点的资源获取请求,管理服务器上部署有虫洞网格管理平面,该管理服务器用于提供P2P网络的相关服务,包括记录多个电子设备和多个CDN边缘节点的资源拓扑、辅助多个电子设备进行NAT穿透、对分享的资源进行管控与校验等。The cloud includes CDN central nodes and management servers. Among them, the CDN central node is used to respond to the resource acquisition request of the CDN edge node, and the wormhole grid management plane is deployed on the management server. The management server is used to provide related services of the P2P network, including recording multiple electronic devices and multiple CDNs. Resource topology of edge nodes, assisting multiple electronic devices to perform NAT penetration, controlling and verifying shared resources, etc.
边缘端包括多个CDN边缘节点,该多个CDN边缘节点可提供多种类型的资源,包括文件资源、视频资源、音频资源等。The edge end includes multiple CDN edge nodes, and the multiple CDN edge nodes can provide various types of resources, including file resources, video resources, audio resources, and so on.
接入端包括多个提供网络通信服务的设备,如路由设备、5G基站、4G基站等,接入端用于为设备端的多个电子设备提供网络通信服务,使设备端的多个电子设备能够与云端和边缘端进行通信。The access terminal includes multiple devices that provide network communication services, such as routing equipment, 5G base stations, 4G base stations, etc. The access terminal is used to provide network communication services for multiple electronic devices at the device end, so that multiple electronic devices at the device end can communicate with The cloud and the edge communicate.
设备端包括多个电子设备,该多个电子设备能够与管理服务器构成P2P网络,该多个电子设备中存储有多种类型的资源,任一电子设备能够向距离最近的CDN边缘节点以及其他电子设备请求所需资源,也能够向其他的电子设备分享资源。The device side includes multiple electronic devices, which can form a P2P network with the management server. Multiple types of resources are stored in the multiple electronic devices, and any electronic device can send to the nearest CDN edge node and other electronic Devices request required resources and can also share resources with other electronic devices.
CDN源站用于存储该CDN网络中的所有资源。The CDN origin site is used to store all resources in the CDN network.
在介绍了该基于P2P技术的CDN网络的网络架构的基础上,下面对电子设备进行资源请求的过程进行说明。示例性地,以第一电子设备请求应用P1的资源D1以及应用P2的资源D2为例,假设第一CDN边缘节点为与第一电子设备距离最近的存储有资源D1和资源D2 的CDN边缘节点,第一电子设备请求资源D1和资源D2的过程包括以下2个过程。On the basis of introducing the network architecture of the P2P technology-based CDN network, the process of requesting resources by electronic devices will be described below. Exemplarily, taking the resource D1 of the application P1 and the resource D2 of the application P2 requested by the first electronic device as an example, it is assumed that the first CDN edge node is the CDN edge node storing the resources D1 and D2 closest to the first electronic device , the process of the first electronic device requesting the resource D1 and the resource D2 includes the following two processes.
过程1、请求应用P1的资源D1。第一电子设备向管理服务器发送资源获取请求M1,管理服务器基于调度服务,确定第一CDN边缘节点的地址,将该第一CDN边缘节点的地址发送给第一电子设备,管理服务器基于与上述步骤402同理的方法,确定第二电子设备的第二设备信息,并将第二设备信息发送给第一电子设备,第一电子设备向第一CDN边缘节点请求资源D1,并基于与步骤403至405同理的方法,与第二电子设备建立连接,向第二电子设备请求资源D1。Process 1. Request resource D1 of application P1. The first electronic device sends a resource acquisition request M1 to the management server, the management server determines the address of the first CDN edge node based on the scheduling service, and sends the address of the first CDN edge node to the first electronic device, and the management server based on the above steps 402 is the same method, determine the second device information of the second electronic device, and send the second device information to the first electronic device, and the first electronic device requests resource D1 from the first CDN edge node, and based on steps 403 to 405 In the same way, establish a connection with the second electronic device, and request the resource D1 from the second electronic device.
过程2、请求应用P2的资源D2。第一电子设备向管理服务器发送资源获取请求M2,管理服务器基于调度服务,确定第一CDN边缘节点的地址,将该第一CDN边缘节点的地址发送给第一电子设备,管理服务器基于与上述步骤406同理的方法,确定第二电子设备的第二设备信息,并将第二设备信息发送给第一电子设备,第一电子设备向第一CDN边缘节点请求资源D2,并基于与步骤407至409同理的方法,复用与第二电子设备之间的连接,向第二电子设备请求资源D2。Process 2. Request resource D2 of application P2. The first electronic device sends a resource acquisition request M2 to the management server, the management server determines the address of the first CDN edge node based on the scheduling service, and sends the address of the first CDN edge node to the first electronic device, and the management server based on the above steps 406 In the same way, determine the second device information of the second electronic device, and send the second device information to the first electronic device, and the first electronic device requests the resource D2 from the first CDN edge node, and based on steps 407 to 409 In the same way, multiplex the connection with the second electronic device, and request the resource D2 from the second electronic device.
可选地,若管理服务器从资源拓扑中查询到存在多个第二电子设备存储有第一电子设备所请求的资源,则将该多个第二电子设备的第二设备信息发送给第一电子设备,第一电子设备能够向该多个第二电子设备请求所需资源。Optionally, if the management server inquires from the resource topology that there are multiple second electronic devices storing the resources requested by the first electronic device, then send the second device information of the multiple second electronic devices to the first electronic device. devices, the first electronic device can request required resources from the plurality of second electronic devices.
在一些实施例中,若边缘端的多个CDN边缘节点和设备端的多个电子设备中均不存在第一电子设备请求的资源,则第一电子设备向任一CDN边缘节点请求所需资源,该CDN边缘节点能够通过CDN中心节点,向源站请求所需资源,并将该资源返回给第一电子设备。In some embodiments, if the resource requested by the first electronic device does not exist in the plurality of CDN edge nodes at the edge end and the plurality of electronic devices at the device end, the first electronic device requests the required resource from any CDN edge node, the The CDN edge node can request the required resource from the source station through the CDN central node, and return the resource to the first electronic device.
通过将本申请所提供的方法与CDN网络相结合,实现了基于P2P技术的CDN网络,使得电子设备能够同时向CDN边缘节点和其他电子设备请求所需资源,提升了资源请求的效率,并且,在两个电子设备进行不同应用的资源请求时,能够复用两个设备之间已经建立的连接,从而达到了节约网络资源的目的。By combining the method provided by this application with the CDN network, a CDN network based on P2P technology is realized, so that electronic devices can request required resources from CDN edge nodes and other electronic devices at the same time, improving the efficiency of resource requests, and, When two electronic devices request resources from different applications, the connection established between the two devices can be reused, thereby achieving the purpose of saving network resources.
图9是本申请实施例提供的一种资源请求装置的结构示意图,该资源请求装置用于上述第一电子设备中,以执行上述资源请求方法执行时的步骤,参见图9,该资源请求装置包括:发送模块901和连接复用模块902。FIG. 9 is a schematic structural diagram of a resource requesting device provided by an embodiment of the present application. The resource requesting device is used in the above-mentioned first electronic device to perform the steps of the above-mentioned resource requesting method. Referring to FIG. 9, the resource requesting device It includes: a sending module 901 and a connection multiplexing module 902 .
发送模块901,用于向管理服务器发送第一资源获取请求,该第一资源获取请求携带第一应用的标识和第一资源的标识;A sending module 901, configured to send a first resource acquisition request to a management server, where the first resource acquisition request carries the identifier of the first application and the identifier of the first resource;
连接复用模块902,用于接收该第二设备信息,复用该第一电子设备与该第二电子设备之间已建立的连接,向该第二电子设备请求该第一资源。The connection multiplexing module 902 is configured to receive the second device information, multiplex the established connection between the first electronic device and the second electronic device, and request the first resource from the second electronic device.
在一些实施例中,该连接复用模块902,用于基于该第一电子设备的第一设备信息和该第二设备信息,确定该第一电子设备中已存储的目标连接信息,该目标连接信息用于指示该第一电子设备与该第二电子设备之间已建立的连接;基于该目标连接信息,向该第二电子设备请求该第一资源。In some embodiments, the connection multiplexing module 902 is configured to determine the target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection The information is used to indicate the established connection between the first electronic device and the second electronic device; based on the target connection information, request the first resource from the second electronic device.
在一些实施例中,该发送模块901,还用于向该管理服务器发送第二资源获取请求,该第二资源获取请求携带第二应用的标识和第二资源的标识;In some embodiments, the sending module 901 is further configured to send a second resource acquisition request to the management server, where the second resource acquisition request carries the identifier of the second application and the identifier of the second resource;
该装置还包括:The unit also includes:
连接建立模块,用于接收该第二设备信息,基于该第一设备信息和该第二设备信息,与 该第二电子设备建立该连接,存储该目标连接信息。A connection establishing module, configured to receive the second device information, establish the connection with the second electronic device based on the first device information and the second device information, and store the target connection information.
在一些实施例中,该第一设备信息包括该第一电子设备的互联网协议第6版IPv6地址和互联网协议第4版IPv4地址中至少一项,该第二设备信息包括该第二电子设备的IPv6地址和IPv4地址中至少一项;In some embodiments, the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the second device information includes an address of the second electronic device. At least one of IPv6 address and IPv4 address;
该连接建立模块,用于若该第一电子设备和该第二电子设备均支持IPv6通信,该第一电子设备基于该第二电子设备的IPv6地址和该第一电子设备的IPv6地址,与该第二电子设备建立该连接;若该第一电子设备和该第二电子设备中至少一个电子设备不支持IPv6通信,该第一电子设备基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接。The connection establishment module is configured to, if both the first electronic device and the second electronic device support IPv6 communication, the first electronic device communicates with the first electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device The second electronic device establishes the connection; if at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device based on the IPv4 address of the second electronic device and the first electronic device The IPv4 address of the second electronic device to establish the connection.
在一些实施例中,该连接建立模块,用于基于该第一电子设备的NAT设备和该第二电子设备的IPv4地址,进行NAT穿透,向该管理服务器发送穿透消息,该穿透消息用于指示该第二电子设备基于该第一设备信息进行NAT穿透;接收第二电子设备的穿透响应,该穿透响应用于表示已完成NAT穿透,基于该第二电子设备的IPv4地址和该第一电子设备的IPv4地址,与该第二电子设备建立该连接。In some embodiments, the connection establishment module is configured to perform NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and send a traversal message to the management server, the traversal message It is used to instruct the second electronic device to perform NAT traversal based on the first device information; receive a traversal response from the second electronic device, the traversal response is used to indicate that NAT traversal has been completed, based on the second electronic device's IPv4 address and the IPv4 address of the first electronic device, and establish the connection with the second electronic device.
在一些实施例中,该发送模块901,用于向该管理服务器发送通知消息,该通知消息用于表示该第一电子设备已启用连接复用功能;In some embodiments, the sending module 901 is configured to send a notification message to the management server, where the notification message is used to indicate that the first electronic device has enabled the connection multiplexing function;
该连接建立模块,用于接收该连接建立消息,与该至少一个电子设备建立连接,该至少一个电子设备包括该第二电子设备,存储该第一电子设备与该至少一个电子设备之间的连接的连接信息。The connection establishment module is configured to receive the connection establishment message, establish a connection with the at least one electronic device, the at least one electronic device includes the second electronic device, and store the connection between the first electronic device and the at least one electronic device connection information.
需要说明的是:上述实施例提供的资源请求装置在进行资源请求时,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。另外,上述实施例提供的资源请求装置与资源请求方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。It should be noted that: when the resource request device provided in the above embodiment requests resources, it only uses the division of the above functional modules as an example. In practical applications, the above function allocation can be completed by different functional modules according to needs. That is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the resource requesting device provided in the above embodiments is based on the same idea as the resource requesting method embodiments, and its specific implementation process is detailed in the method embodiments, and will not be repeated here.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,所述的程序可以存储于一种计算机可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps for implementing the above embodiments can be completed by hardware, and can also be completed by instructing related hardware through a program. The program can be stored in a computer-readable storage medium. The above-mentioned The storage medium mentioned may be a read-only memory, a magnetic disk or an optical disk, and the like.
以上所述仅为本申请的可选实施例,并不用以限制本申请,凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above are only optional embodiments of the application, and are not intended to limit the application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the application shall be included in the protection of the application. within range.

Claims (16)

  1. 一种资源请求方法,其特征在于,所述方法包括:A resource request method, characterized in that the method comprises:
    第一电子设备向管理服务器发送第一资源获取请求,所述第一资源获取请求携带第一应用的标识和第一资源的标识;The first electronic device sends a first resource acquisition request to the management server, where the first resource acquisition request carries an identifier of the first application and an identifier of the first resource;
    所述管理服务器接收所述第一资源获取请求,基于所述第一应用的标识和所述第一资源的标识,确定第二电子设备的第二设备信息,将所述第二设备信息发送至所述第一电子设备,所述第二电子设备存储有所述第一应用的所述第一资源;The management server receives the first resource acquisition request, determines second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource, and sends the second device information to The first electronic device, the second electronic device stores the first resource of the first application;
    所述第一电子设备接收所述第二设备信息,复用所述第一电子设备与所述第二电子设备之间已建立的连接,向所述第二电子设备请求所述第一资源。The first electronic device receives the second device information, multiplexes the established connection between the first electronic device and the second electronic device, and requests the first resource from the second electronic device.
  2. 根据权利要求1所述的方法,其特征在于,所述基于所述第一应用的标识和所述第一资源的标识,确定第二电子设备的第二设备信息包括:The method according to claim 1, wherein the determining the second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource comprises:
    所述管理服务器基于所述第一应用的标识和所述第一资源的标识,查询对等网络的资源拓扑,得到所述第二电子设备的第二设备信息,所述资源拓扑用于记录所述对等网络中多个电子设备的设备信息、每个所述电子设备上应用的标识和每个所述电子设备所存储资源的标识之间的对应关系。The management server queries the resource topology of the peer-to-peer network based on the identifier of the first application and the identifier of the first resource to obtain the second device information of the second electronic device, and the resource topology is used to record the The corresponding relationship between the device information of multiple electronic devices in the peer-to-peer network, the application identifier on each electronic device, and the resource identifier stored in each electronic device.
  3. 根据权利要求1所述的方法,其特征在于,所述复用所述第一电子设备与所述第二电子设备之间已建立的连接,向所述第二电子设备请求所述第一资源包括:The method according to claim 1, wherein the multiplexing the established connection between the first electronic device and the second electronic device requests the first resource from the second electronic device include:
    所述第一电子设备基于所述第一电子设备的第一设备信息和所述第二设备信息,确定所述第一电子设备中已存储的目标连接信息,所述目标连接信息用于指示所述第一电子设备与所述第二电子设备之间已建立的连接;The first electronic device determines, based on the first device information and the second device information of the first electronic device, target connection information stored in the first electronic device, where the target connection information is used to indicate the an established connection between the first electronic device and the second electronic device;
    所述第一电子设备基于所述目标连接信息,向所述第二电子设备请求所述第一资源。The first electronic device requests the first resource from the second electronic device based on the target connection information.
  4. 根据权利要求3所述的方法,其特征在于,所述第一电子设备向管理服务器发送第一资源获取请求之前,所述方法还包括:The method according to claim 3, wherein before the first electronic device sends the first resource acquisition request to the management server, the method further comprises:
    所述第一电子设备向所述管理服务器发送第二资源获取请求,所述第二资源获取请求携带第二应用的标识和第二资源的标识;The first electronic device sends a second resource acquisition request to the management server, where the second resource acquisition request carries an identifier of a second application and an identifier of a second resource;
    所述管理服务器接收所述第二资源获取请求,基于所述第二应用的标识和所述第二资源的标识,确定所述第二电子设备的第二设备信息,将所述第二设备信息发送至所述第一电子设备,所述第二电子设备存储有所述第二应用的所述第二资源;The management server receives the second resource acquisition request, determines second device information of the second electronic device based on the identifier of the second application and the identifier of the second resource, and stores the second device information sending to the first electronic device, where the second electronic device stores the second resource of the second application;
    所述第一电子设备接收所述第二设备信息,基于所述第一设备信息和所述第二设备信息,与所述第二电子设备建立所述连接,存储所述目标连接信息。The first electronic device receives the second device information, establishes the connection with the second electronic device based on the first device information and the second device information, and stores the target connection information.
  5. 根据权利要求4所述的方法,其特征在于,所述第一设备信息包括所述第一电子设备的互联网协议第6版IPv6地址和互联网协议第4版IPv4地址中至少一项,所述第二设备信息包括所述第二电子设备的IPv6地址和IPv4地址中至少一项;The method according to claim 4, wherein the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the first electronic device The second device information includes at least one of the IPv6 address and the IPv4 address of the second electronic device;
    所述基于所述第一设备信息和所述第二设备信息,与所述第二电子设备建立所述连接包括:The establishing the connection with the second electronic device based on the first device information and the second device information includes:
    若所述第一电子设备和所述第二电子设备均支持IPv6通信,所述第一电子设备基于所述第二电子设备的IPv6地址和所述第一电子设备的IPv6地址,与所述第二电子设备建立所述连接;If both the first electronic device and the second electronic device support IPv6 communication, the first electronic device communicates with the second electronic device based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device The electronic device establishes the connection;
    若所述第一电子设备和所述第二电子设备中至少一个电子设备不支持IPv6通信,所述第一电子设备基于所述第二电子设备的IPv4地址和所述第一电子设备的IPv4地址,与所述第二电子设备建立所述连接。If at least one of the first electronic device and the second electronic device does not support IPv6 communication, the first electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device , establishing the connection with the second electronic device.
  6. 根据权利要求5所述的方法,其特征在于,所述第一电子设备基于所述第二电子设备的IPv4地址和所述第一电子设备的IPv4地址,与所述第二电子设备建立所述连接包括:The method according to claim 5, wherein the first electronic device establishes the Connections include:
    所述第一电子设备基于所述第一电子设备的NAT设备和所述第二电子设备的IPv4地址,进行NAT穿透,向所述管理服务器发送穿透消息,所述穿透消息用于指示所述第二电子设备基于所述第一设备信息进行NAT穿透;The first electronic device performs NAT traversal based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and sends a traversal message to the management server, the traversal message is used to indicate The second electronic device performs NAT penetration based on the information of the first device;
    所述管理服务器向所述第二电子设备转发所述穿透消息;The management server forwards the penetration message to the second electronic device;
    所述第二电子设备接收所述穿透消息,基于所述第二电子设备的NAT设备、所述第一电子设备的IPv4地址,进行NAT穿透,向所述第一电子设备发送穿透响应,所述穿透响应用于表示已完成NAT穿透;The second electronic device receives the penetration message, performs NAT penetration based on the NAT device of the second electronic device and the IPv4 address of the first electronic device, and sends a penetration response to the first electronic device , the traversal response is used to indicate that NAT traversal has been completed;
    所述第一电子设备接收所述穿透响应,基于所述第二电子设备的IPv4地址和所述第一电子设备的IPv4地址,与所述第二电子设备建立所述连接。The first electronic device receives the penetration response, and establishes the connection with the second electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device.
  7. 根据权利要求3所述的方法,其特征在于,所述第一电子设备向管理服务器发送第一资源获取请求之前,所述方法还包括:The method according to claim 3, wherein before the first electronic device sends the first resource acquisition request to the management server, the method further comprises:
    所述第一电子设备向所述管理服务器发送通知消息,所述通知消息用于表示所述第一电子设备已启用连接复用功能;The first electronic device sends a notification message to the management server, where the notification message is used to indicate that the first electronic device has enabled a connection multiplexing function;
    所述管理服务器接收所述通知消息,向所述第一电子设备发送连接建立消息,所述连接建立消息用于指示与至少一个电子设备建立连接,所述至少一个电子设备启用所述连接复用功能;The management server receives the notification message, and sends a connection establishment message to the first electronic device, where the connection establishment message is used to indicate establishment of a connection with at least one electronic device, and the at least one electronic device enables the connection multiplexing Function;
    所述第一电子设备接收所述连接建立消息,与所述至少一个电子设备建立连接,所述至少一个电子设备包括所述第二电子设备,存储所述第一电子设备与所述至少一个电子设备之间的连接的连接信息。The first electronic device receives the connection establishment message, establishes a connection with the at least one electronic device, the at least one electronic device includes the second electronic device, and stores the connection between the first electronic device and the at least one electronic device. Connection information for connections between devices.
  8. 一种网络系统,其特征在于,所述系统包括第一电子设备、第二电子设备和管理服务器,A network system, characterized in that the system includes a first electronic device, a second electronic device and a management server,
    所述第一电子设备,用于向管理服务器发送第一资源获取请求,所述第一资源获取请求携带第一应用的标识和第一资源的标识;The first electronic device is configured to send a first resource acquisition request to a management server, where the first resource acquisition request carries an identifier of a first application and an identifier of a first resource;
    所述管理服务器,用于接收所述第一资源获取请求,基于所述第一应用的标识和所述第一资源的标识,确定第二电子设备的第二设备信息,将所述第二设备信息发送至所述第一电子设备,所述第二电子设备存储有所述第一应用的所述第一资源;The management server is configured to receive the first resource acquisition request, determine second device information of the second electronic device based on the identifier of the first application and the identifier of the first resource, and assign the second device to sending information to the first electronic device, and the second electronic device stores the first resource of the first application;
    所述第一电子设备,用于接收所述第二设备信息,复用所述第一电子设备与所述第二电子设备之间已建立的连接,向所述第二电子设备请求所述第一资源。The first electronic device is configured to receive the information of the second device, multiplex the established connection between the first electronic device and the second electronic device, and request the second electronic device to a resource.
  9. 根据权利要求8所述的系统,其特征在于,The system of claim 8, wherein
    所述管理服务器,用于基于所述第一应用的标识和所述第一资源的标识,查询对等网络的资源拓扑,得到所述第二电子设备的第二设备信息,所述资源拓扑用于记录所述对等网络中多个电子设备的设备信息、每个所述电子设备上应用的标识和每个所述电子设备所存储资源的标识之间的对应关系。The management server is configured to query the resource topology of the peer-to-peer network based on the identifier of the first application and the identifier of the first resource, and obtain the second device information of the second electronic device, and the resource topology uses The device information of multiple electronic devices in the peer-to-peer network, the application identifier of each electronic device, and the identifier of resources stored in each electronic device are recorded.
  10. 根据权利要求8所述的系统,其特征在于,The system of claim 8, wherein
    所述第一电子设备,用于基于所述第一电子设备的第一设备信息和所述第二设备信息,确定所述第一电子设备中已存储的目标连接信息,所述目标连接信息用于指示所述第一电子设备与所述第二电子设备之间已建立的连接;The first electronic device is configured to determine target connection information stored in the first electronic device based on the first device information and the second device information of the first electronic device, and the target connection information is used indicating an established connection between the first electronic device and the second electronic device;
    所述第一电子设备,用于基于所述目标连接信息,向所述第二电子设备请求所述第一资源。The first electronic device is configured to request the first resource from the second electronic device based on the target connection information.
  11. 根据权利要求10所述的系统,其特征在于,The system of claim 10, wherein
    所述第一电子设备,用于向所述管理服务器发送第二资源获取请求,所述第二资源获取请求携带第二应用的标识和第二资源的标识;The first electronic device is configured to send a second resource acquisition request to the management server, where the second resource acquisition request carries an identifier of a second application and an identifier of a second resource;
    所述管理服务器,用于接收所述第二资源获取请求,基于所述第二应用的标识和所述第二资源的标识,确定所述第二电子设备的第二设备信息,将所述第二设备信息发送至所述第一电子设备,所述第二电子设备存储有所述第二应用的所述第二资源;The management server is configured to receive the second resource acquisition request, determine the second device information of the second electronic device based on the identifier of the second application and the identifier of the second resource, and store the second resource The second device information is sent to the first electronic device, and the second electronic device stores the second resource of the second application;
    所述第一电子设备,用于接收所述第二设备信息,基于所述第一设备信息和所述第二设备信息,与所述第二电子设备建立所述连接,存储所述目标连接信息。The first electronic device is configured to receive the second device information, establish the connection with the second electronic device based on the first device information and the second device information, and store the target connection information .
  12. 根据权利要求11所述的系统,其特征在于,所述第一设备信息包括所述第一电子设备的互联网协议第6版IPv6地址和互联网协议第4版IPv4地址中至少一项,所述第二设备信息包括所述第二电子设备的IPv6地址和IPv4地址中至少一项;The system according to claim 11, wherein the first device information includes at least one of an Internet Protocol version 6 IPv6 address and an Internet Protocol version 4 IPv4 address of the first electronic device, and the first The second device information includes at least one of the IPv6 address and the IPv4 address of the second electronic device;
    所述第一电子设备,用于若所述第一电子设备和所述第二电子设备均支持IPv6通信,基于所述第二电子设备的IPv6地址和所述第一电子设备的IPv6地址,与所述第二电子设备建立所述连接;The first electronic device is configured to, if both the first electronic device and the second electronic device support IPv6 communication, based on the IPv6 address of the second electronic device and the IPv6 address of the first electronic device, and the second electronic device establishes the connection;
    所述第一电子设备,用于若所述第一电子设备和所述第二电子设备中至少一个电子设备不支持IPv6通信,基于所述第二电子设备的IPv4地址和所述第一电子设备的IPv4地址,与所述第二电子设备建立所述连接。The first electronic device is configured to, if at least one of the first electronic device and the second electronic device does not support IPv6 communication, based on the IPv4 address of the second electronic device and the first electronic device IPv4 address, and establish the connection with the second electronic device.
  13. 根据权利要求12所述的系统,其特征在于,The system of claim 12 wherein,
    所述第一电子设备,用于基于所述第一电子设备的NAT设备和所述第二电子设备的IPv4地址,进行NAT穿透,向所述管理服务器发送穿透消息,所述穿透消息用于指示所述第二电子设备基于所述第一设备信息进行NAT穿透;The first electronic device is configured to perform NAT penetration based on the NAT device of the first electronic device and the IPv4 address of the second electronic device, and send a penetration message to the management server, the penetration message used to instruct the second electronic device to perform NAT traversal based on the information of the first device;
    所述管理服务器,用于向所述第二电子设备转发所述穿透消息;The management server is configured to forward the penetration message to the second electronic device;
    所述第二电子设备,用于接收所述穿透消息,基于所述第二电子设备的NAT设备、所述第一电子设备的IPv4地址,进行NAT穿透,向所述第一电子设备发送穿透响应,所述穿透响应用于表示已完成NAT穿透;The second electronic device is configured to receive the penetration message, perform NAT penetration based on the NAT device of the second electronic device and the IPv4 address of the first electronic device, and send the message to the first electronic device A traversal response, the traversal response is used to indicate that NAT traversal has been completed;
    所述第一电子设备,用于接收所述穿透响应,基于所述第二电子设备的IPv4地址和所述第一电子设备的IPv4地址,与所述第二电子设备建立所述连接。The first electronic device is configured to receive the penetration response, and establish the connection with the second electronic device based on the IPv4 address of the second electronic device and the IPv4 address of the first electronic device.
  14. 根据权利要求10所述的系统,其特征在于,The system of claim 10, wherein
    所述第一电子设备,用于向所述管理服务器发送通知消息,所述通知消息用于表示所述第一电子设备已启用连接复用功能;The first electronic device is configured to send a notification message to the management server, where the notification message is used to indicate that the first electronic device has enabled a connection multiplexing function;
    所述管理服务器,用于接收所述通知消息,向所述第一电子设备发送连接建立消息,所述连接建立消息用于指示与至少一个电子设备建立连接,所述至少一个电子设备启用所述连接复用功能;The management server is configured to receive the notification message, and send a connection establishment message to the first electronic device, where the connection establishment message is used to indicate establishment of a connection with at least one electronic device, and the at least one electronic device enables the Connection multiplexing function;
    所述第一电子设备,用于接收所述连接建立消息,与所述至少一个电子设备建立连接,所述至少一个电子设备包括所述第二电子设备,存储所述第一电子设备与所述至少一个电子设备之间的连接的连接信息。The first electronic device is configured to receive the connection establishment message, establish a connection with the at least one electronic device, the at least one electronic device includes the second electronic device, and store the first electronic device and the Connection information of a connection between at least one electronic device.
  15. 一种计算机设备,其特征在于,所述计算机设备包括通信总线、至少一个网络接口、存储器以及至少一个处理器,所述通信总线用于在上述组件之间传送信息,所述至少一个网络接口用于与其它设备或通信网络通信,所述存储器保存有程序代码,所述至少一个处理器通过读取并执行所述存储器中保存的程序代码实现如权利要求1-7任一项所述的资源请求方法。A kind of computer equipment, it is characterized in that, described computer equipment comprises communication bus, at least one network interface, memory and at least one processor, and described communication bus is used for transmitting information between above-mentioned components, and described at least one network interface uses For communicating with other devices or communication networks, the memory stores program codes, and the at least one processor implements the resource according to any one of claims 1-7 by reading and executing the program codes stored in the memory request method.
  16. 一种计算机可读存储介质,其特征在于,当所述计算机可读存储介质中的程序代码由计算机设备的处理器执行时,使得所述计算机设备能够执行如权利要求1-7任一项所述的资源请求方法。A computer-readable storage medium, characterized in that, when the program code in the computer-readable storage medium is executed by a processor of a computer device, the computer device is able to perform the operation described in any one of claims 1-7. The resource request method described above.
PCT/CN2022/093659 2021-09-07 2022-05-18 Resource request method, system and apparatus, and device and storage medium WO2023035660A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111045623.7 2021-09-07
CN202111045623.7A CN115776493A (en) 2021-09-07 2021-09-07 Resource request method, system, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2023035660A1 true WO2023035660A1 (en) 2023-03-16

Family

ID=85387804

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/093659 WO2023035660A1 (en) 2021-09-07 2022-05-18 Resource request method, system and apparatus, and device and storage medium

Country Status (2)

Country Link
CN (1) CN115776493A (en)
WO (1) WO2023035660A1 (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102291808A (en) * 2011-06-03 2011-12-21 莫雅静 Network communication method, communication equipment and middleware of communication equipment
CN105376299A (en) * 2015-09-30 2016-03-02 深圳市先河系统技术有限公司 A network communication method, an apparatus and a network attached storage apparatus
CN107205026A (en) * 2017-05-22 2017-09-26 厦门市美亚柏科信息股份有限公司 A kind of Point-to-Point Data Transmission method and system
CN112055037A (en) * 2019-06-06 2020-12-08 深圳市尚云互联技术有限公司 NAT (network Address translation) penetration connection method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102291808A (en) * 2011-06-03 2011-12-21 莫雅静 Network communication method, communication equipment and middleware of communication equipment
CN105376299A (en) * 2015-09-30 2016-03-02 深圳市先河系统技术有限公司 A network communication method, an apparatus and a network attached storage apparatus
CN107205026A (en) * 2017-05-22 2017-09-26 厦门市美亚柏科信息股份有限公司 A kind of Point-to-Point Data Transmission method and system
CN112055037A (en) * 2019-06-06 2020-12-08 深圳市尚云互联技术有限公司 NAT (network Address translation) penetration connection method and system

Also Published As

Publication number Publication date
CN115776493A (en) 2023-03-10

Similar Documents

Publication Publication Date Title
WO2020228505A1 (en) Method, device, and system for selecting mobile edge computing node
WO2020228469A1 (en) Method, apparatus and system for selecting mobile edge computing node
CN108650182B (en) Network communication method, system, device, equipment and storage medium
CN107534565B (en) Processing meetings through the use of highly distributed agents
WO2020135800A1 (en) Domain name server allocation method and device
KR101862274B1 (en) Low latency connections to workspaces in a cloud computing environment
EP2112788B1 (en) A method and node for p2p content sharing
US9614748B1 (en) Multitenant data center providing virtual computing services
US8959185B2 (en) Multitenant server for virtual networks within datacenter
WO2023000935A1 (en) Data processing method, network element device, and readable storage medium
CN108780410A (en) The network virtualization of container in computing system
WO2014190791A1 (en) Method for setting identity of gateway device and management gateway device
US20120191769A1 (en) Site-aware distributed file system access from outside enterprise network
CN113364741A (en) Application access method and proxy server
US7965630B1 (en) Load balancing port proxy for dynamically controlling routing of query requests
EP3937502A1 (en) Method, apparatus and device for pushing video stream, and storage medium
US20220166715A1 (en) Communication system and communication method
CN111726400A (en) Reverse connection method, device and server-side system
WO2023035660A1 (en) Resource request method, system and apparatus, and device and storage medium
JP5716745B2 (en) Data transfer system
CA3135722C (en) Sharing resources between client devices in a virtual workspace environment
JP2004264911A (en) Computer node, cluster system, cluster control method, and cluster control program
JP5803924B2 (en) Data transfer system
US20200127923A1 (en) System and method of performing load balancing over an overlay network
CN112019641A (en) Data transmission method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22866138

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE