Network connection method, device, system and program product

Through the two-level service discovery method, combined with service discovery before and after network connection, the problem of low efficiency and missed detection of service discovery in WiFi direct connection is solved, and efficient service discovery and connection are achieved.

CN115175148BActive Publication Date: 2025-08-26ALIBABA INNOVATION PRIVATE LIMITED
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110292097.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-18
Publication Date
2025-08-26
Estimated Expiration
2041-03-18

AI Technical Summary

Technical Problem

When direct WiFi connection between different devices, the prior art has problems such as low service discovery efficiency and missed service inspection, resulting in long connection and easy to miss devices that support target services.

Method used

Using a two-level service discovery method, first broadcast the supported service information through the service discovery protocol. If the target service is not listened to, a short connection is established based on the MAC address of other devices recorded and the services provided by other devices are queried. If the target service is discovered, a long connection is established.

Benefits of technology

It improves the efficiency of service discovery, reduces the probability of service omission, saves service discovery time, and avoids omissions caused by inability to use or modification after service information is revealed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115175148B_ABST
    Figure CN115175148B_ABST
Patent Text Reader

Abstract

The present application provides a network connection method, device, system, and program product. In the present application, a two-level service discovery method combines service discovery before and after network connection, achieving complementary advantages and disadvantages of the two-level service discovery method. For devices that can perform service discovery by transmitting service information before connection, service discovery time can be saved. For devices that do not support pre-connection service information transmission, service discovery is performed through a short post-connection query method, avoiding missing devices that support the target service. This can improve service discovery efficiency while reducing the probability of service omission.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a network connection method, device, system and program product. Background Art

[0002] With the advancement of communication technology, the Wi-Fi Alliance has developed the Wi-Fi Direct standard for ease of use. Wi-Fi Direct allows devices on a wireless network to connect to each other without requiring a wireless router. This standard allows wireless devices to connect in a point-to-point manner, significantly improving transmission speed and range compared to Bluetooth.

[0003] In practical applications, when Wi-Fi Direct connects different devices, they can only establish connections with devices that provide the services they need. To prevent misconnections, service discovery is necessary. However, how to balance service discovery efficiency and avoid omissions during service discovery remains a challenge that continues to be researched and addressed by those skilled in the art. Summary of the Invention

[0004] Various aspects of the present application provide a network connection method, device, system, and program product for improving service discovery efficiency while reducing the probability of missed service detection.

[0005] An embodiment of the present application provides a network system, including: a first device, broadcasting service information supported by the first device through a service discovery protocol; a second device, listening for service broadcasts; if no service information carrying a target service required by the second device is detected within a first set time period, establishing a short connection with one of the third devices based on the MAC address of the third device recorded by the second device; and querying the services provided by the third device; if the service provided by the third device is the target service required by the second device, establishing a long connection with the third device; the third device and the first device may be the same or different devices.

[0006] The present application also provides a network connection method, including:

[0007] In response to a start event for a discovery service, listening for service broadcasts;

[0008] If no service information carrying the required target service is detected within the first set time period, a short connection is established with one of the other devices based on the recorded MAC addresses of the other devices;

[0009] Query the services provided by other devices currently connected to the server;

[0010] If it is found that the services provided by the other devices in the current short connection include the required target service, a long connection is established with the other devices in the current short connection.

[0011] An embodiment of the present application further provides a network device, comprising: a memory, a processor, and a communication component supporting WiFi direct connection; wherein the memory is used to store a computer program;

[0012] The processor is coupled to the memory and the communication component, and is configured to execute the computer program to perform the steps in the above-mentioned network connection method.

[0013] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the steps in the above-mentioned network connection method.

[0014] An embodiment of the present application also provides a computer program product, including a computer program; when the computer program is executed by a processor, the steps in the above-mentioned network connection method can be implemented.

[0015] In an embodiment of the present application, a first device in a network system that supports service broadcasting can broadcast supported service information through a service discovery protocol; a second device in the network system can listen to service broadcasts, and if service information carrying the required target service is not heard within a set time period, establish a short connection with one of the other devices based on the recorded MAC addresses of the other devices; and query the services provided by the other devices currently in the short connection; if the services provided by the other devices currently in the short connection are found to include the target service, a long connection is established with the device currently in the short connection. The two-level service discovery method provided by the embodiment of the present application combines the service discovery before and after the network connection, and realizes the complementary advantages and disadvantages of the two-level service discovery method. For devices that can perform service discovery by transmitting service information before connection, service discovery time can be saved. For devices that do not support transmitting service information before connection, service discovery is performed by querying after the short connection to avoid missing devices that support the target service. This can improve the efficiency of service discovery while reducing the probability of service omission. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0017] Figure 1a A schematic diagram of a solution for service discovery via mDNS provided in an embodiment of the present application;

