WO2021018297A1 - 一种基于p2p的服务通信方法、装置及系统 - Google Patents

一种基于p2p的服务通信方法、装置及系统 Download PDF

Info

Publication number
WO2021018297A1
WO2021018297A1 PCT/CN2020/106333 CN2020106333W WO2021018297A1 WO 2021018297 A1 WO2021018297 A1 WO 2021018297A1 CN 2020106333 W CN2020106333 W CN 2020106333W WO 2021018297 A1 WO2021018297 A1 WO 2021018297A1
Authority
WO
WIPO (PCT)
Prior art keywords
identifier
service
message
module
link
Prior art date
Application number
PCT/CN2020/106333
Other languages
English (en)
French (fr)
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 WO2021018297A1 publication Critical patent/WO2021018297A1/zh

Links

Images

Classifications

    • 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
    • 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
    • GPHYSICS
    • G08SIGNALLING
    • G08BSIGNALLING OR CALLING SYSTEMS; ORDER TELEGRAPHS; ALARM SYSTEMS
    • G08B13/00Burglar, theft or intruder alarms
    • G08B13/18Actuation by interference with heat, light, or radiation of shorter wavelength; Actuation by intruding sources of heat, light, or radiation of shorter wavelength
    • G08B13/189Actuation by interference with heat, light, or radiation of shorter wavelength; Actuation by intruding sources of heat, light, or radiation of shorter wavelength using passive radiation detection systems
    • G08B13/194Actuation by interference with heat, light, or radiation of shorter wavelength; Actuation by intruding sources of heat, light, or radiation of shorter wavelength using passive radiation detection systems using image scanning and comparing systems
    • G08B13/196Actuation by interference with heat, light, or radiation of shorter wavelength; Actuation by intruding sources of heat, light, or radiation of shorter wavelength using passive radiation detection systems using image scanning and comparing systems using television cameras
    • G08B13/19654Details concerning communication with a camera
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N21/00Selective content distribution, e.g. interactive television or video on demand [VOD]
    • H04N21/60Network structure or processes for video distribution between server and client or between remote clients; Control signalling between clients, server and network components; Transmission of management data between server and client, e.g. sending from server to client commands for recording incoming content stream; Communication details between server and client 
    • H04N21/63Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing
    • H04N21/632Control signaling related to video distribution between client, server and network components; Network processes for video distribution between server and clients or between remote clients, e.g. transmitting basic layer and enhancement layers over different transmission paths, setting up a peer-to-peer communication via Internet between remote STB's; Communication protocols; Addressing using a connection between clients on a wide area network, e.g. setting up a peer-to-peer communication via Internet for retrieving video segments from the hard-disk of other client devices

