CN114390491A - Networking method, device and system - Google Patents

Networking method, device and system Download PDF

Info

Publication number
CN114390491A
CN114390491A CN202011125466.6A CN202011125466A CN114390491A CN 114390491 A CN114390491 A CN 114390491A CN 202011125466 A CN202011125466 A CN 202011125466A CN 114390491 A CN114390491 A CN 114390491A
Authority
CN
China
Prior art keywords
connection
information
establish
request
tcp
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011125466.6A
Other languages
Chinese (zh)
Inventor
钱夏欢
蒋钟寅
凌波
李丽
乐超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies Co Ltd
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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202011125466.6A priority Critical patent/CN114390491A/en
Publication of CN114390491A publication Critical patent/CN114390491A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/14Direct-mode setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • H04W76/15Setup of multiple wireless link connections
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W84/00Network topologies
    • H04W84/18Self-organising networks, e.g. ad-hoc networks or sensor networks
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Abstract

The application provides a networking method, a device and a system, wherein in the networking method: a first P2P connection is established between the second device and the first device, the first device has a GO role in the group, and the second device has a GC role in the group; the second device receiving a first P2P connection request from a third device; when the second device determines that the second device cannot establish the P2P connection with the third device, the second device returns the first information to the third device, so that the third device establishes a second P2P connection with the first device based on the first information; the second device then establishes a TCP connection with the third device based on the first P2P connection and the second P2P connection. According to the method, under the condition that the P2P connection established between the second device and the first device is not disconnected, the P2P connection is established between the third device and the first device through the GC role, and therefore the second device and the third device can carry out short-distance communication in a WiFi P2P mode, and user experience can be improved.

Description