[0018] Figure 1bA schematic diagram of a solution for service discovery through a P2P discovery service provided in an embodiment of the present application;

[0019] Figure 2a A schematic diagram of the network system structure and service discovery process provided in an embodiment of the present application;

[0020] Figure 2b Schematic diagram of the service discovery process provided in this embodiment of the application;

[0021] Figure 3 A flowchart of a network connection method provided in an embodiment of the present application;

[0022] Figure 4 A schematic diagram of the structure of the network device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0023] To make the purpose, technical solutions, and advantages of this application more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this application and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0024] WiFi Direct (WiFi Direct) is a peer-to-peer (P2P) network technology, also known as point-to-point technology, that allows devices in a wireless network to connect to each other without going through a wireless router. WiFi Direct, also known as WiFi P2P, enables multiple network devices to form a network and communicate with each other without a wireless access point (AP). The network formed is a P2P network (P2P Network), also known as a P2P group (P2P Group). In the embodiments of the present application, P2P refers to WiFi P2P.

[0025] In this embodiment, multiple network devices can connect directly via WiFi to form a P2P network. In practical applications, when different devices connect directly via WiFi, they can only establish connections with devices that provide the required services. To prevent accidental connections, service discovery is required. For example, a car device equipped with a mapping application can connect to a camera via WiFi Direct, but for greater specificity, only cameras that provide services provided by the mapping application will be connected.

[0026] To achieve service discovery, in some embodiments, such as Figure 1aAs shown, after network devices are connected via an AP or WiFi P2P, they can use the Multicast Domain Name System (mDNS) to discover services. mDNS can be understood as the DNS system within a local area network (LAN). mDNS enables service discovery, lookup, and broadcast within the LAN. mDNS is also a multicast-based protocol.

[0027] mDNS generally operates within a local area network (LAN), has a specific IP address (224.0.0.251), and a specific port (5353). mDNS is used to enable service discovery, query, and registration within the LAN, and can resolve host names to IP addresses in small networks that do not have a local name server.

[0028] exist Figure 1a In this example, device A connects to a local area network (LAN) via an access point (AP) or Wi-Fi P2P, enables the mDNS service, and registers the following information with the mDNS service: "Service A is provided, my IP address is IP_A, and my port is Port_A." When device C connects to the LAN, it sends a service request to the mDNS server on device C's host, looking for service A within the LAN. The mDNS server on device C then queries the mDNS servers on other hosts within the LAN and eventually learns that there is a host with IP_A and port number Port_A, indicating that device A provides service A. This allows device C to determine the IP address and port number of device A's host, and thus, that device A provides service A.

[0029] In the above Figure 1a The provided service discovery solution requires devices to be connected to the network before multicast can be enabled, using mDNS to discover the required services. Therefore, in a Wi-Fi P2P environment with multiple devices, it is necessary to repeatedly connect to each device to discover whether the required service exists. If not, a Wi-Fi direct connection is required to the next device until the required service is found. Each network connection takes a long time, and many connections may be unused, resulting in a waste of time.

[0030] In other embodiments, Figure 1bAs shown, network devices can discover services through service discovery technology (Service Discovery) before connecting to other P2P devices through WiFi. Before connecting to the network with device B, device A can broadcast the services it supports through the service discovery protocol. Specifically, the supported services are broadcast through the service broadcast (ServiceBroadcast) in the service discovery protocol. When device B needs a WiFi direct connection, it starts scanning and can use the Service Listen service to scan for services broadcast by surrounding devices. When device B detects the required service, it initiates a WiFi direct connection request to device A that provides it. After device A confirms the request, the connection between device B and device A is established.

[0031] exist Figure 1b The provided service discovery solution requires device A to declare its support for certain services at the underlying layer. This service declaration relies on the device manufacturer or system provider. This requires significant permissions and is often impossible for Android devices or embedded Linux devices. Android devices cannot prevent other apps from modifying the advertised service name. Embedded Linux devices require underlying support, and at the WiFi layer, Linux system providers are reluctant to easily declare specific services.

[0032] exist Figure 1b In the provided service discovery solution, for a device that does not support service declaration, even if the device can provide the service required by device B, device B cannot discover the device, resulting in missed service detection and subsequent missed connection between device B and the device.