Definitions

  • This application relates to the field of monitoring, in particular to a P2P-based service communication method, device and system.
  • an alarm center will manage the monitoring equipment of many homes or shops, and the monitoring equipment can provide one or more services.
  • the alarm center can receive alarms from monitoring equipment, and the alarm center can notify users.
  • the user uses the terminal to request the monitoring device to provide services.
  • the monitoring equipment can be a camera installed at home, which can provide services such as video surveillance.
  • the monitoring equipment sends an alarm to the alarm center when it detects that someone breaks into the home.
  • the alarm center informs the user.
  • the user can use a mobile phone or computer to request Surveillance equipment provides surveillance video.
  • the terminal can establish a peer-to-peer (P2P) link with the monitoring device, use the P2P link to request the monitoring device to provide a service, and the monitoring device uses the P2P link to send the service data to the terminal.
  • P2P peer-to-peer
  • the terminal needs to establish multiple P2P links with the monitoring device, and request one service from the monitoring device on one P2P link.
  • each terminal establishes a P2P link with the monitoring device.
  • the monitoring device needs to establish a large number of P2P links, and the monitoring device requires a lot of resources to maintain the P2P link, which increases the network delay.
  • the embodiments of the present application provide a P2P-based service communication method, device, and system to reduce network delay.
  • the technical solution is as follows:
  • this application provides a P2P-based service communication method, the method includes:
  • a first message is received, the first message includes a first identifier and first data, the first identifier is used to identify a device and a service in the device, and the first data is used to request the device
  • the service module used to provide the service in the execution operation
  • this application provides a P2P-based service communication method, the method includes:
  • the P2P module receives the second packet through the P2P link between the device and the proxy server.
  • the device includes the P2P module and at least one service module. Each service module is used to provide services.
  • the second packet is The proxy server is sent when the terminal requests the device to provide a service, and the second message includes the service type of the service requested by the terminal and the first data;
  • the P2P module sends a fifth message to a target service module through a second connection, where the target service module is a service module corresponding to the service type, and the fifth message includes the first data, the The first data is used by the target service module to obtain second data belonging to the service, and the second connection is a virtual connection between the P2P module and the target service module.
  • this application provides a P2P-based service communication device, the device includes:
  • the receiving module is configured to receive a first message, the first message includes a first identifier and first data, the first identifier is used to identify a device and a service in the device, and the first data is used Requesting a service module in the device for providing the service to perform an operation;
  • a determining module configured to determine the device identifier and service type corresponding to the service identified by the first identifier
  • the sending module is configured to send a second message to the device through the P2P link when there is a P2P link between the devices corresponding to the device identifier, the second message including the service type and The first data.
  • this application provides a P2P-based service communication device, the device includes:
  • the receiving module is configured to receive a second packet through the P2P link between the device and the proxy server, the device includes the P2P module and at least one service module, each service module is used to provide services, and the second packet
  • the message is sent by the proxy server when the terminal requests the device to provide a service, and the second message includes the service type and first data of the service requested by the terminal;
  • the sending module is configured to send a fifth message to a target service module through a second connection, where the target service module is a service module corresponding to the service type, and the fifth message includes the first data, so The first data is used to request the target service module to perform an operation, and the second connection is a virtual connection between the P2P module and the target service module.
  • the present application provides a P2P-based service communication system, which includes the device described in one aspect and the device described in the other aspect.
  • the present application provides a non-volatile computer-readable storage medium for storing a computer program that is loaded by a processor to execute the instructions of the above-mentioned P2P-based service method.
  • the present application provides an electronic device that includes a processor and a memory, the memory stores at least one instruction, and the at least one instruction is loaded and executed by the processor, so as to implement the above-mentioned P2P-based Service method.
  • the present application provides a non-volatile computer-readable storage medium for storing at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the above-mentioned P2P-based service communication method.
  • the computer program product includes a computer program stored in a computer-readable storage medium, and the computer program is loaded by a processor to implement the above-mentioned P2P-based service communication. method.
  • the device ID and service type corresponding to the service identified by the first ID included in the first message are determined, so that when there is a P2P link between the devices corresponding to the device ID, pass The P2P link sends a second message to the device.
  • the second message includes the service type and the first data.
  • the device only needs to establish a P2P link, which avoids establishing a large number of P2P links for the device. Few resources are needed to maintain this P2P link to avoid the increase of network delay.
  • FIG. 1 is a schematic structural diagram of a P2P-based service communication system provided by an embodiment of the present application
  • FIG. 2 is a schematic structural diagram of another P2P-based service communication system provided by an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of another P2P-based service communication system provided by an embodiment of the present application.
  • FIG. 4 is a flowchart of a P2P-based service communication method provided by an embodiment of the present application.
  • FIG. 5 is a flowchart of another P2P-based service communication method provided by an embodiment of the present application.
  • Fig. 6 is a flowchart of another P2P-based service communication method provided by an embodiment of the present application.
  • FIG. 7 is a schematic structural diagram of a P2P-based service communication device provided by an embodiment of the present application.
  • FIG. 8 is a schematic structural diagram of another P2P-based service communication device provided by an embodiment of the present application.
  • FIG. 9 is a schematic structural diagram of a P2P-based service communication system provided by an embodiment of the present application.
  • FIG. 10 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • an embodiment of the present application provides a P2P-based service communication system, the communication system including:
  • the device 3 can provide at least one service.
  • the proxy server 2 can assign a first identifier to each service in the device 3, and combine the device identifier of the device 3 and each service in the device 3
  • the corresponding service type and the first identifier are correspondingly stored in the corresponding relationship between the device identifier, the service type and the first identifier.
  • the first identifier of the service is the port number corresponding to the service in the proxy server 2, or the identifier assigned to the service by the proxy server 2.
  • the assigned identifier may be a character string.
  • the character string may include at least one number, at least one letter, or the character string is a combination of at least one number and at least one character, and so on.
  • the device 3 can provide three types of services, and the three types of services are network (Web) services, real-time streaming protocol (RTSP) services, and private protocol services.
  • the proxy server 2 assigns first identifiers 10080, 10554, and 18000 to the Web service, RTSP service, and private protocol service of the device 3, respectively.
  • the device ID of device 3 is 894EAW, 894EAW, the first ID "10080" corresponding to the Web service, and the service type "Web protocol" are stored in the device ID, service type, and first ID as shown in Table 1 below. Corresponding relationship.
  • the first identifier "10554" corresponding to the 894EAW and RTSP service and the service type "RTDP protocol” are correspondingly stored in the corresponding relationship between the device identifier, service type and the first identifier as shown in Table 1 below.
  • 894EAW, the first identifier "18000” corresponding to the private protocol service, and the service type "private protocol” are correspondingly stored in the corresponding relationship between the device identifier, service type and the first identifier as shown in Table 1 below.
  • Each service in the device 3 corresponds to a service type, and the service type corresponding to the service may be the protocol type corresponding to the service.
  • the service type may be RTSP, hypertext transfer protocol (hypertext transfer protocol, HTTP), and private protocol.
  • RTSP, HTTP, and private protocol correspond to RTSP service, Web service, and private protocol service in device 3, respectively.
  • the proxy server 2 stores the device identifier, the correspondence relationship 22 between the service type and the first identifier, and the P2P module 21.
  • the device 3 includes a P2P module 31 and at least one service module 32, and each service module 32 is used to provide services.
  • the service module corresponds to the service type corresponding to the service provided by the service module.
  • the device 3 shown in FIG. 2 includes a Web service module 321, an RTSP service module 322, and a private protocol module 323.
  • the Web service module 321 is used to provide Web services and corresponds to the service type "HTTP"; the RTSP service module 322 uses To provide RTSP service, it corresponds to the service type "RTSP"; the private protocol module 323 is used to provide private protocol services, which corresponds to the service type "private protocol”.
  • the communication system may also include an alarm center 4, and the alarm center 4 may be connected to each device 3 and each terminal 1.
  • the device 3 can report to the alarm center 4, and the alarm center 4 can notify the terminal 1 so that the terminal 1 requests to communicate with the device 3.
  • the device 3 can be a camera or an access control system installed at home, which can provide services such as video surveillance.
  • the device 3 sends an alarm to the alarm center 4 when it detects an intrusion, and the alarm center 4 can send a notification to the terminal 1.
  • the notification includes the device identification of the device 3, and the terminal 1 may be a terminal such as a mobile phone or a computer.
  • the terminal 1 may send a query request to the proxy server 2, the query request carrying the device identification of the device 3 and the service type corresponding to the service requested by the terminal 1.
  • the proxy server 2 receives the query request, obtains the corresponding first identifier from the corresponding relationship between the device identifier, service type, and the first identifier according to the device identifier and service type of the device carried in the query request, and sends a query response to the terminal 1.
  • the query response carries the first identifier.
  • the terminal 1 may establish a first connection with the proxy server 2 for transmitting the service corresponding to the service type.
  • the first connection may be a transmission control protocol (transmission control protocol, TCP) connection or an HTTP connection.
  • TCP transmission control protocol
  • the terminal 1 receives the query response, and sends a first message in the first format to the proxy server 2 through the first connection, the first message including the first identifier and the first data.
  • the first identifier is used to identify the device 3 and a service in the device 3, and the first data is used to request the service module of the device 3 for providing the service to perform an operation.
  • the first data may be a request message used to request the service or may be an upgrade package used to upgrade the service module.
  • the request message may be a request message of a Web page, a video request message, or the like.
  • the service module for providing the service in the device 3 can provide the data requested by the request message.
  • the service module used for providing the service in the device 3 is upgraded based on the first data.
  • the header of the first message includes the first identifier, and the payload part of the first message includes the first data.
  • the first format may be a real-time transport protocol (RTP) or RTSP message format.
  • RTP real-time transport protocol
  • the proxy server 2 receives the first message, and according to the first identifier, obtains the service type corresponding to the service requested by the terminal 1 and the device identifier of the device 3 from the corresponding relationship between the device identifier, the service type, and the first identifier, and according to the device identifier , To determine whether there is a P2P link with device 3.
  • a second packet is sent to the device 3 through the P2P link, and the second packet includes the service type.
  • a P2P link with device 3 is established, and a second packet is sent to device 3 through the established P2P link.
  • the second packet includes the service type and the first packet.
  • the proxy server 2 may store a corresponding relationship between a device identifier and a link identifier. Each record in the corresponding relationship includes a device identifier and the current existing relationship between the proxy server 2 and the device corresponding to the device identifier.
  • Link ID of the P2P link For example, referring to the corresponding relationship between the device identifier and the link identifier shown in Table 2 below, the link identifier of the P2P link in the corresponding relationship may be the port number corresponding to the P2P link, and the port number is the P2P link The port number of the corresponding port in the proxy server 2. The port is the end point of the P2P link on the proxy server 2.
  • the proxy server 2 can query the corresponding relationship between the device ID and the link ID according to the device ID of the device 3.
  • the corresponding link ID is queried, it can be determined that there is a link ID corresponding to the proxy server 2 and the device 3.
  • P2P link when the corresponding link identifier is not found out, it is determined that there is no P2P link between the proxy server and the device 3.
  • the proxy server 2 includes a register corresponding to an existing P2P link, and the register corresponding to the P2P link is used to store the device identification of the device that has established the P2P link with the proxy server 2. For example, for a device corresponding to the device identifier "894EAW", the proxy server 2 includes a register corresponding to the P2P link between the devices, and the register stores the device identifier "894EAW”.
  • the proxy server 2 searches for the register corresponding to the currently existing P2P link according to the device ID of the device 3; when inquiring about the register holding the device ID of the device 3, it determines the P2P link corresponding to the register, and the proxy server
  • the P2P link existing between 2 and device 3 is a certain P2P link; when the register storing the device identification of device 3 is not queried, it is determined that there is no P2P link with device 3.
  • the communication system further includes a P2P server 5.
  • the proxy server 2 determines that there is no P2P link with the device 3, it establishes a P2P link with the device 3 through the P2P server 5.
  • the proxy server 2 may also assign a second identifier, which is used to identify the terminal 1 and the service requested by the terminal 1.
  • the second identifier is a character string allocated by the proxy server 2.
  • the character string may include at least one number, at least one letter, or the character string is a combination of at least one number and at least one character, and so on.
  • the proxy server 2 stores the second identifier, the device identifier, and the connection identifier of the first connection between the terminal 1 and the proxy server 2 in the corresponding relationship between the second identifier, the device identifier and the connection identifier; and through the P2P link
  • the device 3 sends a second message in the second format, the message header of the second message includes the second identifier and the service type, and the payload part of the second message includes the first data.
  • the second format is different from the first format.
  • the second format may be a message format transmitted on the P2P link, and the first format may be a message format transmitted on the first connection.
  • the P2P module 21 in the proxy server 2 may send the second packet in the second format to the device 3 through the P2P link.
  • the P2P module 31 of the device 3 receives the second message through the P2P link, determines the target service module corresponding to the service type, and sends the format to the target service module through the second connection between the P2P module 31 and the target service module.
  • the fifth message includes first data so that the target service module obtains the second data belonging to the service according to the first data.
  • the second connection is the connection between the P2P module 31 and the target service module. Virtual connection.
  • the target service module obtains the second data belonging to the service as a web page according to the request message of the web page .
  • the request message is a video request message
  • the target service module obtains the second data belonging to the service as video data according to the video request message.
  • the target service module is upgraded according to the upgrade package.
  • the second data obtained is the upgrade result.
  • the payload part of the fifth message includes the first data; the P2P module 31 stores the second identifier and the connection identifier of the second connection in the corresponding relationship between the second identifier and the connection identifier.
  • connection type of the second connection is the same as the connection type of the first connection, so the first format is the same as the message format of the message transmitted on the second connection.
  • the target service module can send second data to terminal 1.
  • the second data belongs to the service of the service type.
  • the sending process is as follows:
  • the target service module sends a sixth packet in the first format to the P2P module 31 through the second connection between the P2P module 31 and the target service module, and the payload of the sixth packet includes the second data.
  • the P2P module 31 obtains the second identifier from the corresponding relationship between the second identifier and the connection identifier according to the connection identifier of the second connection; and sends a third packet in the second format to the proxy server 2 through the P2P link.
  • the message header of the message includes the second identifier, and the payload part of the third message includes the second data.
  • the proxy server 2 receives the third message sent by the device 3 through the P2P link, the header of the third message includes the second identifier, and the payload part of the third message includes the second data; according to the second identifier and the device 3, the connection identifier of the first connection is obtained from the second identifier, the corresponding relationship between the device identifier and the connection identifier; the first connection corresponding to the connection identifier of the first connection sends the first connection in the first format to the terminal 1 Four messages, the payload part of the fourth message includes the second data.
  • connection identifier of the first connection may be the connection socket of the first connection
  • connection identifier of the second connection may be the connection socket of the second connection
  • the present application provides a P2P-based service communication method, the method includes:
  • Step 101 Receive a first message.
  • the first message includes a first identifier and first data.
  • the first identifier is used to identify a device and a service in the device, and the first data is used to request the device to provide The service module of the service performs the operation.
  • Step 102 Determine the device identifier and service type corresponding to the service identified by the first identifier.
  • Step 103 When there is a P2P link between the devices corresponding to the device identifier, send a second message to the device through the P2P link, the second message including the service type and the first data.
  • the first message is received, and the device ID and service type corresponding to the service identified by the first ID in the first message are determined, so that there is a P2P link between the devices corresponding to the device ID
  • the P2P link sends a second message to the device
  • the second message includes the service type and the first data, so the device only needs to establish a P2P link, avoiding the establishment of a large number of P2P links for the device , Thereby avoiding the increase of network delay.
  • the present application provides a P2P-based service communication method, which is applied to a device including a P2P module and at least one service module, each service module is used to provide services, and the method includes:
  • Step 201 The P2P module receives a second message through the P2P link between the device and the proxy server, the device includes the P2P module and at least one service module, each service module is used to provide services, and the second message is the proxy server Sent when the terminal requests the device to provide a service, the second message includes the service type of the service requested by the terminal and the first data.
  • Step 202 The P2P module sends a fifth message to the target service module through the second connection.
  • the target service module is a service module corresponding to the service type.
  • the fifth message includes first data, and the first data is used to request the target service.
  • the module performs the operation, and the second connection is a virtual connection between the P2P module and the target service module.
  • the P2P module receives the second packet through a P2P link between the device and the proxy server, so that the device only needs to establish one P2P link, which avoids establishing a large number of P2P links for the device , Thereby avoiding the increase of network delay.
  • this application provides a P2P-based service communication method, which can be applied to the communication system shown in FIG. 1, including:
  • Step 301 The terminal sends a query request to the proxy server.
  • the query request carries the device identifier of the device and the service type corresponding to the service requested by the terminal.
  • the communication system includes an alarm center, which can receive equipment alarms, and the alarm center informs users so that the user can handle equipment alarms.
  • the alarm center sends a notification to the terminal corresponding to the user, and the notification includes the device identification of the device.
  • the terminal receives the notification and displays the notification to the user.
  • the user can input the service type corresponding to the service provided by the request device to the terminal.
  • the terminal sends a query request to the proxy server through the first connection, and the query request carries the device identifier of the device and the service type corresponding to the service requested by the terminal.
  • Step 302 The proxy server receives the query request, obtains the first identifier according to the device identifier and service type carried in the query request, and sends a query response to the terminal, where the query response carries the first identifier.
  • the first identifier is used to identify the device and the service corresponding to the service type provided in the device.
  • the proxy server may assign a first identifier to each service in the device in advance, and store the device identifier of the device, the service type corresponding to each service in the device, and the first identifier in the correspondence between the device identifier, service type and the first identifier. relationship.
  • the device may send a registration request message for allocating the first identifier to the proxy server when it is powered on, and the registration request message includes the service type corresponding to each service in the device.
  • the proxy server receives the registration request message, and assigns a first identifier to each service in the device according to the service type corresponding to each service in the device.
  • the first identifier of the service can uniquely identify the service in the proxy server.
  • the first identifier allocated for the service may be a port number.
  • the proxy server may establish the first connection with the terminal based on the port number.
  • the first connection between the terminal and the proxy server may be a TCP connection or an RTSP connection.
  • the proxy server obtains the corresponding first identifier from the corresponding relationship between the device identifier, service type, and the first identifier according to the device identifier and service type carried in the query request, and sends a query response to the terminal.
  • the query response carries the The first logo.
  • the terminal After receiving the first identifier, the terminal uses the first identifier to send a message to the device.
  • the detailed implementation process is as follows:
  • Step 303 The terminal sends a first message to the proxy server, where the first message includes the first identifier and the first data.
  • the header of the first message may include the first identifier, and the payload part of the first message may include the first data.
  • the header of the first message includes a port number field, and the port number field carries the first identifier.
  • the message format of the first message is the first format, and the first format may be the message format of RTP or RTSP.
  • the first identifier is used to identify a device and a service in the device.
  • the first data can be used to request a service module in the device for providing the service to perform an operation.
  • the first data may be a request message, for example, a request message of a Web page, a video request message, etc.
  • the first data is used to request the service module to provide data belonging to the service. or,
  • the first data is an upgrade package used to upgrade the service module, and the first data is used to request the service module to upgrade.
  • the header and payload components of the first message in the first format includes an internet protocol address (IP) header and a TCP header.
  • IP internet protocol address
  • the first format may be a message format of a message transmitted on the first connection.
  • the first format may be a message format of the RTP or RTSP protocol. Therefore, the terminal can send the first message in the first format to the proxy server through the first connection.
  • Step 304 The proxy server receives the first message, and determines the device identifier and service type corresponding to the service identified by the first identifier.
  • the proxy server may obtain the service type corresponding to the service requested by the terminal and the device identifier of the device from the corresponding relationship between the first identifier, the service type, and the device identifier according to the first identifier.
  • the proxy server obtains the corresponding relationship from the device identifier, service type and the first identifier according to the first identifier 10554 as shown in Table 1.
  • the device identification of the device is "894EAW" and the service type is RTSP protocol.
  • Step 305 The proxy server allocates a second identifier, which is used to identify the terminal and the service requested by the terminal.
  • the terminal can request the device to provide multiple services, and the proxy server can transmit a message for requesting each service on the P2P link.
  • multiple terminals may request the device to provide services, and the proxy server may transmit a service request message for each terminal on the P2P link. Therefore, the one P2P link can be used to transmit data of multiple services or data of services requested by multiple terminals.
  • the second identifier can be used to identify the terminal and the service provided by the terminal, so that the second identifier can be used to distinguish different services requested by different terminals, so as to achieve multiple transmissions on the one P2P link. Data for one service or data for multiple terminals requesting services.
  • the assigned second identifier is a character string, and the character string is used to identify the terminal and the service requested by the terminal on the proxy server.
  • Step 306 The proxy server saves the second identifier, the device identifier, and the connection identifier of the first connection between the terminal and the proxy server in the corresponding relationship between the second identifier, the device identifier, and the connection identifier.
  • connection identifier of the first connection may be a connection socket of the first connection or the like.
  • Step 307 The proxy server judges whether there is a P2P link with the device according to the device identification. When there is a P2P link with the device, it executes the following step 308. When there is no P2P link with the device, it establishes a connection with the device. P2P link between.
  • the proxy server may store a corresponding relationship between a device identifier and a link identifier, and each record in the corresponding relationship includes a device identifier and a link identifier of a P2P link currently existing between the devices corresponding to the device identifier.
  • the proxy server can query the corresponding relationship between the device identifier and the link identifier according to the device identifier of the device, and when querying the corresponding link identifier, it determines that there is a link identifier corresponding to the device.
  • P2P link when the corresponding link identifier is not queried, it is determined that there is no P2P link with the device. or,
  • the proxy server includes a register corresponding to the currently existing P2P link, and the register corresponding to the P2P link is used to store the device identification of the device that establishes the P2P link with the proxy server.
  • the proxy server searches for the register corresponding to the currently existing P2P link according to the device ID of the device; when inquiring the register holding the device ID of the device, it determines that there is a registered register with the device. Corresponding P2P link; when the register holding the device identification of the device is not found, it is determined that there is no P2P link with the device.
  • Step 308 The proxy server sends a second message to the device through the P2P link, the second message including the second identifier, the service type, and the first data.
  • the message header of the second message includes the second identifier and the service type, and the payload part of the second message includes the first data.
  • the message format of the second message may be a second format, the first format is different from the second format, and the second format may be a message format transmitted on the P2P link.
  • the header and payload part of the second message in the second format includes an IP header, a user datagram protocol (UDP) header, a P2P header, and Agency agreement header.
  • the proxy protocol header may include the second identifier and the service type.
  • Step 309 The P2P module of the device receives the second message through the P2P link, determines the target service module corresponding to the service type, and sends the fifth message to the target service module through the second connection between the P2P module and the target service module. Message.
  • the P2P module of the device receives the second message, converts the second message into a fifth message in the first format, and the payload part of the fifth message includes the first data.
  • the P2P module After determining the target service module corresponding to the service type, the P2P module establishes a second connection between the P2P module and the target service module.
  • the second connection is used to transmit data belonging to the service currently requested by the terminal.
  • the second connection may be a virtual connection or the like.
  • the message format of the fifth message is the first format, which can be transmitted on the second connection between the P2P module and the target service module.
  • Step 310 The P2P module correspondingly saves the second identifier and the connection identifier of the second connection in the corresponding relationship between the second identifier and the connection identifier.
  • connection identifier of the second connection may be a connection socket of the second connection, etc.
  • the target service module receives the fifth message, and performs an operation according to the first data included in the payload part of the fifth message.
  • the target service module When the first data is a request message for requesting the service, the target service module obtains the second data belonging to the service according to the first data, and sends a sixth packet in the first format to the P2P module through the second connection,
  • the payload part of the sixth message includes the second data.
  • the request message is a request message of a Web page
  • the target service module obtains the second data belonging to the service as the Web page according to the request message of the Web page.
  • the request message is a video request message
  • the target service module obtains the second data belonging to the service as video data according to the video request message. or,
  • the target service module When the first data is an upgrade package for upgrading the target service module, the target service module is upgraded according to the upgrade package. After the upgrade is completed, the target service module can send a sixth packet in the first format to the P2P module through the second connection.
  • the payload of the sixth packet includes the second data, and the second data is the upgrade result.
  • Step 311 The P2P module receives the sixth message sent by the target service module through the second connection with the target service module.
  • Step 312 The P2P module obtains the second identifier from the corresponding relationship between the second identifier and the connection identifier according to the connection identifier of the second connection.
  • Step 313 The P2P module sends a third message in the second format to the proxy server through the P2P link, where the third message includes the device identifier, the second identifier and the second data of the device.
  • the P2P module converts the sixth message into a third message in the second format.
  • the header of the third message may include the second identifier, and the third message
  • the payload part of the message may include the second data.
  • Step 314 The proxy server receives the third message through the P2P link, and obtains the first identifier from the second identifier, the correspondence relationship between the device identifier and the connection identifier according to the second identifier included in the third message and the device identifier of the device.
  • the connection ID of the connection The connection ID of the connection.
  • Step 315 The proxy server sends a fourth packet in the first format to the terminal through the first connection corresponding to the connection identifier of the first connection, and the payload part of the fourth packet includes the second data.
  • the proxy server after receiving the third message, the proxy server converts the third message into a fourth message in the first format.
  • the terminal receives the fourth message from the first connection.
  • the proxy server when the proxy server receives the first message sent by the terminal, it allocates a second identifier for identifying the terminal and the service requested by the terminal, and the second identifier, the device identifier, and the connection identifier of the first connection are assigned It is stored in the corresponding relationship between the second identifier, the device identifier, and the connection identifier.
  • the proxy server sends a second message including the second identifier and the service type to the device through the P2P link, so that the third message sent by the device to the proxy server may include the device identifier and the second identifier, and the proxy server receives After the third message, the connection identifier of the first connection may be obtained based on the device identifier and the second identifier, so that the message is sent to the terminal based on the first connection corresponding to the connection identifier.
  • an embodiment of the present application provides a P2P-based service communication device 400.
  • the device 400 can be deployed in the proxy server provided in any of the foregoing embodiments, including:
  • the receiving module 401 is configured to receive a first message, where the first message includes a first identifier and first data, where the first identifier is used to identify a device and a service in the device, and the first data Used to request the service module used to provide the service in the device to perform an operation;
  • the determining module 402 is configured to determine the device identifier and service type corresponding to the service identified by the first identifier;
  • the sending module 403 is configured to send a second packet to the device through the P2P link when there is a P2P link between the devices corresponding to the device identifier, and the second packet includes the service type And the first data.
  • the device 400 further includes:
  • An establishment module configured to establish a P2P link with the device when there is no P2P link between the device corresponding to the device identifier
  • the sending module 403 is further configured to send the second packet to the device through the established P2P link.
  • the device 400 further includes:
  • the first query module is configured to query the corresponding relationship between the device identifier and the link identifier according to the device identifier of the device.
  • Each record in the corresponding relationship includes a device identifier and the relationship between the device identifier and the device identifier.
  • the link identifier of the P2P link currently existing between the two; when the corresponding link identifier is queried, it is determined that there is a P2P link corresponding to the link identifier between the devices, and the corresponding link identifier is not queried When it is determined that there is no P2P link with the device.
  • the device further includes:
  • the second query module is used to query the register corresponding to the currently existing P2P link according to the device identifier of the device; when the register holding the device identifier of the device is inquired, it is determined that there is a connection with the device The P2P link corresponding to the queried register; when no register storing the device identifier of the device is queried, it is determined that there is no P2P link with the device.
  • the second message further includes a second identifier, and the second identifier is used to identify the terminal that sends the first message and the service;
  • the apparatus 400 further includes:
  • the first saving module is configured to allocate the second identifier, and save the second identifier, the device identifier, and the connection identifier of the first connection in the corresponding relationship between the first identifier, the device identifier, and the connection identifier.
  • the first connection is a connection with the terminal for transmitting the first message.
  • the device 400 further includes an acquisition module,
  • the receiving module 401 is further configured to receive a third message sent by the device through the P2P link, where the third message includes the second identifier, the device identifier of the device, and the device belonging to the service The second data;
  • the determining module is configured to obtain the connection identifier of the first connection from the second identifier, the corresponding relationship between the device identifier and the connection identifier according to the second identifier and the device identifier of the device;
  • the sending module 403 is further configured to send the fourth message to the terminal through the first connection corresponding to the connection identifier, where the fourth message includes the second data.
  • the message format of the first message and the third message is a first format, and the first format is a message format transmitted on the first connection;
  • the message format of the second message is a second format
  • the second format is a message format transmitted on the P2P link
  • the first format is different from the second format
  • the device 400 further includes: a second storage module,
  • the receiving module 401 is further configured to receive a registration request message sent by the device, the registration request message including the device identifier of the device and the service type of the service provided by the device;
  • the second storage module is configured to allocate a first identifier, and store the first identifier, the device identifier of the device, and the service type of the service provided by the device in the corresponding storage of the first identifier, device identifier, and service type. Corresponding relationship.
  • the determining module allocates a second identifier for identifying the terminal and the service requested by the terminal, and the saving module assigns the second identifier, the device identifier, and the first connection
  • the connection identifier of is stored in the corresponding relationship between the second identifier, the device identifier, and the connection identifier.
  • the sending module sends a second message including the second identifier, the service type, and the first data to the device through the P2P link
  • the receiving module receives the device returned by the device that carries the device identifier and the second identifier Message
  • the connection identifier of the first connection may be obtained based on the device identifier and the second identifier, so that the message is sent to the terminal based on the first connection corresponding to the connection identifier.
  • an embodiment of the present application provides a P2P-based service communication device 500.
  • the device 500 is used for equipment including the device 500 and at least one service module. Each service module is used to provide services.
  • the device 500 includes:
  • the receiving module 501 is configured to receive a second message through the P2P link between the device and the proxy server.
  • the second message is sent by the proxy server when the terminal requests the device to provide services.
  • the message includes the service type and first data of the service requested by the terminal;
  • the sending module 502 is configured to send a fifth message to a target service module through a second connection, where the target service module is a service module corresponding to the service type, and the fifth message includes the first data, The first data is used to request the target service module to perform an operation, and the second connection is a virtual connection with the target service module.
  • the message header of the second message further includes a second identifier, and the second identifier is used to identify the terminal and the service requested by the terminal;
  • the apparatus 500 further includes:
  • the saving module is configured to save the second identifier and the connection identifier of the second connection in the corresponding relationship between the second identifier and the connection identifier.
  • the device 500 further includes an acquisition module,
  • the receiving module 501 is further configured to receive a sixth packet through the second connection, where the sixth packet includes the second data;
  • the acquiring module is configured to acquire the second identifier from the corresponding relationship between the second identifier and the connection identifier according to the connection identifier of the second connection;
  • the sending module 502 is further configured to send a third message to the proxy server through the P2P link, the third message including the device identifier of the device, the second identifier, and the second data.
  • the message formats of the fifth message and the sixth message are a first format, and the first format is a message format transmitted on the second connection;
  • the message format of the second message is a second format
  • the second format is a message format transmitted on the P2P link
  • the first format is different from the second format
  • the receiving module receives the second message including the second identifier and the service type through the P2P link between the device and the proxy server, so that when the message is sent to the proxy server, the message may include
  • the device identifier and the second identifier enable the proxy server to obtain the connection identifier of the first connection based on the device identifier and the second identifier, and thereby send the message to the terminal based on the first connection corresponding to the connection identifier.
  • the second identifier is used to identify the terminal and the service requested by the terminal, so that the second identifier can be used to distinguish multiple services requested by the terminal or services requested by multiple terminals transmitted on the P2P link between the proxy server and the device
  • the device only needs to establish one P2P link, which avoids establishing a large number of P2P links for the device, thereby avoiding the phenomenon of increased network delay.
  • an embodiment of the present application provides a communication system 600 that includes the device described in FIG. 6 and the device described in FIG. 7.
  • the device described in FIG. 6 may be a proxy server 601, and the device described in FIG. 7 may be a device 602.
  • FIG. 10 shows a structural block diagram of an electronic device 700 provided by an exemplary embodiment of the present application.
  • the electronic device 700 may be a terminal, such as a smart phone, a tablet computer, a notebook computer, or a desktop computer.
  • the electronic device 700 may also be called user equipment, portable terminal, laptop terminal, desktop terminal and other names.
  • the electronic device 700 includes a processor 701 and a memory 702.
  • the processor 701 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and so on.
  • the processor 701 can use at least one hardware form among DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array, Programmable Logic Array). achieve.
  • the processor 701 may also include a main processor and a coprocessor.
  • the main processor is a processor used to process data in the awake state, also called a CPU (Central Processing Unit, central processing unit); the coprocessor is A low-power processor used to process data in the standby state.
  • the processor 701 may be integrated with a GPU (Graphics Processing Unit, image processor), and the GPU is used to render and draw content that needs to be displayed on the display screen.
  • the processor 701 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
  • AI Artificial Intelligence
  • the memory 702 may include one or more computer-readable storage media, which may be non-transitory.
  • the memory 702 may also include high-speed random access memory and non-volatile memory, such as one or more magnetic disk storage devices and flash memory storage devices.
  • the non-transitory computer-readable storage medium in the memory 702 is used to store at least one instruction, and the at least one instruction is used to be executed by the processor 701 to implement a method provided in the method embodiment of the present application. P2P-based service communication method.
  • the electronic device 700 may optionally further include: a peripheral device interface 703 and at least one peripheral device.
  • the processor 701, the memory 702, and the peripheral device interface 703 may be connected by a bus or a signal line.
  • Each peripheral device can be connected to the peripheral device interface 703 through a bus, a signal line or a circuit board.
  • the peripheral device includes: at least one of a radio frequency circuit 704, a touch display screen 705, a camera 706, an audio circuit 707, a positioning component 708, and a power supply 709.
  • the peripheral device interface 703 may be used to connect at least one peripheral device related to I/O (Input/Output) to the processor 701 and the memory 702.
  • the processor 701, the memory 702, and the peripheral device interface 703 are integrated on the same chip or circuit board; in some other embodiments, any one of the processor 701, the memory 702, and the peripheral device interface 703 or The two can be implemented on separate chips or circuit boards, which are not limited in this embodiment.
  • the radio frequency circuit 704 is used for receiving and transmitting RF (Radio Frequency, radio frequency) signals, also called electromagnetic signals.
  • the radio frequency circuit 704 communicates with a communication network and other communication devices through electromagnetic signals.
  • the radio frequency circuit 704 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals into electrical signals.
  • the radio frequency circuit 704 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, and so on.
  • the radio frequency circuit 704 can communicate with other terminals through at least one wireless communication protocol.
  • the wireless communication protocol includes but is not limited to: World Wide Web, Metropolitan Area Network, Intranet, various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area network and/or WiFi (Wireless Fidelity, wireless fidelity) network.
  • the radio frequency circuit 704 may also include NFC (Near Field Communication) related circuits, which is not limited in this application.
  • the display screen 705 is used to display UI (User Interface, user interface).
  • the UI can include graphics, text, icons, videos, and any combination thereof.
  • the display screen 705 also has the ability to collect touch signals on or above the surface of the display screen 705.
  • the touch signal may be input to the processor 701 as a control signal for processing.
  • the display screen 705 may also be used to provide virtual buttons and/or virtual keyboards, also called soft buttons and/or soft keyboards.
  • the display screen 705 may be a flexible display screen, which is arranged on a curved surface or a folding surface of the electronic device 700. Furthermore, the display screen 705 can also be set as a non-rectangular irregular figure, that is, a special-shaped screen.
  • the display screen 705 may be made of materials such as LCD (Liquid Crystal Display) and OLED (Organic Light-Emitting Diode).
  • the camera assembly 706 is used to capture images or videos.
  • the camera assembly 706 includes a front camera and a rear camera.
  • the front camera is arranged on the front panel of the electronic device 700
  • the rear camera is arranged on the back of the electronic device 700.
  • the camera assembly 706 may also include a flash.
  • the flash can be a single-color flash or a dual-color flash. Dual color temperature flash refers to a combination of warm light flash and cold light flash, which can be used for light compensation under different color temperatures.
  • the audio circuit 707 may include a microphone and a speaker.
  • the microphone is used to collect sound waves of the user and the environment, and convert the sound waves into electrical signals and input them to the processor 701 for processing, or input to the radio frequency circuit 704 to implement voice communication.
  • the microphone can also be an array microphone or an omnidirectional acquisition microphone.
  • the speaker is used to convert the electrical signal from the processor 701 or the radio frequency circuit 704 into sound waves.
  • the speaker can be a traditional membrane speaker or a piezoelectric ceramic speaker.
  • the speaker When the speaker is a piezoelectric ceramic speaker, it can not only convert the electrical signal into human audible sound waves, but also convert the electrical signal into human inaudible sound waves for purposes such as distance measurement.
  • the audio circuit 707 may also include a headphone jack.
  • the positioning component 708 is used to locate the current geographic location of the electronic device 700 to implement navigation or LBS (Location Based Service, location-based service).
  • the positioning component 708 may be a positioning component based on the GPS (Global Positioning System, Global Positioning System) of the United States, the Beidou system of China, or the Galileo system of Russia.
  • the power supply 709 is used to supply power to various components in the electronic device 700.
  • the power source 709 may be alternating current, direct current, disposable batteries, or rechargeable batteries.
  • the rechargeable battery may be a wired rechargeable battery or a wireless rechargeable battery.
  • a wired rechargeable battery is a battery charged through a wired line
  • a wireless rechargeable battery is a battery charged through a wireless coil.
  • the rechargeable battery can also be used to support fast charging technology.
  • the electronic device 700 further includes one or more sensors 710.
  • the one or more sensors 710 include, but are not limited to, an acceleration sensor 711, a gyroscope sensor 712, a pressure sensor 713, a fingerprint sensor 714, an optical sensor 715, and a proximity sensor 716.
  • the acceleration sensor 711 can detect the magnitude of acceleration on the three coordinate axes of the coordinate system established by the electronic device 700.
  • the acceleration sensor 711 may be used to detect the components of the gravitational acceleration on three coordinate axes.
  • the processor 701 may control the touch screen 705 to display the user interface in a horizontal view or a vertical view according to the gravity acceleration signal collected by the acceleration sensor 711.
  • the acceleration sensor 711 may also be used for the collection of game or user motion data.
  • the gyroscope sensor 712 can detect the body direction and the rotation angle of the electronic device 700, and the gyroscope sensor 712 can cooperate with the acceleration sensor 711 to collect the user's 3D actions on the electronic device 700.
  • the processor 701 can implement the following functions according to the data collected by the gyroscope sensor 712: motion sensing (for example, changing the UI according to the user's tilt operation), image stabilization during shooting, game control, and inertial navigation.
  • the pressure sensor 713 may be disposed on the side frame of the electronic device 700 and/or the lower layer of the touch screen 705.
  • the processor 701 performs left and right hand recognition or quick operation according to the holding signal collected by the pressure sensor 713.
  • the processor 701 controls the operability controls on the UI interface according to the user's pressure operation on the touch display screen 705.
  • the operability control includes at least one of a button control, a scroll bar control, an icon control, and a menu control.
  • the fingerprint sensor 714 is used to collect the user's fingerprint.
  • the processor 701 can identify the user's identity based on the fingerprint collected by the fingerprint sensor 714, or the fingerprint sensor 714 can identify the user's identity based on the collected fingerprint. When it is recognized that the user's identity is a trusted identity, the processor 701 authorizes the user to perform related sensitive operations, including unlocking the screen, viewing encrypted information, downloading software, paying, and changing settings.
  • the fingerprint sensor 714 may be provided on the front, back or side of the electronic device 700. When the electronic device 700 is provided with a physical button or a manufacturer logo, the fingerprint sensor 714 may be integrated with the physical button or the manufacturer logo.
  • the optical sensor 715 is used to collect the ambient light intensity.
  • the processor 701 may control the display brightness of the touch screen 705 according to the ambient light intensity collected by the optical sensor 715. Specifically, when the ambient light intensity is high, the display brightness of the touch display screen 705 is increased; when the ambient light intensity is low, the display brightness of the touch display screen 705 is decreased.
  • the processor 701 may also dynamically adjust the shooting parameters of the camera assembly 706 according to the ambient light intensity collected by the optical sensor 715.
  • the proximity sensor 716 also called a distance sensor, is usually provided on the front panel of the electronic device 700.
  • the proximity sensor 716 is used to collect the distance between the user and the front of the electronic device 700.
  • the processor 701 controls the touch screen 705 to switch from the on-screen state to the off-screen state; when the proximity sensor 716 When it is detected that the distance between the user and the front of the electronic device 700 is gradually increasing, the processor 701 controls the touch display screen 705 to switch from the on-screen state to the on-screen state.
  • FIG. 10 does not constitute a limitation on the electronic device 700, and may include more or fewer components than shown, or combine some components, or adopt different component arrangements.
  • the present application also provides a non-volatile computer-readable storage medium in which code instructions are stored, and the code instructions are executed by a processor, To implement the P2P-based service communication method provided in the above embodiment.
  • the non-volatile computer-readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
  • the second identifier used to identify the terminal and the service requested by the terminal is allocated when the first message sent by the terminal is received, the second identifier, the device identifier, and the connection identifier of the first connection are stored in The second identifier, the corresponding relationship between the device identifier and the connection identifier.
  • the connection identifier of the first connection may be obtained based on the device identifier and the second identifier, so that a message is sent to the monitoring terminal based on the first connection corresponding to the connection identifier.
  • multiple services requested by the terminal or services requested by multiple terminals transmitted on the P2P link between the device can be distinguished by the first identifier, so that the device only needs to establish a P2P link, avoiding a large number of establishments for the device P2P link to avoid the increase of network delay.
  • the present disclosure also provides a computer program product, the computer program product includes a computer program stored in a computer-readable storage medium, and the calculation program is loaded by a processor to implement the above-mentioned implementation Examples provide P2P-based service communication methods.
  • the second identifier used to identify the terminal and the service requested by the terminal is allocated, and the second identifier, the device identifier, and the connection identifier of the first connection are stored in The second identifier, the corresponding relationship between the device identifier and the connection identifier.
  • the connection identifier of the first connection may be obtained based on the device identifier and the second identifier, so that a message is sent to the terminal based on the first connection corresponding to the connection identifier.
  • multiple services requested by the terminal or services requested by multiple terminals transmitted on the P2P link with the device can be distinguished by the first identifier, so that the device only needs to establish a P2P link, which avoids the establishment of the device A large number of P2P links prevent the increase of network delay.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephonic Communication Services (AREA)

Abstract

本申请是关于一种基于P2P的服务通信方法、装置及系统,属于监控领域。所述方法包括:接收第一报文,所述第一报文包括第一标识和第一数据,所述第一标识用于标识一设备和所述设备中的服务,所述第一数据用于请求所述设备中的用于提供所述服务的服务模块执行操作;确定所述第一标识所标识的服务对应的设备标识和服务类型;在与所述设备标识对应的设备之间存在P2P链路时,通过所述P2P链路向所述设备发送第二报文,所述第二报文包括所述服务类型和所述第一数据。本申请能够减小网络延时。

Description

一种基于P2P的服务通信方法、装置及系统
本申请要求于2019年8月1日提交的申请号为201910708630.7、发明名称为“一种基于P2P的服务通信方法、装置及系统”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及监控领域,特别涉及一种基于P2P的服务通信方法、装置及系统。
背景技术
在报警中心的业务场景中,一个报警中心会管理很多家庭或者商铺的监控设备,监控设备可以提供一个或多个服务。报警中心可以接收来自监控设备的报警,报警中心可以通知用户。用户使用终端请求该监控设备提供服务。例如监控设备可以是安装在家中的摄像头等,可以提供视频监控等服务,监控设备在检测到有人员闯入家时向报警中心发送报警,报警中心通知用户,用户可以使用手机或电脑等终端请求监控设备提供监控视频。
终端可以建立与监控设备之间的点对点(peer-to-peer,P2P)链路,使用该P2P链路请求监控设备提供服务,监控设备使用该P2P链路向终端发送该服务的数据。其中,当该终端向监控设备请求多个服务时,终端需要建立与监控设备之间的多条P2P链路,在一条P2P链路上向监控设备请求一个服务。当多个终端向监控设备请求服务时,每个终端都与监控设备建立P2P链路。这样导致监控设备需要建立大量的P2P链路,导致监控设备需要大量资源维护P2P链路,使网络延时增加。
发明内容
本申请实施例提供了一种基于P2P的服务通信方法、装置及系统,以减小网络延时。所述技术方案如下:
一方面,本申请提供了一种基于P2P的服务通信方法,所述方法包括:
接收第一报文,所述第一报文包括第一标识和第一数据,所述第一标识用于标识一设备和所述设备中的服务,所述第一数据用于请求所述设备中的用于提供所述服务的服务模块执行操作;
确定所述第一标识所标识的服务对应的设备标识和服务类型;
在与所述设备标识对应的设备之间存在P2P链路时,通过所述P2P链路向所述设备发送第二报文,所述第二报文包括所述服务类型和所述第一数据。
另一方面,本申请提供了一种基于P2P的服务通信方法,所述方法包括:
P2P模块通过设备与代理服务器之间的P2P链路接收第二报文,所述设备包括所述P2P模块和至少一个服务模块,每个服务模块用于提供服务,所述第二报文是所述代理服务器在终端请求所述设备提供服务时发送的,所述第二报文包括所述终端请求的服务的服务类型和第一数据;
所述P2P模块通过第二连接向目标服务模块发送第五报文,所述目标服务模块是与所述服务类型相对应的服务模块,所述第五报文包括所述第一数据,所述第一数据用于所述目标服务模块获取属于所述服务的第二数据,所述第二连接为所述P2P模块与目标服务模块之间的虚拟连接。
另一方面,本申请提供了一种基于P2P的服务通信装置,所述装置包括:
接收模块,用于接收第一报文,所述第一报文包括第一标识和第一数据,所述第一标识用于标识一设备和所述设备中的服务,所述第一数据用于请求所述设备中的用于提供所述服务的服务模块执行操作;
确定模块,用于确定所述第一标识所标识的服务对应的设备标识和服务类型;
发送模块,用于在与所述设备标识对应的设备之间存在P2P链路时,通过所述P2P链路向所述设备发送第二报文,所述第二报文包括所述服务类型和所述第一数据。
另一方面,本申请提供了一种基于P2P的服务通信装置,所述装置包括:
接收模块,用于通过设备与代理服务器之间的P2P链路接收第二报文,所述设备包括所述P2P模块和至少一个服务模块,每个服务模块用于提供服务,所述第二报文是所述代理服务器在终端请求所述设备提供服务时发送的,所述第二报文包括所述终端请求的服务的服务类型和第一数据;
发送模块,用于通过第二连接向目标服务模块发送第五报文,所述目标服务模块是与所述服务类型相对应的服务模块,所述第五报文包括所述第一数据,所述第一数据用于请求所述目标服务模块执行操作,所述第二连接为所述P2P模块与目标服务模块之间的虚拟连接。
另一方面,本申请提供了一种基于P2P的服务通信系统,所述系统包括如一方面所述的装置和如另一方面所述的装置。
另一方面,本申请提供了一种非易失性计算机可读存储介质,用于存储计算机程序,所述计算机程序通过处理器进行加载来执行上述基于P2P的服务方法的指令。
另一方面,本申请提供了一种电子设备,所述电子设备包括处理器和存储器,所述存储器存储至少一条指令,所述至少一条指令被所述处理器加载并执行,以实现上述基于P2P的服务方法。
另一方面,本申请提供了一种非易失性计算机可读存储介质,用于存储至少一个指令,所述至少一个指令被处理器加载并运行,以实现上述基于P2P的服务通信方法。
另一方面,本申请提供了一种计算机程序产品,所述计算机程序产品包括在计算机可读存储介质中存储的计算机程序,并且所述计算程序通过处理器进行加载来实现上述基于P2P的服务通信方法。
本申请实施例提供的技术方案可以包括以下有益效果:
由于在接收到第一报文,确定第一报文中包括的第一标识所标识的服务对应的设备标识和服务类型,这样在与该设备标识对应的设备之间存在P2P链路时,通过该P2P链路向设备发送第二报文,第二报文包括该服务类型和第一数据,如此设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,只需要很少资源来维护该一条P2P链路,避免网络延时增加的现象发生。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本申请。
附图说明
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。
图1是本申请实施例提供的一种基于P2P的服务通信系统结构示意图;
图2是本申请实施例提供的另一种基于P2P的服务通信系统结构示意图;
图3是本申请实施例提供的另一种基于P2P的服务通信系统结构示意图;
图4是本申请实施例提供的一种基于P2P的服务通信方法流程图;
图5是本申请实施例提供的另一种基于P2P的服务通信方法流程图;
图6是本申请实施例提供的另一种基于P2P的服务通信方法流程图;
图7是本申请实施例提供的一种基于P2P的服务通信装置结构示意图;
图8是本申请实施例提供的另一种基于P2P的服务通信装置结构示意图;
图9是本申请实施例提供的一种基于P2P的服务通信系统结构示意图;
图10是本申请实施例提供的一种电子设备结构示意图。
通过上述附图,已示出本申请明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本申请构思的范围,而是通过参考特定实施例为本领域技术人员说明本申请的概念。
具体实施方式
这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。
参见图1,本申请实施例提供了一种基于P2P的服务通信系统,该通信系统包括:
终端1、代理服务器2和设备3,设备3可以提供至少一种服务,代理服务器2可以为设备3中的每个服务分配第一标识,将设备3的设备标识、设备3中的每个服务对应的服务类型和第一标识对应保存在设备标识、服务类型与第一标识的对应关系。
可选的,对于每个服务,该服务的第一标识为该服务在代理服务器2中对应的端口号,或者,为代理服务器2为该服务分配的标识,分配的标识可以为字符串,该字符串可以包括至少一个数字、至少一个字母或该字符串是至少一个数字和至少一个字符的组合等。
例如,参见图1,设备3可以提供三种服务,该三种服务分别为网络(Web)服务、实时流传输协议(real time streaming protocol,RTSP)服务和私有协议服务。代理服务器2为设备3的Web服务、RTSP服务和私有协议服务分配第一标识分别为10080、10554和18000。假设,设备3的设备标识为894EAW,将894EAW、Web服务对应的第一标识“10080”和服务类型“Web协议”对应保存在如下下表1所示的设备标识、服务类型与第一标识的对应关系中。将894EAW、RTSP服务对应的第一标识“10554”和服务类型“RTDP协议”对应保存在如下下表1所示的设备标识、服务类型与第一标识的对应关系中。将894EAW、私有协议服务对应的第一标识“18000”和服务类型“私有协议”对应保存在如下下表1所示的设备 标识、服务类型与第一标识的对应关系中。
表1
设备标识 服务类型 第一标识
894EAW Web协议 10080
894EAW RTSP协议 10554
894EAW 私有协议 18000
…… …… ……
设备3中的每个服务对应一个服务类型,服务对应的服务类型可以是该服务对应的协议类型。例如,服务类型可以为RTSP、超文本传输协议(hyperText transfer protocol,HTTP)和私有协议,RTSP、HTTP和私有协议分别与设备3中的RTSP服务、Web服务和私有协议服务一一对应。
参见图1,代理服务器2中保存有设备标识、服务类型与第一标识的对应关系22和P2P模块21。设备3包括P2P模块31和至少一个服务模块32,每个服务模块32用于提供服务。对于每个服务模块,该服务模块与该服务模块提供的服务对应的服务类型相对应。例如,图2所示的设备3中包括Web服务模块321、RTSP服务模块322和私有协议模块323,Web服务模块321用于提供Web服务,与服务类型“HTTP”相对应;RTSP服务模块322用于提供RTSP服务,与服务类型“RTSP”相对应;私有协议模块323用于提供私有协议服务,与服务类型“私有协议”相对应。
参见图2,该通信系统还可以包括报警中心4,报警中心4可以与每个设备3和每个终端1相连。设备3可以向报警中心4报警,报警中心4可以通知终端1,使终端1请求与设备3通信。
例如,设备3可以是安装在家中的摄像头或门禁系统等,可以提供视频监控等服务,设备3在检测到有人员闯入时向报警中心4发送报警,报警中心4可以向终端1发送通知,该通知包括设备3的设备标识,终端1可以为手机或电脑等终端。
终端1可以在接收该通知后,向代理服务器2发送查询请求,该查询请求携带设备3的设备标识和终端1请求的服务对应的服务类型。代理服务器2接收该查询请求,根据该查询请求携带的设备的设备标识和服务类型,从设备标识、服务类型与第一标识的对应关系中获取对应的第一标识,向终端1发送查询响应,该查询响应携带该第一标识。
可选的,终端1接收该查询响应后,可以与代理服务器2之间可以建立用于传输该服务类型对应服务的第一连接。
第一连接可以为传输控制协议(transmission control protocol,TCP)连接或HTTP连接等。
终端1接收该查询响应,通过第一连接向代理服务器2发送格式为第一格式的第一报文,第一报文包括该第一标识和第一数据。
第一标识用于标识设备3和设备3中的一种服务,第一数据用于请求设备3中的用于提供该服务的服务模块执行操作。
第一数据可以是用于请求该服务的请求消息或者可以是用于升级该服务模块的升级包,例如,该请求消息可以是Web页面的请求消息、视频请求消息等。
在第一数据为请求消息时,设备3中的用于提供该服务的服务模块可以提供该请求消息 请求的数据。在第一数据为升级包时,设备3中的用于提供该服务的服务模块基于第一数据进行升级。
可选的,第一报文的报文头包括该第一标识,第一报文的净荷部分包括第一数据。
第一格式可以为实时传输协议(real-time transport protocol,RTP)或RTSP的报文格式。
代理服务器2接收第一报文,根据该第一标识,从设备标识、服务类型与第一标识的对应关系中获取终端1请求的服务对应的服务类型和设备3的设备标识,根据该设备标识,判断与设备3是否存在P2P链路。在与设备3之间存在P2P链路时,通过该P2P链路向设备3发送第二报文,第二报文包括该服务类型。在与设备3之间不存在P2P链路时,建立与设备3之间的P2P链路,通过该建立的P2P链路向设备3发送第二报文,第二报文包括该服务类型和第一数据。
作为一种示例,代理服务器2可以保存有设备标识与链路标识的对应关系,该对应关系中的每条记录包括一设备标识和代理服务器2与该一设备标识对应的设备之间当前存在的P2P链路的链路标识。例如,参见下表2所示的设备标识与链路标识的对应关系,该对应关系中的P2P链路的链路标识可以是该P2P链路对应的端口号,该端口号是该P2P链路在代理服务器2中对应的端口的端口号,该端口是P2P链路在代理服务器2侧的端点。
表2
设备标识 链路标识
894EAW 10090
…… ……
这样,代理服务器2可以根据设备3的设备标识,查询设备标识与链路标识的对应关系,在查询出对应的链路标识时,确定代理服务器2与设备3之间存在该链路标识对应的P2P链路,在没有查询出对应的链路标识时,确定代理服务器与设备3之间不存在P2P链路。
作为一种示例,代理服务器2中包括当前已存在的P2P链路对应的寄存器,P2P链路对应的寄存器用于保存与代理服务器2之间建立有该P2P链路的设备的设备标识。例如,对于设备标识“894EAW”对应的设备,代理服务器2中包括与该设备之间的P2P链路对应的寄存器,该寄存器保存该设备标识“894EAW”。
这样,代理服务器2根据设备3的设备标识,查找当前已存在的P2P链路对应的寄存器;在查询出保存有设备3的设备标识的寄存器时,确定该寄存器对应的P2P链路,且代理服务器2与设备3之间存在的P2P链路为确定的P2P链路;在没有查询出保存有设备3的设备标识的寄存器时,确定与设备3之间不存在P2P链路。
参见图3,该通信系统还包括P2P服务器5,代理服务器2在判断出与设备3之间不存在P2P链路时,通过P2P服务器5建立与设备3之间的P2P链路。
代理服务器2接收第一报文后,还可以分配第二标识,第二标识用于标识终端1和终端1请求的服务。
可选的,第二标识为代理服务器2分配的字符串,该字符串可以包括至少一个数字、至少一个字母或该字符串是至少一个数字和至少一个字符的组合等。
代理服务器2将第二标识、该设备标识和终端1与代理服务器2之间的第一连接的连接标识保存在第二标识、设备标识与连接标识的对应关系中;以及通过该P2P链路向设备3发 送格式为第二格式的第二报文,第二报文的报文头包括第二标识和该服务类型,第二报文的净荷部分包括第一数据。
第二格式与第一格式不同,第二格式可以为在P2P链路上传输的报文格式,第一格式可以为在第一连接上传输的报文格式。
可选的,代理服务器2中的P2P模块21可以通过该P2P链路向设备3发送格式为第二格式的第二报文。
设备3的P2P模块31通过该P2P链路接收第二报文,确定与该服务类型相对应的目标服务模块,通过P2P模块31与目标服务模块之间的第二连接向目标服务模块发送格式为第一格式的第五报文,第五报文包括第一数据,以使目标服务模块根据第一数据获取属于该服务的第二数据,第二连接为P2P模块31与目标服务模块之间的虚拟连接。
例如,在第一数据为用于请求该服务的请求消息时,假设该请求消息为Web页面的请求消息,目标服务模块根据该Web页面的请求消息,获取属于该服务的第二数据为Web页面。再例如,假设该请求消息为视频请求消息,目标服务模块根据该视频请求消息,获取属于该服务的第二数据为视频数据。或者,
在第一数据为用于升级目标服务模块的升级包时,目标服务模块根据该升级包进行升级。目标服务模块在升级结束后,得到第二数据为升级结果。
可选的,第五报文的净荷部分包括第一数据;P2P模块31将第二标识和第二连接的连接标识保存在第二标识与连接标识的对应关系中。
第二连接的连接类型与第一连接的连接类型相同,所以第一格式和在第二连接上传输报文的报文格式相同。
目标服务模块接收第五报文后,可以向终端1发送第二数据,第二数据属于该服务类型的服务,发送过程如下:
目标服务模块通过P2P模块31与目标服务模块之间的第二连接向P2P模块31发送格式为第一格式的第六报文,第六报文的净荷部分包括第二数据。
P2P模块31根据第二连接的连接标识,从第二标识与连接标识的对应关系中获取第二标识;通过该P2P链路向代理服务器2发送格式为第二格式的第三报文,第三报文的报文头包括第二标识,第三报文的净荷部分包括第二数据。
代理服务器2通过该P2P链路接收设备3发送的第三报文,第三报文的报文头包括第二标识,第三报文的净荷部分包括第二数据;根据第二标识和设备3的设备标识,从第二标识、设备标识与连接标识的对应关系中获取第一连接的连接标识;通过第一连接的连接标识对应的第一连接向终端1发送格式为第一格式的第四报文,第四报文的净荷部分包括第二数据。
第一连接的连接标识可以为第一连接的连接套接字,第二连接的连接标识可以为第二连接的连接套接字。
参见图4,本申请提供了一种基于P2P的服务通信方法,所述方法包括:
步骤101:接收第一报文,第一报文包括第一标识和第一数据,第一标识用于标识一设备和该设备中的服务,第一数据用于请求该设备中的用于提供该服务的服务模块执行操作。
步骤102:确定第一标识所标识的服务对应的设备标识和服务类型。
步骤103:在与该设备标识对应的设备之间存在P2P链路时,通过该P2P链路向该设备 发送第二报文,第二报文包括该服务类型和第一数据。
在本申请实施例中,接收到第一报文,确定第一报文中的第一标识所标识的服务对应的设备标识和服务类型,这样在与设备标识对应的设备之间存在P2P链路时,通过该P2P链路向设备发送第二报文,第二报文包括该服务类型和第一数据,如此设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,进而避免网络延时增加的现象发生。
参见图5,本申请提供了一种基于P2P的服务通信方法,所述方法应用于包括P2P模块和至少一个服务模块的设备,每个服务模块用于提供服务,所述方法包括:
步骤201:P2P模块通过设备与代理服务器之间的P2P链路接收第二报文,该设备包括该P2P模块和至少一个服务模块,每个服务模块用于提供服务,第二报文是代理服务器在终端请求该设备提供服务时发送的,第二报文包括终端请求的服务的服务类型和第一数据。
步骤202:P2P模块通过第二连接向目标服务模块发送第五报文,目标服务模块是与该服务类型相对应的服务模块,第五报文包括第一数据,第一数据用于请求目标服务模块执行操作,第二连接为P2P模块与目标服务模块之间的虚拟连接。
在本申请实施例中,P2P模块通过该设备与代理服务器之间的一条P2P链路接收第二报文,这样设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,进而避免网络延时增加的现象发生。
参见图6,本申请提供了一种基于P2P的服务通信方法,该通信方法可以应用于如图1所示的通信系统,包括:
步骤301:终端向代理服务器发送查询请求,该查询请求携带设备的设备标识和终端请求的服务对应的服务类型。
参见图2,该通信系统包括报警中心,报警中心可以接收设备的报警,报警中心通知用户,使该用户对设备的报警进行处理。例如,报警中心向用户对应的终端发送通知,该通知包括该设备的设备标识。
终端接收该通知,并向用户显示该通知。用户可以向终端输入请求设备提供的服务对应的服务类型。终端通过第一连接向代理服务器发送查询请求,该查询请求携带该设备的设备标识和终端请求的服务对应的服务类型。
步骤302:代理服务器接收该查询请求,根据该查询请求携带的设备标识和服务类型,获取第一标识,向终端发送查询响应,该查询响应携带第一标识。
第一标识用于标识该设备和该设备中提供的与该服务类型相对应的服务。代理服务器可以事先为设备中的每个服务分配第一标识,将设备的设备标识、设备中的每个服务对应的服务类型和第一标识对应保存在设备标识、服务类型与第一标识的对应关系。
可选的,该设备在上电启动时可以向代理服务器发送用于分配第一标识的注册请求消息,该注册请求消息中包括该设备中的每个服务对应的服务类型。代理服务器接收该注册请求消息,根据该设备中的每个服务对应的服务类型,为该设备中的每个服务分配第一标识,该服务的第一标识可以在代理服务器中唯一标识该服务。
作为一种示例,为服务分配的第一标识可以为端口号。代理服务器可以基于该端口号建立与终端之间的第一连接。终端与代理服务器之间的第一连接可以为TCP连接或RTSP连接 等。
在本步骤中,代理服务器根据该查询请求携带的设备标识和服务类型,从设备标识、服务类型与第一标识的对应关系获取对应的第一标识,向终端发送查询响应,该查询响应携带该第一标识。
终端接收第一标识后,使用第一标识向设备发送报文。详细实现过程如下:
步骤303:终端向代理服务器发送第一报文,第一报文包括第一标识和第一数据。
第一报文的报文头可以包括第一标识,第一报文的净荷部分可以包括第一数据。
第一报文的报文头中包括端口号字段,该端口号字段携带第一标识。
第一报文的报文格式为第一格式,第一格式可以为RTP或RTSP的报文格式。
第一标识用于标识一设备和该设备中的服务。第一数据可以用于请求该设备中的用于提供该服务的服务模块执行操作。
第一数据可以是请求消息,例如可以是Web页面的请求消息、视频请求消息等。第一数据用于请求该服务模块提供属于该服务的数据。或者,
第一数据为用于升级该服务模块的升级包,第一数据用于请求该服务模块进行升级。
参见下表3,第一格式的第一报文的报文头和净荷部件,第一报文的报文头包括互联网协议地址(internet protocol address,IP)头和TCP头。
表3
IP头 TCP头 净荷部分
第一格式可以为在第一连接上传输的报文的报文格式。第一格式可以为RTP或RTSP协议的报文格式。所以终端可以通过第一连接向代理服务器发送第一格式的第一报文。
步骤304:代理服务器接收第一报文,确定第一标识所标识的服务对应的设备标识和服务类型。
在本步骤中,代理服务器可以根据第一标识从第一标识、服务类型与设备标识的对应关系中获取终端请求的服务对应的服务类型和设备的设备标识。
例如,假设第一报文的报文头中包括第一标识为10554,代理服务器根据该第一标识10554,从如表1所示的设备标识、服务类型与第一标识的对应关系中获取对应的设备的设备标识为“894EAW”和服务类型为RTSP协议。
步骤305:代理服务器分配第二标识,第二标识用于标识该终端和终端请求的服务。
终端可以请求设备提供多个服务,代理服务器可以在该P2P链路上传输用于请求每个服务的报文。或者,多个终端可以请求设备提供服务,代理服务器可以在该P2P链路上传输每个终端请求服务的报文。所以该一条P2P链路可以用于传输多个服务的数据或多个终端请求的服务的数据。对于每个终端请求的服务,可以使用第二标识来标识该终端和该终端提供的服务,从而可以使用第二标识来区分不同终端请求的不同服务,以实现在该一条P2P链路上传输多个服务的数据或多个终端请求服务的数据。
可选的,分配的第二标识为字符串,该字符串用于在代理服务器标识该终端和该终端请求的服务。
步骤306:代理服务器将第二标识、该设备标识、以及终端与代理服务器之间的第一连接的连接标识保存在第二标识、设备标识与连接标识的对应关系中。
可选的,第一连接的连接标识可以为第一连接的连接套接字等。
步骤307:代理服务器根据该设备标识,判断与设备是否存在P2P链路,在与设备之间存在P2P链路时,执行如下步骤308,在与设备之间不存在P2P链路时,建立与设备之间的P2P链路。
代理服务器可以保存有设备标识与链路标识的对应关系,该对应关系中的每条记录包括一设备标识和与该一设备标识对应的设备之间当前存在的P2P链路的链路标识。
这样,在本步骤中:代理服务器可以根据该设备的设备标识,查询设备标识与链路标识的对应关系,在查询出对应的链路标识时,确定与设备之间存在该链路标识对应的P2P链路,在没有查询出对应的链路标识时,确定与设备之间不存在P2P链路。或者,
代理服务器中包括当前已存在的P2P链路对应的寄存器,P2P链路对应的寄存器用于保存与代理服务器建立该P2P链路的设备的设备标识。
这样,在本步骤中:代理服务器根据设备的设备标识,查找当前已存在的P2P链路对应的寄存器;在查询出保存有设备的设备标识的寄存器时,确定与设备之间存在查询出的寄存器对应的P2P链路;在没有查询出保存有设备的设备标识的寄存器时,确定与设备之间不存在P2P链路。
步骤308:代理服务器通过该P2P链路向设备发送第二报文,第二报文包括第二标识、该服务类型和第一数据。
第二报文的报文头包括第二标识和该服务类型,第二报文的净荷部分包括第一数据。
第二报文的报文格式可以为第二格式,第一格式与第二格式不同,第二格式可以为在P2P链路上传输的报文格式。
参见下表4,第二格式的第二报文的报文头和净荷部分,第二报文的报文头包括IP头、用户数据报协议(user datagram protocol,UDP)头、P2P头和代理协议头。代理协议头中可以包括第二标识和该服务类型。
表4
IP头 UDP头 P2P头 代理协议头 净荷部分
步骤309:设备的P2P模块通过该P2P链路接收第二报文,确定与该服务类型相对应的目标服务模块,通过P2P模块与目标服务模块之间的第二连接向目标服务模块发送第五报文。
可选的,在本步骤中,设备的P2P模块接收第二报文,将第二报文转换成第一格式的第五报文,第五报文的净荷部分包括第一数据。
P2P模块确定该服务类型相对应的目标服务模块后,建立P2P模块与该目标服务模块之间的第二连接,第二连接用于传输属于该终端当前请求的服务的数据。
第二连接可以为虚拟连接等。
第五报文的报文格式为第一格式,可以在P2P模块与目标服务模块之间的第二连接上传输。
步骤310:P2P模块将第二标识和第二连接的连接标识对应保存在第二标识与连接标识的对应关系中。
第二连接的连接标识可以为第二连接的连接套接字等。
目标服务模块接收第五报文,根据第五报文的净荷部分包括的第一数据执行操作。
在第一数据为用于请求该服务的请求消息时,目标服务模块根据第一数据获取属于该服务的第二数据,通过第二连接向P2P模块发送格式为第一格式的第六报文,第六报文的净荷部分包括第二数据。例如,假设该请求消息为Web页面的请求消息,目标服务模块根据该Web页面的请求消息,获取属于该服务的第二数据为Web页面。再例如,假设该请求消息为视频请求消息,目标服务模块根据该视频请求消息,获取属于该服务的第二数据为视频数据。或者,
在第一数据为用于升级目标服务模块的升级包时,目标服务模块根据该升级包进行升级。目标服务模块在升级结束后,可以通过第二连接向P2P模块发送格式为第一格式的第六报文,第六报文的净荷部分包括第二数据,第二数据为升级结果。
步骤311:P2P模块通过与目标服务模块之间的第二连接接收目标服务模块发送的第六报文。
步骤312:P2P模块根据第二连接的连接标识,从第二标识与连接标识的对应关系中获取第二标识。
步骤313:P2P模块通过该P2P链路向代理服务器发送格式为第二格式的第三报文,第三报文包括该设备的设备标识、第二标识和第二数据。
可选的,在本步骤中,P2P模块接收第六报文后,将第六报文转换成第二格式的第三报文,第三报文的报文头可以包括第二标识,第三报文的净荷部分可以包括第二数据。
步骤314:代理服务器通过该P2P链路接收第三报文,根据第三报文包括的第二标识和该设备的设备标识,从第二标识、设备标识与连接标识的对应关系中获取第一连接的连接标识。
步骤315:代理服务器通过第一连接的连接标识对应的第一连接向终端发送格式为第一格式的第四报文,第四报文的净荷部分包括第二数据。
可选的,在本步骤中,代理服务器接收第三报文后,将第三报文转换成第一格式的第四报文。
终端从第一连接上接收第四报文。
在本申请实施例中,由于代理服务器接收终端发送的第一报文时,分配用于标识终端和终端请求的服务的第二标识,将第二标识、该设备标识、第一连接的连接标识保存在第二标识、设备标识与连接标识的对应关系中。代理服务器通过该P2P链路向该设备发送包括第二标识和该服务类型的第二报文,这样该设备向代理服务器发送第三报文可以包括该设备标识和第二标识,代理服务器接收到第三报文后可以基于该设备标识和第二标识获取到第一连接的连接标识,从而基于该连接标识对应的第一连接向该终端发送报文。如此可以通过第一标识区别在代理服务器与设备之间的P2P链路上传输的终端请求的多个服务或多个终端请求的服务,如此设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,进而避免网络延时增加的现象发生。
下述为本申请装置实施例,可以用于执行本申请方法实施例。对于本申请装置实施例中未披露的细节,请参照本申请方法实施例。
参见图7,本申请实施例提供了一种基于P2P的服务通信装置400,所述装置400可以部 署上述任一实施例提供的代理服务器中,包括:
接收模块401,用于接收第一报文,所述第一报文包括第一标识和第一数据,所述第一标识用于标识一设备和所述设备中的服务,所述第一数据用于请求所述设备中的用于提供所述服务的服务模块执行操作;
确定模块402,用于确定所述第一标识所标识的服务对应的设备标识和服务类型;
发送模块403,用于在与所述设备标识对应的设备之间存在P2P链路时,通过所述P2P链路向所述设备发送第二报文,所述第二报文包括所述服务类型和所述第一数据。
可选的,所述装置400还包括:
建立模块,用于在与所述设备标识对应的设备之间不存在P2P链路时,建立与所述设备之间的P2P链路;
所述发送模块403,还用于通过所述建立的P2P链路向所述设备发送所述第二报文。
可选的,所述装置400还包括:
第一查询模块,用于根据所述设备的设备标识,查询设备标识与链路标识的对应关系,所述对应关系中的每条记录包括一设备标识和与所述一设备标识对应的设备之间当前存在的P2P链路的链路标识;在查询出对应的链路标识时,确定与所述设备之间存在所述链路标识对应的P2P链路,在没有查询出对应的链路标识时,确定与所述设备之间不存在P2P链路。
可选的,所述装置还包括:
第二查询模块,用于根据所述设备的设备标识,查询当前已存在的P2P链路对应的寄存器;在查询出保存有所述设备的设备标识的寄存器时,确定与所述设备之间存在所述查询出的寄存器对应的P2P链路;在没有查询出保存有所述设备的设备标识的寄存器时,确定与所述设备之间不存在P2P链路。
可选的,所述第二报文还包括第二标识,所述第二标识用于标识发送所述第一报文的终端和所述服务;所述装置400还包括:
第一保存模块,用于分配所述第二标识,将所述第二标识、所述设备标识、第一连接的连接标识保存在第一标识、设备标识与连接标识的对应关系中,所述第一连接为与所述终端之间的用于传输所述第一报文的连接。
可选的,所述装置400还包括获取模块,
所述接收模块401,还用于通过所述P2P链路接收所述设备发送的第三报文,所述第三报文包括所述第二标识、所述设备的设备标识和属于所述服务的第二数据;
所述确定模块,用于根据所述第二标识和所述设备的设备标识,从所述第二标识、设备标识与连接标识的对应关系中获取所述第一连接的连接标识;
所述发送模块403,还用于通过所述连接标识对应的第一连接向所述终端发送所述第四报文,所述第四报文包括所述第二数据。
可选的,所述第一报文和所述第三报文的报文格式为第一格式,所述第一格式为在所述第一连接上传输的报文格式;
所述第二报文的报文格式为第二格式,所述第二格式为在所述P2P链路上传输的报文格式,所述第一格式和所述第二格式不同。
可选的,所述装置400还包括:第二保存模块,
所述接收模块401,还用于接收所述设备发送的注册请求消息,所述注册请求消息包括 所述设备的设备标识和所述设备提供的服务的服务类型;
所述第二保存模块,用于分配第一标识,将所述第一标识、所述设备的设备标识和所述设备提供的服务的服务类型对应保存在第一标识、设备标识与服务类型的对应关系中。
在本申请实施例中,接收模块接收终端发送的第一报文时,确定模块分配用于标识终端和终端请求的服务的第二标识,保存模块将第二标识、该设备标识、第一连接的连接标识保存在第二标识、设备标识与连接标识的对应关系中。这样在发送模块通过该P2P链路向该设备发送包括第二标识、服务类型和第一数据的第二报文后,如果接收模块接收到该设备返回的携带有该设备标识和第二标识的报文,则可以基于该设备标识和第二标识获取到第一连接的连接标识,从而基于该连接标识对应的第一连接向该终端发送该报文。如此可以通过第二标识区别在代理服务器与设备之间的P2P链路上传输的终端请求的多个服务或多个终端请求的服务,如此设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,进而避免网络延时增加的现象发生。
参见图8,本申请实施例提供了一种基于P2P的服务通信装置500,所述装置500用于包括所述装置500和至少一个服务模块的设备,每个服务模块用于提供服务,所述装置500包括:
接收模块501,用于通过设备与代理服务器之间的P2P链路接收第二报文,所述第二报文是所述代理服务器在终端请求所述设备提供服务时发送的,所述第二报文包括所述终端请求的服务的服务类型和第一数据;
发送模块502,用于通过第二连接向目标服务模块发送第五报文,所述目标服务模块是与所述服务类型相对应的服务模块,所述第五报文包括所述第一数据,所述第一数据用于请求所述目标服务模块执行操作,所述第二连接为与目标服务模块之间的虚拟连接。
可选的,所述第二报文的报文头还包括第二标识,所述第二标识用于标识所述终端和所述终端请求的服务;所述装置500还包括:
保存模块,用于将所述第二标识和所述第二连接的连接标识保存在第二标识与连接标识的对应关系中。
可选的,所述装置500还包括获取模块,
所述接收模块501,还用于通过所述第二连接接收第六报文,所述第六报文包括所述第二数据;
所述获取模块,用于根据所述第二连接的连接标识,从第二标识与连接标识的对应关系中获取所述第二标识;
所述发送模块502,还用于通过所述P2P链路向所述代理服务器发送第三报文,所述第三报文包括所述设备的设备标识、所述第二标识和所述第二数据。
可选的,所述第五报文和所述第六报文的报文格式为第一格式,所述第一格式为在所述第二连接上传输的报文格式;
所述第二报文的报文格式为第二格式,所述第二格式为在所述P2P链路上传输的报文格式,所述第一格式和所述第二格式不同。
在本申请实施例中,接收模块通过该设备与代理服务器之间的P2P链路接收包括第二标识和服务类型的第二报文,这样在向代理服务器发送报文时,该报文可以包括该设备标识和 第二标识,使得代理服务器可以基于该设备标识和第二标识获取到第一连接的连接标识,从而基于该连接标识对应的第一连接向该终端发送该报文。如此第二标识用于标识终端和终端请求的服务,这样可以通过第二标识区别在代理服务器与所述装置之间的P2P链路上传输的终端请求的多个服务或多个终端请求的服务,所述装置只需要建立一条P2P链路即可,避免了给所述装置建立大量的P2P链路,进而避免网络延时增加的现象发生。
参见图9,本申请实施例提供了一种通信系统600,所述系统600包括如图6所述的装置和如图7所述的装置。如图6所述的装置可以为代理服务器601,如图7所述的装置可以为设备602。
关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。
图10示出了本申请一个示例性实施例提供的电子设备700的结构框图。该电子设备700可以是终端,比如:智能手机、平板电脑、笔记本电脑或台式电脑。电子设备700还可能被称为用户设备、便携式终端、膝上型终端、台式终端等其他名称。
通常,电子设备700包括有:处理器701和存储器702。
处理器701可以包括一个或多个处理核心,比如4核心处理器、8核心处理器等。处理器701可以采用DSP(Digital Signal Processing,数字信号处理)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)、PLA(Programmable Logic Array,可编程逻辑阵列)中的至少一种硬件形式来实现。处理器701也可以包括主处理器和协处理器,主处理器是用于对在唤醒状态下的数据进行处理的处理器,也称CPU(Central Processing Unit,中央处理器);协处理器是用于对在待机状态下的数据进行处理的低功耗处理器。在一些实施例中,处理器701可以在集成有GPU(Graphics Processing Unit,图像处理器),GPU用于负责显示屏所需要显示的内容的渲染和绘制。一些实施例中,处理器701还可以包括AI(Artificial Intelligence,人工智能)处理器,该AI处理器用于处理有关机器学习的计算操作。
存储器702可以包括一个或多个计算机可读存储介质,该计算机可读存储介质可以是非暂态的。存储器702还可包括高速随机存取存储器,以及非易失性存储器,比如一个或多个磁盘存储设备、闪存存储设备。在一些实施例中,存储器702中的非暂态的计算机可读存储介质用于存储至少一个指令,该至少一个指令用于被处理器701所执行以实现本申请中方法实施例提供的一种基于P2P的服务通信方法。
在一些实施例中,电子设备700还可选包括有:外围设备接口703和至少一个外围设备。处理器701、存储器702和外围设备接口703之间可以通过总线或信号线相连。各个外围设备可以通过总线、信号线或电路板与外围设备接口703相连。具体地,外围设备包括:射频电路704、触摸显示屏705、摄像头706、音频电路707、定位组件708和电源709中的至少一种。
外围设备接口703可被用于将I/O(Input/Output,输入/输出)相关的至少一个外围设备连接到处理器701和存储器702。在一些实施例中,处理器701、存储器702和外围设备接口703被集成在同一芯片或电路板上;在一些其他实施例中,处理器701、存储器702和外围设 备接口703中的任意一个或两个可以在单独的芯片或电路板上实现,本实施例对此不加以限定。
射频电路704用于接收和发射RF(Radio Frequency,射频)信号,也称电磁信号。射频电路704通过电磁信号与通信网络以及其他通信设备进行通信。射频电路704将电信号转换为电磁信号进行发送,或者,将接收到的电磁信号转换为电信号。可选地,射频电路704包括:天线系统、RF收发器、一个或多个放大器、调谐器、振荡器、数字信号处理器、编解码芯片组、用户身份模块卡等等。射频电路704可以通过至少一种无线通信协议来与其它终端进行通信。该无线通信协议包括但不限于:万维网、城域网、内联网、各代移动通信网络(2G、3G、4G及5G)、无线局域网和/或WiFi(Wireless Fidelity,无线保真)网络。在一些实施例中,射频电路704还可以包括NFC(Near Field Communication,近距离无线通信)有关的电路,本申请对此不加以限定。
显示屏705用于显示UI(User Interface,用户界面)。该UI可以包括图形、文本、图标、视频及其它们的任意组合。当显示屏705是触摸显示屏时,显示屏705还具有采集在显示屏705的表面或表面上方的触摸信号的能力。该触摸信号可以作为控制信号输入至处理器701进行处理。此时,显示屏705还可以用于提供虚拟按钮和/或虚拟键盘,也称软按钮和/或软键盘。在一些实施例中,显示屏705可以为一个,设置电子设备700的前面板;在另一些实施例中,显示屏705可以为至少两个,分别设置在电子设备700的不同表面或呈折叠设计;在再一些实施例中,显示屏705可以是柔性显示屏,设置在电子设备700的弯曲表面上或折叠面上。甚至,显示屏705还可以设置成非矩形的不规则图形,也即异形屏。显示屏705可以采用LCD(Liquid Crystal Display,液晶显示屏)、OLED(Organic Light-Emitting Diode,有机发光二极管)等材质制备。
摄像头组件706用于采集图像或视频。可选地,摄像头组件706包括前置摄像头和后置摄像头。通常,前置摄像头设置在电子设备700的前面板,后置摄像头设置在电子设备700的背面。在一些实施例中,后置摄像头为至少两个,分别为主摄像头、景深摄像头、广角摄像头、长焦摄像头中的任意一种,以实现主摄像头和景深摄像头融合实现背景虚化功能、主摄像头和广角摄像头融合实现全景拍摄以及VR(Virtual Reality,虚拟现实)拍摄功能或者其它融合拍摄功能。在一些实施例中,摄像头组件706还可以包括闪光灯。闪光灯可以是单色温闪光灯,也可以是双色温闪光灯。双色温闪光灯是指暖光闪光灯和冷光闪光灯的组合,可以用于不同色温下的光线补偿。
音频电路707可以包括麦克风和扬声器。麦克风用于采集用户及环境的声波,并将声波转换为电信号输入至处理器701进行处理,或者输入至射频电路704以实现语音通信。出于立体声采集或降噪的目的,麦克风可以为多个,分别设置在电子设备700的不同部位。麦克风还可以是阵列麦克风或全向采集型麦克风。扬声器则用于将来自处理器701或射频电路704的电信号转换为声波。扬声器可以是传统的薄膜扬声器,也可以是压电陶瓷扬声器。当扬声器是压电陶瓷扬声器时,不仅可以将电信号转换为人类可听见的声波,也可以将电信号转换为人类听不见的声波以进行测距等用途。在一些实施例中,音频电路707还可以包括耳机插孔。
定位组件708用于定位电子设备700的当前地理位置,以实现导航或LBS(Location Based Service,基于位置的服务)。定位组件708可以是基于美国的GPS(Global Positioning System, 全球定位系统)、中国的北斗系统或俄罗斯的伽利略系统的定位组件。
电源709用于为电子设备700中的各个组件进行供电。电源709可以是交流电、直流电、一次性电池或可充电电池。当电源709包括可充电电池时,该可充电电池可以是有线充电电池或无线充电电池。有线充电电池是通过有线线路充电的电池,无线充电电池是通过无线线圈充电的电池。该可充电电池还可以用于支持快充技术。
在一些实施例中,电子设备700还包括有一个或多个传感器710。该一个或多个传感器710包括但不限于:加速度传感器711、陀螺仪传感器712、压力传感器713、指纹传感器714、光学传感器715以及接近传感器716。
加速度传感器711可以检测以电子设备700建立的坐标系的三个坐标轴上的加速度大小。比如,加速度传感器711可以用于检测重力加速度在三个坐标轴上的分量。处理器701可以根据加速度传感器711采集的重力加速度信号,控制触摸显示屏705以横向视图或纵向视图进行用户界面的显示。加速度传感器711还可以用于游戏或者用户的运动数据的采集。
陀螺仪传感器712可以检测电子设备700的机体方向及转动角度,陀螺仪传感器712可以与加速度传感器711协同采集用户对电子设备700的3D动作。处理器701根据陀螺仪传感器712采集的数据,可以实现如下功能:动作感应(比如根据用户的倾斜操作来改变UI)、拍摄时的图像稳定、游戏控制以及惯性导航。
压力传感器713可以设置在电子设备700的侧边框和/或触摸显示屏705的下层。当压力传感器713设置在电子设备700的侧边框时,可以检测用户对电子设备700的握持信号,由处理器701根据压力传感器713采集的握持信号进行左右手识别或快捷操作。当压力传感器713设置在触摸显示屏705的下层时,由处理器701根据用户对触摸显示屏705的压力操作,实现对UI界面上的可操作性控件进行控制。可操作性控件包括按钮控件、滚动条控件、图标控件、菜单控件中的至少一种。
指纹传感器714用于采集用户的指纹,由处理器701根据指纹传感器714采集到的指纹识别用户的身份,或者,由指纹传感器714根据采集到的指纹识别用户的身份。在识别出用户的身份为可信身份时,由处理器701授权该用户执行相关的敏感操作,该敏感操作包括解锁屏幕、查看加密信息、下载软件、支付及更改设置等。指纹传感器714可以被设置电子设备700的正面、背面或侧面。当电子设备700上设置有物理按键或厂商Logo时,指纹传感器714可以与物理按键或厂商Logo集成在一起。
光学传感器715用于采集环境光强度。在一个实施例中,处理器701可以根据光学传感器715采集的环境光强度,控制触摸显示屏705的显示亮度。具体地,当环境光强度较高时,调高触摸显示屏705的显示亮度;当环境光强度较低时,调低触摸显示屏705的显示亮度。在另一个实施例中,处理器701还可以根据光学传感器715采集的环境光强度,动态调整摄像头组件706的拍摄参数。
接近传感器716,也称距离传感器,通常设置在电子设备700的前面板。接近传感器716用于采集用户与电子设备700的正面之间的距离。在一个实施例中,当接近传感器716检测到用户与电子设备700的正面之间的距离逐渐变小时,由处理器701控制触摸显示屏705从亮屏状态切换为息屏状态;当接近传感器716检测到用户与电子设备700的正面之间的距离逐渐变大时,由处理器701控制触摸显示屏705从息屏状态切换为亮屏状态。
本领域技术人员可以理解,图10中示出的结构并不构成对电子设备700的限定,可以包 括比图示更多或更少的组件,或者组合某些组件,或者采用不同的组件布置。
在示例性实施例中,本申请还提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质中存储有代码指令,所述代码指令由处理器执行,以执行上述实施例提供的基于P2P的服务通信方法。例如,所述非易失性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。
在本申请实施例中,由于接收终端发送的第一报文时,分配用于标识终端和终端请求的服务的第二标识,将第二标识、该设备标识、第一连接的连接标识保存在第二标识、设备标识与连接标识的对应关系中。通过该P2P链路向该设备发送包括第二标识和该服务类型的第二报文,这样在该设备发送的第三报文中可以包括该设备标识和第二标识,接收到第三报文后可以基于该设备标识和第二标识获取到第一连接的连接标识,从而基于该连接标识对应的第一连接向该监控终端发送报文。如此可以通过第一标识区别与设备之间的P2P链路上传输的终端请求的多个服务或多个终端请求的服务,如此设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,进而避免网络延时增加的现象发生。
在示例性实施例中,本公开还提供了一种计算机程序产品,所述计算机程序产品包括在计算机可读存储介质中存储的计算机程序,并且所述计算程序通过处理器进行加载来实现上述实施例提供的基于P2P的服务通信方法。
在本申请实施例中,由于接收终端发送的第一报文时,分配用于标识终端和终端请求的服务的第二标识,将第二标识、该设备标识、第一连接的连接标识保存在第二标识、设备标识与连接标识的对应关系中。通过该P2P链路向该设备发送包括第二标识和该服务类型的第二报文,这样在该设备发送的第三报文中可以包括该设备标识和第二标识,接收到第三报文后可以基于该设备标识和第二标识获取到第一连接的连接标识,从而基于该连接标识对应的第一连接向该终端发送报文。如此可以通过第一标识区别在与设备之间的P2P链路上传输的终端请求的多个服务或多个终端请求的服务,如此设备只需要建立一条P2P链路即可,避免了给设备建立大量的P2P链路,进而避免网络延时增加的现象发生。
本领域技术人员在考虑说明书及实践这里公开的申请后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求指出。
应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求来限制。

