Service discovery method and device
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2023-09-22
- Publication Date
- 2026-05-01
AI Technical Summary
In wireless networks, it is difficult for the prior art to efficiently discover service, especially when traditional DNS servers are not deployed, service query speed is slow and network resources are consumed.
A service discovery method is adopted. By transmitting query messages in unicast form between nodes in the wireless network, if the node publishes or subscribes to the corresponding service when receiving the query message, it sends service attribute information to the requesting node to realize service discovery.
Without deploying traditional DNS servers, mutual service discovery between nodes in the wireless network is realized, service search efficiency is improved, and network resource consumption is reduced.
Smart Images

Figure CN121970437A_ABST
Abstract
Description
A service discovery method and device Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a service discovery method and device. Background Art
[0002] In wireless networks, the service registration protocol based on Domain Name System (DNS) service discovery uses border routers to register and respond to network nodes' services, and combines unicast queries with network nodes for service discovery. However, border routers are vulnerable to attacks due to centralized management, and redundant deployment is generally required to ensure robustness and reliability, which is costly.
[0003] Although multicast DNS (mDNS) technology can achieve mutual discovery of services between network nodes without traditional DNS servers, it is not suitable for large-scale wireless distributed self-organizing networks because mDNS transmits service queries and responses in multicast form during the service discovery process. The service query speed is slow and the message transmission consumes a lot of network resources.
[0004] Therefore, how to more efficiently find services in wireless networks is a technical problem that needs to be solved urgently.
[0005] Summary of the Invention
[0006] The present application discloses a service discovery method and device, which can realize mutual discovery of services between network nodes in a wireless network without deploying a traditional DNS server, and can also improve the service search efficiency with as little resource consumption as possible, thereby more efficiently realizing the search of services in the wireless network.
[0007] In the first aspect, the present application provides a service discovery method, which is applied to a first node, and the method includes: receiving a first query message from a second node, where the second node is a neighbor node of the first node, and the first query message is used to request a query for a first service. The first query message is transmitted in a unicast form, and the first query message includes a requesting node identifier; when the first node publishes or subscribes to the first service, the attribute information of the first service is sent to a third node indicated by the requesting node identifier.
[0008] Here, the first node can be a network device with routing and forwarding capabilities, such as a wireless router, a wireless access point (AP), etc., or it can be a component within the network device, and the component can be, for example, a single board, a line card, a chip, etc.; it can also be a terminal device with routing and forwarding capabilities, or a terminal device without routing capabilities, and the terminal device can be, for example, a smart home device (such as a television, a sweeping robot, a smart desk lamp, an audio system, a smart lighting system, an electrical control system, a home background music, a home theater system, an intercom system, a video surveillance system, etc.), an intelligent transportation equipment (such as a car, a ship, a drone, a train, a van, a truck, etc.), an intelligent manufacturing equipment (such as a robot, an industrial equipment, an intelligent logistics, an intelligent factory, etc.), a user device (a mobile phone, a computer, a tablet computer, a PDA, a desktop computer, headphones, audio, a wearable device, a vehicle-mounted device, a virtual reality device, an augmented reality device, etc.), or it can be a component within the terminal device (such as a chip or an integrated circuit).
[0009] For example, publishing a first service by a first node can be understood as: when the first node, as a service provider, can provide the first service externally, sending attribute information of the first service externally, for example, in a non-unicast format. This process can be called service publishing. Furthermore, the attribute information of the first service published by the first node does not need to be registered on any node in the network.
[0010] Exemplarily, the first node subscribing to the first service can be understood as: when the first node, as a service demander, receives the attribute information of the first service, for example, the attribute information of the first service is transmitted in a non-unicast form, the first node stores the attribute information of the first service based on the business needs of using the first service.
[0011] In one implementation, the first query message is included in a first message, and the first query message is transmitted in a unicast manner, that is, the first message is a unicast message.
[0012] Exemplarily, the first message includes a network layer message header and a payload field, wherein the payload field is used to carry the first query message. In the network layer message header of the first message, the source address field indicates the address of the second node, and the destination address field indicates the address of the first node.
[0013] In one implementation, sending the attribute information of the first service to the third node includes: sending a first response message to the third node, the first response message including the attribute information of the first service. Here, the message type of the first query message is a service query request message, and the message type of the first response message is a service query response message.
[0014] In the above method, when the node that publishes the first service or subscribes to the first service receives the first query message requesting to query the first service from its own neighbor node, it can act as a service query proxy node to provide the function of querying the corresponding service, that is, it can send the attribute information of the first service in response to the first query message. In this way, the mutual discovery of services between nodes in the wireless network is achieved without the need for centralized registration and management of the attribute information of services in the network (that is, without the need to deploy a traditional DNS server). Compared with service discovery using multicast DNS, it is also beneficial to reduce the overhead of network resources.
[0015] As an example, before receiving the first query message, the method also includes: receiving a first message, the first message indicating the first service published by the fourth node, the first message including attribute information of the first service; subscribing to the first service includes: storing the attribute information of the first service in the first message.
[0016] Exemplarily, the first message is transmitted in a non-unicast manner. The message type of the first message is a service release message. Here, non-unicast includes multicast and broadcast. When the first message is transmitted in a multicast manner, the first message can be carried by a multicast message; when the first message is transmitted in a broadcast manner, the first message can be carried by a broadcast message.
[0017] By implementing the above implementation, the first node can subscribe to the first service when receiving the attribute information of the first service. In this way, the node subscribed to the first service can provide a proxy query function for the first service for subsequent nodes with service query requirements.
[0018] Optionally, the attribute information of the first service includes one or more of the following information: the identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0019] Here, the identifier of the first service is used to identify the first service. The first service can be accessed through the network address of the first service.
[0020] For example, the types of transport layer protocols may be classified into, for example, lightweight connectionless transport protocol (CLTP), lightweight connection-oriented transport protocol (LWCTP), and the like.
[0021] Exemplarily, application types can be divided into native applications, Hypertext Transfer Protocol (http) / Hypertext Transfer Protocol (https), File Transfer Protocol (FTP), Real-time Transport Protocol (RTP), Message Queue Telemetry Transport Protocol (MQTT), etc.
[0022] Optionally, the method further includes: receiving first indication information from the second node, where the first indication information indicates a maximum number of forwarding times of the first query message.
[0023] Exemplarily, the first indication information and the first query message may be sent separately, or may be sent through one message, for example, the first indication information and the first query message are both included in the above-mentioned first message.
[0024] By implementing the above implementation method, the first indication information can limit the number of forwarding times of the first query message, avoiding the first query message from being forwarded infinitely, and making the first service be successfully queried within the maximum forwarding number of the first query message as much as possible, which is conducive to reducing network overhead.
[0025] Optionally, the maximum forwarding times is zero, and the method further includes: sending second indication information to the third node, where the second indication information indicates that the query result of the first service is query failure.
[0026] Exemplarily, sending the second indication information to the third node includes: sending a second response message to the third node, the second response message including the second indication information. Here, the second response message is a service query response message.
[0027] When the above implementation is implemented, if the first node has not published and subscribed to the first service, the first node fails to query the first service locally, and the maximum forwarding times of the first query message is also zero, then the first node can promptly inform the third node that the first service query has failed.
[0028] Optionally, the second node is the third node, or the second node is separated from the third node by at least one hop.
[0029] Here, the third node can be understood as the node that initiates the service query. The second node is the third node, which means that the first service is queried through one hop; the second node and the third node are separated by at least one hop, which means that the first service is queried through multiple hops.
[0030] In the second aspect, the present application provides a service discovery method, which is applied to a first node, and the method includes: sending a first query message to a second node in a unicast form, where the second node is a neighbor node of the first node, and the first query message is used by the first node to request to query the first service; receiving attribute information of the first service from a third node, where the first service is a service published or subscribed by the third node.
[0031] Here, the first node can be a network device with routing and forwarding capabilities, such as a wireless router, a wireless access point (AP), etc., or it can be a component within the network device, and the component can be, for example, a single board, a line card, a chip, etc.; it can also be a terminal device with routing and forwarding capabilities, or a terminal device without routing capabilities, and the terminal device can be, for example, a smart home device (such as a television, a sweeping robot, a smart desk lamp, an audio system, a smart lighting system, an electrical control system, a home background music, a home theater system, an intercom system, a video surveillance system, etc.), an intelligent transportation equipment (such as a car, a ship, a drone, a train, a van, a truck, etc.), an intelligent manufacturing equipment (such as a robot, an industrial equipment, an intelligent logistics, an intelligent factory, etc.), a user device (a mobile phone, a computer, a tablet computer, a PDA, a desktop computer, headphones, audio, a wearable device, a vehicle-mounted device, a virtual reality device, an augmented reality device, etc.), or it can be a component within the terminal device (such as a chip or an integrated circuit).
[0032] Here, the third node publishes or subscribes to the first service, which can refer to the description of the first node publishing or subscribing to the first service in the first aspect, and will not be repeated here.
[0033] Here, the carrying form of the first query message can refer to the description of the corresponding content of the first aspect, and will not be repeated here.
[0034] In the above method, the first node sends a first query message requesting to query the first service to the neighboring node in the form of unicast. When the node that publishes the first service or subscribes to the first service in the network receives the first query message from its own neighboring node, it can act as a service query agent node to provide the function of querying the corresponding service, that is, it can send the attribute information of the first service in response to the first query message. In this way, mutual discovery of services between nodes in the wireless network is achieved without the need for centralized registration and management of the attribute information of services in the network (that is, without the need to deploy traditional DNS servers). Compared with service discovery using multicast DNS, it is also beneficial to reduce the overhead of network resources.
[0035] Optionally, the third node is the second node, or the third node is separated from the second node by at least one hop.
[0036] Optionally, before receiving the attribute information of the first service from the third node, the method further includes: sending first indication information to the second node in a unicast form, where the first indication information indicates a maximum number of forwarding times of the first query message.
[0037] Exemplarily, the first indication information and the first query message may be sent separately or in one message.
[0038] By implementing the above implementation method, the first indication information can limit the number of forwarding times of the first query message, avoiding the first query message from being forwarded infinitely, and making the first service be successfully queried within the maximum forwarding number of the first query message as much as possible, which is conducive to reducing network overhead.
[0039] Optionally, the attribute information of the first service includes one or more of the following information: an identifier of the first service, a network address of the first service, a port number of the first service, a type of transport layer protocol used by the first service, an application type corresponding to the first service, and a lifetime of the first service. For details on each piece of information in the attribute information of the first service, refer to the description of the corresponding content in the first aspect and are not repeated here.
[0040] In the third aspect, the present application provides a device for service discovery, which is a first node or is included in the first node, and the device includes: a receiving unit, used to receive a first query message from a second node, the second node is a neighbor node of the first node, the first query message is used to request a query for a first service, the first query message is transmitted in a unicast form, and the first query message includes a requesting node identifier; a sending unit, used to send attribute information of the first service to a third node indicated by the requesting node identifier when the first node publishes or subscribes to the first service.
[0041] Optionally, the attribute information of the first service includes one or more of the following information: the identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0042] Optionally, the receiving unit is further configured to: receive first indication information from the second node, where the first indication information indicates a maximum number of forwarding times of the first query message.
[0043] Optionally, the maximum forwarding times is zero, and the sending unit is further used to: send second indication information to the third node, where the second indication information indicates that the query result of the first service is query failure.
[0044] Optionally, the second node is the third node, or the second node is separated from the third node by at least one hop.
[0045] In a fourth aspect, the present application provides a device for service discovery, which is a first node or is included in the first node, and the device includes: a sending unit, used to send a first query message to a second node in a unicast form, the second node is a neighbor node of the first node, and the first query message is used by the first node to request to query the first service; a receiving unit, used to receive attribute information of the first service from a third node, and the first service is a service published or subscribed by the third node.
[0046] Optionally, the third node is the second node, or the third node is a node that is at least one hop away from the second node.
[0047] Optionally, the sending unit is further configured to send first indication information to the second node in a unicast manner, where the first indication information indicates a maximum number of forwarding times of the first query message.
[0048] Optionally, the attribute information of the first service includes one or more of the following information: the identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0049] In the fifth aspect, the present application provides a service discovery method, which is applied to a first node, and the method includes: receiving a first query message, the first query message is used to request a query for a first service, the first query message is transmitted in a non-unicast form, and the first query message includes a requesting node identifier; when the first node subscribes to the first service, sending attribute information of the first service to the second node indicated by the requesting node identifier.
[0050] Here, the first node can refer to the description of the first node in the first aspect above, and will not be repeated here.
[0051] Exemplarily, the first node subscribing to the first service can be understood as: when the first node, as a service demander, receives the attribute information of the first service, the attribute information of the first service is transmitted in a non-unicast form, and the first node stores the attribute information of the first service based on the business needs of using the first service. This process can be called subscribing to the first service.
[0052] Here, non-unicast includes multicast and broadcast. For example, if the first query message is transmitted in multicast form, the first query message is carried in the multicast message. For another example, if the first query message is transmitted in broadcast form, the first query message is carried in the broadcast message.
[0053] In the above method, when the first node receives the first query message requesting to query the first service, the first query message is transmitted in the form of multicast or broadcast. The first node that has subscribed to the first service can reply with the attribute information of the queried first service. The discovery of the service does not depend on the deployment of the DNS server, which is conducive to improving the query efficiency of the service.
[0054] Optionally, the method further includes receiving first indication information, the first indication information being transmitted in a non-unicast manner, the first indication information indicating a first maximum number of forwarding times for the first query message. In this manner, the first indication information limits the number of forwarding times for the first query message, thereby reducing network resource consumption. If a subsequent local query for the first service by the first node fails, the first indication information may influence the execution of the first node's decision.
[0055] Exemplarily, the first indication information and the first query message may also be sent together, for example, carried by a multicast message or a broadcast message.
[0056] Optionally, the second node is a neighbor node of the first node, the first maximum forwarding number is 1, and the method further includes: sending second indication information to the second node, the second indication information indicating that the query result of the first service is query failure.
[0057] When implementing the above implementation method, the first maximum forwarding number is 1, which limits only the neighboring node of the first node (i.e., the first node) to process the first query message. If the first node has not published and subscribed to the first service, the first node's local query for the first service fails. In this case, the query result of the second node can be directly replied as query failure.
[0058] Optionally, the method also includes: receiving the first query message and third indication information, the third indication information is transmitted in a non-unicast form, the third indication information indicates the second maximum forwarding number of the first query message, and the second maximum forwarding number is the first maximum forwarding number plus 1; the second maximum forwarding number minus 1 is not zero, and the first query message and fourth indication information are sent in a non-unicast form, the fourth indication information indicates the third maximum forwarding number of the first query message, and the third maximum forwarding number is the second maximum forwarding number minus 1.
[0059] When implementing the above implementation method, if the first node does not receive the first query message for the first time and the first node fails to query the first service locally, if the second maximum forwarding number of the first query message is greater than 1, the first node can continue to transmit the first query message in a non-unicast form without replying to the second node.
[0060] Optionally, the first maximum forwarding number is greater than 1, and the number of hops between the second node and the first node is the first maximum forwarding number. It can be understood that the number of hops between the second node that successfully queries the first service and the first node is the first maximum forwarding number.
[0061] Optionally, the attribute information of the first service includes one or more of the following information: an identifier of the first service, a network address of the first service, a port number of the first service, a type of transport layer protocol used by the first service, an application type corresponding to the first service, and a lifetime of the first service. For the attribute information of the first service, reference may be made to the description of the corresponding content of the first aspect.
[0062] In the sixth aspect, the present application provides a service discovery method, which is applied to a first node, and the method includes: sending a first query message in a non-unicast form, and the first query message is used by the first node to request to query the first service; receiving attribute information of the first service from a second node, and the first service is a service subscribed by the second node.
[0063] Here, the first node, the first query message, the attribute information of the first service, etc. can refer to the description of the corresponding content in the above-mentioned first aspect, and will not be repeated here.
[0064] In the above method, the initiating node (i.e., the first node) that queries the first service queries the first service in a non-unicast form, and can obtain the attribute information of the first service from the second node that subscribes to the first service in the wireless network. The discovery of the service does not depend on the deployment of the DNS server, which is conducive to improving the query efficiency of the service.
[0065] Optionally, the method further includes: sending first indication information in a non-unicast form, where the first indication information indicates a first maximum forwarding times of the first query message.
[0066] By implementing the above implementation, the first node can limit the number of forwarding times of the first query message through the first indication information, thereby avoiding unlimited flooding of the first query message in the network, which is beneficial to reducing the overhead of network resources.
[0067] Optionally, the first maximum forwarding number is 1, and the second node is a neighbor node of the first node.
[0068] In this way, the nodes in the wireless network that are only one hop away from the first node are limited to receiving and processing the first query message, so that the first service is first queried on the node closest to the first node. Here, "closest" means the node with the least number of hops away from the first node, for example, only 1 hop.
[0069] Optionally, the method also includes: receiving a second indication message sent by the remaining neighboring nodes of the first node, the second indication message indicating that the query result of the first service is a query failure; sending the first query message and a third indication message in a non-unicast form, the third indication message indicating the second maximum forwarding number of the first query message, and the second maximum forwarding number is the first maximum forwarding number plus 1.
[0070] By implementing the above implementation method, the first node gradually queries the first service from near to far by setting the maximum number of forwarding times of the first query message to increase gradually, thereby avoiding infinite flooding of the service query request message in the wireless network, and being able to quickly find the first service in the nearest range as much as possible, which is conducive to reducing the overhead of network resources.
[0071] Optionally, the first maximum forwarding number is greater than 1, and the number of hops between the second node and the first node is the first maximum forwarding number.
[0072] Optionally, the attribute information of the first service includes one or more of the following information: an identifier of the first service, a network address of the first service, a port number of the first service, a type of transport layer protocol used by the first service, an application type corresponding to the first service, and a lifetime of the first service. For the attribute information of the first service, reference may be made to the description of the corresponding content of the first aspect.
[0073] In the seventh aspect, the present application provides a device for service discovery, which is a first node or is included in the first node, and the device includes: a receiving unit, used to receive a first query message, the first query message is used to request a query for a first service, the first query message is transmitted in a non-unicast form, and the first query message includes a requesting node identifier; a sending unit, used to send attribute information of the first service to a second node indicated by the requesting node identifier when the first node subscribes to the first service.
[0074] Optionally, the receiving unit is further used to: receive first indication information, where the first indication information is transmitted in a non-unicast form, and the first indication information indicates a first maximum forwarding count of the first query message.
[0075] Optionally, the second node is a neighbor node of the first node, the first maximum forwarding number is 1, and the sending unit is further used to: send second indication information to the second node, and the second indication information indicates that the query result of the first service is query failure.
[0076] Optionally, the receiving unit is also used to: receive the first query message and third indication information, the third indication information is transmitted in a non-unicast form, the third indication information indicates the second maximum forwarding number of the first query message, and the second maximum forwarding number is the first maximum forwarding number plus 1; the second maximum forwarding number minus 1 is not zero, and the sending unit is also used to send the first query message and fourth indication information in a non-unicast form, the fourth indication information indicates the third maximum forwarding number of the first query message, and the third maximum forwarding number is the second maximum forwarding number minus 1.
[0077] Optionally, the first maximum forwarding number is greater than 1, and the number of hops between the second node and the first node is the first maximum forwarding number.
[0078] Optionally, the attribute information of the first service includes one or more of the following information: the identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0079] In the eighth aspect, the present application provides a device for service discovery, which is a first node or is included in the first node, and the device includes: a sending unit, used to send a first query message in a non-unicast form, and the first query message is used by the first node to request to query the first service; a receiving unit, used to receive attribute information of the first service from a second node, and the first service is a service subscribed to by the second node.
[0080] Optionally, the sending unit is further configured to send first indication information in a non-unicast manner, where the first indication information indicates a first maximum forwarding times of the first query message.
[0081] Optionally, the first maximum forwarding number is 1, and the second node is a neighbor node of the first node.
[0082] Optionally, the receiving unit is also used to: receive a second indication message sent by the remaining neighboring nodes of the first node, the second indication message indicating that the query result of the first service is a query failure; the sending unit is also used to: send the first query message and the third indication message in a non-unicast form, the third indication message indicating the second maximum forwarding times of the first query message, and the second maximum forwarding times is the first maximum forwarding times plus 1.
[0083] Optionally, the first maximum forwarding number is greater than 1, and the number of hops between the second node and the first node is the first maximum forwarding number.
[0084] Optionally, the attribute information of the first service includes one or more of the following information: the identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0085] In a ninth aspect, the present application provides an apparatus for service discovery, comprising at least one processor and a communication interface, wherein the communication interface is configured to provide information input and / or output to the at least one processor. The apparatus may be a chip or an integrated circuit, or may be the apparatus described in the third aspect above, configured to implement the method described in the first aspect or any possible embodiment of the first aspect.
[0086] In a tenth aspect, the present application provides an apparatus for service discovery, comprising at least one processor and a communication interface, wherein the communication interface is configured to provide information input and / or output to the at least one processor. The apparatus may be a chip or an integrated circuit, or may be the apparatus described in the fourth aspect, configured to implement the method described in the second aspect or any possible embodiment of the second aspect.
[0087] In an eleventh aspect, the present application provides an apparatus for service discovery, comprising at least one processor and a communication interface, the communication interface being configured to provide information input and / or output to the at least one processor. The apparatus may be a chip or an integrated circuit, or may be the apparatus described in the seventh aspect, configured to implement the method described in the fifth aspect or any possible embodiment of the fifth aspect.
[0088] In a twelfth aspect, the present application provides an apparatus for service discovery, comprising at least one processor and a communication interface, wherein the communication interface is configured to provide information input and / or output to the at least one processor. The apparatus may be a chip or an integrated circuit, or may be the apparatus described in the eighth aspect, configured to implement the method described in the sixth aspect or any possible embodiment of the sixth aspect.
[0089] In the thirteenth aspect, the present application provides a system for service discovery, the system comprising a first device and a second device, wherein the first device is used to implement the method in the above-mentioned first aspect or any possible implementation of the first aspect, and the second device is used to implement the method in the above-mentioned second aspect or any possible implementation of the second aspect; or, the first device is used to implement the method in the above-mentioned fifth aspect or any possible implementation of the fifth aspect, and the second device is used to implement the method in the above-mentioned sixth aspect or any possible implementation of the sixth aspect.
[0090] Exemplarily, the first device may be a device in the third aspect or any possible implementation of the third aspect, or may be the device described in the ninth aspect; the second device may be a device in the fourth aspect or any possible implementation of the fourth aspect, or may be the device described in the tenth aspect.
[0091] Exemplarily, the first device may be a device in the seventh aspect or any possible implementation of the seventh aspect, or may be the device described in the eleventh aspect; the second device may be a device in the eighth aspect or any possible implementation of the eighth aspect, or may be the device described in the twelfth aspect.
[0092] In the fourteenth aspect, the present application provides a computer-readable storage medium comprising computer instructions, which, when executed by a processor, implement the method of the first aspect or any possible implementation of the first aspect, or implement the method of the second aspect or any possible implementation of the second aspect, or implement the method of the fifth aspect or any possible implementation of the fifth aspect, or implement the method of the sixth aspect or any possible implementation of the sixth aspect.
[0093] In the fifteenth aspect, the present application provides a computer program product, which, when executed by a processor, implements the method in the first aspect or any possible embodiment of the first aspect, or implements the method in the second aspect or any possible embodiment of the second aspect, or implements the method in the fifth aspect or any possible implementation of the fifth aspect, or implements the method in the sixth aspect or any possible implementation of the sixth aspect.
[0094] Exemplarily, the computer program product may be a software installation package.
[0095] In the sixteenth aspect, the present application provides a network device, which includes the apparatus described in the ninth aspect, the tenth aspect, the eleventh aspect, or the twelfth aspect.
[0096] In the seventeenth aspect, the present application provides a terminal, which includes the device described in the ninth aspect, the tenth aspect, the eleventh aspect, or the twelfth aspect.
[0097] Examples of the terminal include, but are not limited to: smart home devices (such as televisions, sweeping robots, smart desk lamps, audio systems, smart lighting systems, electrical control systems, home background music, home theater systems, intercom systems, video surveillance, etc.), smart transportation equipment (such as cars, ships, drones, trains, vans, trucks, etc.), smart manufacturing equipment (such as robots, industrial equipment, smart logistics, smart factories, etc.), smart terminals (mobile phones, computers, tablets, PDAs, desktops, headphones, audio, wearable devices, vehicle-mounted equipment, virtual reality equipment, augmented reality equipment, etc.). BRIEF DESCRIPTION OF THE DRAWINGS
[0098] FIG1 is a schematic diagram of the architecture of a communication system provided in an embodiment of the present application;
[0099] FIG2 is a flow chart of a service publishing method provided in an embodiment of the present application;
[0100] FIG3A is a format diagram of a multicast message for carrying a first message provided in an embodiment of the present application;
[0101] FIG3B is a schematic diagram of the format of a first message provided in an embodiment of the present application;
[0102] FIG3C is a format diagram of a broadcast message for carrying a first message provided in an embodiment of the present application;
[0103] FIG4 is a flow chart of a service discovery method provided in an embodiment of the present application;
[0104] FIG5A is a schematic diagram of the format of a unicast message carrying a first query message provided in an embodiment of the present application;
[0105] FIG5B is a schematic diagram of the format of a first query message provided in an embodiment of the present application;
[0106] 6 is a schematic diagram of the format of a service query response message when a first service query is successful according to an embodiment of the present application;
[0107] 7 is a schematic diagram of the format of a service query response message when a first service query fails according to an embodiment of the present application;
[0108] FIG8 is a schematic diagram of a networking scenario provided in an embodiment of the present application;
[0109] FIG9 is a flowchart of another service discovery method provided in an embodiment of the present application;
[0110] FIG10 is a schematic structural diagram of an apparatus for service discovery according to an embodiment of the present application;
[0111] FIG11 is a schematic structural diagram of a device for service discovery provided in an embodiment of the present application. DETAILED DESCRIPTION
[0112] It should be noted that the prefixes such as "first" and "second" used in this application are only for distinguishing different description objects, and do not have any limiting effect on the position, order, priority, quantity or content of the described objects. For example, if the described object is a "field", then the ordinal number before the "field" in the "first field" and the "second field" does not limit the position or order between the "fields", and "first" and "second" do not limit whether the "fields" they modify are in the same message, nor do they limit the order of the "first field" and the "second field". For another example, if the described object is a "level", then the ordinal number before the "level" in the "first level" and the "second level" does not limit the priority between the "levels". For another example, the number of described objects is not limited by the prefix and can be one or more. Taking "first device" as an example, the number of "devices" can be one or more. In addition, the objects modified by different prefixes can be the same or different. For example, if the described object is a "device," then the "first device" and the "second device" can be the same device, the same type of device, or different types of devices. For another example, if the described object is "information," then the "first information" and the "second information" can be information of the same content or information of different contents. In short, the use of prefixes to distinguish the described objects in the embodiments of this application does not constitute a limitation on the described objects. For the description of the described objects, please refer to the description in the context of the claims or embodiments, and the use of such prefixes should not constitute an unnecessary limitation.
[0113] It should be noted that the descriptions used in the embodiments of the present application, such as "at least one of a1, a2, ..., and an" and the like, include any one of a1, a2, ..., and an existing alone, and any combination of any multiple of a1, a2, ..., and an, each of which can exist alone. For example, the description "at least one of a, b, and c" includes a alone, b alone, c alone, a combination of a and b, a combination of a and c, a combination of b and c, or a combination of ab and c.
[0114] The following first introduces the relevant terms that may be involved in the embodiments of this application.
[0115] (1) Publishing services
[0116] When a service provider provides a service (e.g., Service 1) to the outside world, it can send the attribute information of Service 1. This process can be called publishing a service. For example, the attribute information of Service 1 is sent in a non-unicast format. The attribute information of Service 1 published by the service provider does not need to be registered on a node in the network. The attribute information of Service 1 includes at least one of the following: the service identifier, the network address of the service, the port number of the service, the type of transport layer protocol used by the service, the application type corresponding to the service, and the lifetime of the service.
[0117] (2) Subscription Service
[0118] When a service demander (or service consumer) receives the attribute information of a service (such as service 1), for example, the attribute information of service 1 is transmitted in a non-unicast form, the service demander stores the attribute information of service 1 based on the business needs of using service 1. This process can be called a subscription service.
[0119] (3) Unicast
[0120] Unicast is a one-to-one communication method. Unicast means a sender sends information to a specific receiver. The receiver's address must be explicitly specified when sending information. This address is typically a specific unicast address.
[0121] (4) Multicast
[0122] Multicast is a one-to-many communication method, also known as multicast. It allows a multicast source to send the same message to all receivers in a multicast group. Receivers in a multicast group are logically grouped, identified by a multicast address. A multicast source sends information to this multicast address, and all receivers that have joined the group can receive and process it.
[0123] (5) Broadcast
[0124] Broadcasting is a one-to-many communication method. It allows a broadcast source to send information to all receivers within its broadcast communication domain. Each receiver within the broadcast communication domain is identified by a broadcast address. When a broadcast source sends information to this broadcast address, all receivers within the broadcast communication domain can receive and process the information.
[0125] In the embodiment of the present application, different from the communication mode of unicast, the above-mentioned two communication modes of multicast and broadcast can be summarized as non-unicast, that is, non-unicast includes multicast and broadcast.
[0126] The technical solution in this application will be described below with reference to the accompanying drawings.
[0127] Referring to Figure 1 , Figure 1 is a schematic diagram of the architecture of a communication system provided in an embodiment of the present application. The system is used to implement service discovery between network nodes in a wireless network. As shown in Figure 1 , the system includes multiple intermediate nodes and multiple end nodes, wherein the end nodes access the wireless network through the intermediate nodes.
[0128] Here, intermediate nodes have the characteristic of infrequent mobility. Intermediate nodes can be network devices with routing and forwarding capabilities, such as wireless routers and wireless access points (APs), or components within such network devices, such as boards, line cards, and chips. Intermediate nodes can also be terminal devices with routing and forwarding capabilities, such as smart home devices (such as TVs, robot vacuums, smart lamps, audio systems, smart lighting systems, appliance control systems, home background music, home theater systems, intercom systems, and video surveillance), smart transportation equipment (such as cars, ships, drones, trains, vans, and trucks), smart manufacturing equipment (such as robots, industrial equipment, smart logistics, and smart factories), and user devices (such as mobile phones, computers, tablets, PDAs, desktops, headphones, speakers, wearable devices, in-vehicle devices, virtual reality devices, augmented reality devices, etc.), or components within such terminal devices (such as chips or integrated circuits).
[0129] Here, the end node is mobile, for example, it can be migrated from one intermediate node to another based on networking requirements. The end node can be a terminal device without routing capabilities. Here, the terminal device can refer to the examples in the corresponding content above and will not be repeated here.
[0130] In the embodiments of the present application, during the service publishing process, the node that publishes the service (or referred to as the service publishing node) can be the above-mentioned end node or intermediate node. During the service discovery process, the node that initiates the query service (or referred to as the initiating node of the service query) can be the above-mentioned end node or intermediate node.
[0131] It is understood that the aforementioned end nodes and intermediate nodes are all nodes, which is a name for electronic devices with forwarding capabilities. In some application scenarios or certain network types, devices with similar capabilities may be called other than nodes, for example, devices or network nodes, without specific limitation here.
[0132] The communication system shown in FIG1 can be applied to a variety of application scenarios, such as the following application scenarios: mobile internet (MI), industrial control (industrial control), self-driving, transportation safety (transportation safety), Internet of Things (IoT), smart city (smart city), or smart home (smart home).
[0133] The communication system shown in Figure 1 can be applied to a variety of network types, for example, one or more of the following network types: SparkLink or NearLink, long term evolution (LTE) network, fifth generation mobile communication technology (5G), sixth generation (6G) communication system, wireless local area networks (WLAN) (for example, Wi-Fi), Bluetooth (BT), Zigbee, or vehicle-mounted short-range wireless communication network, etc.
[0134] It should be noted that Figure 1 is merely an exemplary architecture diagram and does not limit the number of network elements included in the system shown in Figure 1. Although not shown in Figure 1, Figure 1 may also include other functional entities in addition to the functional entities shown in Figure 1. Furthermore, the methods provided in the embodiments of the present application can be applied to the communication system shown in Figure 1. Of course, the methods provided in the embodiments of the present application can also be applied to other communication systems, and the embodiments of the present application are not limited in this regard.
[0135] Based on the system architecture shown in Figure 1 above, in an embodiment of the present application, service publishing can be enabled before implementing service discovery between network nodes. Referring to Figure 2, Figure 2 is a flow chart of a service publishing method provided in an embodiment of the present application. The method can be applied to a communication system, which includes at least node 1 and at least one node 2, wherein node 1 is a node that publishes a service and node 2 is a node that subscribes to a service. The method includes but is not limited to the following steps:
[0136] S201: Node 1 sends a first message in a non-unicast form. The first message is used to indicate a first service published by node 1. The first message includes attribute information of the first service.
[0137] Here, node 1 publishing the first service can also be understood as node 1 publishing the application carried by itself. For details on publishing the first service, please refer to the relevant description of the term "publishing service" mentioned above, which will not be repeated here.
[0138] For example, node 1 may be a node newly added to the wireless network and carrying an application, and may be the aforementioned end node or intermediate node. In some possible embodiments, node 1 may also be a node already existing in the wireless network but with a newly added service, and may be the aforementioned end node or intermediate node.
[0139] Exemplarily, the message type of the first message is a service publishing message.
[0140] In one implementation, the attribute information of the first service includes at least one of the following information: the identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0141] For example, the attribute information of the first service includes the identifier of the first service, the network address of the first service, and the port number of the first service. Furthermore, the attribute information of the first service also includes at least one of the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service.
[0142] Here, the first service can be accessed through the network address of the first service. When the network where node 1 is located is a Star Flash wireless communication network, the network address of the first service can be a Star Flash network address. The Star Flash network address can be understood as a network layer short address, and its length can be 2 bytes (i.e., 16 bits). The Star Flash network address can be used for addressing within the Star Flash communication network. It can be understood that the Star Flash network address is another address type different from the IP address.
[0143] Here, the types of the above-mentioned transport layer protocols can be divided into, for example, Lightweight Connectionless Transport Protocol (CLTP), Lightweight Connection-oriented Transport Protocol (LWCTP), and the like.
[0144] Here, the above application types can be divided into native applications, Hypertext Transfer Protocol (http) / Hypertext Transfer Protocol (https), File Transfer Protocol (FTP), Real-time Transport Protocol (RTP), Message Queue Telemetry Transport Protocol (MQTT), etc.
[0145] In one implementation, node 1 sends a first message in a non-unicast manner, including: node 1 sends a first message in a non-unicast manner, where the first message includes the first message. Here, non-unicast includes multicast and broadcast. When node 1 sends the first message in a multicast manner, the first message is a multicast message; when node 1 sends the first message in a broadcast manner, the first message is a broadcast message.
[0146] The following describes how the first message is carried in the two sending modes described above.
[0147] Method 1: The first message is a multicast message
[0148] Here, the multicast message includes a network layer message header, a multicast header, and a payload field, wherein the network layer message header indicates that the message header of the next layer message is a multicast header, and the payload field is used to carry the first message.
[0149] See Figure 3A, which is a schematic diagram of the format of a multicast message for carrying a first message, provided in an embodiment of the present application. As can be seen in Figure 3A, the multicast message includes a network layer header, a multicast header, and a payload field. The network layer header indicates that the header of the next layer message is a multicast header, and the payload field is used to carry the first message. The payload field has a variable length.
[0150] The meanings of the fields in the network layer message header and the multicast header in FIG3A are described below.
[0151] In FIG3A , the network layer header includes one or more of the following fields:
[0152] Version number: indicates the version number of the network communication protocol;
[0153] Type of service (ToS): indicates the type of service and is related to the quality of service (QoS).
[0154] Topology ID (Topo ID): Indicates the type of forwarding path. For example, a value of 0 indicates a standard topology; a value of 1 indicates a unicast advanced topology, which provides a topology that meets QoS requirements for applications.
[0155] Flow label: A flow label that indicates the data flow to which the packet belongs.
[0156] Payload length: indicates the length of the payload of the message;
[0157] Next header: indicates the type of the header of the next layer of the message; the length is, for example, 8 bits; in Figure 3A, this field indicates the multicast header;
[0158] Hop limit: indicates the maximum number of hops for a message;
[0159] Source address: indicates the source address of the node that generates the message; in Figure 3A, this field indicates the network address of node 1;
[0160] Destination address: indicates the destination address of the node that receives and processes the message; in FIG3A , this field indicates a multicast address, which can be a well-known multicast address defined in the wireless address allocation protocol or a multicast address allocated in other ways.
[0161] As an example, in the network layer packet header in Figure 3A, the length of the version number field can be 3 bits, the length of the service type field can be 8 bits, the length of the topology identification field can be 2 bits, the length of the flow label field can be 19 bits, the length of the payload length field can be 16 bits, the length of the next header field can be 8 bits, the length of the hop limit field can be 8 bits, the length of the source address field can be 16 bits, and the length of the destination address field can be 16 bits.
[0162] In FIG3A , the multicast header includes one or more of the following fields:
[0163] Next header: indicates the header of the next layer of message;
[0164] Type: Indicates the type of the multicast message. For example, a value of 0 indicates non-reliable multicast, and a value of 1 indicates reliable multicast.
[0165] ACK: In reliability multicast, the receiver sends a unicast response ACK message to the sender. ACK is set to 1. In other cases, ACK is set to 0.
[0166] Reserved: for future functional expansion;
[0167] Alive time: indicates the maximum survival time of a multicast message in the network;
[0168] Sequence number: Indicates the sequence number of a multicast message. The value of this field increases by 1 each time the multicast message generator sends a multicast message. This field is used to distinguish multicast messages.
[0169] As an example, in the multicast header shown in Figure 3A, the length of the next header field is 8 bits, the length of the type field is 2 bits, the length of the ACK field is 1 bit, the length of the reserved field is 13 bits, the length of the survival time field is 8 bits, and the length of the sequence number field is 32 bits.
[0170] See Figure 3B, which is a schematic diagram of the format of a first message provided in an embodiment of the present application.
[0171] In FIG3B , the first message includes one or more of the following fields:
[0172] Message type: indicates that the type of the first message is a service public message;
[0173] Message length: indicates the length of the first message;
[0174] Service universally unique identifier length (service UUID length): indicates the length of the identifier of the first service;
[0175] Service Universal Unique Identifier (service UUID): an identifier indicating the first service;
[0176] Service network address: indicates the network address of the first service;
[0177] Service port number (service port): indicates the port number of the first service.
[0178] Exemplarily, in the message format of the first message shown in FIG3B , the fields of the message type, service universal unique identifier, service network address and service port number are mandatory fields, and the other fields in FIG3B may be optional fields.
[0179] As can be seen from Figure 3B, when the attribute information of the first service includes the identifier of the first service, the network address of the first service and the port number of the first service, the first message includes the attribute information of the first service, including: the first message includes a service universal unique identifier field, a service network address field and a service port number field, wherein the service universal unique identifier field is used to carry the identifier of the first service, the service network address field is used to carry the network address of the first service, and the service port number field is used for the port number of the first service.
[0180] In some possible embodiments, if the attribute information of the first service also includes the type of transport layer protocol used by the first service, the application type corresponding to the first service, and the lifetime of the first service, then the first message also includes at least one of the three fields shown in Figure 3B: transport layer protocol indication, application type indication, and service lifetime. For example, in Figure 3B, there are six fields used to carry the attribute information of the first service. In Figure 3B, the meanings of the three fields of transport layer protocol indication, application type indication, and service lifetime are as follows:
[0181] Transport layer protocol index: indicates the type of transport layer protocol used by the first service;
[0182] Application type indication (app.type index): indicates the application type corresponding to the first service;
[0183] Service Time to Live (Service TTL): Indicates the lifetime of the primary service. Before the timeout, the server (i.e., the node publishing the service) can send a service publishing message to the network again to update the service's attribute information (including the TTL information). After the timeout, nodes in the network that have subscribed to the service automatically delete the service's attribute information locally. If the value is 0, the service attribute information is not aged, meaning the service lifetime is permanent.
[0184] Exemplarily, in FIG3B , the first message may further include a subtype-length-value (TLV) field, which is used for future expansion of attribute information of the service.
[0185] As an example, in the first message shown in Figure 3B, the length of the message type field is 1 byte, the length of the message length field is 1 byte, the length of the service universal unique identifier length field is 1 byte, the length of the service universal unique identifier field is 2 bytes or 16 bytes, the length of the service network address field is 2 bytes, the length of the service port number field is 2 bytes, the length of the transport layer protocol indication field is 1 byte, the length of the application type indication field is 1 byte, the length of the service lifetime field is 2 bytes, and the length of the sub-TLV field may vary.
[0186] As can be seen from FIG. 3B , the first message carries only the attribute information of one service (eg, the first service), but it is not limited that a service publishing message can only be used to publish one service.
[0187] In some possible embodiments, node 1 may simultaneously publish multiple services via a first message. The first message is used to indicate the multiple services published by node 1, and therefore includes attribute information for these multiple services. In this case, the first message includes a set of fields corresponding to each of the multiple services, which are used to carry the attribute information of the service. Additionally, the first message may also include a quantity field, which indicates the number of services published by node 1.
[0188] In some possible embodiments, a service publishing message can also correspond to one service. In this case, when there are multiple services (for example, the first service and the second service) that need to be published on node 1, the multicast message includes service publishing message 1 and service publishing message 2, wherein service publishing message 1 corresponds to the first service and service publishing message 2 corresponds to the second service.
[0189] It can be understood that the message format of the first message shown in Figure 3B above is only an example, and the message format of the first message is not limited to that shown in Figure 3B. For example, the number of fields in the first message, the position arrangement of each field, and the length setting of the field are not limited to those shown in Figure 3B.
[0190] Method 2: The first message is a broadcast message
[0191] Here, the broadcast message includes a network layer message header, a broadcast header, and a payload field, wherein the network layer message header indicates that the message header of the next layer message is a broadcast header, and the payload field is used to carry the first message.
[0192] See Figure 3C, which is a schematic diagram of the format of a broadcast message for carrying a first message, provided in an embodiment of the present application. As can be seen from Figure 3C, the broadcast message includes a network layer message header, a broadcast header, and a payload field. The network layer message header indicates that the message header of the next layer message is a broadcast header, and the payload field is used to carry the first message.
[0193] Compared to Figure 3A , in Figure 3C , the Next Message field in the network layer header indicates that the next-layer message header is a broadcast header, and the Destination Address field indicates a broadcast address, not a multicast address. The remaining fields in the network layer header and broadcast header in Figure 3C can be found in the description of the corresponding fields in Figure 3A , with the difference being that the fields shown in Figure 3C are broadcast-related. Furthermore, the format of the first message in Figure 3C can be found in the description of Figure 3B above and will not be repeated here.
[0194] S202: Upon receiving the first message, at least one node 2 stores attribute information of the first service in the first message.
[0195] Exemplarily, node 2 may be an intermediate node or an end node in FIG. 1 .
[0196] Here, since node 2 is a node that needs to subscribe to the first service, node 2 can store the attribute information of the first service when it receives the first message. It can be understood that the process of node 2 storing the attribute information of the first service based on the first message can also be called node 2 subscribing to the first service.
[0197] Exemplarily, storing the attribute information of the first service includes: storing a correspondence between an identifier of the first service, a network address of the first service, and a port number of the first service.
[0198] It can be understood that although node 2 is not the node that publishes the first service, node 2 can also store the attribute information of the first service locally by subscribing to the first service when receiving the first message.
[0199] It is understood that the embodiment of FIG2 is an example of a service publishing method and should not limit the service publishing method. In some possible embodiments, node 1 may also send the first message in a unicast manner.
[0200] It can be seen that by implementing the embodiments of the present application, nodes newly connected to the wireless network or nodes with newly added services in the wireless network can publish service release messages in a non-unicast manner, so that the nodes in the wireless network that receive the service release messages can subscribe to the corresponding services according to their own business needs. In this way, the nodes that have subscribed to the service can provide the function of proxy query service for subsequent nodes that have service query needs.
[0201] After the first service is published in the wireless network based on the service publishing method shown in Figure 2, any node in the wireless network or a node newly connected to the wireless network, when there is a need to query the first service, can perform service query through the service discovery method provided in the following embodiment of the present application. This does not rely on the deployment of traditional DNS servers and can effectively reduce the network resources occupied by message transmission during the service discovery process.
[0202] Referring to Figure 4, which is a flow chart of a service discovery method provided in an embodiment of the present application, the method can be applied to a communication system comprising at least node 3 and node 4, wherein node 3 is the node initiating the service query and node 4 is a neighbor node of node 3.
[0203] In some possible embodiments, the communication system further includes a node 5, which is a neighbor node of the node 4. The method includes but is not limited to the following steps:
[0204] S401: Node 3 sends a first query message to node 4 in unicast form. The first query message is used by node 3 to request to query a first service. Node 4 is a neighbor node of node 3.
[0205] Correspondingly, node 4 receives the first query message from node 3, where the first query message is transmitted in a unicast manner.
[0206] Exemplarily, the node 3 may also be referred to as a source node that initiates a query for the first service, or as an initiating node that requests a query for the first service.
[0207] Here, node 3 may be a node newly connected to the wireless network, and node 3 may be the aforementioned end node or intermediate node. In some possible embodiments, node 3 may also be a node already existing in the wireless network, and the node may be the aforementioned end node or intermediate node, which is not specifically limited here.
[0208] Exemplarily, when node 3 is an end node newly accessing a wireless network, node 3 accesses the wireless network through node 4 .
[0209] The first query message includes a requesting node identifier, and the requesting node identifier indicates an identifier of node 3 .
[0210] In some possible embodiments, node 3 may further send indication information 1 to node 4, where indication information 1 indicates the maximum number of forwarding times of the first query message (or indicates the remaining number of forwarding times of the first query message). Indication information 1 is sent by node 3 in unicast form.
[0211] Here, the first query message and indication information 1 may be sent separately by node 3, or may be carried in one message sent by node 3. In some possible embodiments, indication information 1 may also be included in the first query message, which is not specifically limited here.
[0212] It can be seen that the indication information 1 can limit the number of forwarding times of the first query message, avoid the first query message from being forwarded infinitely, and make the first service be successfully queried within the maximum forwarding number of the first query message as much as possible, which is conducive to reducing network overhead.
[0213] In one implementation, node 3 sends a first query message to node 4 in unicast form, including: node 3 sends a second message to node 4 in unicast form, where the second message includes the first query message. Correspondingly, node 4 receives the first query message from node 3, including: node 4 receives a second message from node 3, where the second message includes the first query message, and the second message is a unicast message.
[0214] Exemplarily, the unicast message includes a network layer message header and a payload field, wherein the payload field is used to carry the first query message.
[0215] 5A is a schematic diagram of a format of a unicast message for carrying a first query message provided in an embodiment of the present application. As can be seen from FIG5A , the unicast message includes a network layer message header and a payload field, wherein the payload field is used to carry the first query message.
[0216] In FIG5A , the network layer header includes one or more of the following fields:
[0217] Version number: indicates the version number of the network communication protocol;
[0218] Type of service (ToS): indicates the type of service and is related to the quality of service (QoS).
[0219] Topology ID (Topo ID): Indicates the type of forwarding path. For example, a value of 0 indicates a standard topology; a value of 1 indicates a unicast advanced topology, which provides a topology that meets QoS requirements for applications.
[0220] Flow label: A flow label that indicates the data flow to which the packet belongs.
[0221] Payload length: indicates the length of the payload of the message;
[0222] Next header: indicates the type of header of the next layer of message; in FIG5A , this field is set to empty;
[0223] Source address: indicates the address of the current sender of the unicast message; in the embodiment of the present application, this field indicates the address of node 3;
[0224] Destination address: indicates the address of the receiver currently receiving and processing the unicast message; in the embodiment of the present application, this field indicates the address of node 4;
[0225] Hop limit: indicates the maximum number of forwarding times of the unicast message; in an embodiment of the present application, this field can be used to carry the above-mentioned indication information 1, and indication information 1 indicates the remaining number of forwarding times of the first query message.
[0226] It can be understood that in the network layer message header shown in FIG. 5A , the source address field, the destination address field, and the hop limit field will change accordingly as the service query message (eg, the first query message) is forwarded between nodes.
[0227] Further, the message format of the first query message can refer to Figure 5B, which is a schematic diagram of the format of a first query message provided in an embodiment of the present application. As can be seen from Figure 5B, the first query message includes one or more of the following fields:
[0228] Message type: indicates that the type of the first query message is a service query request message;
[0229] Message length: indicates the length of the first query message;
[0230] Request transaction number: indicates the sequence number of the first query message. This field is used to distinguish different service query request messages. Accordingly, subsequent service query response messages must also carry the corresponding request transaction number so that the recipient of the service query response message can determine which service query request message it is responding to.
[0231] Original requester node ID: indicates the identifier of the node that generates the first query message, or is understood to indicate the identifier of the initiating node requesting the query service; in the embodiment of the present application, this field is used to carry the above-mentioned requester node identifier, which is the identifier of the above-mentioned node 3. The identifier of node 3 can be, for example, the layer 2 identifier of node 3 or the network address of node 3, which is not specifically limited here;
[0232] Service UUID length: indicates the length of the identifier of the service to be queried. In this embodiment of the present application, this field indicates the length of the identifier of the first service.
[0233] Service Universal Unique Identifier (service UUID): indicates the identifier of the service to be queried; for example, this field indicates the identifier of the first service mentioned above.
[0234] Illustratively, in the message format of the first query message shown in FIG5B , the fields of the message type, original requesting node identifier, and service universal unique identifier are mandatory fields, and other fields may be optional fields.
[0235] As an example, in the first query message shown in Figure 5B, the length of the message type field is 1 byte, the length of the message length field is 1 byte, the length of the request transaction number field is 2 bytes, the length of the original request node identification field is 6 bytes, the length of the service universal unique identifier length field is 1 byte, and the length of the service universal unique identifier field is 2 bytes or 16 bytes.
[0236] It should be understood that the message format of the first query message shown in FIG5B is merely an example and is not limited to the message format shown in FIG5B . For example, the number of fields, the arrangement of the fields, and the field lengths in the first query message are not limited to those shown in FIG5B . For another example, the indication information 1 may be carried not by the hop limit field in the network layer header, but by a newly added field in the first query message. In this case, the value of this field will decrease as the first query message is forwarded.
[0237] In one implementation, a service query request message is used to request a query for a single service. For example, when node 3 needs to query multiple services (e.g., a first service and a second service), the second message may also carry two service query request messages, namely service query request message 1 and service query request message 2. Service query request message 1 is used by node 3 to request the first service, and service query request message 2 is used by node 3 to request the second service.
[0238] In another implementation, a service query request message can also be used to query multiple services. For example, when node 3 needs to query multiple services (such as a first service and a second service), the first query message is used by node 3 to query both the first service and the second service.
[0239] S402: Node 4 sends attribute information of a first service to node 3, where the first service is a service published or subscribed by node 4.
[0240] Exemplarily, the first service is a service published by node 4, that is, node 4 publishes the first service, which means that node 4 is node 1 in the embodiment of Figure 2. In some possible embodiments, node 4 may not be node 1 in the embodiment of Figure 2, but another node in the network that also publishes the first service.
[0241] Exemplarily, the first service is a service subscribed to by node 4, which means that node 4 subscribes to the first service, meaning that node 4 is node 2 in the embodiment of Figure 2. Exemplarily, node 4 subscribes to the first service, including: node 4 stores attribute information of the first service based on the first message sent by node 1 in Figure 2.
[0242] That is, when node 4 publishes or subscribes to the first service, node 4 sends the attribute information of the first service to node 3. Here, the attribute information of the first service can refer to the description of the corresponding content in the embodiment of Figure 2, which will not be repeated here.
[0243] It can be understood that when node 4 publishes or subscribes to the first service, node 4 locally stores the attribute information of the first service. In this case, when node 4 receives the first query message sent by node 3, node 4 successfully queries the first service locally. Node 4 can also send result indication information 1 to node 3. Result indication information 1 indicates that the query result of the first service is a successful query.
[0244] Exemplarily, the attribute information of the first service and the result indication information 1 may be sent separately by the node 4, or may be carried by one message (eg, a first response message).
[0245] In one implementation, the attribute information of the first service can be carried in a first response message. Node 4 then sends the attribute information of the first service to node 3, including: Node 4 sends the attribute information of the first service to node 3, including: Node 4 sends a first response message to node 3, the first response message including the attribute information of the first service. Exemplarily, the message type of the first response message is a service query response message, and the first response message is a response to the first query message.
[0246] Exemplarily, the first response message also includes the above-mentioned result indication information 1.
[0247] In one implementation, node 4 sends a first response message to node 3, including: node 4 sends a third message to node 3, where the third message includes the first response message. Exemplarily, the third message is sent by node 4 in a unicast manner, that is, the third message is a unicast message.
[0248] As an example, the third message includes a network layer message header and a payload field, wherein the payload field is used to carry the first response message, or in other words, the payload field carries the attribute information of the first service. Here, the fields in the network layer message header can refer to the description of the network layer message header in Figure 5A, except that in the third message, the source address field in the network layer message header indicates the address of node 4, and the destination address field in the network layer message header indicates the address of node 3.
[0249] The message format of the first response message can be seen in Figure 6, which is a schematic diagram of the format of a service query response message when the first service query is successful provided in an embodiment of the present application. As can be seen from Figure 6, the first response message includes one or more of the following fields:
[0250] Message type: indicates that the type of the first response message is a service query response message;
[0251] Message length: indicates the length of the first response message;
[0252] Request transaction number: indicates the sequence number of the first query message to which the node responds. In this embodiment of the present application, the value of this field is taken from the request transaction number field in the first query message to which node 4 responds.
[0253] Original Request Node ID: indicates the identifier of the node that generated the first query message, or is understood to indicate the identifier of the node that initiated the query service request. In the embodiment of the present application, this field indicates the identifier of the aforementioned node 3. The identifier of node 3 can be, for example, the layer 2 identifier of node 3 or the network address of node 3, which is not specifically limited here.
[0254] Service UUID length: indicates the length of the identifier of the service to be queried. In this embodiment of the present application, this field indicates the length of the identifier of the first service.
[0255] Service Universal Unique Identifier (Service UUID): indicates the identifier of the service to be queried; in the embodiment of the present application, this field indicates the identifier of the first service mentioned above;
[0256] Result: indicates that the query result of the service requested by the first query message is successful. In the embodiment of the present application, this field indicates that the query result of the first service is successful.
[0257] Service network address: indicates the address of the service being queried; in the embodiment of the present application, this field indicates the network address of the first service;
[0258] Service port number: indicates the port number of the service being queried; in the embodiment of the present application, indicates the port number of the first service;
[0259] Transport layer protocol index: indicates the type of transport layer protocol corresponding to the queried service. In this embodiment of the present application, this field indicates the type of transport layer protocol used by the first service.
[0260] Application type indication (app.type index): indicates the application type of the queried service; in the embodiment of the present application, this field indicates the application type of the first service;
[0261] Service TTL: Indicates the lifetime of the service being queried. In this embodiment, this field indicates the service lifetime of the first service. For details about this field, please refer to the description of the corresponding field in Figure 3B above and will not be repeated here.
[0262] Exemplarily, in the message format of the first response message shown in FIG6 , the fields of the message type, original requesting node identifier, service universal unique identifier, service network address and service port number are mandatory fields, and other fields can be optional fields.
[0263] Exemplarily, the first response message may be generated by node 4 based on the obtained first query message. For example, in comparison with the first response message shown in FIG6 , when node 4 successfully queries the first service locally, node 4 changes the two fields of "message type" and "message length" in the first query message shown in FIG5B . In addition, on this basis, node 4 also adds the fields of "result", "service network address", "service port number", "transport layer protocol indication", "application type indication" and "service lifetime", thereby generating the first response message. In some possible embodiments, in the message format of the first response message, the three fields of "transport layer protocol indication", "application type indication" and "service lifetime" may be optional fields, depending on whether the attribute information of the first service stored locally by node 4 includes the type of transport layer protocol used by the first service, the application type and the lifetime of the first service.
[0264] Optionally, in some possible embodiments, the above S402 may not be performed, and the following S403 and S404 may be performed:
[0265] S403: Node 4 sends a first query message to node 5 in unicast form. Node 5 is a neighbor node of node 4.
[0266] Here, the content of the first query message may be specifically referred to the related description of the first query message in S401 above, which will not be repeated here.
[0267] In this case, it indicates that the first service is neither a service published by node 4 (ie, node 4 is not node 1 in the embodiment of FIG. 2 ) nor a service subscribed by node 4 (ie, node 4 is not node 2 in the embodiment of FIG. 2 ).
[0268] That is, when node 4 has not subscribed to and has not published the first service, node 4 may send a first query message to its other neighbor nodes (eg, node 5).
[0269] In some possible embodiments, node 4 receives the above-mentioned indication information 1 from node 3, where the indication information 1 indicates the maximum number of forwarding times of the first query message (referred to as the first maximum forwarding number), and node 4 sends the first query message to node 5 in unicast form, including: if the first maximum forwarding number is not zero, node 4 sends the first query message to node 5 in unicast form. That is, if node 4 has not subscribed to and has not published the first service and the first maximum forwarding number is not zero, node 4 sends the first query message to node 5 in unicast form.
[0270] Furthermore, node 4 also sends indication information 2 to node 5, where indication information 2 indicates the maximum forwarding times of the first query message (recorded as the second maximum forwarding times), where the second maximum forwarding times is the first maximum forwarding times minus 1.
[0271] Here, the indication information 2 and the first query message may be sent separately or carried in one message.
[0272] In one implementation, node 4 sends the first query message to node 5, including: node 4 sends a fourth message to node 5, the fourth message including the first query message. The fourth message is sent by node 4 in unicast form, that is, the fourth message is a unicast message.
[0273] As an example, the fourth message includes a network layer message header and a payload field, where the payload field is used to carry the first query message. Compared to the second message sent by node 3 to node 4 in S401 above, the fourth message differs in that the source address field in the network layer message header indicates the address of node 4, and the destination address field in the network layer message header indicates the address of node 5.
[0274] As an example, the indication information 2 may be carried by the "Hop Limit" field in the network layer header of the fourth message. It is understood that, if the "Hop Limit" field in the network layer header of the second message carries the indication information 1, the "Hop Limit" field in the network layer header of the fourth message carries the indication information 2.
[0275] In some possible embodiments, for node 4, the number of neighboring nodes other than node 3 may be multiple, that is, the number of nodes 5 may be multiple. In this case, in one implementation, node 4 can send the first query message to each node 5 in parallel, in which case node 4 does not perceive the result of each node 5 querying the first service. In another implementation, node 4 can send the first query message to each node 5 in series. For example, node 4 first sends the first query message to the first node 5. After receiving the information indicating that the query for the first service has failed from the first node 5, node 4 sends the first query message to the second node 5. And so on. When node 4 receives the information indicating that the query for the first service has failed from each node 5, node 4 can send result indication information to node 3. The result indication information indicates that the query result for the first service is a query failure.
[0276] S404: Node 5 sends attribute information of a first service to node 3. The first service is a service published or subscribed by node 5.
[0277] In this embodiment of the present application, node 5 receives a first query message from node 4. The first query message is transmitted in unicast form and is used to request a first service. The first query message includes a requesting node identifier, which indicates the identifier of node 3. When node 5 publishes or subscribes to the first service, node 5 sends attribute information of the first service to node 3.
[0278] Exemplarily, node 5 sends attribute information of the first service to node 3, including: node 5 sends a first response message to node 3, where the first response message includes the attribute information of the first service. Exemplarily, the first response message also includes result indication information 1, where the result indication information 1 indicates that the query result of the first service is successful.
[0279] As an example, node 5 sends a first response message to node 3, including: node 5 sends a fifth message to node 3, the fifth message including the first response message. The fifth message includes a network layer message header and a payload field, with the payload field being used to carry the first response message. For the fields in the network layer message, refer to the description of the network layer message header in FIG. 5A . In the network layer message header of the fifth message, the source address field indicates the address of node 5, and the destination address field indicates the address of node 3. For the sake of brevity, the message format of the first response message can be referred to the description in FIG. 6 , and for the sake of brevity, it will not be further described here.
[0280] Referring to the above-mentioned behavior of node 4, it can be known that in some possible embodiments, if node 5 has not published and is not subscribed to the first service, then after node 5 receives the first query message from node 4, node 5 can send the first query message to other neighbor nodes of node 5.
[0281] Optionally, in some possible embodiments, the above S402 may not be performed, and the following S405 may be performed:
[0282] S405: Node 4 sends result indication information to node 3, where the result indication information indicates that the query result of the first service is query failure, and the indication information 1 received from node 3 indicates that the maximum forwarding times of the first query message is zero.
[0283] Exemplarily, the indication information 1 may be transmitted together with the first query message in S401 in a unicast form.
[0284] In the embodiment of the present application, indication information 1 indicates that the maximum number of forwarding times of the first query message is zero, and when the first service is neither a service published by node 4 nor a service subscribed by node 4 (i.e., node 4 has neither published nor subscribed to the first service), node 4 sends result indication information to node 3, and the result indication information indicates that the first query result is a query failure. In other words, for any node in the network that receives the first query message (for requesting a query for the first service), if the node's local query for the first service fails and the maximum number of forwarding times of the first query message is zero, the node can inform the node that initiated the query for the first service (i.e., node 3) that the first service query failed.
[0285] In one implementation, the node 4 sends the result indication information to the node 3, including: the node 4 sends a second response message to the node 3, where the second response message includes the result indication information.
[0286] As an example, the message format of the second response message can be seen in Figure 7, which is a schematic diagram of the format of a service query response message when the first service query fails, provided in an embodiment of the present application. As can be seen from Figure 7, the second response message includes one or more of the following fields:
[0287] Message type: indicates that the type of the second response message is a service query response message;
[0288] Message length: indicates the length of the second response message;
[0289] Request transaction number: indicates the sequence number of the first query message to which the node responds. In this embodiment of the present application, the value of this field is taken from the request transaction number field in the first query message.
[0290] Original Request Node ID: indicates the ID of the node that generated the first query message. In this embodiment of the present application, the content indicated by this field comes from the Original Request Node ID field in the first query message. This field indicates the ID of the aforementioned node 3. The ID of node 3 can be, for example, the layer 2 ID of node 3 or the network address of node 3, which is not specifically limited here.
[0291] Service UUID length: indicates the length of the identifier of the service to be queried. In this embodiment of the present application, this field indicates the length of the identifier of the first service.
[0292] Service Universal Unique Identifier (Service UUID): indicates the identifier of the service to be queried; in the embodiment of the present application, this field indicates the identifier of the first service mentioned above;
[0293] Result: indicates that the query result of the service requested by the first query message is a query failure; in the embodiment of the present application, this field indicates that the query result of the first service is a query failure.
[0294] Exemplarily, in the message format of the second response message shown in FIG7 , the fields of the message type, original requesting node identifier, service universal unique identifier, and result are mandatory fields, and other fields may be optional fields.
[0295] Exemplarily, the second response message can be carried in a message. Node 4 sending the second response message to node 3 includes: node 4 sending a sixth message to node 3, where the sixth message includes the second response message. The sixth message includes a network layer message header and a payload field, with the payload field being used to carry the second response message. For the fields in the network layer message, reference can be made to the description of the network layer message header in FIG. 5A . In the network layer message header of the sixth message, the source address field indicates the address of node 4, and the destination address field indicates the address of node 3.
[0296] It can be seen that by implementing the embodiments of the present application, in a wireless network, when a node that publishes a first service or subscribes to a first service receives a service request query message requesting to query the first service from its own neighbor node, it can act as a service query proxy node to provide the function of querying the corresponding service, that is, it can send attribute information of the first service in response to the service request query message. In this way, mutual discovery of services between network nodes in the wireless network is achieved without deploying a traditional DNS server. Compared with service discovery using multicast DNS, it is also beneficial to reduce the overhead of network resources.
[0297] The following uses a specific networking scenario to illustrate the application of the service discovery method provided in FIG4 .
[0298] See Figure 8, which is a schematic diagram of a networking scenario provided by an embodiment of the present application. In Figure 8, the network includes four intermediate nodes (node I1, node I2, node I3, and node I4) and three end nodes (node E1, node E2, and node E3). Node E1 accesses the network through node I3, node E2 accesses the network through node I4, and node E3 accesses the network through node I2.
[0299] In the service publishing stage, it is assumed that node E3 publishes the first service at the network layer through a multicast message, and among the nodes in the network that receive the multicast message, only node E1 and node I3 subscribe to the first service. The publication of the first service and the subscription to the first service can refer to the description of the embodiment of Figure 2 above, and will not be repeated here.
[0300] In Figure 8, assume that node E5 is a newly joined node in the network and that node E5 accesses the network through node I1. Assuming that node E5 is the initiating node for querying the first service, the service discovery process of the first service among the nodes in the network is as follows:
[0301] Node E5 sends message 1 to its directly connected neighbor node I1 in unicast form. Message 1 includes service query request message 1, indicating that node E5 is requesting to query the first service. Furthermore, the hop limit field in message 1 indicates that the maximum number of forwarding times for service query request message 1 is 3. The source address field of message 1 indicates the address of node E5, and the destination address field of message 1 indicates the address of node I1.
[0302] For node I1: Message 1 is received from node E3. Since the attribute information of the first service is not stored locally, that is, node I1 has not published or subscribed to the first service, and message 1 shows that the maximum forwarding count of service query request message 1 is 3 (not 0), node I1 sends message 2 carrying the service query request message 1 in unicast form to its neighbor node I2. The hop limit field in message 2 indicates that the maximum forwarding count of service query request message 1 is 2. In addition, the source address field of message 2 indicates the address of node I1, and the destination address field of message 2 indicates the address of node I2.
[0303] For node I2: Message 2 is received from node I1. Since the attribute information of the first service is not stored locally, that is, node I2 has not published or subscribed to the first service, and it can be seen from message 2 that the maximum forwarding number of service query request message 1 is 2 (not 0), node I2 continues to send messages carrying service query request message 1 to its other neighbor nodes in the form of unicast. As shown in Figure 8, node I2 has multiple neighbor nodes in addition to node I1. Based on the different sending objects, they are described below:
[0304] 1) Node I2 sends message 3 to node I3
[0305] Message 3 includes the service query request message 1, and the hop limit field in message 3 indicates that the maximum number of forwarding times of the service query request message 1 is 1. In addition, the source address field of message 3 indicates the address of node I2, and the destination address field of message 3 indicates the address of node I3.
[0306] 2) Node I2 sends message 4 to node I4
[0307] Message 4 includes the service query request message 1, and the hop limit field in message 4 indicates that the maximum number of forwarding times of the service query request message 1 is 1. In addition, the source address field of message 4 indicates the address of node I2, and the destination address field of message 4 indicates the address of node I4.
[0308] 3) Node I2 sends message 5 to node E3
[0309] Message 5 includes the service query request message 1, and the hop limit field in message 5 indicates that the maximum number of forwarding times of the service query request message 1 is 1. In addition, the source address field of message 5 indicates the address of node I2, and the destination address field of message 5 indicates the address of node E3.
[0310] Node I3 receives message 3 from node I2. Since it has subscribed to the first service locally, it has the first service's attribute information stored locally. In this case, node I3 can send message 6 to node E5. Message 6 includes service query response message 1. The result field in service query response message 1 indicates that the query result for the first service is successful. Service query response message 1 also includes the first service's attribute information. Furthermore, the source address field in message 6 indicates the address of node I3, and the destination address field in message 6 indicates the address of node E5. It can be understood that since node I3 successfully locally queries the first service, node T3 no longer forwards service query request message 1 to its other neighboring nodes.
[0311] Node I4 receives message 4 from node I2. Since it does not store the attribute information of the first service locally, i.e., node I4 has neither published nor subscribed to the first service, and message 4 indicates that the maximum forwarding count of service query request message 1 is 1 (not 0), node I4 continues to unicast message 7 carrying service query request message 1 to its neighbor node E2. The hop limit field in message 7 indicates that the maximum forwarding count of service query request message 1 is 0. The source address field of message 7 indicates the address of node I4, and the destination address field of message 7 indicates the address of node E2.
[0312] Node E2 receives message 7 from node I4. Since the first service's attribute information is not locally stored, meaning node E2 has neither published nor subscribed to the first service, and message 7 indicates that the maximum forwarding count for service query request message 1 is 0, node I4 can send message 8 to node E5. Message 8 includes service query response message 2. The result field in service query response message 2 indicates that the query result for the first service failed. The source address field of message 8 indicates the address of node E2, and the destination address field of message 8 indicates the address of node E5.
[0313] Node E3 receives message 5 from node I2. Since it is the node publishing the first service, node E3 successfully queries the first service locally. Therefore, node E3 can send message 9 to node E5. Message 9 includes a service query response message 3. The result field in service query response message 3 indicates that the query result for the first service is successful. Service query response message 3 also includes attribute information of the first service. In addition, the source address field of message 9 indicates the address of node E3, and the destination address field of message 9 indicates the address of node E5.
[0314] In summary, node E5 can receive message 6 from node I3 (indicating a successful query result for the first service), message 8 from node E2 (indicating a failed query result for the first service), and message 9 from node E3 (indicating a successful query result for the first service). When node E5 receives multiple messages from different nodes indicating a successful query result for the first service, it can perform redundant processing and only process the first received message indicating a successful query result for the first service.
[0315] It can be understood that FIG8 above is only an example of the service discovery process of the first service in the network shown in FIG8 .
[0316] In some possible embodiments, a node may receive a unicast message carrying a service query request message, and the hop limit field in the unicast message indicates that the maximum number of forwarding times of the service query request message is not zero, but the node has not published and subscribed to the first service locally and the node has no other neighbor nodes. In this case, the node can send a message to the initiating node of the query for the first service, indicating that the query result of the first service is a query failure.
[0317] After the first service is published in the wireless network based on the service publishing method shown in Figure 2, any node in the wireless network or a node newly connected to the wireless network, when there is a need to query the first service, can perform service query through the service discovery method provided in the following embodiment of the present application. This does not rely on the deployment of traditional DNS servers and can also achieve rapid search for services in the nearest range possible.
[0318] 9 is a flowchart of another service discovery method provided by an embodiment of the present application. The method can be applied to a communication system including a node 3 and at least one neighboring node of the node 3 (eg, a node 4).
[0319] In some possible embodiments, the communication system further includes at least one node (eg, node 5) two hops away from node 3. The method includes but is not limited to the following steps:
[0320] S901: Node 3 sends a first query message in a non-unicast manner. The first query message is used by node 3 to request to query a first service.
[0321] Here, the description of node 3 in the embodiment of FIG. 4 may be referred to for node 3, which will not be repeated here.
[0322] Here, the first query message includes a requesting node identifier, which indicates the identifier of node 3. The message type of the first query message is a service query request message. The message format of the first query message can refer to the relevant description of the embodiment of FIG. 5B above, which will not be repeated here.
[0323] Exemplarily, non-unicast includes multicast and broadcast.
[0324] In one implementation, when the node 3 sends the first query message in a multicast manner, the first query message is carried in the multicast message.
[0325] For example, node 3 sends a first query message in a non-unicast manner, including: node 3 sends message A, which includes the first query message. Message A is a multicast message. Message A includes a network layer header, a multicast header, and a payload field. The payload field is used to carry the first query message. For details about the fields in the network layer header and the multicast header, refer to the description of the corresponding content in the embodiment of FIG. 3A .
[0326] In message A, the "Source Address" field in the network layer header indicates the address of node 3, and the "Destination Address" field in the network layer header indicates a multicast address. If the "Hop Limit" field is not set, nodes in the network that listen to this multicast address can process message A upon receiving it. This multicast address can be, for example, a well-known multicast address defined in the wireless address allocation protocol, or a multicast address allocated by other means.
[0327] In another implementation, when the node 3 sends the first query message in a broadcast form, the first query message is carried by the broadcast message.
[0328] For example, node 3 sends a first query message in a non-unicast manner, including: node 3 sends message B, message B includes the first query message, and message B is a broadcast message. Message B includes a network layer message header, a broadcast header, and a payload field, wherein the payload field is used to carry the first query message. The fields in the network layer message header and the broadcast header can be referred to the description of the corresponding content in the embodiment of FIG. 3C and are not repeated here.
[0329] S902: Node 3 sends indication information A in a non-unicast manner, where the indication information A indicates a first maximum forwarding times of the first query message.
[0330] The first maximum forwarding count is 1. This limits the number of nodes in the wireless network to being able to receive and process the first query message. In other words, only neighboring nodes of node 3 in the wireless network can receive the first query message. That is, node 3 first requests the first service from the node closest to itself.
[0331] Exemplarily, the indication information A and the first query message may also be carried in a single message. For example, when the first query message is carried by message A, the "Hop Limit" field in the network layer header of message A may carry the indication information A. Similarly, when the first query message is carried by message B, the "Hop Limit" field in the network layer header of message B may carry the indication information A.
[0332] S903: Node 4 sends attribute information of a first service to node 3. The first service is a service subscribed by node 4. Node 4 is a neighbor node of node 3.
[0333] Here, the attribute information of the first service can refer to the description of the corresponding content in the embodiment of FIG. 4 above, which will not be repeated here.
[0334] Exemplarily, each of at least one neighboring nodes of node 3, for example node 4, receives the first query message, parses the first query message, and queries B locally for the first service based on the identifier of the first service obtained from the first query message. If node 4 locally stores attribute information of the first service, node 4 sends the attribute information of the first service to node 3. Here, node 4 locally stores attribute information of the first service, which means that the first service is a service subscribed to by node 4, or the first service is a service published by node 4.
[0335] In some possible embodiments, if node 4 does not store the attribute information of the first service locally, the following S904 is executed.
[0336] Correspondingly, if node 3 receives the attribute information of the first service from node 4, node 3 confirms that the query for the first service was successful. Because node 3 sends the first query message in a non-unicast format, if node 3 has multiple neighboring nodes, node 3 will also receive replies from these multiple neighboring nodes. When node 3 receives the first reply carrying the attribute information of the first service, node 3 confirms that the query for the first service was successful, and the process ends.
[0337] For example, the first service is a service subscribed to by node 4, i.e., node 4 is node 2 in the embodiment of Figure 2; the first service is a service published by node 4, i.e., node 4 is node 1 in the embodiment of Figure 2. For the terms "subscribe" and "publish," please refer to the introduction of the corresponding terms above and will not be repeated here.
[0338] Here, since node 4 receives the first query message for the first time, after parsing the first query message, node 4 will locally record the request transaction number of the first query message to mark that the first query message has been processed.
[0339] In one implementation, the attribute information of the first service can be carried by a first response message. Here, the message type of the first response message is a service query response message. The first response message can be carried by a unicast message (e.g., the third message in the embodiment of FIG. 4 above). The first response message can refer to the description of the corresponding content in S402 of the embodiment of FIG. 4 above and the description of the embodiment of FIG. 6, and will not be repeated here.
[0340] Optionally, in some possible embodiments, the above S903 may not be executed, and the following S904-S907 may be executed:
[0341] S904: The first maximum forwarding number is 1, and node 4 sends result indication information 1 to node 3. Result indication information 1 indicates that the query result of the first service is query failure.
[0342] In one implementation, node 4 receives the first query message, and the first maximum forwarding number is 1. If node 4 does not store the attribute information of the first service locally, node 4 sends result indication information 1 to node 3 to inform it that the first service query has failed.
[0343] Here, the node 4 does not store the attribute information of the first service locally, which means that the node 4 has neither published the first service nor subscribed to the first service.
[0344] Exemplarily, the result indication information 1 can be carried by a second response message. Here, the message type of the second response message is a service query response message. The second response message can be carried by a unicast message (e.g., the sixth message in the embodiment of FIG. 4 above). The second response message can refer to the description of the corresponding content in S405 of the embodiment of FIG. 4 above and the description of the embodiment of FIG. 7, and will not be repeated here.
[0345] S905: When node 3 receives result indication information 1 from all other neighboring nodes, node 3 sends the first query message and indication information B in a non-unicast manner, where indication information B indicates the second maximum forwarding times of the first query message.
[0346] The second maximum forwarding number is the first maximum forwarding number plus 1. For example, if the first maximum forwarding number is 1, the second maximum forwarding number is 2.
[0347] That is to say, the first maximum forwarding number is 1. Node 3 knows that the first service has failed to be found on its own neighboring nodes based on the result indication information 1 received from its own neighboring nodes. Therefore, node 3 sends the first query message again in a non-unicast form, and sets the second maximum forwarding number of the first query message to 2. In this way, it is limited that only nodes that are at most two hops away from node 3 in the wireless network can receive the first query message. Compared with the first time node 3 sent the first query message for the first time by setting the first maximum forwarding number to 1, which limited only node 3's neighboring nodes to receive the first query message, the range of nodes that can receive the first query message in this round of service query has been expanded.
[0348] For example, the first query message and the indication information B may be sent separately or carried in a single broadcast message or multicast message. The manner in which the first query message and the indication information B are carried in the multicast message or broadcast message may be described in the same manner as in S901-S902 above, and will not be further elaborated here.
[0349] S906: Node 4 determines that the first query message history has been processed, and the value after the second maximum forwarding number is reduced by 1 is not zero.
[0350] Exemplarily, node 4 receives a first query message, which carries a request transaction number. Node 4 determines that the request transaction number is a duplicate value (i.e., the request transaction number is stored locally), which means that node 4 has processed the first query message in the past. Therefore, node 4 reduces the second maximum forwarding times by 1, and the value after reducing the second maximum forwarding times by 1 is not zero.
[0351] S907: Node 4 sends the first query message and indication information C in a non-unicast manner, where the indication information C indicates the third maximum forwarding times of the first query message.
[0352] For example, the first query message and the indication information C may be sent separately or carried in a single broadcast message or multicast message. The manner in which the first query message and the indication information C are carried in the multicast message or broadcast message may be described in the corresponding sections of S901-S902 above and will not be repeated here.
[0353] The third maximum forwarding number is the second maximum forwarding number minus 1. For example, if the second maximum forwarding number is 2, then the third maximum forwarding number is 1.
[0354] For example, if node 4 fails to query the first service locally, and the value after deducting 1 from the second maximum forwarding count is not zero, node 4 sends the first query message and indication information C in a non-unicast manner, where the third maximum forwarding count indicated by indication information C is 1. Thus, since the third maximum forwarding count is 1, the first query message and indication information C sent by node 4 can only be received and processed by node 4's neighboring nodes, thus preventing the first query message from being infinitely flooded in the network and saving network resource overhead.
[0355] Correspondingly, at least one neighboring node of node 4 (for example, node 5) receives the first query message and indication information C. Because node 5 receives the first query message for the first time, it parses the first query message, locally records the request transaction number carried by the first query message, and locally queries the first service based on the identifier of the first service carried by the first query message. If the first service is a service published or subscribed by node 5, it means that the first service is successfully queried on node 5, and node 5 sends the attribute information of the first service to node 3; if the first service is neither a service published by 5 nor a service of node 5, that is, node 5 does not store the attribute information of the first service locally, then the first service fails to be queried on node 5, and the third maximum forwarding number is 1, so node 5 sends result indication information 1 to node 3, and result indication information 1 indicates that the first service query failed.
[0356] For example, if the query for the first service fails on all nodes that are two hops away from node 3, node 3 can send the first query message for the third time and indicate that the maximum number of forwarding times of the first query message is 3. In this way, it is limited that only nodes that are at most three hops away from node 3 in the wireless network can receive the first query message, and the range of nodes that query the first service in the wireless network is gradually expanded until a node in the wireless network successfully queries the first service.
[0357] As can be seen, the initiating node querying the first service queries the first service in a non-unicast manner. Nodes publishing and subscribing to the first service in the wireless network can all reply with the queried attribute information of the first service, independent of the deployment of a DNS server. Furthermore, the initiating node querying the first service gradually queries the first service from near to far by setting the maximum forwarding times for the service query request message to increase incrementally. This prevents the service query request message from flooding the wireless network infinitely, enabling the first service to be found quickly within the closest possible range, thus reducing network resource overhead.
[0358] The application of the service discovery method described in Figure 9 is described below using the networking scenario shown in Figure 8. The description of the application scenario and service publishing phase of Figure 8 can be referred to the description of Figure 8 above and will not be repeated here.
[0359] In Figure 8, assume that node E5 is a newly joined node in the network and that node E5 accesses the network through node I1. Assuming that node E5 is the initiating node for querying the first service, the service discovery process of the first service among the nodes in the network is as follows:
[0360] For node E5: Message 1 is sent in multicast form. Message 1 includes Service Query Request Message 1, which indicates that node E5 is requesting to query the first service. The Hop Limit field in Message 1 indicates that the maximum number of forwarding times for Service Query Request Message 1 is set to 1 (meaning that only neighboring nodes of node E5 can receive and process Message 1). The Source Address field of Message 1 indicates the address of node E5, and the Destination Address field of Message 1 indicates a multicast address.
[0361] Node I1 receives Message 1 (i.e., receives Service Query Request Message 1 for the first time). Since the local server does not store the attribute information for the first service, Message 1 indicates that the maximum number of forwarding times for Service Query Request Message 1 is 1 (which minus 1 equals 0). Therefore, node I1 sends Message 2 to node E5. Message 2 carries Service Query Response Message 1. The result field in Service Query Response Message 1 indicates that the query result for the first service failed. Furthermore, the source address field of Message 2 indicates the address of node I1, and the destination address field of Message 2 indicates the address of node E5.
[0362] For node E5: Since node E5 has only one neighbor, node I1, and based on received message 2, it knows that node I1's query for the first service has failed, node E5 sends message 3 in multicast form. Message 3 includes the aforementioned service query request message 1. In addition, the hop limit field in message 3 indicates that the maximum number of forwarding times for service query request message 1 is 2 (meaning that nodes at most two hops away from node E5 can receive and process message 3). The source address field of message 3 indicates the address of node E5, and the destination address field of message 3 indicates a multicast address.
[0363] For node I1: receive message 3, determine that the service query request message 1 carried by message 3 has been processed historically, subtract 1 from the value indicated by the hop limit field in message 3 to obtain message 4, and send message 4 in the form of multicast, where the maximum forwarding number indicated by the hop limit field in message 4 is 1 (meaning that only the remaining neighboring nodes of node I1 can receive and process message 4).
[0364] Node I2 receives message 4. Since the local query for the first service fails because the attribute information for the first service is not stored locally, and message 4 indicates that the maximum number of forwarding times for Service Query Request Message 1 is 1 (which minus 1 equals 0), node I2 sends message 5 to node E5. Message 5 carries Service Query Response Message 1 to inform node E5 that the first service query has failed. Furthermore, the source address field of message 5 indicates the address of node I2, and the destination address field of message 5 indicates the address of node E5.
[0365] For node E5: Since node E5 has only one node, I2, two hops away, and based on received message 5, it knows that node I2's query for the first service has failed, node E5 sends message 6 in multicast form. Message 6 includes the aforementioned service query request message 1. The hop limit field in message 6 indicates that the maximum number of forwarding times for service query request message 1 is 3 (meaning that nodes at most three hops away from node E5 can receive and process message 6). The source address field of message 6 indicates the address of node E5, and the destination address field of message 6 indicates a multicast address.
[0366] For node I1: determine the service query request message 1 carried by message 6 that has been processed historically, subtract 1 from the value indicated by the hop limit field in message 6 to obtain message 7, the maximum forwarding times indicated by the hop limit field in message 7 is 2, and then send message 7 in the form of multicast.
[0367] Node I2 determines whether it has previously processed Service Query Request Message 1 carried in Message 7. It decrements the value indicated by the Hop Limit field in Message 7 by 1 to obtain Message 8, where the maximum number of forwarding times indicated by the Hop Limit field in Message 8 is 1. Message 8 is then multicasted. Accordingly, Nodes I3, I4, and E3 can receive and process Message 8.
[0368] Node I3 receives message 8. Since node I3 has subscribed to the first service, the local query for the first service is successful. Node I3 then sends message 9 to node E5. Message 9 carries service query response message 2, which includes attribute information about the first service. The source address field of message 9 indicates the address of node I3, and the destination address field indicates the address of node E5.
[0369] Node I4 receives message 8. Since node I4 does not store the attribute information of the first service, the local query for the first service fails. Message 8 indicates that the maximum number of forwarding times for Service Query Request Message 1 is 1 (which minus 1 equals 0). Therefore, node I4 sends message 10 to node E5. Message 10 carries Service Query Response Message 1, notifying node E5 of the failure of the first service query. Furthermore, the source address field of message 10 indicates the address of node I4, and the destination address field of message 10 indicates the address of node E5.
[0370] For node E3: Because node I3 publishes the first service, the local query for the first service succeeds. Node E3 sends message 11 to node E5. Message 11 carries service query response message 2, which includes attribute information about the first service. The source address field of message 11 indicates the address of node E3, and the destination address field of message 11 indicates the address of node E5.
[0371] In summary, node E5 can receive message 9 from node I3 (carrying attribute information of the first service), message 10 from node I4 (indicating that the query result for the first service is a failure), and message 11 from node E3 (carrying attribute information of the first service). When node E5 can receive multiple messages from different nodes, if one message carries attribute information of the first service, it means that the query for the first service is successful, and the remaining messages can be processed redundantly.
[0372] It can be understood that the above description is only an example of the service discovery process of the first service in the network shown in FIG8 .
[0373] In some possible embodiments, the setting of the first maximum number of forwarding times may not start from 1, for example, from 2 or other values.
[0374] In some possible embodiments, when node E5 sends the first query message for requesting to query the first service in a non-unicast form, if the maximum number of forwarding times of the first query message is not limited, then the nodes that publish and subscribe to the first service in the wireless network can send the attribute information of the first service to node E5.
[0375] 10 is a schematic diagram of a structure of a device for service discovery provided by an embodiment of the present application, wherein the device 30 for service discovery includes a sending unit 310 and a receiving unit 312. The device 30 for service discovery can be implemented by hardware, software, or a combination of hardware and software.
[0376] As an example, the device 30 for service discovery may be a node that generates the first query message, such as the first node.
[0377] In one implementation, a sending unit 310 is configured to send a first query message in unicast format to a second node, where the second node is a neighboring node of the first node. The first query message is used by the first node to request a query for a first service. A receiving unit 312 is configured to receive attribute information of the first service from a third node, where the first service is a service published or subscribed to by the third node. For example, in the embodiment of FIG4 , the first node is node 3, the second node is node 4, and the third node can be node 4 or node 5. It should be understood that the first node, second node, and third node herein are merely examples used to distinguish different nodes in this implementation and should not constitute limitations on the first node, second node, and third node in other implementations. In this case, the apparatus 30 for service discovery can be used to implement the method described on the node 3 side of the embodiment of FIG4 . In the embodiment of FIG4 , the sending unit 310 can be used to perform S401, and the receiving unit 312 can be used to perform S402 or S404. In some possible embodiments, the receiving unit 312 can also be used to perform S405.
[0378] In another implementation, the sending unit 310 is used to send a first query message in a non-unicast form, where the first query message is used by the first node to request a query for a first service; the receiving unit 312 is used to receive attribute information of the first service from the second node, where the first service is a service subscribed to by the second node. For example, in the embodiment of Figure 9, the first node is node 3, and the second node can be node 4 or node 5. It can be understood that the first node and the second node here are only examples in this implementation, used to distinguish different nodes in this implementation, and should not constitute a limitation on the first node and the second node in other implementations. In this case, the device 30 for service discovery can be used to implement the method on the node 3 side described in the embodiment of Figure 9. In the embodiment of Figure 9, the sending unit 310 can be used to execute S901, S902 or S905, and the receiving unit 312 can be used to execute S903 or S904.
[0379] As another example, the device 30 for service discovery may be a node that receives the first query message, such as the first node.
[0380] In one implementation, the receiving unit 312 is configured to receive a first query message from a second node, where the second node is a neighbor node of the first node. The first query message is used to request a query for a first service. The first query message is transmitted in a unicast manner, and the first query message includes a requesting node identifier. The sending unit 310 is configured to send attribute information of the first service to a third node indicated by the requesting node identifier when the first node publishes or subscribes to the first service. For example, in the embodiment of FIG4 , when the first node is node 4, the second node and the third node are both node 3; when the first node is node 5, the second node is node 4, and the third node is node 3. It can be understood that the first node, second node, and third node here are merely examples in this implementation, used to distinguish different nodes in this implementation, and should not constitute a limitation on the first node, second node, and third node in other implementations.
[0381] For example, the apparatus 30 for service discovery may be used to implement the method on the node 4 side described in the embodiment of Figure 4. In the embodiment of Figure 4, the receiving unit 312 may be used to execute S401, and the sending unit 310 may be used to execute S402, S403, or S405.
[0382] For example, the apparatus 30 for service discovery may also be used to implement the method on the node 5 side described in the embodiment of Figure 4. In the embodiment of Figure 4, the receiving unit 312 may be used to execute S403, and the sending unit 310 may be used to execute S404.
[0383] In another implementation, the receiving unit 312 is configured to receive a first query message, the first query message being used to request a first service. The first query message is transmitted in a non-unicast manner and includes a requesting node identifier. The sending unit 310 is configured to, when the first node subscribes to the first service, send attribute information of the first service to a second node indicated by the requesting node identifier. For example, in the embodiment of FIG. 9 , the first node is node 4 or node 5, and the second node may be node 3. It will be understood that the first and second nodes herein are merely examples in this implementation, used to distinguish between different nodes in this implementation, and should not constitute limitations on the first and second nodes in other implementations. In this case, the apparatus 30 for service discovery can be used to implement the method described in the embodiment of FIG. 9 on the node 4 or node 5 side. In the embodiment of FIG. 9 , the sending unit 310 can be used to execute S903, S904, S906, or S907, and the receiving unit 312 can be used to execute S901, S902, or S905.
[0384] In some possible embodiments, the device 30 for service discovery may also be used to implement the method described in the embodiment of FIG. 2 (eg, the method on the node 1 side or the method on the node 2 side), which will not be described in detail here for the sake of brevity.
[0385] It should be understood that the division of the various units in the above-mentioned device 30 for service discovery is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. In addition, the units in the device can be implemented in the form of a processor calling software; for example, the device includes a processor, the processor is connected to a memory, and the memory stores instructions. The processor calls the instructions stored in the memory to implement any of the above methods or implement the functions of the various units of the device, wherein the processor is, for example, a general-purpose processor, such as a central processing unit (CPU) or a microprocessor, and the memory is a memory within the device or a memory outside the device. Alternatively, the units in the device can be implemented in the form of hardware circuits, and the functions of some or all of the units can be realized by designing the hardware circuits. The hardware circuit can be understood as one or more processors. For example, in one implementation, the hardware circuit is an application-specific integrated circuit (ASIC), which realizes the functions of some or all of the above units by designing the logical relationship of the components in the circuit. For another example, in another implementation, the hardware circuit can be implemented by a programmable logic device (PLD). Taking a field programmable gate array (FPGA) as an example, it can include a large number of logic gate circuits, and the connection relationship between the logic gate circuits is configured by configuring the configuration file, thereby realizing the functions of some or all of the above units. All units of the above devices can be implemented in the form of software called by the processor, or in the form of hardware circuits, or in part by software called by the processor, and the rest by hardware circuits.
[0386] In an embodiment of the present application, a processor is a circuit with a signal processing capability. In one implementation, the processor can be a circuit with instruction reading and execution capability, such as a central processing unit (CPU), a microprocessor, a graphics processing unit (GPU) (which can be understood as a microprocessor), or a digital signal processor (DSP). In another implementation, the processor can implement certain functions through the logical relationship of a hardware circuit. The logical relationship of the hardware circuit is fixed or reconfigurable, such as a hardware circuit implemented by a processor as an application-specific integrated circuit (ASIC) or a programmable logic device (PLD), such as an FPGA. In a reconfigurable hardware circuit, the processor loads a configuration document to implement the process of hardware circuit configuration, which can be understood as the process of the processor loading instructions to implement the functions of some or all of the above units. In addition, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as a neural network processing unit (NPU), a tensor processing unit (TPU), a deep learning processing unit (DPU), etc.
[0387] It can be seen that each unit in the above device can be one or more processors (or processing circuits) configured to implement the above method, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0388] In addition, the various units in the above devices can be fully or partially integrated together, or can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a system-on-a-chip (SOC). The SOC may include at least one processor for implementing any of the above methods or implementing the functions of the various units of the device. The type of the at least one processor can be different, for example, including a CPU and FPGA, a CPU and an artificial intelligence processor, a CPU and a GPU, etc.
[0389] Referring to Figure 11 , Figure 11 is a schematic diagram of the structure of a device for service discovery provided in an embodiment of the present application. As shown in Figure 11 , device 40 for service discovery includes a processor 401, a communication interface 402, a memory 403, and a bus 404. Processor 401, memory 403, and communication interface 402 communicate with each other via bus 404. It should be understood that this application does not limit the number of processors and memories in device 40 for service discovery.
[0390] In one implementation, the device 40 for service discovery can be a network device with routing and forwarding capabilities, such as a wireless router, a wireless access point (AP), etc., or it can be a component within the network device, and the component can be, for example, a single board, a line card, a chip, etc.; it can also be a terminal device with routing and forwarding capabilities, such as smart home devices (such as televisions, sweeping robots, smart desk lamps, audio systems, smart lighting systems, electrical control systems, home background music, home theater systems, intercom systems, video surveillance, etc.), smart transportation equipment (such as cars, ships, drones, trains, vans, trucks, etc.), smart manufacturing equipment (such as robots, industrial equipment, smart logistics, smart factories, etc.), user devices (mobile phones, computers, tablets, PDAs, desktops, headphones, audio, wearable devices, vehicle-mounted devices, virtual reality devices, augmented reality devices, etc.), or it can be a component within the terminal device (such as a chip or integrated circuit).
[0391] In another implementation, the device 40 for service discovery may be a terminal device without routing capability. Here, the terminal device may refer to the examples of the above corresponding content, which will not be described in detail here.
[0392] Bus 404 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, among others. Buses may be classified as address buses, data buses, control buses, and the like. For ease of illustration, FIG11 uses only one line, but this does not imply a single bus or type of bus. Bus 404 may include a path for transmitting information between various components of device 40 for service discovery (e.g., memory 403, processor 401, and communication interface 402).
[0393] The processor 401 can refer to the relevant description of the processor in the above embodiment, which will not be repeated here.
[0394] Memory 403 is used to provide storage space for storing data such as the operating system and computer programs. Memory 403 can be one or a combination of random access memory (RAM), erasable programmable read-only memory (EPROM), read-only memory (ROM), or compact disc read-only memory (CD-ROM). Memory 403 can exist independently or be integrated into processor 401.
[0395] The communication interface 402 can be used to provide information input or output for the processor 401. Alternatively, the communication interface 402 can be used to receive data transmitted externally and / or transmit data externally. It can be a wired link interface such as an Ethernet cable, or a wireless link interface (such as Wi-Fi, Bluetooth, general wireless transmission, etc.). Alternatively, the communication interface 402 can also include a transmitter (such as a radio frequency transmitter, antenna, etc.) or a receiver coupled to the interface.
[0396] The processor 401 in the device 40 for service discovery is used to read the computer program stored in the memory 403 to execute the aforementioned method, such as the method described in FIG. 2 or FIG. 4 .
[0397] In one possible design, the device 40 for service discovery may be one or more modules in an execution entity (e.g., node 3) that executes the method shown in FIG. 4 . The processor 401 may be configured to read one or more computer programs stored in a memory to perform the following operations:
[0398] Sending a first query message to node 4 in unicast form by the sending unit 310, where the first query message is used by node 3 to request querying the first service, and node 4 is a neighbor node of node 3;
[0399] The receiving unit 312 receives attribute information of the first service sent by the node 4 , where the first service is a service published or subscribed by the node 4 .
[0400] In one possible design, the device 40 for service discovery may be one or more modules in an execution entity (e.g., node 4) that executes the method shown in FIG. 4 . The processor 401 may be configured to read one or more computer programs stored in a memory to perform the following operations:
[0401] Receiving, by the receiving unit 312, a first query message sent by node 3, where node 3 is a neighbor node of node 4, the first query message is used to request a first service, the first query message is transmitted in a unicast manner, and the first query message includes a requesting node identifier;
[0402] The sending unit 310 sends attribute information of the first service to the node 3 indicated by the requesting node identifier. The first service is a service published or subscribed by the node 4.
[0403] In one possible design, the device 40 for service discovery may be one or more modules in an execution entity (e.g., node 3) that executes the method shown in FIG. 9 . The processor 401 may be configured to read one or more computer programs stored in a memory to perform the following operations:
[0404] Sending a first query message in a non-unicast form by the sending unit 310, where the first query message is used by the first node to request to query the first service;
[0405] The receiving unit 312 receives attribute information of a first service from the second node, where the first service is a service subscribed by the second node.
[0406] In one possible design, the device 40 for service discovery may be one or more modules in an execution entity (e.g., node 4) that executes the method shown in FIG. 9 . The processor 401 may be configured to read one or more computer programs stored in a memory to perform the following operations:
[0407] Receiving a first query message through the receiving unit 312, the first query message is used to request a first service, the first query message is transmitted in a non-unicast form, and the first query message includes a requesting node identifier;
[0408] When the first node subscribes to the first service, the sending unit 310 sends the attribute information of the first service to the second node indicated by the requesting node identifier.
[0409] In the embodiments described above, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a particular embodiment, please refer to the relevant descriptions of other embodiments. In addition, in the various embodiments of this application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between the various embodiments are consistent and can be referenced to each other. The technical features in different embodiments can be combined to form new embodiments based on their inherent logical relationships.
[0410] It should be noted that, those skilled in the art can see that all or part of the steps in the various methods of the above embodiments can be completed by a program to instruct relevant hardware. The program can be stored in a computer-readable storage medium, and the storage medium includes a read-only memory (ROM), a random access memory (RAM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), a one-time programmable read-only memory (OTPROM), an electrically erasable programmable read-only memory (EEPROM), a compact disc read-only memory (CD-ROM) or other optical disc storage, magnetic disk storage, magnetic tape storage, or any other computer-readable medium that can be used to carry or store data.
[0411] The technical solution of the present application may essentially or contribute to the part or all or part of the technical solution in the form of a software product. The computer program product is stored in a storage medium and includes a number of instructions for enabling a device (which may be a personal computer, a server, or a network device, a robot, a single-chip microcomputer, a chip, a robot, etc.) to execute all or part of the steps of the method described in each embodiment of the present application.
Claims
1. A service discovery method, characterized in that: The method is applied to a first node, and the method comprises: receiving a first query message from a second node, where the second node is a neighbor node of the first node, the first query message is used to request a query for a first service, the first query message is transmitted in a unicast form, and the first query message includes a requesting node identifier; In the case where the first node publishes or subscribes to the first service, the attribute information of the first service is sent to the third node indicated by the requesting node identifier.
2. The method according to claim 1, characterized in that The attribute information of the first service includes one or more of the following information: The identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service and the lifetime of the first service.
3. The method according to claim 1 or 2, characterized in that: The method further comprises: First indication information is received from the second node, where the first indication information indicates a maximum number of forwarding times of the first query message.
4. The method according to claim 3, characterized in that The maximum number of forwarding times is zero, and the method further includes: Second indication information is sent to the third node, where the second indication information indicates that a query result of the first service is a query failure.
5. The method according to any one of claims 1 to 4, characterized in that: The second node is the third node, or the second node is separated from the third node by at least one hop.
6. A service discovery method, characterized in that: The method is applied to a first node, and the method comprises: Sending a first query message to a second node in a unicast form, where the second node is a neighbor node of the first node, and the first query message is used by the first node to request to query the first service; Receive attribute information of the first service from a third node, where the first service is a service published or subscribed by the third node.
7. The method according to claim 6, characterized in that The third node is the second node, or the third node is separated from the second node by at least one hop.
8. The method according to claim 6, characterized in that Before receiving the attribute information of the first service from the third node, the method further includes: First indication information is sent to the second node in a unicast manner, where the first indication information indicates a maximum number of forwarding times of the first query message.
9. The method according to any one of claims 6 to 8, characterized in that: The attribute information of the first service includes one or more of the following information: The identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service and the lifetime of the first service.
10. A device for service discovery, characterized in that: The device is a first node or is included in the first node, and the device includes: A receiving unit, configured to receive a first query message from a second node, where the second node is a neighbor node of the first node, the first query message is used to request a query for a first service, the first query message is transmitted in a unicast form, and the first query message includes a requesting node identifier; A sending unit is used to send the attribute information of the first service to the third node indicated by the requesting node identifier when the first node publishes or subscribes to the first service.
11. The device according to claim 10, characterized in that The attribute information of the first service includes one or more of the following information: The identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service and the lifetime of the first service.
12. The device according to claim 10 or 11, characterized in that The receiving unit is also used for: First indication information is received from the second node, where the first indication information indicates a maximum number of forwarding times of the first query message.
13. The device according to claim 12, characterized in that The maximum number of forwarding times is zero, and the sending unit is further used for: Second indication information is sent to the third node, where the second indication information indicates that a query result of the first service is a query failure.
14. The device according to any one of claims 10 to 13, characterized in that: The second node is the third node, or the second node is separated from the third node by at least one hop.
15. A device for service discovery, characterized in that: The device is a first node or is included in the first node, and the device includes: a sending unit, configured to send a first query message to a second node in a unicast form, where the second node is a neighbor node of the first node, and the first query message is used by the first node to request to query the first service; The receiving unit is configured to receive attribute information of the first service from a third node, where the first service is a service published or subscribed by the third node.
16. The device according to claim 15, characterized in that The third node is the second node, or the third node is separated from the second node by at least one hop.
17. The device according to claim 15, characterized in that The sending unit is also used for: First indication information is sent to the second node in a unicast manner, where the first indication information indicates a maximum number of forwarding times of the first query message.
18. The device according to any one of claims 15 to 17, characterized in that: The attribute information of the first service includes one or more of the following information: The identifier of the first service, the network address of the first service, the port number of the first service, the type of transport layer protocol used by the first service, the application type corresponding to the first service and the lifetime of the first service.
19. A device for service discovery, characterized in that: The device includes at least one processor and an interface circuit, and the processor is used to execute instructions and / or data interaction through the interface circuit, so that the device executes the method according to any one of claims 1-5, or executes the method according to any one of claims 6-9.
20. A system for service discovery, characterized in that: The system comprises a first device and a second device, wherein the first device is used to execute the method according to any one of claims 1 to 5, and the second device is used to execute the method according to any one of claims 6 to 9.
21. A computer-readable storage medium, characterized in that: The method comprises computer instructions, which, when executed by a processor, implement the method according to any one of claims 1 to 5, or execute the method according to any one of claims 6 to 9.