[0033] To sum up, Figure 1a The provided service discovery solution has problems such as long connection time and low service discovery efficiency; Figure 1b The provided service discovery solution is prone to missing services, which can lead to the problem of missing subsequent device connections. Therefore, how to balance service discovery efficiency and avoid service omissions during service discovery has become a problem that technicians in this field need to continue to study.

[0034] In order to solve the above technical problems, the present application provides some embodiments:

[0035] The first device in the network system that supports service broadcasting can broadcast the supported service information through the service discovery protocol; the second device in the network system can listen to the service broadcast, and if the service information carrying the required target service is not heard within the set time, it can establish a short connection with one of the other devices based on the recorded MAC addresses of the other devices; and query the services provided by the other devices currently in the short connection; if it is found that the services provided by the other devices currently in the short connection include the target service, a long connection is established between the device currently in the short connection. The two-level service discovery method provided by the embodiment of the present application combines the service discovery before and after the network connection to achieve complementary advantages and disadvantages of the two-level service discovery method. For devices that can perform service discovery by transmitting service information before connection, service discovery time can be saved. For devices that do not support the transmission of service information before connection, service discovery is performed by querying after the short connection to avoid missing devices that support the target service. This can improve the efficiency of service discovery while reducing the probability of service omission.

[0036] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.

[0037] It should be noted that the same reference numerals denote the same objects in the following drawings and embodiments, and therefore, once an object is defined in one drawing or embodiment, it does not need to be further discussed in the subsequent drawings and embodiments.

[0038] Figure 2a This is a schematic diagram of the structure of the network system provided in the embodiment of the present application. Figure 2a As shown, the network system includes: a plurality of network devices 11. Wherein, a plurality refers to 2 or more. In the embodiment of the present application, the focus is mainly on the case where the number of network devices is 3 or more.

[0039] In this embodiment, the plurality of network devices 11 are devices that support WiFi direct connection, i.e., devices that support WiFi P2P (hereinafter referred to as P2P devices). In this embodiment of the present application, the implementation form of the network device 11 is not limited. For example, the network device can be a computer device (such as a terminal device or server, etc.) that supports WiFi direct connection, a hub, a switch, a bridge, a router, a gateway, a printer, or a camera, etc. Among them, the terminal device can be a smartphone, a tablet computer, a personal computer, a wearable device, or an in-vehicle device, etc.

[0040] In this embodiment, multiple network devices 11 may all support service broadcast (Service Broadcast), may partially support service broadcast, or may not support service broadcast at all. For the case where multiple network devices 11 include devices that support service broadcast, the device 11a that supports service broadcast among the multiple network devices 11 can broadcast the service information supported by the first device through the service discovery protocol. In the embodiment of the present application, for the convenience of description, the device 11a that supports service broadcast is defined as the first device 11a. The number of first devices 11a can be one or more, and multiple means two or more. Optionally, for the first device 11a, it can periodically broadcast its own service information according to the set broadcast period.

[0041] The service information of the first device 11a includes the services supported by the first device 11a. Since the first device 11a broadcasts the service information at the link layer, the service information complies with the link layer protocol. Accordingly, the service information may also include the MAC address of the first device 11a.

[0042] In this embodiment, for devices that need to perform service discovery, the P2P Discovery service can be enabled. P2P Discovery allows multiple WiFi P2P-enabled devices (referred to as P2P devices) to discover each other and build a network. P2P Discovery may include the following parts:

[0043] (1) Device Discovery: Used by a P2P device to search for other P2P devices around it.

[0044] (2) Service Discovery: It is used to search for a specified service among the services provided by the P2P devices based on the P2P-supported devices discovered by the above devices.

[0045] (3) Group Formation: This determines which of the two P2P devices will act as the Group Owner (GO) and which will act as the P2P Client. The GO acts like an AP, while the P2P Client acts like a STA.

[0046] (4) P2P Invitation: used to activate a persistent group or to invite a P2P client to join an existing group.

[0047] Based on the above analysis, device 11b with the P2P discovery service enabled among multiple network devices 11 can listen to service broadcasts to obtain service information broadcast by other P2P devices. In this embodiment, for ease of description, the device with the P2P discovery service enabled is defined as the second device 11b. There can be one or more second devices 11b. "Multiple" refers to two or more.

[0048] For the second device 11b, in response to the start event of the P2P discovery service, the P2P discovery service can be started and the function of listening for service broadcasts can be enabled. In response to the start event of the P2P discovery service, the second device 11b can also determine the service that the P2P discovery service needs to discover, that is, the service required by the second device 11b, which is defined as the target service. In this embodiment, the specific content of the target service is not limited. Optionally, the target service can be, but is not limited to, a printer service, a screen projection service, a camera service, a sound service, a microphone service, a transmission service, or a communication service.