Networking method, device and system
Technical Field
The present application relates to the field of communications technologies, and in particular, to a networking method, apparatus, and system.
Background
At present, after two devices establish a wireless fidelity (WiFi) point-to-point (P2P) connection, the two devices may establish a Transmission Control Protocol (TCP)/User Datagram Protocol (UDP) connection, and then perform data communication through the TCP/UDP connection, that is, perform short-distance communication in a WiFi P2P manner. After the two devices establish a P2P connection, devices corresponding to the roles of a group administrator (GO)/a Group Client (GC) in the P2P connection are fixed (for example, after the first device and the second device establish a P2P connection, the first device is in a GO role, the second device is in a GC role), and the GO device and the GC device perform short-range communication in a WiFi P2P manner.
When other devices need to perform short-distance communication with a GC device (i.e., a second device) in a WiFi P2P manner, the other devices may send a P2P establishment request to the GC device, but at this time, the role of the second device is already fixed to the GC role, and a P2P connection is established with the corresponding GO device, and then no role negotiation with the other devices can be performed, so that the second device either rejects the P2P establishment request, and the other devices cannot perform short-distance communication with the second device in a WiFi P2P manner, or disconnects the P2P connection with the original GO device (i.e., the first device), and further establishes a P2P connection with the other devices, but this may cause interruption of ongoing services of the original GC device and the original GO device.
Disclosure of Invention
The embodiment of the application provides a networking method, a networking device and a networking system, which are used for adding other devices to perform short-distance communication with original GC equipment under the condition that the connection of P2P of the original GO equipment and the original GC equipment is not interrupted, and the experience effect that a user uses a plurality of devices to perform short-distance communication in a WiFi P2P mode is improved.
In a first aspect, a networking method is provided, which is applied to a second device, and in the networking method: the second device establishes a first P2P connection with the first device, the first device is in a GO role as an intra-group administrator, the second device is in a GC role as an intra-group client, and after receiving a first P2P connection request from a third device, if the second device determines that the second device cannot establish a P2P connection with the third device, the second device may return first information to the third device, where the first information is used to indicate that the third device establishes a second P2P connection with the first device; after the third device establishes the second P2P connection with the first device, the second device may establish an upper layer TCP connection with the third device based on the first P2P connection and the second P2P connection.
In this embodiment, after the original GC device (i.e., the second device) and the GO device (i.e., the first device) establish the first P2P connection, if the original GC device receives a P2P connection request from another device, the original GC device may send first information to the other device to instruct the other device and the GO device to establish the second P2P connection, and establish a TCP connection with the other device based on the first P2P connection and the second P2P connection. Therefore, the GC equipment is used as a data transfer station under the condition that the original P2P connection is not interrupted, short-distance communication is carried out between the GO equipment and other equipment in a WiFi P2P mode, and the experience effect that a user uses a plurality of equipment to carry out short-distance communication in the WiFi P2P mode is effectively improved.
In a possible design, after determining that the second device cannot establish the P2P connection with the third device, before returning the first information to the third device, the second device may further send a query request to the first device, and then receive a first reply message from the first device; the query request is used to query whether the first device is allowed to access the new GC device, and the first reply message is used to indicate that the first device is allowed to access the new GC device.
In this design, an original GC device (i.e., a second device) queries, to a GO device (i.e., a first device), whether to allow access to a new GC device, and returns first information (indicating that the third device establishes a second P2P connection with the first device) to the third device only when the first device allows access to the new GC device, so that it is possible to avoid that the third device performs a procedure of establishing a second P2P connection with the first device when the GO device does not allow access to the new GC device, reduce a failure probability of establishing a second P2P connection with the third device, further improve networking efficiency, and further improve user experience.
In one possible design, the first information includes: link establishment information of the first device.
In the design, other devices (i.e., the third device) may not need to perform role negotiation with the GO device, so that the efficiency of establishing the P2P connection between the other devices and the GO device is effectively improved, and the user experience can be further improved.
In one possible design, the first information includes: the link establishment information of the first device, the P2P port allocated by the first device to the third device, and the IP address.
In the design, the first information includes a P2P port and an IP address allocated by the GO device to the third device, and other devices (i.e., the third device) do not need to perform role negotiation with the GO device and do not need to query the GO device for the P2P port and the IP address; the efficiency that other equipment and GO equipment establish P2P connection is improved, and then effective networking efficiency is improved, user experience can be further improved.
In one possible design, the first P2P connection request carries link establishment information of the third device; the second device may also determine that the P2P port of the third device is available according to the link establishment information of the third device before sending the query request to the first device after receiving the first P2P connection request.
In this design, after the original GC device (i.e., the second device) receives the P2P connection request of the other device (i.e., the third device), it may determine whether the P2P port of the other device is available according to the link establishment information of the other device carried in the P2P connection request. Therefore, the process of establishing the second P2P connection with the first device when the P2P port of the third device is unavailable can be avoided, the failure probability of establishing the second P2P connection with the third device is reduced, the networking efficiency is further improved, and the user experience can be further improved.
In one possible design, the second device may also send a bluetooth low energy, BLE, connection request to the third device after receiving the first P2P connection request and before sending an inquiry request to the first device; receiving a third response message from the third device, where the third response message is used to indicate that the third device agrees to establish a BLE connection with the second device; the BLE connection is established with the third equipment, and third information from the third equipment is received through the BLE connection, wherein the third information carries the link establishment information of the third equipment; and determining that the P2P port of the third device is available according to the link establishment information of the third device.
In this design, the original GC device (i.e., the second device), after receiving the P2P connection request of the other device (i.e., the third device), may receive the link establishment information of the third device through the BLE connection and determine whether the P2P port of the third device is available. Therefore, the process of establishing the second P2P connection with the first device when the P2P port of the third device is unavailable can be avoided, the failure probability of establishing the second P2P connection by the third device is reduced, and the networking efficiency is further improved.
In a possible design, after the third device establishes the second P2P connection with the first device, based on the first P2P connection and the second P2P connection, the specific implementation manner of establishing the upper layer transmission control protocol TCP connection with the third device may be: receiving request information forwarded by first equipment, wherein the request information is information used by third equipment for requesting to establish TCP connection with second equipment, and the request information carries a first TCP port used by the third equipment for establishing TCP connection; and responding to the request information, and sending a fourth response message to the third equipment through the first equipment, wherein the fourth response message carries a second TCP port used for establishing the TCP connection by the second equipment.
In this design, the original GC device (i.e., the second device) may establish a TCP connection with the new GC device (i.e., the third device) based on the first P2P connection and the second P2P connection, so that the original GC device may perform short-range communication with the new GC device in a WiFi P2P manner, thereby effectively improving the communication efficiency between the original GC device and the new GC device.
In a second aspect, a networking method applied to a third device is provided, the method including: sending a first P2P connection request to the second device; the second device and the first device establish a first P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; then receiving first information from the second device, wherein the first information is sent by the second device when the P2P connection cannot be established with the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device; establishing a second P2P connection with the first device according to the first information; the third device may establish an upper layer transmission control protocol, TCP, connection with the second device based on the first P2P connection and the second P2P connection.
In one possible design, the first information includes link establishment information of the first device; the third device establishes a second P2P connection with the first device according to the first information, which may be: sending a second P2P setup request to the first device; receiving a second response message from the first device, wherein the second response message carries a P2P port and an IP address which are allocated to the third device by the first device; a P2P connection is established with the first device in a GC role based on the P2P port and IP address.
In one possible design, the first information includes: the link establishment information of the first equipment, the P2P port allocated by the first equipment to the third equipment and the IP address; establishing a second P2P connection with the first device based on the first information, comprising: a second P2P connection is established with the first device in a GC role based on the P2P port and IP address.
In one possible design, the first P2P connection request carries link establishment information of the third device.
In one possible design, after the third device sends the first P2P connection request to the second device, it may further: receiving a BLE connection request from a second device; sending a third response message to the second device, where the third response message is used to indicate that the third device agrees to establish BLE connection with the second device, so that the second device and the third device establish BLE connection; and sending third information to the second device through the BLE connection, wherein the third information carries link establishment information of the third device, and the link establishment information of the third device is used for indicating that a P2P port of the third device is available.
In one possible design, the third device establishes an upper layer transmission control protocol, TCP, connection with the second device based on the first P2P connection and the second P2P connection, including: request information is sent to second equipment through first equipment, the request information is used for requesting to establish TCP connection with the second equipment, and the request information carries a first TCP port used for establishing the TCP connection by third equipment; receiving a fourth response message from the second device through the first device, wherein the fourth response message carries a second TCP port used by the second device for establishing a TCP connection; a TCP connection is established based on the first TCP port, the second TCP port, and the second device.
In a third aspect, a networking method is provided, where the networking method is applied to a first device, the first device and a second device establish a first peer-to-peer P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; the method comprises the following steps: establishing a second P2P connection with a third device based on the first information; an upper layer transport control protocol, TCP, connection is established between the second device and the third device based on the first P2P connection and the second P2P connection. When the first information is that the third device requests to establish the P2P connection with the second device, the second device confirms that the P2P connection cannot be established with the third device and sends the connection to the third device; the first information is used to instruct the third device to establish a second P2P connection with the first device.
In one possible design, before the first device establishes the second P2P connection with the third device, the method further includes: receiving a query request from second equipment, and responding to the query request, and sending a first response message to the second equipment; the query request is used to query whether the first device is allowed to access the new GC device, and the first reply message is used to indicate that the first device is allowed to access the new GC device.
In one possible design, the first device establishes a second P2P connection with a third device, including: receiving a second P2P setup request from a third device; and responding to the second P2P establishment request, and sending a second response message to the third device, wherein the second response message carries the P2P port and the IP address which are allocated to the third device by the first device.
In one possible design, the first device establishes an upper TCP connection between the second device and the third device based on the first P2P connection and the second P2P connection, which may be: receiving request information from the third device over the second P2P connection and forwarding the request information to the second device over the first P2P connection; the request information is used for indicating the third equipment to request to establish TCP connection with the second equipment, and the request information carries a first TCP port used for establishing the TCP connection by the third equipment; receiving a fourth response message from the second device through the first P2P connection, where the fourth response message carries a second TCP port used by the second device to establish a TCP connection; the fourth response message is forwarded to the third device via the second P2P connection.
In a fourth aspect, a networking apparatus is provided, which is applied to a second device in a networking system, where the networking system further includes a first device and the second device that establish a first P2P connection, the first device is in a GO role as an intra-group administrator, and the second device is in a GC role as an intra-group client, and the networking apparatus includes modules/units configured to perform the method described in the first aspect or any one of the possible designs of the first aspect.
Illustratively, the networking device may include:
a communication module for receiving a first P2P connection request from a third device;
the communication module is further used for returning the first information to the third device after determining that the third device cannot establish the P2P connection with the third device, so that the third device establishes a second P2P connection with the first device according to the first information;
and the processing module is used for establishing an upper layer Transmission Control Protocol (TCP) connection with the third equipment based on the first P2P connection and the second P2P connection after the third equipment establishes the second P2P connection with the first equipment.
In a fifth aspect, a networking apparatus is provided, which is applied to a third device in a networking system, where the networking system further includes a first device and a second device, where the first device and the second device establish a first P2P connection, the first device is in a role of a GO administrator in a group, and the second device is in a role of a GC client in the group, and the networking apparatus includes modules/units configured to perform the method in any one of the possible designs of the second aspect or the second aspect.
Illustratively, the networking device may include:
a communication module, configured to send a first P2P connection request to a second device;
the communication module is further used for receiving first information from the second device, wherein the first information is sent by the second device when the P2P connection cannot be established with the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
the processing module is used for establishing a second P2P connection with the first equipment according to the first information;
and the processing module is further used for establishing an upper layer Transmission Control Protocol (TCP) connection with the second equipment based on the first P2P connection and the second P2P connection.
A sixth aspect provides a networking apparatus, which is applied to a first device in a networking system, where the networking system further includes a second device and a third device, where the first device and the second device establish a first peer-to-peer P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; the networking device comprises means for performing the method of the third aspect or any one of the possible designs of the third aspect.
Illustratively, the networking device may include:
the processing module is used for establishing a second P2P connection with the third equipment; the second P2P connection is established by the third device with the third device based on the first information, and when the third device requests to establish a P2P connection with the second device, the second device confirms that the P2P connection cannot be established with the third device and sends the connection to the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
and the processing module is further configured to establish an upper layer Transmission Control Protocol (TCP) connection between the second device and the third device based on the first P2P connection and the second P2P connection when the third device establishes the second P2P connection with the first device based on the first information.
A seventh aspect provides a networking system, where the networking system includes a first device, a second device, and a third device, where the first device and the second device establish a first peer-to-peer P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC;
a second apparatus for performing a method as in any one of the previous first aspect or possible designs of the first aspect;
a third apparatus for performing the method as in any one of the previous possible designs of the second aspect or the second aspect;
a first apparatus for performing a method as in any one of the previous possible designs of the third aspect or the third aspect.
In an eighth aspect, an electronic device is provided, including: at least one processor; and a memory communicatively coupled to the at least one processor, a communication interface; wherein the memory stores instructions executable by the at least one processor, the at least one processor causing the electronic device to perform a method as in any one of the foregoing possible designs of the first aspect or the first aspect, or as in any one of the foregoing possible designs of the second aspect or the second aspect, or as in any one of the foregoing possible designs of the third aspect or the third aspect, by executing the instructions stored by the memory.
A ninth aspect provides a computer readable storage medium comprising a program or instructions which, when run on a computer, causes a method as in any one of the previous possible designs of the first aspect or the first aspect, or a method as in any one of the previous possible designs of the second aspect or the second aspect, or a method as in any one of the previous possible designs of the third aspect or the third aspect, to be performed.
In a tenth aspect, there is provided a chip, coupled to a memory, for reading and executing program instructions stored in the memory, such that the method in any one of the possible designs of the aforementioned first aspect or first aspect, or the method in any one of the possible designs of the aforementioned second aspect or second aspect, or the method in any one of the possible designs of the aforementioned third aspect or third aspect, is performed.
In an eleventh aspect, there is provided computer program instructions which, when run on a computer, cause a method in any one of the possible designs of the aforementioned first aspect or first aspect, or a method in any one of the possible designs of the aforementioned second aspect or second aspect, or a method in any one of the possible designs of the aforementioned third aspect or third aspect, to be performed.
Drawings
Fig. 1 is a flowchart illustrating a method for establishing a P2P connection;
FIG. 2A is a diagram illustrating a networking method;
FIG. 2B is a diagram illustrating an exemplary networking method;
FIG. 2C is a schematic diagram of another specific networking method;
FIG. 3 is a schematic structural diagram of a networking system according to an embodiment of the present application;
fig. 4 is a diagram illustrating a structure of a mobile phone according to an embodiment of the present application;
fig. 5A is a schematic flowchart of a networking method according to an embodiment of the present application;
fig. 5B is a schematic diagram of a graphical user interface of the second device 32 according to an embodiment of the present disclosure;
fig. 5C is a schematic diagram of a graphical user interface of the third device 33 according to the embodiment of the present application;
fig. 5D is a schematic view of a short-range communication scenario provided in an embodiment of the present application;
fig. 5E is a schematic diagram of a graphical user interface of a third device according to an embodiment of the present application;
fig. 6 is a flowchart illustrating a method for establishing a TCP connection according to an embodiment of the present application;
fig. 7A is a schematic flowchart of a method for establishing a BLE connection according to an embodiment of the present application;
figure 7B is a schematic diagram of a user graphical interface for enabling BLE functionality according to an embodiment of the present disclosure;
fig. 8 is a schematic flowchart of another networking method according to an embodiment of the present application;
fig. 9 is a schematic view of another short-range communication scenario provided in an embodiment of the present application;
fig. 10 is a schematic structural diagram of a networking device according to an embodiment of the present application;
fig. 11 is a schematic structural diagram of another networking apparatus according to an embodiment of the present application;
fig. 12 is a schematic structural diagram of another networking apparatus according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The WiFi alliance (WFA) defines WiFi peer-to-peer (WiFi P2P) technology for communication between different WiFi devices, which is also called Wireless Local Area Networks (WLANs) direct connection in the industry, and supports two or more devices to form a P2P network (also called P2P group) and communicate with each other without wireless Access Points (APs). There can only be one GO device in a P2P Group, but there can be one or more GC devices.
The architecture of P2P will be briefly described.
Three components are defined in the P2P architecture: P2P Device (Device), P2P GO, P2P GC, wherein P2P Device is an entity in the role of P2P architecture, which can be understood as a WiFi Device. Wherein, GO is a role similar to an AP for forwarding data in an Infrastructure basic service set (Infrastructure BSS), so that devices in the GO role can be used for forwarding data; the GC is another role similar to a Station (STA) in an Infrastructure BSS, that is, a device in the GC role may be a terminal device with a WiFi communication function, such as a mobile phone, a tablet computer, a notebook computer, and the like, connected to a wireless network.
Before the P2P Group is established, each Device is a P2P Device, and when P2P role negotiation is completed between P2P devices, one of the P2P devices will play the role of GO (i.e., act as AP) and the other P2P devices will play the role of GC (i.e., act as STA).
For example, after role negotiation is performed on a mobile phone a supporting P2P function, a mobile phone B supporting P2P function, and a television C supporting P2P function, the mobile phone a is in a GO role, the mobile phone B is in a GC role, and the television C is in a GC role, then the mobile phone a establishes P2P connection with the mobile phone B in the GC role and the television C in the GC role, and the mobile phone a, the mobile phone B, and the television C form a P2P Group. The mobile phone a can transmit data to the mobile phone B or the television C (for example, the mobile phone a transmits image information displayed on its own screen to the television C, and the television C displays the image information), and the mobile phone a can also receive data from the mobile phone B or the television C, so that screen sharing and resource sharing are realized.
By means of the P2P technology, different WiFi devices can be directly connected, and the use scene of the WiFi technology can be expanded. Some applications such as direct connection and fast transmission and wireless display (wifi display) are realized based on the function.
The P2P Group is divided into a permanent (persistent) Group and a temporary (temporal) Group, which are explained separately by way of example below.
Example 1, suppose that when a user uses a printer for the first time, a Group is established by a mobile phone with a P2P function and the printer, and the mobile phone and the printer both store related security configuration information (such as a key, an authentication method, and the like) and other information related to the Group (such as role information of GO and GC) in the process of establishing the Group; in such a Group, devices corresponding to the roles of GO and GC are already designated in the first connection process of P2P, and devices corresponding to the roles of GO and GC remain unchanged in the subsequent connection process. Thus, when the user uses the printer through the mobile phone next time, the mobile phone can quickly establish the P2P connection according to the previously stored security configuration information and the information related to the Group. For such a Group, it is called a Persistent Group.
Example 2, when a file is first transferred, a device a and a device B establish a P2P Group through role negotiation, and disconnect the P2P connection after the transfer is completed, where the device a and the device B do not store security configuration information, other information related to the Group, and the like involved in the process of establishing the Group. Therefore, when the device a and the device B perform file transfer for the second time, the role negotiation needs to be performed again to establish a new P2P Group. In the two role negotiation processes, the role allocation of GO and GC is determined by the intention value and/or the random value breaker carried in the probe frames sent by the device a and the device B, so the two previous and subsequent role negotiation results may be different or the same. For such a Group, it is called a Temporary Group.
Fig. 1 is a schematic flow chart of a method for establishing a P2P connection, which specifically includes the following steps:
s11, the first device and the second device turn on the P2P function.
For example, assuming that the first device is a mobile phone and the second device is a computer, when the mobile phone receives a first operation (e.g., clicking) on a P2P function switch of the mobile phone, the P2P function is turned on. The manner in which the computer turns on the P2P function may also be similar to the manner in which the cell phone turns on the P2P function.
And S12, the first device and the second device mutually transmit the detection frame.
After the first device and the second device turn on the P2P function, the first device and the second device start to scan surrounding devices supporting the P2P function, and a specific scanning manner is not limited, for example, a Probe Request (Probe Request) frame may be sent on 1, 6, and 11 frequency bands of 2.4GHz, respectively.
And S13, the second device sends a response message to the first device.
In the process of sending the detection frame by the first device and the second device, the first device and the second device are respectively switched to a monitoring state according to a preset rule, and if the first device monitors a Probe Request frame sent by the second device on a frequency band 11, the first device returns response information to the second device; on the contrary, if the second device monitors the Probe Request frame sent by the first device on the 11 frequency band, the second device returns response information to the first device. In fig. 1, the second device returns response information to the first device as an example.
And S14, after the first device receives the response information, starting a GO negotiation process, determining the role of the GO/GC, and finishing Group establishment.
After receiving the response message sent by the second device at the preset frequency band, the first device compares the value of the Intent carried in the detection frame sent by the first device with the value of the Intent carried in the response message. If the Intent value carried in the detection frame sent by the first device is larger, determining the first device as a GO role and determining the second device as a GC role; if the Intent value carried in the response message sent by the second device is larger, determining the second device as a GO role and determining the first device as a GC role; if the value of the Intent carried in the probe frame sent by the first device is equal to the value of the Intent carried in the response message, the GO/GC role is further determined according to the breaker value carried in the probe frame sent by the first device and the breaker value carried in the response message. Specifically, if the breaker value carried in the probe frame sent by the first device is 1, the first device is in a GO role and the second device is in a GC role, and if the breaker value in the response message is 1, the second device is determined to be in the GO role and the first device is determined to be in the GC role.
S15, the first device and the second device establish a P2P connection.
After determining the GO/GC roles (i.e., completing the Group establishment), the first device and the second device establish a P2P connection according to their respective roles.
The P2P protocol specifies: in the process of establishing the P2P connection between the two devices and maintaining data communication, the roles of the devices of P2P supported by the two devices are fixed, and the other devices cannot establish P2P connection with the GC device therein any more, in other words, if there is another device that wants to perform short-distance communication with the GC device of the two devices that have established P2P connection, if the GC device does not disconnect the original P2P connection, the other device cannot perform short-distance communication with the GC device through the WiFi method.
For example, referring to fig. 2A, fig. 2A is a schematic diagram of a networking method, in fig. 2A, after a device i playing a GO role and a device ii playing a GC role establish a P2P connection, when the device ii receives a P2P connection request of the device iii, the device ii either rejects the request of the device iii, so that the device iii and the device ii cannot establish a P2P connection, and the device iii and the device ii cannot perform short-range communication in a WiFi manner. If device II is to establish a P2P connection with device III, the connection with device I, P2P, must be broken.
It should be understood that the device i, the device ii, or the device iii may be any terminal device supporting P2P function, such as a mobile phone supporting P2P function, a mobile computer, a tablet computer, a Personal Digital Assistant (PDA), a media player, a smart television, a smart wearable device (e.g., a smart watch, smart glasses, and a smart bracelet, etc.), an electronic reader, a handheld game machine, a point of sale (POS), a vehicle-mounted electronic device (vehicle-mounted computer), and the like.
This is further illustrated by two specific examples in fig. 2B and 2C.
In fig. 2B, after the connection between the large-screen computer 201 playing the GO role and the mobile phone 202 playing the GC role is established as P2P, if the mobile phone 203 sends a P2P connection request to the mobile phone 202, the mobile phone 202 rejects the request.
In fig. 2C, after the connection between the large-screen computer 201 playing a GO role and the mobile phone 202 playing a GC role is established as P2P, if the mobile phone 203 initiates a P2P connection request to the mobile phone 202, the mobile phone 202 is disconnected from the P2P of the large-screen computer 201, the mobile phone 202 and the large-screen computer 201 exchange GO roles, that is, the large-screen computer 201 serves as a GC device, the mobile phone 202 serves as a GO device, then the large-screen computer 201 and the mobile phone 202 reestablish a P2P connection, and at the same time, the mobile phone 203 establishes a P2P connection with the mobile phone 202(GO role) in the GC role, so that the mobile phone 202 and the mobile phone 203 can perform short-distance communication in a WiFi P2P manner.
However, the disconnection of P2P between the large-screen computer 201 and the mobile phone 202 during the role exchange process can cause the interruption of the ongoing service (e.g., sharing the screen) between the large-screen computer 201 and the mobile phone 202, resulting in poor user experience.
In view of this, an embodiment of the present application provides a networking communication scheme, where a P2P technology and a Bluetooth Low Energy (BLE) technology are combined, after any GC device in an original P2P Group receives a P2P establishment request sent by another device, the GC device may exchange link establishment information with the other device through a BLE connection, and further control the other device to establish a P2P connection with a GO device in the original P2P Group, and further add the other device to an existing P2P Group in a GC role under the condition that the P2P connection of the original device is not disconnected, and perform data transmission between the other device and the GC device by using the GO device as a data transfer station, so as to achieve a technical effect that the other device and the GC device perform short-distance communication in a WiFi P2P mode. The specific technical solution will be described in detail later.
The technical solution of the embodiment of the present application may be applied to various short-range wireless communication systems, such as a WiFi P2P communication system, a bluetooth communication system, or an infrared communication system, and the present application is not limited specifically herein. The technical solution of the embodiment of the present application may also be applicable to a Wireless Local Area Network (WLAN) scenario, may be applicable to IEEE 802.11 system standards (e.g., IEEE such as 802.11a/n/ac standards, etc.), next-generation WLAN standards (e.g., 802.11be), or standards of the next generation, and may be applicable to a wireless local area network system including, but not limited to, an internet of things (IoT) network or a Vehicle networking (V2X) network. Hereinafter, the WiFi P2P communication system will be used as an example for explanation.
Fig. 3 is a schematic structural diagram of a networking system provided in an embodiment of the present application, where the networking system includes a first device 31, a second device 32, and a third device 33. The first device 31, the second device 32, and the third device 33 each have a short-range wireless communication function, and here, it is described that the three devices have a WiFi P2P function, respectively, and a P2P connection can be established between the first device 31 and any two of the second device 32 and the third device 33, and based on the P2P connection, the any two WiFi devices can perform short-range communication in a WiFi P2P manner.
In fig. 3, the first device 31 and the second device 32 establish a P2P connection as an example, and the first device 31 has a GO role and the second device 32 has a GC role. After the first device 31 and the second device 32 establish the P2P connection, the first device 31 or the second device 32 may receive a P2P connection request from the third device 33 (of course, other types of requests, such as a bluetooth connection request, etc., may also be received).
It should be understood that the actual networking system includes devices not limited to the first device 31, the second device 32, and the third device 33 shown in fig. 3, but may also include more WiFi devices or other electronic devices without WiFi P2P function, which is not limited herein.
The first device 31, the second device 32, the third device 33 may be any one of the following devices: a tablet computer, a notebook computer, a palm computer, a Mobile Internet Device (MID), a vehicle-mounted device, a Virtual Reality (VR) device, an Augmented Reality (AR) device, an intelligent home device, an intelligent robot, and the like. The embodiment of the present application is not limited as long as the electronic device has the WiFi P2P function. The structures of the first device 31, the second device 32, and the third device 33 may be the same or different, and are not limited herein.
In the following, the first device 31, the second device 32, or the third device 33 is taken as an example of a mobile phone.
Please refer to fig. 4, which is a schematic structural diagram of a mobile phone 400 according to an embodiment of the present application. In fig. 4, a mobile phone 400 includes a communication unit 401, a processing unit 402, a memory unit 403, and a storage unit 404.
The communication unit 401 may be one or more devices integrating at least one wireless communication processing module. The communication unit 401 may provide solutions for wireless communication applied to the mobile phone 400, including conventional bluetooth (Classic BT), low power Bluetooth (BLE), Wireless Local Area Network (WLAN) (e.g., wireless fidelity (WiFi) network), Near Field Communication (NFC), Global Navigation Satellite System (GNSS), Frequency Modulation (FM), Near Field Communication (NFC), Infrared (IR), and the like, which have respective advantages and disadvantages and usage scenarios. The method includes the steps of integrating key parameters such as communication distance (NFC < BLE BT < WiFi), transmission rate (NFC < BLE BT < WiFi), throughput (NFC < BLE BT < WiFi), power consumption (NFC/BLE < BLE BT < WiFi), and the like. The technical scheme provided in the embodiment of the application mainly relates to a BLE module and a WiFi module.
The processing unit 402 may be a single processing unit or a processor integrated with multiple processing units, where different processing units may be independent devices or integrated into one or more processors. The processing unit 402 is configured to run an operating system of the mobile phone 400 and a plurality of upper layer applications (such as a gallery, file management, and the like) running in the operating system, and control execution of application program codes to implement the functions of the mobile phone 400 in this embodiment. For example, a P2P connection, a TCP connection, a BLE connection, or the like is established with other devices, and data is transmitted with other devices based on these connections.
The operating system includes, but is not limited to, any operating system, such as Android, Windows, Linux, Ubuntu, Tizen, and the like, and a core module mainly involved in the operating system is a management module, which provides a plurality of application program interfaces for interacting with various upper layer applications, where the management module may be further divided into a session management module, an authentication management module, a transmission management module, and the like. The management module can also interact with other modules in the mobile phone 400, such as the communication unit 401, the memory unit 403 and the storage unit 404. For example, the session management module in the processing unit 402 may also schedule the BLE module in the communication unit 401 to enable the handset 400 to establish BLE connections with other devices, or schedule the WiFi module in the communication unit 401 to enable the handset 400 to establish TCP connections with other devices. For another example, the transmission management module of the mobile phone 400 may read the file data in the local storage unit 404 and send the file to other devices that have established a TCP connection with the mobile phone 400.
In some embodiments, processing unit 402 may include one or more interfaces. The interface may include an integrated circuit (I2C) interface, an integrated circuit built-in audio (I2S) interface, a Pulse Code Modulation (PCM) interface, a universal asynchronous receiver/transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a general-purpose input/output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and/or a Universal Serial Bus (USB) interface, etc.
Memory unit 403 is used to store instructions and data. In some embodiments, the memory in memory unit 403 is a cache memory. The memory may hold instructions or data that have just been used or recycled by the processing unit 402. If processing unit 402 needs to reuse the instruction or data, it can be called directly from the memory. Avoiding repeated accesses reduces the latency of processing unit 402, thereby increasing the efficiency of the system. For example, the processing unit 402 may store role information and security configuration information related to the process of establishing P2P connection between the mobile phone 400 and a certain device 1 in the memory unit 403, and if the mobile phone 400 needs to establish P2P connection with the device 1 again, the processing unit 402 may directly call the role information, security configuration information, and the like from the memory unit 403, and based on the called information, the mobile phone 400 and the device 1 may establish P2P connection.
The storage unit 404 may be configured with an external memory interface and an internal memory interface, where the external memory interface may be used to connect an external memory card, such as a Micro SD card, to implement the expansion of the storage capability of the mobile phone 400. The external memory card communicates with the processing unit 402 through an external memory interface to implement a data storage function. For example, files such as music, video, etc. are saved in an external memory card. For another example, in the process of establishing BLE connection between the mobile phone 400 and the other device 2, the authentication management module in the processing unit 402 may perform authentication and verification on information such as the security key of the device 2 to obtain an authentication result, and store the authentication result in the storage unit 404, when the mobile phone 400 establishes BLE connection with the device 2 again next time, the processing unit 402 may directly obtain the authentication result from the storage unit 404, and thus it is not necessary for the authentication management module in the processing unit 402 to authenticate the device 2 again.
It should be understood that the illustrated structure of the embodiment of the present application does not specifically limit the mobile phone 400. In other embodiments of the present application, the handset 400 may include more or fewer components than shown, or combine certain components, or split certain components, or a different arrangement of components. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
It should be understood that the terms "system" and "network" in the embodiments of the present application may be used interchangeably. "at least one" means one or more, "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone, wherein A and B can be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions, refer to any combination of these items, including single item(s) or multiple items(s), such as at least one of a, b, or c, which may represent: a, or b, or c, or a and b, or b and c, or a and b and c.
And, unless stated to the contrary, the embodiments of the present application refer to the ordinal numbers "first", "second", etc., for distinguishing a plurality of objects, and do not limit the sequence, timing, priority, or importance of the plurality of objects. For example, the first priority criterion and the second priority criterion are only used for distinguishing different criteria, and do not represent the difference of the content, priority, importance, and the like of the two criteria.
As shown in fig. 5A, a schematic flow chart of a networking method provided in the embodiment of the present application is shown, where the method is applied to the networking system shown in fig. 3 as an example, and the method mainly includes the following steps:
s501, the first device 31 and the second device 32 establish a P2P connection.
Specifically, after the WIFI P2P function is turned on, the first device 31 and the second device 32 perform a role negotiation process, for example: the second device 32 sends a P2P connection request to the first device 31, the first device 31 receives the P2P connection request, determines roles of the first device 31 and the second device 32 according to preset rules (e.g., the value of Intent and the value of break), for example, the second device 32 is a GC role, the first device 31 is a GO role, and sends negotiated role information to the second device 32; the second device 32, having received the role information, determines itself to be a GC role.
It can be understood that, when the first device 31 and the second device 32 perform role negotiation, the first device 31 assigns IP addresses for establishing P2P connection to P2P GO devices (i.e., the first device 31) and P2P GC devices (i.e., the second device 32), and creates a P2P interface address for the P2P GO device (i.e., the first device 31), and the first device 31 and the second device 32 use the P2P interface address as a MAC address and a Basic Service Set Identifier (BSSID) of the P2P connection. The first device 31 will select an operation Operating channel where probe frames and probe response frames are sent, and continuously send Beacon (Beacon) frames to broadcast Time Synchronization Function (TSF), required operation parameters to clarify capabilities of GO devices, GC devices, and available services.
Further, the first device 31 and the second device 32 negotiate a key in a Push Button Configuration (PBC) manner in a Wi-Fi access technology (WPS), obtain a Pairwise Master Key (PMK) and a Pairwise Transient Key (PTK), and perform encrypted data transmission according to the PTK and the GTK.
Of course, the role negotiation process may also be that the first device 31 sends a P2P connection request to the second device 32; after receiving the P2P connection request, the second device 32 determines roles of the first device 31 and the second device 32 according to a preset rule, and sends role information to the first device 31; after receiving the role information, the first device 31 determines that it is the GO role. Thereafter, the first device 31 and the second device 32 playing a GC role establish a P2P connection.
In some possible embodiments, the second device 32 and the first device 31 may have previously established a P2P connection, and both the second device 32 and the first device 31 store role information of the last P2P connection (the first device 31 is in a GO role, and the second device 32 is in a GC role), when the second device 32 and the first device 31 need to establish a P2P connection again, the first device 31 may directly generate a two-dimensional code carrying role negotiation information of the P2P connection, the second device 32 may acquire the role information only by scanning the two-dimensional code and further automatically establish a P2P connection with the role of the GC and the first device 31 in the GO role, and without performing role negotiation again, the efficiency of establishing a P2P connection may be better improved.
It can be understood that, before the first device 31 and the second device 32 establish the P2P connection, the first device 31 and the second device 32 need to receive user operations, turn on the Wi-Fi P2P function, and the first device and the second device need to be in the Wi-Fi P2P scanning state all the time, at this time, the two devices enable the Wi-Fi P2P capability and broadcast a signal indicating that it can be found to the surroundings. For example, taking the second device 32 as an example, please refer to fig. 5B and 5C, if the user needs to start the Wi-Fi P2P function of the second device 32, the user may click a menu pull-down function button of the WLAN through the setting interface of the second device 32, enter a pull-down selection menu of the WLAN, the second device 32 continues to detect that the user has clicked menu pull-down function buttons of more WLAN settings, and display multiple connection modes (WLAN direct connection, WPS connection, and the like) supported by the WLAN; when a touch or click action of a menu pull-down function button for the WLAN direct connection is detected, the WiFi P2P function of the second device 32 is turned on; the second device 32 starts scanning the available devices, as shown in fig. 5B, there are the first device 31, the third device 33, and the fourth device in the available device list; if the user wants to control the second device 32 to stop the scanning device, the user clicks the stop button 501. When the second device 32 detects a click operation of the user on the name of the first device 31, role negotiation with the first device 31 is started, and after the P2P connection is established, a prompt box 502 shown in fig. 5C is displayed below the notification bar of the second device 32, where the prompt box 502 is used for prompting the user that the second device 32 is WLAN-directly connected with the first device 31.
S502, the third device 33 sends a P2P setup request to the second device, and the second device 32 receives a P2P setup request from the third device 33.
After the second device 32 receives the P2P establishment request from the third device 33, it queries the link establishment information (e.g., P2P port information) of the second device 32, finds that the first device 31, which has itself performed the GC role and the GO role, has established the P2P connection, and cannot establish the P2P connection with the third device 33 (negotiated role), and then step S503A is performed.
In a possible design, the P2P connection request sent by the third device 33 may simultaneously carry the link establishment information of the third device 33. The link establishment information may include: WiFi channel, Media Access Control (MAC) address, P2P port, Service Set Identifier (SSID), authentication method, key, and Internet Protocol (IP) address.
In another possible design, the P2P connection request sent by the third device 33 may not carry the link establishment information of the third device 33, but the third device 33 encapsulates the link establishment information of the third device 33 into a short message, and sends the short message to the second device 32 in a bluetooth manner, where the bluetooth may be Classic BT or BLE, and the embodiment of the present application is not particularly limited.
Optionally, after receiving the link establishment information of the third device, the second device 32 determines whether the P2P port of the third device 33 is available, if so, then goes to step S503A, if not, then directly performs step S505A, and the second device 32 sends rejection information to the third device 33.
S503A, the second device 32 sends query information to the first device 31, the query information being used to inquire whether the first device 31 can join a new GC device.
S503B, the first device 31 returns a reply message to the second device 32, the reply message indicating whether the first device 31(GO device) can join the new GC device.
S504, the second device 32 receives the response information, and determines whether the first device 31 can join a new GC device according to the response information. If so, then S505B is performed, otherwise S505A is performed.
In a possible embodiment, the second device 32 may send a TCP query message to the first device 31 to query whether there are available ports and assignable IP addresses in the first device 31, and after receiving the TCP query message, the first device 31 returns a response message to the second device 32. If the second device 32 determines that the GO device may not access the new GC device according to the response message, step S505A is executed; if the second device 32 determines from the response message that the GO device can access the new GC device, S505B is performed.
S505A, the second device 32 sends rejection information to the third device 33.
Illustratively, the rejection information may be prompt information of "unable to establish P2P connection" fed back from the second device 32 to the third device 33.
Alternatively, the second device 32 may not send the rejection information to the third device 33, and after the second device 32 sends the P2P establishment request to the third device 33, if the information that is not returned by the second device 32 is not received after the preset time elapses, the second device 32 rejects the P2P establishment request of the third device 33 by default.
S505B, the second device 32 sends the first information to the third device 33.
S506, the third device 33 establishes a P2P connection with the first device 31 based on the first information.
The first information may specifically have various implementation manners.
In a first possible design, the first information includes information of the GO device (i.e., the first device 31), port information and an IP address assigned by the first device 31 to the third device 33, and port information and an IP address of the second device 32. The third device 33, after receiving the first information, establishes the P2P connection directly based on the port information and the IP address allocated by the first device 31 to the third device 33, and then the third device 33 establishes the P2P connection with the first device 31 in the GC role quickly.
Optionally, before performing S506, the third device 33 may disconnect BLE connection with the second device 32 to create a P2P interface, and configure the IP address assigned to it by the first device 31 on the interface, and the third device 33 establishes P2P connection with its available IP address and port in the role of GC and the GO device, i.e., the first device 31, according to the IP address and port assigned to it by the first device 31.
In a second possible design, the first information includes the device information of GO, the port information of the second device 32, and the IP address, then the third device 33 receives the first information and sends a request for establishing P2P to the first device 31 based on the first information, the request for establishing P2P may carry link establishment information of the third device 33, after receiving the request, the first device 31 returns the P2P port and the IP address allocated by the first device 31 to the third device 33, and then the third device 33 establishes P2P connection with the first device 31 in the GC role according to the P2P port and the IP address.
S507, the second device 32 and the third device 33 establish a TCP connection.
After the third device 33 establishes a P2P connection with the first device 31 (i.e., the GO device) in the GC role, the second device 32 can establish a TCP connection with the third device 33. Thereafter, the second device 32 and the third device 33 can perform data communication with the first device 31 as a data relay station.
The specific process when the upper TCP connection is established between the second device 32 and the third device 33 is as follows:
the third device 33 sends request information for requesting to establish a TCP connection with the second device to the first device 33, and the request information carries a first TCP port used by the third device 31 for establishing a TCP connection; the first device 31 receives the request information and forwards the request information to the second device 32; the second device 32 receives the request information, and sends a response message to the first device 31 in response to the request information, where the response message carries a second TCP port used by the second device 32 to establish a TCP connection; the first device 31 receives the response message and forwards the response message to the third device 33; the third device 33 receives the response message, and establishes a TCP connection with the second device based on the first TCP port, the second TCP port, and the second device.
In the above process, the first device 31 serves as a data transfer station, and data interaction for establishing a TCP connection between the third device 33 and the second device 32 is completed.
Through the networking method provided by the embodiment of the present application, under the condition that the P2P connection established between the second device 32 and the first device 31 is not disconnected, the third device 33 establishes a P2P connection with the first device 31(GO device) in a GC role, so that the second device 32 and the third device 33 can establish a TCP connection, and mutually transmit data by using the first device 31 as a relay station, thereby implementing short-distance communication between the second device 32 and the third device 33 in a WiFi P2P manner. Further, the second device 32(GC role) can simultaneously perform short-range communication with the original first device 31(GO role) and the newly added third device 33(GC role) in the WiFi P2P manner.
For example, referring to fig. 5D, the second device 32 may share a file with the third device 33 while sharing a screen with the first device 31. The transmission path of the shared file indicated by the dotted line in fig. 5D is a transmission path seen by the user, and the actual transmission path is the data transmission path of the shared file indicated by the solid line.
It can be understood that, when the user shares a picture with the second device 32 through the third device 33, and the user clicks the function button of the WLAN direct, the third device 33 may also be triggered to initiate a P2P connection request to the second device 32.
Illustratively, referring to fig. 5E, after the third device 33 detects that the user selects a target picture (i.e., a picture to be transmitted) from the album application and detects a click operation on the sharing control 504 in the interface 500, the interface 510 is displayed, a plurality of available data transmission modes are displayed in the interface 510, for example, bluetooth 511, information 512, WLAN 513, etc., and the third device 33 further detects a click or touch operation on the WLAN 513 and displays the interface 520.
The WLAN direct connection function is turned on in the interface 520, scanning available devices around is started, if the third device 33 detects a click operation for the identifier of the second device 32, the second device is determined as a target device, a P2P connection request is sent to the second device 32, information returned by the second device 32 is received, a P2P connection is established with the first device 31 based on the indication information, then a prompt box 532 that is already connected to the first device WLAN is displayed below a notification bar of the third device 33, and prompt information 533 that prompts a user to cancel sending a picture is displayed.
During the process of picture transmission shown in the interface 530, a prompt box 541 for WiFi P2P transmission may be always displayed, in which a picture transmission progress 543 and a transmission task (for example, sending 20 pictures to the second device 32542) may be displayed; after the third device 33 detects that the transmission task is completed, the interface 550 is displayed, in the interface 550, a prompt box 551 transmitted by the WiFi P2P is displayed, and in the prompt box 551, a prompt message 552 for informing the user that the transmission task is completed (for example, 20 pictures are successfully transmitted, 0 picture is failed) is displayed.
It should be understood that the request of the TCP connection in the above process may be initiated by the third device 33, or may be initiated by the second device 32, and the application is not limited thereto. Referring to fig. 6, taking an example that the third device 33 initiates a TCP establishment request to the second device 32 and referring to fig. 6, a process of establishing a TCP connection is described in detail below, which specifically includes the following steps:
s601, the third device 33 sends TCP establishment request information to the second device 32 through the first device 31.
In a possible embodiment, the third device 33 needs to determine whether its address is a public network address or not, or whether it uses the sock5 proxy according to a recorded software setting file (e.g. configuration file) before sending the TCP setup request; if the address is a public network address or a proxy server sock5 is used for proxy, a TCP connection request message is sent to the second device 32, and the public IP address and the public TCP port of the third device 33 are carried in the specified address of the request message; if it is neither a public network address nor a sock5 proxy is used, the request message sent by the third device 33 to the second device 32 carries a specific address with both IP and TCP ports 0 to tell the second device 32 that the third device 33 is in the same network as it is.
Wherein the third device 33 determines the IP addresses of the three devices 33 to be public network addresses by determining that the IP addresses of the third device 33 do not belong to the private network addresses (e.g., 192.168., 10.1., 172. (16-31.). etc.).
S602, the second device 32 determines that the IP and TCP port fields in the specified address in the request message are 0.
Specifically, if the IP and TCP port fields in the specified address in the request message are both 0, step S603 is executed; if the IP and TCP port fields in the specified address in the request message are not 0, the second device 32 directly uses the TCP protocol to connect to the public IP address and the public TCP port in the specified address carried in the request message, and establishes a TCP connection from the second device 32 to the third device 33.
S603, the second device 32 judges whether the second device is on the public network or whether the second device uses the sock5 proxy.
Specifically, if the second device 32 is on the public network or uses the sock5 proxy, step S604 is executed; after receiving the message, the third device 33 directly uses the TCP protocol to connect to the public IP address and the public TCP port of the second device 32, and establishes a TCP connection from the third device 33 to the second device 32. If the address of the second device is neither the public network address nor the sock5 proxy is used, step S605 is executed to send a connection failure message to the third device 33.
S604, the second device 32 sends a message carrying an assigned address to the third device 33 through the first device 31, where the assigned address includes a public IP address and a public TCP port of the second device 32.
S605, the second device 32 sends the connection failure information to the third device 33 through the first device 31.
Optionally, the connection failure information is used to instruct the third device 33 to reinitiate the TCP connection request.
Referring to fig. 7A, BLE is taken as an example to describe a process of sending link establishment information from the third device 33 to the second device 32 through bluetooth, which specifically includes the following steps:
and S701, the third equipment 33 performs BLE broadcasting, and broadcasts a first message, wherein the first message carries account information of the third equipment 33.
Specifically, the third device 33 turns on BLE function, sets BLE of the third device 33 to discoverable mode, and sends a BLE broadcast message to the second device 32.
For example, referring to fig. 7B, the user may slide from the top to the bottom of the display screen of the third device 33, the electronic device may display the notification bar in response to the sliding operation of the user, and the user may click the bluetooth icon 503 in the notification bar to open the BLE function of the third device 33. Of course, it is understood that the BLE may be opened in a plurality of ways, for example, the user may also open the BLE function through a voice instruction (e.g., "open the BLE function"), or through a shortcut gesture operation (e.g., sliding up the three fingers, etc.), which is not limited in this application.
S702, the second device 32 performs BLE scanning, and receives the first packet broadcast by the third device 33.
Specifically, the second device 32 starts the BLE function, performs BLE scanning, and executes step S703 when a first packet broadcast by the third device 33 is scanned. The procedure of turning on the BLE function by the second device 32 is described in the third device 33, and is not described here again.
S703, the second device 32 parses the first packet.
Specifically, the second device 32 obtains account information (for example, a device identifier) of the target device (i.e., the third device 33) by analyzing the obtained BLE broadcast packet.
In some possible embodiments, the second device 32 analyzes the first packet, and if it is found that the third device 33 needs to authenticate and authenticate the second device 32, the second device 32 sends an authentication request to the third device 33 to obtain an authentication result of the third device 33 authenticating the second device 32, and if the authentication result shows that the authentication is passed, the second device 32 determines the third device 33 as the target device of the BLE connection, and performs step 704; otherwise, the second device 32 determines that the authentication is not passed and displays a prompt for BLE connection failure.
S704, the second device 32 and the third device 33 establish a BLE connection.
S705, the third device 33 sends a second packet to the second device 32 through the BLE connection, where the second packet carries the link establishment information of the third device 33.
As shown in fig. 8, fig. 8 is a flowchart of another networking method provided in the embodiment of the present application. The networking method provided in fig. 8 differs from the networking method provided in fig. 5A in that: after the first device 31 and the second device 32 establish the P2P connection in the GO role and the GC role, respectively, the second device 32 playing the GC role in fig. 5A receives the P2P connection request of the third device 33, and the first device 31 playing the GO role in fig. 8 receives the P2P connection request of the third device 33.
S801, the first device 31 and the second device 32 establish a P2P connection.
The second device 32 has a GC role and the first device 31 has a GO role. Please refer to the description of S501.
S802, the third device 33 sends a P2P connection request to the first device 31, and the first device 31 receives a P2P connection request from the third device 33.
For a specific implementation manner, see the above specific implementation manner in S502, in which the third device 33 sends the P2P connection request to the second device 32, which is not described herein again.
S803, the first device 31 determines that it is a GO device and there are available P2P ports, and then the first device 31 and the third device 33 establish a P2P connection.
Optionally, the first device 31 and the third device 33 may further establish a TCP connection, and the first device 31 and the third device 33 may transmit data to each other through the TCP connection.
Optionally, in S804, the first device 31 sends the link establishment information of the second device 32 to the third device 33.
After receiving the link establishment information of the second device 32, the third device 33 may further send a request message for establishing a TCP connection to the second device 32, knowing that the second device is a GC device.
Optionally, S805, the third device 33 and the second device 32 establish a TCP connection, and the second device 32 and the third device 33 mutually transmit data through the first device 31.
As can be seen from the above description, in the networking method provided in fig. 8, when the first device 31(GO device) receives a P2P connection request from the third device 33, the third device 33 may establish a P2P connection with the first device 31 in the role of GC, and after the third device 33 establishes a P2P connection with the first device 31, the first device 31 may further send link establishment information of the second device 32 (original GC device) to the third device 33, so that the third device 33 and the second device 32 (original GC device) may establish a TCP connection and transmit data to each other based on the TCP connection, so that the second device 32 (original GC device) may perform short-range communication with multiple devices at the same time in the manner of WiFi P2P.
Of course, after the third device 33 joins the P2P Group (P2P Group formed by the first device 31 and the second device 32) shown in fig. 3, there may be other devices such as the fourth device 34 joining the P2P Group (P2P Group formed by the first device 31, the second device 32, and the third device 33), and the method for the fourth device 34 joining the P2P Group is similar to the method for the third device 34 joining the P2P Group.
For example, referring to fig. 9, after the method of fig. 5A is performed, the networking system includes three devices, namely, a first device 31, a second device 32, and a third device 33, where the first device 31 is a GO device, the second device 32, and the third device 33 are GC devices. Then, the fourth device 34 sends a P2P connection request to the third device 33, and the third device 33(GC role) controls the fourth device 34 (GC role) and the first device 31(GO role) to establish a P2P connection, where the specific implementation method may refer to the process shown in fig. 5A, which is not described herein again, and further the third device 33 and the fourth device 34 may establish a TCP connection and transmit data with each other. In this way, on the premise of not interrupting the P2P connection between the third device 33 and the first device 31, data communication between the fourth device 34 and the third device 33 is realized in a WiFi P2P manner, and the requirement of the user for efficient short-distance communication using multiple devices is better satisfied.
The networking method provided by the embodiment of the present application is described above with reference to fig. 5A, fig. 6, fig. 7A, and fig. 8, and the apparatus provided by the embodiment of the present application is described below with reference to fig. 10, fig. 11, and fig. 12.
Based on the same technical concept, an embodiment of the present application further provides a networking apparatus 1000, where the apparatus 1000 has a function of implementing the second device 32 in the embodiments shown in fig. 5A, fig. 6, fig. 7A, or fig. 8, for example, the apparatus 1000 includes a module or a unit or means (means) corresponding to the step executed by the second device 32 in the embodiment shown in fig. 5A, and the function or the unit or the means may be implemented by software, or implemented by hardware executing corresponding software.
For example, referring to fig. 10, the apparatus 1000 may comprise:
a communication module 1001 for receiving a first P2P connection request from a third device;
the communication module 1001 is further configured to, after determining that the third device cannot establish a P2P connection with the third device, return first information to the third device, so that the third device establishes a second P2P connection with the first device according to the first information;
a processing module 1002, configured to establish an upper layer TCP connection with the third device based on the first P2P connection and the second P2P connection after the third device establishes the second P2P connection with the first device.
In one possible design, after the processing module 1002 determines that the second device cannot establish the P2P connection with the third device, before the communication module 1001 returns the first information to the third device, the communication module 1001 is further configured to: sending a query request to first equipment, and receiving a first response message from the first equipment; the query request is used to query whether the first device is allowed to access the new GC device, and the first reply message is used to indicate that the first device is allowed to access the new GC device.
In one possible design, the first information includes: link establishment information of the first device.
In one possible design, the first information includes: the link establishment information of the first device, the P2P port allocated by the first device to the third device, and the IP address.
In one possible design, the first P2P connection request carries link establishment information of the third device; after the communication module 1001 receives the first P2P connection request and before sending the query request to the first device, the processing module 1002 is further configured to: and determining that the P2P port of the third device is available according to the link establishment information of the third device.
In one possible design, after receiving the first P2P connection request, before sending the query request to the first device, the communication module 1001 is further configured to: transmitting a Bluetooth Low Energy (BLE) connection request to a third device; receiving a third response message from the third device, where the third response message is used to indicate that the third device agrees to establish a BLE connection with the second device; the BLE connection is established with the third equipment, and third information from the third equipment is received through the BLE connection, wherein the third information carries the link establishment information of the third equipment; the processing module 1002 is further configured to determine that a P2P port of the third device is available according to the link establishment information of the third device.
In one possible design, after the processing module 1002 is configured to establish the second P2P connection between the third device and the first device, based on the first P2P connection and the second P2P connection, establish an upper layer transmission control protocol TCP connection with the third device, and specifically configured to: controlling the communication module 1001 to receive request information forwarded by the first device, where the request information is information used by a third device to request establishment of a TCP connection with the second device, and the request information carries a first TCP port used by the third device to establish the TCP connection; and controlling the communication module 1001 to respond to the request message, and sending a fourth response message to the third device through the first device, where the fourth response message carries a second TCP port used by the second device to establish a TCP connection.
It should be understood that all relevant contents of each step related to the above method embodiments may be referred to the functional description of the corresponding functional module, and are not described herein again.
Based on the same technical concept, an embodiment of the present application further provides a networking apparatus 1100, where the apparatus 1100 has a function of implementing the third device 33 in the embodiments shown in fig. 5A, fig. 6, fig. 7A, or fig. 8, for example, the apparatus 1100 includes a module or a unit or means (means) corresponding to the step executed by the third device 33 in the embodiment shown in fig. 5A, and the function or the unit or the means may be implemented by software, or implemented by hardware executing corresponding software.
For example, referring to fig. 11, an apparatus 1100 may comprise:
a communication module 1101, configured to send a first P2P connection request to the second device;
a communication module 1101, further configured to receive first information from the second device, where the first information is sent by the second device when the P2P connection cannot be established with the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
a processing module 1102, configured to establish a second P2P connection with the first device according to the first information;
the processing module 1102 is further configured to establish an upper layer transmission control protocol, TCP, connection with the second device based on the first P2P connection and the second P2P connection.
In one possible design, the first information includes: link establishment information of the first device; when the processing module 1102 is configured to establish the second P2P connection with the first device according to the first information, specifically: controlling the communication module 1101 to send a second P2P setup request to the first device; controlling the communication module 1101 to receive a second response message from the first device, where the second response message carries a P2P port and an IP address allocated by the first device to the third device; a P2P connection is established with the first device in a GC role based on the P2P port and IP address.
In one possible design, the first information includes: the link establishment information of the first equipment, the P2P port allocated by the first equipment to the third equipment and the IP address; when the processing module 1102 is configured to establish the second P2P connection with the first device according to the first information, specifically: a second P2P connection is established with the first device in a GC role based on the P2P port and IP address.
In one possible design, the first P2P connection request carries link establishment information of the third device.
In one possible design, the communication module 1101, after being configured to send the first P2P connection request to the second device, is further configured to: receiving a BLE connection request from a second device; sending a third response message to the second device, where the third response message is used to indicate that the third device agrees to establish BLE connection with the second device, so that the second device and the third device establish BLE connection; and sending third information to the second device through the BLE connection, wherein the third information carries link establishment information of the third device, and the link establishment information of the third device is used for indicating that a P2P port of the third device is available.
In one possible design, the processing module 1102 is configured to establish an upper layer TCP connection with the second device based on the first P2P connection and the second P2P connection, and specifically configured to: controlling the communication module 1201 to send request information to the second device through the first device, where the request information is used to request to establish a TCP connection with the second device, and the request information carries a first TCP port used by the third device to establish the TCP connection; controlling the communication module 1201 to receive a fourth response message from the second device through the first device, where the fourth response message carries a second TCP port used by the second device to establish a TCP connection; a TCP connection is established based on the first TCP port, the second TCP port, and the second device.
Based on the same technical concept, an embodiment of the present application further provides a networking apparatus 1200, where the apparatus 1200 has a function of implementing the first device 31 in the embodiments shown in fig. 5A, fig. 6, or fig. 8, for example, the apparatus 1200 includes a module or a unit or means (means) corresponding to the step executed by the first device 31 in the embodiment shown in fig. 5A, and the function or the unit or the means may be implemented by software, or implemented by hardware executing corresponding software.
For example, referring to fig. 12, the apparatus 1200 may include:
a processing module 1201, configured to establish a second P2P connection with the third device; the second P2P connection is established by the third device with the third device based on first information, and when the third device requests to establish a P2P connection with the second device, the second device confirms that a P2P connection cannot be established with the third device and sends the connection to the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
the processing module 1201 is further configured to, when the third device establishes a second P2P connection with the first device based on the first information, establish an upper layer transmission control protocol TCP connection between the second device and the third device based on the first P2P connection and the second P2P connection.
In one possible design, before establishing the second P2P connection with the third device, the networking apparatus 1200 further includes a communication module 1202, where the communication module 1202 is configured to: receiving a query request from second equipment, and responding to the query request, and sending a first response message to the second equipment; the query request is used to query whether the first device is allowed to access the new GC device, and the first reply message is used to indicate that the first device is allowed to access the new GC device.
In one possible design, the processing module 1201 is configured to establish a second P2P connection with a third device, and specifically configured to:
receiving a second P2P setup request from a third device; and responding to the second P2P establishment request, and sending a second response message to the third device, wherein the second response message carries the P2P port and the IP address which are allocated to the third device by the first device.
In one possible design, the processing module 1201, when configured to establish an upper TCP connection between the second device and the third device based on the first P2P connection and the second P2P connection, is specifically configured to: control the communication module 1202 to receive request information from a third device over the second P2P connection and forward the request information to the second device over the first P2P connection; the request information is used for indicating the third equipment to request to establish TCP connection with the second equipment, and the request information carries a first TCP port used for establishing the TCP connection by the third equipment; controlling the communication module 1202 to receive a fourth response message from the second device through the first P2P connection, where the fourth response message carries a second TCP port used by the second device to establish a TCP connection; the fourth response message is forwarded to the third device via the second P2P connection.
Based on the same technical concept, the embodiment of the present application further provides a computer-readable storage medium, which includes a program or instructions, and when the program or instructions are executed on a computer, the method performed by the second device 32 in the embodiment shown in fig. 5A, 6, 7A, or 8 is executed.
Based on the same technical concept, the embodiment of the present application further provides a computer-readable storage medium, which includes a program or instructions, and when the program or instructions are executed on a computer, the method performed by the third device 33 in the embodiment shown in fig. 5A, 6, 7A, or 8 is executed.
Based on the same technical concept, the embodiment of the present application further provides a computer-readable storage medium, which includes a program or instructions, and when the program or instructions are executed on a computer, the method performed by the first device 31 in the embodiment shown in fig. 5A, 6, 7A, or 8 is executed.
Based on the same technical concept, the embodiment of the present application further provides a chip, which is coupled to the memory and configured to read and execute the program instructions stored in the memory, so that the method performed by the second device 32 in the embodiment shown in fig. 5A, fig. 6, fig. 7A, or fig. 8 is performed.
Based on the same technical concept, the embodiment of the present application further provides a chip, which is coupled to the memory and configured to read and execute the program instructions stored in the memory, so that the method performed by the third device 33 in the embodiment shown in fig. 5A, fig. 6, fig. 7A, or fig. 8 is performed.
Based on the same technical concept, the embodiment of the present application further provides a chip, which is coupled to the memory and configured to read and execute the program instructions stored in the memory, so that the method performed by the first device 31 in the embodiment shown in fig. 5A, fig. 6, fig. 7A, or fig. 8 is performed.
Based on the same technical concept, the embodiment of the present application further provides a computer program instruction, which when running on a computer, causes the method performed by the second device 32 in the embodiment shown in fig. 5A, fig. 6, fig. 7A or fig. 8 to be performed.
Based on the same technical concept, the embodiment of the present application further provides a computer program instruction, which when running on a computer, causes the method performed by the third device 33 in the embodiment shown in fig. 5A, fig. 6, fig. 7A or fig. 8 to be performed.
Based on the same technical concept, the embodiment of the present application further provides a computer program instruction, which when running on a computer, causes the method performed by the first device 31 in the embodiment shown in fig. 5A, fig. 6, fig. 7A or fig. 8 to be performed.
The various embodiments described above can be combined with each other to achieve different technical effects.
Based on the same technical concept, the embodiment of the present application further provides an electronic device 1300, configured to implement the method in the embodiment shown in fig. 5A, fig. 6, fig. 7A, or fig. 8.
As shown in fig. 13, the electronic device 1300 may include a processor 1301 for executing programs or instructions stored in a memory 1302, the processor being configured to perform the methods in the embodiments shown in fig. 4-6 when the programs or instructions stored in the memory 1302 are executed.
Optionally, the electronic device 1300 may further include a communication interface 1303. Fig. 13 shows with dashed lines that the communication interface 1303 is optional for the electronic device 1300.
The number of the processors 1301, the memory 1302, and the communication interfaces 1303 does not limit the embodiments of the present application, and in specific implementation, the processors may be configured arbitrarily according to service requirements.
Optionally, the memory 1302 is external to the electronic device 1300.
Optionally, the electronic device 1300 includes the memory 1302, the memory 1302 is connected to the at least one processor 1301, and the memory 1302 stores instructions executable by the at least one processor 1301. Fig. 13 illustrates in dashed lines that the memory 1302 is optional for the electronic device 1300.
The processor 1301 and the memory 1302 may be coupled through an interface circuit, or may be integrated together, which is not limited herein.
In the embodiment of the present application, a specific connection medium among the processor 1301, the memory 1302, and the communication interface 1303 is not limited. In the embodiment of the present application, the processor 1301, the memory 1302, and the communication interface 1303 are connected through a bus 1304 in fig. 13, the bus is represented by a thick line in fig. 13, and the connection manner between other components is only schematically illustrated and is not limited. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 13, but this is not intended to represent only one bus or type of bus.
It should be understood that the processors mentioned in the embodiments of the present application may be implemented by hardware or may be implemented by software. When implemented in hardware, the processor may be a logic circuit, an integrated circuit, or the like. When implemented in software, the processor may be a general-purpose processor implemented by reading software code stored in a memory.
The Processor may be, for example, a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
It will be appreciated that the memory referred to in the embodiments of the application may be either volatile memory or nonvolatile memory, or may include both volatile and nonvolatile memory. The non-volatile Memory may be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable PROM (EPROM), an Electrically Erasable PROM (EEPROM), or a flash Memory. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of example, but not limitation, many forms of RAM are available, such as Static random access memory (Static RAM, SRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic random access memory (Synchronous DRAM, SDRAM), Double Data rate Synchronous Dynamic random access memory (DDR SDRAM), Enhanced Synchronous SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).
It should be noted that when the processor is a general-purpose processor, a DSP, an ASIC, an FPGA or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, the memory (memory module) may be integrated into the processor.
It should be noted that the memory described herein is intended to comprise, without being limited to, these and any other suitable types of memory.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the embodiments of the present application without departing from the scope of the embodiments of the present application. Thus, if such modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to encompass such modifications and variations.