Claims (21)

  1. 一种基于P2P的服务通信方法,所述方法包括:
    接收第一报文,所述第一报文包括第一标识和第一数据,所述第一标识用于标识一设备和所述设备中的服务,所述第一数据用于请求所述设备中的用于提供所述服务的服务模块执行操作;
    确定所述第一标识所标识的服务对应的设备标识和服务类型;
    在与所述设备标识对应的设备之间存在P2P链路时,通过所述P2P链路向所述设备发送第二报文,所述第二报文包括所述服务类型和所述第一数据。
  2. 如权利要求1所述的方法,其中,所述方法还包括:
    在与所述设备标识对应的设备之间不存在P2P链路时,建立与所述设备之间的P2P链路,通过所述建立的P2P链路向所述设备发送所述第二报文。
  3. 如权利要求1所述的方法,其中,所述通过所述P2P链路向所述设备发送第二报文之前,还包括:
    根据所述设备的设备标识,查询设备标识与链路标识的对应关系,所述对应关系中的每条记录包括一设备标识和与所述一设备标识对应的设备之间当前存在的P2P链路的链路标识;在查询出对应的链路标识时,确定与所述设备之间存在所述链路标识对应的P2P链路,在没有查询出对应的链路标识时,确定与所述设备之间不存在P2P链路;或者,
    根据所述设备的设备标识,查询当前已存在的P2P链路对应的寄存器;在查询出保存有所述设备的设备标识的寄存器时,确定与所述设备之间存在所述查询出的寄存器对应的P2P链路;在没有查询出保存有所述设备的设备标识的寄存器时,确定与所述设备之间不存在P2P链路。
  4. 如权利要求1所述的方法,其中,所述第二报文还包括第二标识,所述第二标识用于标识发送所述第一报文的终端和所述服务;所述方法还包括:
    分配所述第二标识,将所述第二标识、所述设备标识、第一连接的连接标识保存在第一标识、设备标识与连接标识的对应关系中,所述第一连接为与所述终端之间的用于传输所述第一报文的连接。
  5. 如权利要求4所述的方法,其中,所述通过所述P2P链路向所述设备发送第二报文之后,还包括:
    通过所述P2P链路接收所述设备发送的第三报文,所述第三报文包括所述第二标识、所述设备的设备标识和属于所述服务的第二数据;
    根据所述第二标识和所述设备的设备标识,从所述第二标识、设备标识与连接标识的对应关系中获取所述第一连接的连接标识;
    通过所述连接标识对应的第一连接向所述终端发送所述第四报文,所述第四报文包括所述第二数据。
  6. 如权利要求1至5任一项所述的方法,其中,所述获取所述服务的服务类型和所述设备的设备标识之前,还包括:
    接收所述设备发送的注册请求消息,所述注册请求消息包括所述设备的设备标识和所述设备提供的服务的服务类型;
    分配第一标识,将所述第一标识、所述设备的设备标识和所述设备提供的服务的服务类型对应保存在第一标识、设备标识与服务类型的对应关系中。
  7. 一种基于P2P的服务通信方法,所述方法包括:
    P2P模块通过设备与代理服务器之间的P2P链路接收第二报文,所述设备包括所述P2P模块和至少一个服务模块,每个服务模块用于提供服务,所述第二报文是所述代理服务器在终端请求所述设备提供服务时发送的,所述第二报文包括所述终端请求的服务的服务类型和第一数据;
    所述P2P模块通过第二连接向目标服务模块发送第五报文,所述目标服务模块是与所述服务类型相对应的服务模块,所述第五报文包括所述第一数据,所述第一数据用于请求所述目标服务模块执行操作,所述第二连接为所述P2P模块与目标服务模块之间的虚拟连接。
  8. 如权利要求7所述的方法,其中,所述第二报文的报文头还包括第二标识,所述第二标识用于标识所述终端和所述终端请求的服务;
    所述P2P模块通过设备与代理服务器之间的P2P链路接收第二报文之后,还包括:
    所述P2P模块将所述第二标识和所述第二连接的连接标识对应保存在第一标识与连接标识的对应关系中。
  9. 如权利要求8所述的方法,其中,所述P2P模块通过第二连接向所述目标服务模块发送第五报文之后,还包括:
    所述P2P模块通过所述第二连接接收第六报文,所述第六报文包括所述第二数据;
    所述P2P模块根据所述第二连接的连接标识,从所述第二标识与连接标识的对应关系中获取所述第二标识;
    所述P2P模块通过所述P2P链路向所述代理服务器发送第三报文,所述第三报文包括所述设备的设备标识、所述第二标识和所述第二数据。
  10. 一种基于P2P的服务通信装置,所述装置包括:
    接收模块,用于接收第一报文,所述第一报文包括第一标识和第一数据,所述第一标识用于标识一设备和所述设备中的服务,所述第一数据用于请求所述设备中的用于提供所述服务的服务模块执行操作;
    确定模块,用于确定所述第一标识所标识的服务对应的设备标识和服务类型;
    发送模块,用于在与所述设备标识对应的设备之间存在P2P链路时,通过所述P2P链路向所述设备发送第二报文,所述第二报文包括所述服务类型和所述第一数据。
  11. 如权利要求12所述的装置,其中,所述装置还包括:
    建立模块,用于在与所述设备标识对应的设备之间不存在P2P链路时,建立与所述设备之间的P2P链路;
    所述发送模块,还用于通过所述建立的P2P链路向所述设备发送所述第二报文。
  12. 如权利要求10所述的装置,其中,所述装置还包括:
    第一查询模块,用于根据所述设备的设备标识,查询设备标识与链路标识的对应关系,所述对应关系中的每条记录包括一设备标识和与所述一设备标识对应的设备之间当前存在的P2P链路的链路标识;在查询出对应的链路标识时,确定与所述设备之间存在所述链路标识对应的P2P链路,在没有查询出对应的链路标识时,确定与所述设备之间不存在P2P链路;或者,
    第二查询模块,用于根据所述设备的设备标识,查询当前已存在的P2P链路对应的寄存器;在查询出保存有所述设备的设备标识的寄存器时,确定与所述设备之间存在所述查询出的寄存器对应的P2P链路;在没有查询出保存有所述设备的设备标识的寄存器时,确定与所述设备之间不存在P2P链路。
  13. 如权利要求10所述的装置,其中,所述第二报文还包括第二标识,所述第二标识用于标识发送所述第一报文的终端和所述服务;所述装置还包括:
    第一保存模块,用于分配所述第二标识,将所述第二标识、所述设备标识、第一连接的连接标识保存在第一标识、设备标识与连接标识的对应关系中,所述第一连接为与所述终端之间的用于传输所述第一报文的连接。
  14. 如权利要求13所述的装置,其中,所述装置还包括获取模块,
    所述接收模块,还用于通过所述P2P链路接收所述设备发送的第三报文,所述第三报文包括所述第二标识、所述设备的设备标识和属于所述服务的第二数据;
    所述获取模块,用于根据所述第二标识和所述设备的设备标识,从所述第二标识、设备标识与连接标识的对应关系中获取所述第一连接的连接标识;
    所述发送模块,还用于通过所述连接标识对应的第一连接向所述终端发送所述第四报文,所述第四报文包括所述第二数据。
  15. 如权利要求10至14任一项所述的装置,其中,所述装置还包括:第二保存模块,
    所述接收模块,还用于接收所述设备发送的注册请求消息,所述注册请求消息包括所述设备的设备标识和所述设备提供的服务的服务类型;
    所述第二保存模块,用于分配第一标识,将所述第一标识、所述设备的设备标识和所述设备提供的服务的服务类型对应保存在第一标识、设备标识与服务类型的对应关系中。
  16. 一种基于P2P的服务通信装置,所述装置包括:
    接收模块,用于通过设备与代理服务器之间的P2P链路接收第二报文,所述设备包括至少一个服务模块,每个服务模块用于提供服务,所述第二报文是所述代理服务器在终端请求 所述设备提供服务时发送的,所述第二报文包括所述终端请求的服务的服务类型和第一数据;
    发送模块,用于通过第二连接向目标服务模块发送第五报文,所述目标服务模块是与所述服务类型相对应的服务模块,所述第五报文包括所述第一数据,所述第一数据用于请求所述目标服务模块执行操作,所述第二连接为与目标服务模块之间的虚拟连接。
  17. 如权利要求16所述的装置,其中,所述第二报文的报文头还包括第二标识,所述第二标识用于标识所述终端和所述终端请求的服务;所述装置还包括:
    保存模块,用于将所述第二标识和所述第二连接的连接标识保存在第二标识与连接标识的对应关系中。
  18. 如权利要求17所述的装置,其中,所述装置还包括获取模块,
    所述接收模块,还用于通过所述第二连接接收第六报文,所述第六报文包括所述第二数据;
    所述获取模块,用于根据所述第二连接的连接标识,从第二标识与连接标识的对应关系中获取所述第二标识;
    所述发送模块,还用于通过所述P2P链路向所述代理服务器发送第三报文,所述第三报文包括所述设备的设备标识、所述第二标识和所述第二数据。
  19. 一种基于P2P的服务通信系统,所述系统包括如权利要求10至15任一项所述的装置和如权利要求16至18任一项所述的装置。
  20. 一种非易失性计算机可读存储介质,用于存储至少一个指令,所述至少一个指令被处理器加载并运行,以实现如权利要求1至9任一项所述的方法。
  21. 一种计算机程序产品,所述计算机程序产品包括在计算机可读存储介质中存储的计算机程序,并且所述计算程序通过处理器进行加载来实现如权利要求1至9任一项所述的方法。