[0049] In some embodiments, the second device 11b may provide a human-computer interaction interface. The human-computer interaction interface may provide a service call control, which a user may trigger to allow the second device 11b to call the service corresponding to the service call control. Accordingly, in response to a start event generated by the triggering of the service call control, the second device 11b may determine that the service to be discovered is the service associated with the service call control (e.g., a camera service). Furthermore, the second device 11b may initiate a P2P discovery service and begin listening for service broadcasts.

[0050] In other embodiments, the second device 11b supports voice recognition. A user can interact with the second device 11b through voice to instruct it to initiate a P2P discovery service. For example, the user can say, "Please connect to a printer" or "Please connect to a camera." The second device 11b can perform semantic recognition on the collected sound signal to identify the service specified in the sound signal as the desired target service. Furthermore, in response to a start event generated by the semantically recognized target service, the second device 11b can initiate the P2P discovery service and begin listening for service broadcasts.

[0051] While starting the function of listening for service broadcasts, the second device 11b can also start timeout detection. If the second device 11b receives service information within the set timeout period (defined as the first set period), it can determine whether the service information intercepted within the first set period includes the required target service; if the judgment result is yes, it can establish a long connection with the first device 11a that broadcasts service information including the target service based on the MAC address of the first device 11a that broadcasts service information including the target service. Among them, this long connection follows the WiFi Direct protocol, that is, the connection between the second device 11b and the device that provides service information including the target service is a WiFi P2P connection.

[0052] Optionally, the second device 11b may parse the MAC address of the device broadcasting the service information from the service information including the target service; and establish a persistent connection with the device broadcasting the service information based on the MAC address of the device broadcasting the service information.

[0053] In some embodiments, for a P2P device, after WiFi P2P is enabled, it can broadcast a probe message (Proberequest) so that other P2P devices can detect it. The P2P device broadcasts the probe message at the link layer of the TCP / IP protocol, so the header of the probe message includes the MAC address of the P2P device. Based on this, the second device 11b can also record the MAC addresses of other devices. Accordingly, the second device 11b can also obtain the MAC address of the first device 11a that broadcasts the service information carrying the target service from the recorded MAC addresses of other devices; and based on the MAC address of the first device 11a, establish a long connection with the first device 11a.

[0054] Accordingly, if the second device 11b does not detect the service information including the target service required by the second device within the first set time period, it can query the services provided by other devices by establishing a short connection with other devices in the network system. Among them, the second device 11b does not detect the service information including the target service required by the second device within the first set time period, including the following two possibilities: (1) the second device 11b does not detect the service information within the first set time period; (2) the second device 11b detects the service information within the first set time period, but the detected service information does not include the target service required by the second device 11b. The following is an exemplary description of the implementation method of service discovery in the case where the second device 11b does not detect the service information including the target service required by the second device within the first set time period.

[0055] In this embodiment, for a P2P device, after WiFi P2P is turned on, it can broadcast a probe message (Proberequest) so that other P2P devices can detect itself. The broadcast of the probe message by the P2P device occurs at the link layer, so the message header of the probe message includes the MAC address of the P2P device. Based on this, the second device 11b can also record the MAC addresses of other devices in the multiple network devices 11. For the convenience of description and distinction, in this embodiment of the application, the device corresponding to the MAC address recorded by the second device 11b is defined as the third device 11c. Among them, the third device 11c and the above-mentioned first device 11a can be the same device or different devices. Optionally, the third device 11c may include the above-mentioned first device 11a or may not include the above-mentioned first device 11a. Optionally, the second device 11b can receive the probe message broadcast by the third device 11c, parse the MAC address of the third device 11c from the received probe message, and record the MAC address of the third device 11c.

[0056] Furthermore, if the second device 11b does not detect the service information including the target service required by the second device within the first set time period, it can establish short connections with the third device 11c in batches based on the recorded MAC address of the third device 11c. Among them, short connection refers to a temporary connection, and the specific connection time can be flexible according to the needs of the device. Among them, the short connection is a link layer connection. Since the MAC address of the third device 11c has been recorded by the second device 11b, when the second device 11b needs to connect to the third device 11c, it does not need to scan the node information of other P2P devices, which can save node scanning time. Among them, the scanning time is about 15-30s.

[0057] Optionally, when establishing short connections with third devices 11c in batches, the second device 11b may select M third devices 11c from the third devices 11c that have not previously established connections; and establish short connections with these M third devices based on their MAC addresses. M is a positive integer less than the total number of third devices 11c. Optionally, M = 1, meaning that the second device 11b establishes short connections with each third device 11c one by one.