Claims (23)

1. A networking method, applied to a second device, where the second device and a first device establish a first P2P connection, the first device has a role of GO as an intra-group administrator, and the second device has a role of GC as an intra-group client, the method comprising:
receiving a first P2P connection request from a third device;
when determining that the third device cannot establish the P2P connection with the third device, returning first information to the third device, wherein the first information is used for indicating the third device to establish a second P2P connection with the first device;
after the third device establishes the second P2P connection with the first device, an upper layer transmission control protocol, TCP, connection is established with the third device based on the first P2P connection and the second P2P connection.
2. The method of claim 1, wherein after determining that the third device cannot establish the P2P connection with itself, and before returning the first information to the third device, the method further comprises:
sending a query request to the first equipment, and receiving a first response message from the first equipment; the query request is used to query whether the first device allows to access a new GC device, and the first reply packet is used to indicate that the first device allows to access the new GC device.
3. The method of claim 1 or 2, wherein the first information comprises: link establishment information of the first device.
4. The method of claim 1 or 2, wherein the first information comprises: the link establishment information of the first device, the P2P port allocated to the third device by the first device, and the IP address.
5. The method according to any of claims 2-4, wherein the first P2P connection request carries link establishment information of the third device; after receiving the first P2P connection request, before sending the query request to the first device, the method further comprises:
and determining that the P2P port of the third device is available according to the link establishment information of the third device.
6. The method of any of claims 2-4, wherein after receiving the first P2P connection request, prior to sending the query request to the first device, the method further comprises:
transmitting a Bluetooth Low Energy (BLE) connection request to the third device;
receiving a third response message from the third device, where the third response message is used to indicate that the third device agrees to establish a BLE connection with the second device;
establishing a BLE connection with the third device, and receiving third information from the third device through the BLE connection, wherein the third information carries link establishment information of the third device;
and determining that the P2P port of the third device is available according to the link establishment information of the third device.
7. The method of any one of claims 1-6, wherein the establishing the TCP connection with the third device based on the first P2P connection and the second P2P connection after the third device establishes the second P2P connection with the first device comprises:
receiving request information forwarded by the first device, wherein the request information is information used by the third device to request to establish a TCP connection with the second device, and the request information carries a first TCP port used by the third device to establish the TCP connection;
and responding to the request information, and sending a fourth response message to the third equipment through the first equipment, wherein the fourth response message carries a second TCP port used by the second equipment for establishing the TCP connection.
8. A networking method, wherein a third device is applied, the method comprising:
sending a first P2P connection request to the second device; the second device and the first device establish a first P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC;
receiving first information from the second device, wherein the first information is sent by the second device when the second device cannot establish a P2P connection with the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
establishing a second P2P connection with the first device according to the first information;
establishing an upper layer transport control protocol, TCP, connection with the second device based on the first P2P connection and the second P2P connection.
9. The method of claim 8, wherein the first information comprises: link establishment information of the first device;
the establishing a second P2P connection with the first device according to the first information includes:
sending a second P2P setup request to the first device;
receiving a second response message from the first device, where the second response message carries a P2P port and an IP address allocated by the first device to the third device;
establishing a P2P connection with the first device in a GC role based on the P2P port and the IP address.
10. The method of claim 8, wherein the first information comprises: link establishment information of the first device, a P2P port allocated to the third device by the first device, and an IP address;
the establishing a second P2P connection with the first device according to the first information includes:
establishing the second P2P connection with the first device in a GC role based on the P2P port and the IP address.
11. The method according to any of claims 9-10, wherein the first P2P connection request carries link establishment information for the third device.
12. The method of any of claims 9-10, further comprising, after sending the first P2P connection request to the second device:
receiving a BLE connection request from the second device;
sending a third response message to the second device, where the third response message is used to indicate that the third device agrees to establish a BLE connection with the second device, so that the second device and the third device establish a BLE connection;
and sending third information to the second device through the BLE connection, where the third information carries link establishment information of the third device, and the link establishment information of the third device is used to indicate that a P2P port of the third device is available.
13. The method of any one of claims 8-12, wherein the establishing the TCP connection with the second device based on the first P2P connection and the second P2P connection, comprises:
request information sent to the second device by the first device, wherein the request information is used for requesting to establish a TCP connection with the second device, and the request information carries a first TCP port used by the third device for establishing the TCP connection;
receiving, by the first device, a fourth response packet from the second device, where the fourth response packet carries a second TCP port used by the second device to establish the TCP connection;
establishing a TCP connection based on the first TCP port, the second TCP port, and the second device.
14. A networking method is applied to a first device, wherein a first peer-to-peer P2P connection is established between the first device and a second device, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; the method comprises the following steps:
establishing a second P2P connection with the third device based on the first information; when the first information is that the third device requests to establish a P2P connection with the second device, the second device confirms that the P2P connection cannot be established with the third device and sends the connection to the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
establishing an upper layer transport control protocol, TCP, connection between the second device and the third device based on the first P2P connection and the second P2P connection.
15. The method of claim 14, wherein prior to establishing the second P2P connection with the third device, the method further comprises:
receiving a query request from the second equipment, and responding to the query request, and sending a first response message to the second equipment; the query request is used to query whether the first device allows to access a new GC device, and the first reply packet is used to indicate that the first device allows to access the new GC device.
16. The method of claim 14 or 15, wherein establishing a second P2P connection with the third device comprises:
receiving a second P2P setup request from the third device;
and sending a second response message to the third device in response to the second P2P establishment request, where the second response message carries the P2P port and the IP address allocated by the first device to the third device.
17. The method of any one of claims 14-16, wherein the establishing an upper layer TCP connection between the second device and the third device based on the first P2P connection and the second P2P connection comprises:
receiving request information from the third device over the second P2P connection and forwarding the request information to the second device over the first P2P connection; the request information is used for indicating the third equipment to request to establish a TCP connection with the second equipment, and the request information carries a first TCP port used by the third equipment to establish the TCP connection;
receiving a fourth response message from the second device through the first P2P connection, where the fourth response message carries a second TCP port used by the second device to establish the TCP connection;
forwarding the fourth response message to the third device through the second P2P connection.
18. A networking apparatus, which is applied to a second device in a networking system, where the networking system further includes a first device and the second device establish a first P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; the networking device includes:
a communication module for receiving a first P2P connection request from a third device;
the communication module is further configured to, after determining that the third device cannot establish a P2P connection with the third device, return first information to the third device, so that the third device establishes a second P2P connection with the first device according to the first information;
a processing module, configured to establish an upper layer TCP connection with the third device based on the first P2P connection and the second P2P connection after the third device establishes the second P2P connection with the first device.
19. A networking apparatus, configured to be applied to a third device in a networking system, where the networking system further includes a first device and a second device, where the first device and the second device establish a first P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; the networking device includes:
a communication module, configured to send a first P2P connection request to the second device;
the communication module is further configured to receive first information from the second device, where the first information is sent by the second device when the P2P connection cannot be established with the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
the processing module is used for establishing a second P2P connection with the first equipment according to the first information;
the processing module is further configured to establish an upper layer transmission control protocol, TCP, connection with the second device based on the first P2P connection and the second P2P connection.
20. A networking apparatus, configured to be applied to a first device in a networking system, where the networking system further includes a second device and a third device, where the first device and the second device establish a first peer-to-peer P2P connection, the first device has a role of a group administrator GO, and the second device has a role of a group client GC; the networking device includes:
a processing module, configured to establish a second P2P connection with the third device; the second P2P connection is established by the third device with the third device based on first information, and when the third device requests to establish a P2P connection with the second device, the second device confirms that a P2P connection cannot be established with the third device and sends the connection to the third device; the first information is used for indicating the third device to establish a second P2P connection with the first device;
the processing module is further configured to establish an upper layer TCP connection between the second device and the third device based on the first P2P connection and the second P2P connection when the third device establishes a second P2P connection with the first device based on the first information.
21. A networking system, comprising a first device, a second device and a third device, wherein the first device and the second device establish a first peer-to-peer P2P connection, the first device has a role of GO as an intra-group administrator, and the second device has a role of GC as an intra-group client;
the second device to perform the method of any one of claims 1-7;
the third device to perform the method of any one of claims 8-13;
the first device to perform the method of any one of claims 14-17.
22. An electronic device, comprising:
at least one processor; and a memory communicatively coupled to the at least one processor, a communication interface;
wherein the memory stores instructions executable by the at least one processor, the at least one processor causing the electronic device to perform the method of any of claims 1-7, or claims 8-13, or claims 14-17 by executing the instructions stored by the memory.
23. A computer-readable storage medium comprising a program or instructions which, when run on a computer, causes the method of any of claims 1-7, or claims 8-13, or claims 14-17 to be performed.
CN202011125466.6A 2020-10-20 2020-10-20 Networking method, device and system Pending CN114390491A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011125466.6A CN114390491A (en) 2020-10-20 2020-10-20 Networking method, device and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011125466.6A CN114390491A (en) 2020-10-20 2020-10-20 Networking method, device and system