PCT/CN2020/106333 2019-08-01 2020-07-31 一种基于p2p的服务通信方法、装置及系统 WO2021018297A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910708630.7 2019-08-01
CN201910708630.7A CN111355774B (zh) 2019-08-01 2019-08-01 一种基于p2p的服务通信方法、装置及系统

Publications (1)

Publication Number Publication Date
WO2021018297A1 true WO2021018297A1 (zh) 2021-02-04

Family

ID=71196773

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/106333 WO2021018297A1 (zh) 2019-08-01 2020-07-31 一种基于p2p的服务通信方法、装置及系统

Country Status (2)

Country Link
CN (1) CN111355774B (zh)
WO (1) WO2021018297A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113055494A (zh) * 2021-03-30 2021-06-29 中国工商银行股份有限公司 通讯方法及通讯装置
CN114679471A (zh) * 2022-02-17 2022-06-28 许强 一种基于云端业务处理的数据匹配方法
CN114679496A (zh) * 2022-02-17 2022-06-28 许强 一种基于云端业务处理的用户筛选方法

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111355774B (zh) * 2019-08-01 2021-10-29 杭州海康威视数字技术股份有限公司 一种基于p2p的服务通信方法、装置及系统
CN115118772A (zh) * 2022-06-21 2022-09-27 壹沓科技(上海)有限公司 一种消息通信的系统及方法

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2239923A1 (en) * 2009-04-09 2010-10-13 Research In Motion Limited Relay access node with separate control and transport signaling for session-based communications
CN102790803A (zh) * 2012-07-19 2012-11-21 南京邮电大学 一种基于多终端融合的流媒体业务多流并发传输方法
CN104041095A (zh) * 2012-08-22 2014-09-10 华为技术有限公司 深度报文检测解析结果共享获取方法、系统及其相应设备
CN105898750A (zh) * 2016-05-27 2016-08-24 北京奇虎科技有限公司 WiFi接入点设备及WiFi接入鉴权控制方法、装置
CN108900549A (zh) * 2018-08-15 2018-11-27 深圳区块大陆科技有限公司 一种安全的区块链组网技术
CN111355774A (zh) * 2019-08-01 2020-06-30 杭州海康威视数字技术股份有限公司 一种基于p2p的服务通信方法、装置及系统

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101616169B (zh) * 2008-06-23 2013-03-13 华为技术有限公司 选择服务提供实体的方法、系统、服务选择实体、服务管理实体
CN102170422A (zh) * 2010-02-25 2011-08-31 腾讯科技(深圳)有限公司 一种节点查询方法、装置及系统
CN103533039B (zh) * 2013-09-27 2017-04-19 深圳市瑞彩电子技术有限公司 P2p数据传输的方法、转发代理服务器与系统
US10200370B2 (en) * 2015-03-20 2019-02-05 Canon Information And Imaging Solutions, Inc. Apparatus, system, and method for authorizing a service
CN108683699B (zh) * 2018-03-29 2021-06-18 广州华多网络科技有限公司 转发业务请求的方法和装置

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2239923A1 (en) * 2009-04-09 2010-10-13 Research In Motion Limited Relay access node with separate control and transport signaling for session-based communications
CN102790803A (zh) * 2012-07-19 2012-11-21 南京邮电大学 一种基于多终端融合的流媒体业务多流并发传输方法
CN104041095A (zh) * 2012-08-22 2014-09-10 华为技术有限公司 深度报文检测解析结果共享获取方法、系统及其相应设备
CN105898750A (zh) * 2016-05-27 2016-08-24 北京奇虎科技有限公司 WiFi接入点设备及WiFi接入鉴权控制方法、装置
CN108900549A (zh) * 2018-08-15 2018-11-27 深圳区块大陆科技有限公司 一种安全的区块链组网技术
CN111355774A (zh) * 2019-08-01 2020-06-30 杭州海康威视数字技术股份有限公司 一种基于p2p的服务通信方法、装置及系统

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113055494A (zh) * 2021-03-30 2021-06-29 中国工商银行股份有限公司 通讯方法及通讯装置
CN114679471A (zh) * 2022-02-17 2022-06-28 许强 一种基于云端业务处理的数据匹配方法
CN114679496A (zh) * 2022-02-17 2022-06-28 许强 一种基于云端业务处理的用户筛选方法
CN114679471B (zh) * 2022-02-17 2023-09-01 人民日报媒体技术股份有限公司 一种基于云端业务处理的数据匹配方法
CN114679496B (zh) * 2022-02-17 2024-03-22 上海生慧樘科技有限公司 一种基于云端业务处理的用户筛选方法