[0058] The following describes in detail the implementation method for establishing a short connection between the second device 11b and one third device 11c at a time. If the second device 11b does not detect service information including the target service required by the second device within a first set time period, it can establish a short connection with one of the third devices 11c based on the recorded MAC address of the third device 11c and query the services provided by the third device 11c currently connected to the second device 11b. If the service provided by the third device 11c includes the target service required by the second device 11b, a long connection is established between the third device 11c and the currently connected third device 11c. The connection is successful, and the service discovery process ends. A long connection is a long-term connection.

[0059] Optionally, if the service provided by the third device 11c that currently establishes a short connection with the second device 11b does not include the target service required by the second device 11b, the second device 11b may disconnect the short connection with the third device 11c; then establish a short connection with one of the third devices 11c that has not currently established a short connection with the second device 11b, and query the services provided by the third device 11c, and repeat this cycle until all third devices 11c have been traversed, or until the target service required by the second device 11b is queried; and establish a long connection with the third device 11c that includes the target service required by the second device 11b.

[0060] The aforementioned multiple network devices 11 may support mDNS services. When accessing a local area network, each of the network devices 11 may register its available services with its host mDNS service. In an embodiment of the present application, the third device 11c may register its available services with its respective host mDNS service when establishing a short connection with the second device 11b. Based on this, the second device 11b may send a multicast query for the required services via mDNS. The specific implementation is as follows:

[0061] like Figure 2b As shown, the second device 11b can request a target service from the mDNS service of the second device 11b and send a query request to the mDNS service of the third device 11c through the mDNS service of the second device 11b. The query request includes the identifier of the target service. Here, the third device 11c is the device that currently has a short connection with the second device 11b.

[0062] Accordingly, the third device 11c can resolve the identifier of the target service through the mDNS service of the third device 11c; and use the identifier of the target service to query the services provided by the pre-registered third device 11c; if the target service is found in the services provided by the pre-registered third device 11c, the IP address and port number of the third device 11c are returned to the second device 11b. When the second device 11b initiates a query request, a timeout detection can also be enabled. If the second device 11b receives the IP address and port number of the third device within the set timeout period (defined as the second set period), it is determined that the services provided by the third device 11c include the target service. Furthermore, the second device 11b can establish a long connection with the third device 11c. Here, the third device 11c is the device that currently establishes a short connection with the second device 11b.

[0063] Accordingly, if the second device 11b does not receive a response to the query request from the third device 11c within the second timeout period, it determines that the service provided by the third device 11c does not include the target service, and disconnects the short connection with the third device 11c.

[0064] Furthermore, the second device 11b may select the next third device 11c with which no connection has been established from the third devices 11c with which the MAC address is recorded, and establish a short connection until the third device 11c with which the MAC address is recorded completes the attempt.

[0065] The two-level service discovery method provided in this embodiment combines the service discovery before and after network connection to achieve complementary advantages and disadvantages of the two-level service discovery methods. For devices that can discover services by transmitting service information before connection, service discovery time can be saved. For devices that do not support the transmission of service information before connection, service discovery is performed through a query method after a short connection to avoid missing devices that support the target service. This can improve service discovery efficiency while reducing the probability of missed service detection.

[0066] On the other hand, the service discovery method provided in this embodiment can prevent some device services from being exposed and unusable. For example, the exposed services are modified, but these devices actually contain the target services, resulting in omissions. By establishing a short connection with the P2P device to query the service, time can be exchanged for reliability, reducing the probability of missing services for such devices.

[0067] In addition to the above-mentioned system embodiment, the embodiment of the present application also provides a network connection method. The network connection method provided in this embodiment is exemplarily described below from the perspective of the above-mentioned second device.

[0068] Figure 3 This is a flow chart of the network connection method provided in the embodiment of the present application. Figure 3 As shown, the method includes:

[0069] 301. In response to a start event for a discovery service, listen to service broadcasts.

[0070] 302. If no service information carrying the required target service is detected within the first set time period, a short connection is established with one of the other devices based on the recorded MAC addresses of the other devices.

[0071] 303. Query the services provided by other devices currently connected to the short connection.

[0072] 304. If it is found that the services provided by the other devices in the current short connection include the required target service, a long connection is established with the other devices in the current short connection.