Publications (1)

Publication Number Publication Date
CN114390491A true CN114390491A (en) 2022-04-22

Family

ID=81192948

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011125466.6A Pending CN114390491A (en) 2020-10-20 2020-10-20 Networking method, device and system

Country Status (1)

Country Link
CN (1) CN114390491A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117135767A (en) * 2023-10-24 2023-11-28 荣耀终端有限公司 Method for connecting devices and electronic device
WO2024012343A1 (en) * 2022-07-14 2024-01-18 华为技术有限公司 Networking method and electronic device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024012343A1 (en) * 2022-07-14 2024-01-18 华为技术有限公司 Networking method and electronic device
CN117135767A (en) * 2023-10-24 2023-11-28 荣耀终端有限公司 Method for connecting devices and electronic device
CN117135767B (en) * 2023-10-24 2024-04-12 荣耀终端有限公司 Method for connecting devices and electronic device

Similar Documents

Publication Publication Date Title
US10932310B2 (en) Communication device, communication method, program, and communication system
EP3700294B1 (en) Method for data transmission using multiple wifi links
US20220201453A1 (en) Service connection establishment method, bluetooth master device, chip, and bluetooth system
WO2020164519A1 (en) Method for data transmission and related products
US9521589B2 (en) Wi-Fi direct service method using NFC and device therefor
EP3550888B1 (en) Wireless connection switching method and terminal
US20130311692A1 (en) Apparatus and method for direct pairing in a wireless docking system
WO2018045561A1 (en) File transmission method, file reception method and terminal
US20100198952A1 (en) Method for WALN network and device role activation
US10292189B2 (en) Method of network configuration for wireless access point
KR20130097265A (en) Method and apparatus for providing ip address in wireless communication network
US10863559B2 (en) Method and apparatus for communicating in a wireless communication network
TWI415501B (en) Wireless network system and wireless access point device thereof
US20180027601A1 (en) Communication apparatus, method of controlling the same, and non-transitory computer-readable storage medium
EP3114821B1 (en) Method and devices for establishing a connection between a seeker device and a target device
WO2022143071A1 (en) Connection establishment method and electronic device
US11611604B2 (en) Method and apparatus for receiving streaming via transport protocol in wireless communication system
WO2022135187A1 (en) Data transmission method under wi-fi peer-to-peer, and electronic device
CN114390491A (en) Networking method, device and system
US20230345221A1 (en) Method for transmitting data in near field, device, and system
JP2014072764A (en) Radio communication device
JP2015176536A (en) Communication device, communication method, communication program, and storage medium
JP5812065B2 (en) External storage device, data file transmission / reception system, data file transmission / reception method / program
JP2013021412A (en) Communication device, communication method, and communication program
WO2020199055A1 (en) Communication method, apparatus and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination