CN-122002638-A - P2P connection method and device
Abstract
The embodiment of the application provides a P2P connection method and device, and relates to the technical field of communication. The method can realize P2P connection of different types of electronic devices (such as a first type of device using an application module for decision and a second type of device using a link module for decision and old devices) in a multi-device scene. The method may include the application module of the second electronic device sending a first bridging request to the application module of the first electronic device, the first bridging request being used to allocate I P for the first electronic device to the third electronic device. The I P of the third electronic device is configured to establish P2P bridging communication with the second electronic device. A first reply message is received, the first reply message including I P of the third electronic device. And establishing P2P bridging communication with the third electronic equipment according to the first reply message.
Inventors
- ZHAO SHUAI
Assignees
- 荣耀终端股份有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20241029
Claims (20)
- 1. A P2P connection method is characterized in that the method is applied to a second electronic device, The second electronic device and the first electronic device are connected by a first P2P connection, and the method is used for establishing the P2P connection between the second electronic device and the third electronic device; The first electronic device and the third electronic device are both devices of a second type, and a frame layer of the devices of the second type is provided with a link module, wherein the link module is used for deciding P2P connection configuration of the devices of the second type, and the P2P connection configuration comprises at least one of network card information used as role information of GO/GC and frequency information for P2P communication; The second electronic device is a first type device, and an application module is arranged at an application layer of the first type device and is used for deciding P2P connection configuration of the first type device; The method comprises the following steps: The application module of the second electronic device sends a first bridging request to the application module of the first electronic device, wherein the first bridging request is used for distributing IP (Internet protocol) for the first electronic device and the third electronic device; receiving a first reply message, wherein the first reply message comprises the IP of the third electronic equipment; the first reply message also comprises at least one item of GO connection information of the first electronic equipment, IP and TCP port information of the first electronic equipment; The GO connection information at least comprises an SSID and a password when the first P2P connection is established by taking a first network card of the first electronic device as GO; And establishing P2P bridging communication with the third electronic equipment according to the first reply message.
- 2. The method of claim 1, wherein the step of determining the position of the substrate comprises, Before sending the first bridge request, the method further comprises: and the application module of the second electronic equipment determines that the first network card of the second electronic equipment works as a GC in the first P2P connection.
- 3. A method according to claim 1 or 2, characterized in that, Before sending the first bridge request, the method further comprises: And the application module of the second electronic device and the application module of the third electronic device establish a first encryption negotiation channel, and the first encryption negotiation channel is used for carrying out data transmission between the application module of the second electronic device and the application module of the third electronic device.
- 4. A method according to any one of claims 1 to 3, wherein, Before sending the first bridge request, the method further comprises: And receiving a first operation of a user, wherein the first operation is used for indicating the second electronic equipment to establish P2P connection with the third electronic equipment.
- 5. A method according to any one of claims 1 to 3, wherein, Before sending the first bridge request, the method further comprises: And receiving a first negotiation packet from the third electronic equipment, wherein the first negotiation packet comprises WIFI capability information of the third electronic equipment, and the WIFI capability information comprises at least one of identification, model number and available channel of at least one network card, and information of the established WIFI connection of the local terminal equipment.
- 6. The method of claim 5, wherein the method further comprises: storing the IP of the third electronic device according to the first reply message, Generating a second bridging request, wherein the second bridging request comprises the content of the first reply message; and sending the second bridging request to an application module of the third electronic device.
- 7. The method of claim 6, wherein the method further comprises: And according to the IP of the third electronic equipment, the intelligent interconnection application of the second electronic equipment and the intelligent interconnection application of the third electronic equipment carry out intelligent interconnection network sharing negotiation.
- 8. A P2P connection method is characterized in that the method is applied to a third electronic device, The method is used for establishing P2P connection between the third electronic equipment and the second electronic equipment, wherein the second electronic equipment and the first electronic equipment are provided with a first P2P connection; The first electronic device and the third electronic device are both devices of a second type, and a frame layer of the devices of the second type is provided with a link module, wherein the link module is used for deciding P2P connection configuration of the devices of the second type, and the P2P connection configuration comprises at least one of network card information used as role information of GO/GC and frequency information for P2P communication; The second electronic device is a first type device, and an application module is arranged at an application layer of the first type device and is used for deciding P2P connection configuration of the first type device; The method comprises the following steps: Receiving a first operation, wherein the first operation is used for indicating the third electronic device to establish P2P connection with the second electronic device; The method comprises the steps of sending a first negotiation packet to the second electronic equipment, wherein the first negotiation packet comprises WIFI capability information of the third electronic equipment, and the WIFI capability information comprises at least one of identification, model and available channel of at least one network card, and information of established WIFI connection of local terminal equipment; receiving a second bridging request, wherein the second bridging request comprises at least one of the following: The first electronic equipment is an IP distributed to the third electronic equipment, GO connection information of the first electronic equipment, and IP and TCP port information of the first electronic equipment; The GO connection information at least comprises an SSID and a password when the first P2P connection is established by taking a first network card of the first electronic device as GO; And establishing P2P bridging communication with the second electronic equipment through the first electronic equipment according to the second bridging request.
- 9. The method of claim 8, wherein after receiving the first request, the method further comprises: The intelligent interconnection application of the third electronic device sends a first connection call to an application module of the third electronic device, the first connection call comprises information of a P2P service corresponding to the first operation, and the first connection call is used for indicating a link module of the third electronic device to establish P2P communication with the second electronic device.
- 10. The method according to claim 8 or 9, characterized in that the method further comprises: and the application module of the third electronic device and the application module of the second electronic device establish a first encryption negotiation channel, and the first encryption negotiation channel is used for carrying out data transmission between the application module of the second electronic device and the application module of the third electronic device.
- 11. The method according to claim 10, wherein the method further comprises: The application module of the third electronic device registers a first auxiliary channel with the link module of the third electronic device, the first auxiliary channel corresponds to the first encryption negotiation channel, and the first auxiliary channel is used for data transmission between the link module of the third electronic device and the application module of the third electronic device.
- 12. The method according to any one of claims 8-11, wherein, Before the sending the first negotiation packet, the method further comprises: the link module of the third electronic device determines that at least one available network card exists; Generating the first negotiation packet.
- 13. The method of any of claims 8-12, wherein after receiving the second bridging request, the method further comprises: The application module of the third electronic device stores at least one of: the IP of the third electronic device, the IP of the second electronic device, the IP of the first electronic device and TCP port information; the application module of the third electronic device sends the second bridging request to the link module of the third electronic device, The link module of the third electronic device establishes WIFI P2P physical link connection with the first electronic device according to the second bridging request; And the application module of the third electronic equipment establishes a TCP encryption channel with the application module of the first electronic equipment according to the second bridging request.
- 14. The method according to any one of claims 8-13, further comprising: And according to the IP of the second electronic equipment, the intelligent interconnection application of the third electronic equipment and the intelligent interconnection application of the second electronic equipment carry out intelligent interconnection network sharing negotiation.
- 15. A P2P connection method is characterized in that the method is applied to a first electronic device, The second electronic equipment and the first electronic equipment are established with a first P2P connection, and the method is used for establishing the P2P connection between the second electronic equipment and the third electronic equipment; The first electronic device and the third electronic device are both devices of a second type, and a frame layer of the devices of the second type is provided with a link module, wherein the link module is used for deciding P2P connection configuration of the devices of the second type, and the P2P connection configuration comprises at least one of network card information used as role information of GO/GC and frequency information for P2P communication; The second electronic device is a first type device, and an application module is arranged at an application layer of the first type device and is used for deciding P2P connection configuration of the first type device; The method comprises the following steps: receiving a first bridging request from a second electronic device, wherein the first bridging request is used for distributing IP to the first electronic device and the third electronic device; The method comprises the steps of sending a first reply message to the second electronic equipment, wherein the first reply message comprises the IP of the third electronic equipment, and at least one item of GO connection information of the first electronic equipment, and IP and TCP port information of the first electronic equipment; The GO connection information at least includes an SSID and a password when the first network card of the first electronic device is used as GO to establish the first P2P connection.
- 16. The method of claim 15, wherein after sending the first reply message, the method further comprises: and establishing WIFIP P physical link connection and TCP encryption channel with the third electronic equipment.
- 17. The method of claim 15 or 16, wherein after receiving the first bridging request from the second electronic device, the method further comprises: the link module of the third electronic device generates a first reply packet, where the first reply packet includes at least one of the following: The IP of the third electronic device, the GO connection information of the first electronic device, the IP of the first electronic device and the TCP port information; the sending the first reply message to the second electronic device includes: And the link module of the first electronic device sends the first reply message to the second electronic device through the application module of the first electronic device.
- 18. An electronic device comprising a memory and one or more processors, the memory and the processors coupled; Wherein the memory is for storing computer program code comprising computer instructions which, when executed by the processor, cause the electronic device to perform the method of any one of claims 1-7, or to perform the method of any one of claims 8-14, or to perform the method of any one of claims 15-17.
- 19. A chip system, characterized in that the chip system is applied to an electronic device, the chip system comprising one or more interface circuits and one or more processors, the interface circuits and the processors being interconnected by wires, the interface circuits being adapted to receive signals from a memory of the electronic device and to send the signals to the processors, the signals comprising computer instructions stored in the memory, the electronic device performing the method according to any one of claims 1-7 or the method according to any one of claims 8-14 or the method according to any one of claims 15-17 when the processor executes the computer instructions.
- 20. A computer readable storage medium comprising computer instructions which, when run on an electronic device, cause the electronic device to perform the method of any one of claims 1-7, or to perform the method of any one of claims 8-14, or to perform the method of any one of claims 15-17.
Description
P2P connection method and device Technical Field The embodiment of the application relates to the technical field of communication, in particular to a P2P connection method and device. Background In order to better serve users, data transmission (information interaction) can be carried out among various electronic devices, so that functions of file sharing, multi-screen collaboration, screen projection and the like are realized. The electronic devices can adopt a WIFI direct connection (WIFI DIRECT, also called peer-to-peer (P2P)) technology for data transmission. Compared with Bluetooth communication, the WIFI P2P communication distance is farther, the bandwidth is larger, and obvious advantages are achieved. However, when the WIFI P2P communication connection is established between the electronic devices, a channel for performing the WIFI P2P connection and a device serving as a group owner/manager (GO) need to be negotiated, and if the negotiation is not reasonable, the communication quality of the WIFI P2P will be degraded. Disclosure of Invention The application provides a P2P connection method and device, which can realize P2P connection of different types of electronic devices (such as a first type of device using an application module for decision and a second type of device using a link module for decision and old devices) under a multi-device scene. In order to achieve the technical purpose, the application adopts the following technical scheme: In a first aspect, a P2P connection method is provided, where the method is applied to a second electronic device, the second electronic device and the first electronic device establish a first P2P connection, and the method is applied to the second electronic device and a third electronic device establish a P2P connection. The first electronic device and the third electronic device are both devices of a second type, and a frame layer of the devices of the second type is provided with a link module, wherein the link module is used for deciding P2P connection configuration of the devices of the second type. The P2P connection configuration includes at least one of the frequency information for P2P communication using network card information as character information of GO/GC. The second electronic device is a first type device, and an application layer of the first type device is provided with an application module, wherein the application module is used for deciding P2P connection configuration of the first type device. The method comprises the steps that an application module of the second electronic device sends a first bridging request to an application module of the first electronic device, and the first bridging request is used for distributing IP (Internet protocol) for the third electronic device to the first electronic device. The IP of the third electronic device is used to establish P2P bridging communication with the second electronic device. A first reply message is received, the first reply message including an IP of the third electronic device. The first reply message also includes at least one of GO connection information of the first electronic device, IP and TCP port information of the first electronic device. The GO connection information at least includes an SSID and a password when the first network card of the first electronic device is used as GO to establish the first P2P connection. And establishing P2P bridging communication with the third electronic equipment according to the first reply message. Illustratively, an originating device (a device that receives a user operation) is taken as a first device. The first device has a P2P connection and has a GC role, and the originating old device can initiate bridging of the old protocol when the receiving device is a connectionless second device. Correspondingly, after receiving the negotiation packet of the bridge negotiation, the new device indicates bridging or direct connection according to the negotiation packet, and the new device can execute the corresponding bridge negotiation or direct connection negotiation. And using either the first protocol or the second protocol, may be determined based on the version of the peer device. Optionally, before sending the first bridging request, the method further includes determining, by the application module of the second electronic device, that the first network card of the second electronic device is operating as a GC in the first P2P connection. Optionally, before sending the first bridging request, the method further includes that the application module of the second electronic device and the application module of the third electronic device establish a first encryption negotiation channel, and the first encryption negotiation channel is used for performing data transmission between the application module of the second electronic device and the application module of the third electronic device. Optionally, before sending the first bridgi