[0073] In this embodiment, for the implementation form of the start event for the discovery service, please refer to the relevant content of the above-mentioned system embodiment, which will not be repeated here. In this embodiment, in step 301, for the P2P device that turns on the P2P discovery service, the service broadcast can be listened to and the timeout detection can be turned on. If the service information is received within the set timeout period (defined as the first set period), it can be determined whether the service information intercepted within the first set period includes the required target service; if the judgment result is yes, the MAC address of the device providing the service information can be parsed from the service information including the target service; and based on the MAC address of the device providing the service information, a long connection is established with the device providing the service information. Among them, the long connection follows the WiFi direct connection protocol, that is, the connection between the device providing the service information including the target service is a WiFi P2P connection.

[0074] Alternatively, the MAC address of the device broadcasting the service information carrying the target service is obtained from the recorded MAC addresses of other devices; and a persistent connection is established with the device based on the MAC address of the device. Regarding the implementation of recording the MAC addresses of other devices, please refer to the relevant content of the above system embodiment and will not be repeated here.

[0075] Accordingly, if the service information including the target service required by the second device is not detected within the first set time period, a short connection can be established with other devices in the network system to query the services provided by other devices. Among them, the failure to detect the service information including the required target service within the first set time period includes the following two possibilities: (1) the service information is not detected within the first set time period; (2) the service information is detected within the first set time period, but the detected service information does not include the required target service. The following is an exemplary description of the implementation method of service discovery in the case where the service information including the required target service is not detected within the first set time period.

[0076] In this embodiment, after WiFi P2P is enabled, a P2P device can broadcast a probe message (Probe Request) to allow other P2P devices to detect it. Probe message broadcasting by a P2P device occurs at the link layer, so the probe message header includes the P2P device's MAC address. Based on this, the P2P device can record the MAC addresses of other devices. Optionally, it can receive probe messages broadcast by other devices, parse the MAC addresses of other devices from the received probe messages, and record the MAC addresses of other devices.

[0077] Furthermore, if no service information including the desired target service is detected within the first set time period, short connections may be established with other devices in batches based on the recorded MAC addresses of other devices in step 302. Since the MAC addresses of other devices are already recorded, there is no need to scan the node information of other devices when connections are needed, thus saving node scanning time.

[0078] Optionally, when establishing short connections with other devices in batches, M devices that have not previously established short connections can be selected from other P2P devices each time; and short connections can be established with these M devices based on their MAC addresses. M is a positive integer less than the total number of other P2P devices. Optionally, M = 1, meaning that the second device 11b establishes short connections with each of the other P2P devices one by one. That is, step 302 can be implemented as follows: if service information including the desired target service is not detected within a first set time period, a short connection is established with one of the other devices based on the recorded MAC addresses of the other devices.

[0079] Furthermore, in step 303, the services provided by other devices in the current short connection may be queried. If the services provided by other devices in the current segment connection include the required target service, in step 304, a long connection is established with the other devices in the current short connection.

[0080] In some embodiments, the network device may support mDNS service. For the network device, it may register the services that can be provided with its host mDNS service when accessing the local area network. In an embodiment of the present application, other devices may register the services that can be provided with their respective host mDNS services when establishing a short connection with the device that performs service discovery. Based on this, the device that performs service discovery can send a multicast query for the required services through mDNS. Accordingly, an optional implementation of step 304 is: requesting the target service from the mDNS service; sending a query request to other devices currently in short connection through the mDNS service, so that other devices currently in short connection can use the identifier of the target service contained in the query request to query the services provided by other pre-registered devices; and receiving the IP address and port number returned by the other devices currently in short connection when querying the target service, and determining that the services provided by the other devices currently in short connection include the target service.

[0081] Correspondingly, if no response to the query request is received from the other device in the current short connection within the second timeout period, it is determined that the service provided by the other device in the current short connection does not include the target service, and the short connection with the other device in the current connection is disconnected.

[0082] Furthermore, a short connection can be established between the next device that has not been connected and the other devices that have recorded the MAC address, until all the other devices that have recorded the MAC address are traversed; or, until the target service required by the second device 11b is found; and a long connection is established between the third device 11c that includes the target service required by the second device 11b.

[0083] The two-level service discovery method provided in this embodiment combines the service discovery before and after network connection to achieve complementary advantages and disadvantages of the two-level service discovery methods. For devices that can discover services by transmitting service information before connection, service discovery time can be saved. For devices that do not support the transmission of service information before connection, service discovery is performed through a short post-connection query method to avoid missing devices that support the target service. This can improve service discovery efficiency while reducing the probability of service omissions.