Also Published As

Publication number Publication date
CN111355774A (zh) 2020-06-30
CN111355774B (zh) 2021-10-29

Similar Documents

Publication Publication Date Title
WO2021018297A1 (zh) 一种基于p2p的服务通信方法、装置及系统
CN111225042B (zh) 数据传输的方法、装置、计算机设备以及存储介质
WO2020001564A1 (zh) 一种处理任务的方法、装置及系统
CN108833607B (zh) 物理地址获取方法、装置及可读介质
WO2021120976A2 (zh) 负载均衡控制方法及服务器
US20210204127A1 (en) Image Sharing Method and System, and Electronic Device
CN109246123B (zh) 媒体流获取方法及装置
CN111614549B (zh) 交互处理方法、装置、计算机设备及存储介质
WO2023125946A1 (zh) 用户访问请求处理方法、装置、设备、介质及产品
CN110636144A (zh) 数据下载的方法和装置
CN111159604A (zh) 图片资源加载方法及装置
CN110704324A (zh) 应用调试方法、装置及存储介质
CN111866140A (zh) 融合管理设备、管理系统、服务调用方法及介质
WO2019223601A1 (zh) 一种数据库系统及其建立方法和装置
CN111131392A (zh) 处理消息的方法、装置、电子设备及介质
CN113144622A (zh) 节点切换方法、装置、设备及计算机可读存储介质
CN111008083B (zh) 页面通信方法、装置、电子设备及存储介质
CN110086814B (zh) 一种数据获取的方法、装置及存储介质
CN112181915B (zh) 执行业务的方法、装置、终端和存储介质
CN111130985B (zh) 关联关系建立方法、装置、终端、服务器及存储介质
CN110366044B (zh) 获取目标物的方法、装置和系统
CN110597840A (zh) 基于区块链的伴侣关系建立方法、装置、设备及存储介质
WO2022247750A1 (zh) 访问请求的处理方法、电子装置、电子设备以及介质
CN114785766A (zh) 智能设备的控制方法、终端及服务器
CN114329292A (zh) 资源信息的配置方法、装置、电子设备以及存储介质

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: 20847782

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20847782

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 15/05/2023)

122 Ep: pct application non-entry in european phase

Ref document number: 20847782

Country of ref document: EP

Kind code of ref document: A1