[0084] It should be noted that the execution entity of each step of the method provided in the above embodiment can be the same device, or the method can be executed by different devices. For example, the execution entity of steps 302 and 303 can be the first device; for another example, the execution entity of step 302 can be the first device, and the execution entity of step 303 can be the second device; and so on.

[0085] In addition, some of the processes described in the above embodiments and the accompanying drawings include multiple operations that appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order in which they appear in this document or may be executed in parallel. The sequence numbers of the operations, such as 302 and 303, are merely used to distinguish between different operations and do not represent any execution order. In addition, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel.

[0086] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing computer instructions. When the computer instructions are executed by one or more processors, the one or more processors are caused to execute the steps in the above-mentioned network connection method.

[0087] An embodiment of the present application also provides a computer program product, including a computer program; when the computer program is executed by a processor, the steps in the above-mentioned network connection method can be implemented.

[0088] Figure 4 This is a schematic diagram of the structure of the network device provided in the embodiment of the present application. Figure 4 As shown, the network device includes: a memory 40a, a processor 40b and a communication component 40c supporting WiFi direct connection. Among them, the memory 40a is used to store computer programs.

[0089] The processor 40a is coupled to the memory 40b and the communication component 40c, and is used to execute a computer program for: in response to a start event for discovering a service, listening to service information through the communication component 40c; if no service information carrying the required target service is heard within a first set time period, then based on the recorded MAC addresses of the other devices, establishing a short connection with one of the other devices through the communication component 40c; and querying the services provided by the other devices currently in the short connection; if the services provided by the other devices currently in the short connection include the target service, then establishing a long connection with the other devices currently in the short connection through the communication component 40c.

[0090] In some embodiments, the processor 40b is further configured to: receive a probe message broadcasted by other devices through the communication component 40c; parse the probe message to obtain a MAC address of the device providing the probe message; and record the MAC address of the device providing the probe message.

[0091] In some embodiments, the processor 40b is also used to: when service information is detected within the first set time period, determine whether the service information detected within the first set time period includes the target service; if the judgment result is yes, parse the MAC address of the device providing the first service information from the first service information including the target service; and based on the MAC address of the device providing the first service information, establish a long connection with the device providing the first service information through the communication component 40c.

[0092] Optionally, the processor 40b may be further configured to establish short connections with other devices in batches based on the recorded MAC addresses of the other devices. Specifically, each time, M devices with which no connection has been established are selected from the other devices; where M is a positive integer and is less than the total number of the other devices; and based on the MAC addresses of the M devices, short connections are established with the M devices via the communication component 40c.

[0093] Optionally, when querying services provided by other devices in the current short connection, the processor 40b is specifically configured to: request a target service from the mDNS service; send a query request to the other devices in the current short connection through the mDNS service, so that the other devices in the current short connection use the identifier of the target service included in the query request to query the pre-registered services provided by the other devices; and receive, through the communication component 40c, the IP address and port number returned by the other devices in the current short connection when querying the target service, and determine that the services provided by the other devices in the current short connection include the target service.

[0094] Accordingly, if no response to the query request is received from the other device in the current short connection within the second set time, it is determined that the service provided by the other device in the current short connection does not include the target service, and the short connection with the currently connected P2P device is disconnected.

[0095] In some optional embodiments, such as Figure 4 As shown, the network device may further include: a power supply component 40d and other components. Figure 4 Only some components are shown schematically, which does not mean that the network equipment must include Figure 4 All components shown do not mean that network equipment can only include Figure 4 Components shown.

[0096] The network device provided in this embodiment can combine the service discovery before and after the network connection, and realize the complementary advantages and disadvantages of the two-level service discovery methods. For devices that can perform service discovery by transmitting service information before connection, service discovery time can be saved. For devices that do not support the transmission of service information before connection, service discovery is performed through a short post-connection query method to avoid missing devices that support the target service. This can improve the service discovery efficiency while reducing the probability of service omission.

[0097] In an embodiment of the present application, the memory is used to store computer programs and can be configured to store various other data to support operations on the device where it is located. The processor can execute the computer program stored in the memory to implement the corresponding control logic. The memory can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0098] In the embodiment of the present application, the processor can be any hardware processing device that can execute the logic of the above method. Optionally, the processor can be a central processing unit (CPU), a graphics processing unit (GPU) or a microcontroller unit (MCU); it can also be a programmable device such as a field programmable gate array (FPGA), a programmable array logic device (PAL), a general array logic device (GAL), a complex programmable logic device (CPLD); or an advanced reduced instruction set (RISC) processor (Advanced RISC Machines, ARM) or a system on chip (System on Chip, SOC), etc., but is not limited thereto.

[0099] In embodiments of the present application, a power supply assembly is configured to provide power to various components of the device in which it is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.

[0100] In an embodiment of the present application, the audio component may be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as call mode, recording mode, and voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal may be further stored in a memory or sent via a communication component. In some embodiments, the audio component further includes a speaker for outputting an audio signal. For example, for a device with a language interaction function, voice interaction with a user can be achieved through the audio component.

[0101] It should be noted that the descriptions such as "first" and "second" in this article are used to distinguish different messages, devices, modules, etc., and do not represent the order of precedence, nor do they limit "first" and "second" to different types.

[0102] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0103] The present application is described with reference to the flow chart and / or block diagram of the method, device (system), and computer program product according to the embodiment of the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart flow or multiple flows and / or one box or multiple boxes of the block diagram.

[0104] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.

[0106] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0107] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0108] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0109] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0110] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A network system, wherein: include: The first device broadcasts service information supported by the first device through a service discovery protocol; The second device listens to the service broadcast. If the service information carrying the target service required by the second device is not heard within the first set time period, a short connection is established with one of the third devices based on the MAC address of the third device recorded by the second device through receiving the detection message, and the service provided by the third device is queried; if the service provided by the third device includes the target service required by the second device, a long connection is established with the third device. The third device and the first device can be the same or different devices.

2. The system according to claim 1, wherein: The second device is further configured to: In the case where service information is intercepted within a first set time period, determining whether the service information intercepted within the first set time period includes the target service; If the judgment result is yes, parsing the MAC address of the device broadcasting the first service information from the first service information including the target service; A long connection is established with the device broadcasting the first service information based on the MAC address of the device broadcasting the first service information.

3. The system according to claim 1, wherein: The third device may register the services that can be provided with the mDNS service of the third device when establishing a short connection with the second device; The second device queries the service provided by the third device, including: requesting the target service from the mDNS service of the second device; and sending a query request to the mDNS service of the third device through the mDNS service of the second device; the query request includes an identifier of the target service; The third device is configured to: resolve the identifier of the target service through the mDNS service of the third device; and use the identifier of the target service to query the services provided by the pre-registered third device; and if the target service is found in the pre-registered services provided by the third device, return the IP address and port number of the third device to the second device; The second device is further configured to: upon receiving the IP address and port number of the third device within a second set time period, determine that the service provided by the third device includes the target service.

4. A network connection method, wherein: include: In response to a start event for a discovery service, listening for service broadcasts; If no service information carrying the required target service is detected within the first set time period, a short connection is established with one of the other devices based on the MAC address of the other device recorded by receiving the probe message; Query the services provided by other devices currently connected to the server; If it is found that the services provided by the other devices in the current short connection include the required target service, a long connection is established with the other devices in the current short connection.

5. The method according to claim 4, wherein Also includes: Receiving a detection message broadcast by the other device; Parsing the MAC address of the device providing the probe message from the probe message; And record the MAC address of the device that provides the detection message.

6. The method according to claim 4, wherein: Also includes: In the case where service information is intercepted within a first set time period, determining whether the service information intercepted within the first set time period includes the target service; If the judgment result is yes, parsing the MAC address of the device providing the first service information from the first service information including the target service; A long connection is established with the device providing the first service information based on the MAC address of the device providing the first service information.

7. The method according to claim 4, wherein: The query of services provided by other devices currently connected to the short connection includes: Request the target service from the mDNS service; Sending a query request to the other device of the current short connection through the mDNS service, so that the other device of the current short connection uses the identifier of the target service included in the query request to query the services provided by the other device of the current short connection that are pre-registered; Furthermore, the other device receiving the current short connection queries the IP address and port number returned by the target service, and determines that the services provided by the other device receiving the current short connection include the target service.

8. The method according to claim 7, wherein: Also includes: If no response to the query request from the currently connected P2P device is received within a second set time period, it is determined that the service provided by the currently connected P2P device does not include the target service, and the short connection with the currently connected P2P device is disconnected.

9. A network device, wherein: include: A memory, a processor, and a communication component supporting WiFi direct connection; wherein the memory is used to store computer programs; The processor is coupled to the memory and the communication component, and is configured to execute the computer program to perform the steps of the method according to any one of claims 4 to 8.

10. A computer program product, wherein include: Computer program; when the computer program is executed by a processor, the steps of the method according to any one of claims 4 to 8 can be implemented.

Citation Information

Patent Citations

  • Wi-Fi (wireless fidelity) environment based mutual and active mobile terminal recognition method

    CN103546589A

  • Service discovery method and terminal

    CN105187387A