Service discovery method and device, equipment and storage medium
By introducing additional data processing units into the client, the server response messages are parsed, and the network security system is bypassed, and the problem that routers and other devices cannot receive response messages is solved, achieving the smooth progress of the service discovery process.
Patent Information
- Application Number
- CN202411942918.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2044-12-26
AI Technical Summary
Clients such as routers with network security systems cannot receive response messages sent by the server, resulting in the inability to complete the service discovery process.
The additional data processing unit analyzes the response messages sent by the server, so that the response messages can bypass the client's network security system to the data processing unit, so that the client can directly identify, access and connect the target services provided by the server based on the message analysis results of the data processing unit.
It provides a new message transmission path for the client to ensure the smooth progress of the service discovery process and ensures that the client can stably receive the response messages sent by the server.
Smart Images

Figure CN119854148A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a service discovery method, apparatus, device and storage medium. Background Art
[0002] Service discovery is a method of automatically identifying and accessing devices and services on the network, so that each service in the system does not need to care about the specific location of other services, but only needs to know the name of the service to communicate and connect.
[0003] In the related art, the client broadcasts a service discovery message to the server. After receiving the service discovery message, the server that can provide the service sends a response message to the client. The client implements operations such as communication and access to the target service through the response message.
[0004] However, for clients such as routers that are equipped with network security systems (firewall rules), response messages are often blocked by the network security system and cannot be received. In order to ensure the security of such clients, the network security system cannot be easily tampered with, making it impossible for the client to receive the response message and thus unable to complete the service discovery process. Summary of the invention
[0005] The present application provides a service discovery method, apparatus, device and storage medium, which provide a new message transmission path for the client, so that the client can stably receive the response message sent by the server.
[0006] In order to achieve the above purpose, this application adopts the following technical solutions:
[0007] In a first aspect, the present application provides a service discovery method, which is applied to a client, the client including a data processing unit of an external device, and the method includes:
[0008] At least one response message sent by the server is obtained, the response message is parsed in the data processing unit to obtain a target response message, and a connection is established with the server based on the target service information in the target response message.
[0009] The data processing unit is used to parse the response message sent by the server. The target response message refers to the reply information sent by the server to the client based on the request of the client.
[0010] The solution provided in the present application uses an additional data processing unit to parse the response message sent by the server, so that the response message can bypass the client's network security system to reach the data processing unit, and then the client can directly identify, access and connect to the target service provided by the server according to the message parsing result of the data processing unit, thereby providing the client with a new message transmission path to ensure the smooth progress of the service discovery process.
[0011] A possible implementation method is to parse the response message in the data processing unit to obtain the target response message, which can be specifically implemented as follows: the response message is filtered based on the preset filtering rules to obtain the response message that meets the preset filtering rules. The response message that meets the preset filtering rules is parsed to obtain the target response message. First, the response message is filtered based on the preset filtering rules to narrow the filtering range, and then the response message that meets the preset filtering rules is parsed, and the target response message is filtered from the response message that meets the preset filtering rules. The recognition accuracy of the target response message is improved by two screenings.
[0012] Another possible implementation method is to filter the response message based on preset filtering rules to obtain the response message that meets the preset filtering rules. This can be specifically implemented as follows: a single response message is captured from the link layer, and when the single response message meets the preset filtering rules, the single response message is used as a response message that meets the preset filtering rules. By capturing the response message from the link layer, while bypassing the client network security system, the response message obtained is more complete and detailed than when it is captured from other network structures. In addition, each time a single response message is captured, it is filtered based on the preset filtering rules, and the amount of calculation in the filtering process is smaller. When a response message that meets the preset filtering rules is obtained through screening, subsequent operations can be directly performed on the response message, thereby improving the processing efficiency of the response message.
[0013] Another possible implementation is to filter the response messages based on preset filtering rules to obtain the response messages that meet the preset filtering rules. This can be specifically implemented as follows: all response messages are captured from the link layer, and the response messages that meet the preset filtering rules are filtered out from all response messages. All response messages are captured at the same time for unified filtering to avoid omission of response messages during the filtering process, thereby avoiding subsequent repeated filtering of response messages and reducing unnecessary consumption of computing resources.
[0014] In another possible implementation, the preset screening rules include source port rules and message feature rules. Among them, the source port rule is used to describe the source port of the response message sent by the server, and the message feature rule is used to describe the message content of the response message sent by the server. The source port rule can preliminarily screen the source of the response message and eliminate other types of messages and messages that may have security risks. The message feature rule further screens the response message that meets the characteristics of the target response message from the message content.
[0015] In another possible implementation, obtaining at least one response message sent by the server can be specifically implemented as follows: when the target response message is obtained, stop obtaining the response message. After successfully obtaining the target response message, the service discovery process is initially completed. At this time, stop obtaining the response message, which reduces the energy consumption of the client on the one hand, and prevents the unauthorized message from entering the client on the other hand.
[0016] Another possible implementation method is to parse the response message that meets the preset screening rules to obtain the target response message, which can be specifically implemented as follows: parse the transport layer and / or application layer of the response message that meets the preset screening rules to obtain the transmission path and / or message data content corresponding to the response message that meets the preset screening rules. Based on the transmission path and / or message data content, filter and obtain the target response message containing the target service information. Parsing the transport layer and application layer of the response message can directly obtain service information such as message data content and transmission path, which is convenient for judging whether the response message is a target response message based on the service information, and can also directly parse and obtain the target service information in the target response message.
[0017] In another possible implementation, the service discovery method provided by the present application may further include: sending a service discovery message to at least one server, where the service discovery message refers to a target service request sent by the client to the server. The client sends the service discovery message, so that the server can accurately identify the target service requested by the client based on the service discovery message, thereby improving the accuracy of the target response message sent to the client.
[0018] Another possible implementation is to send a service discovery message to at least one server, which can be specifically implemented as follows: sending a service discovery message to at least one server via the User Datagram Protocol (UDP). The client does not need to connect to the server, and can send a service discovery message to the server via UDP to implement the service discovery process. And due to the connectionlessness of UDP messages, the delay in establishing a connection and confirming data is reduced, making the sending delay of the service discovery message lower and more efficient.
[0019] In another possible implementation, the target service information includes the port and address of the target service. The client connects to the server through the port and address of the target service, which ensures the accuracy of the connection process, avoids problems such as connection failure or data loss caused by port or address errors, and improves the reliability of the service discovery process.
[0020] In a second aspect, a service discovery device is provided, which includes an acquisition module, a processing module and a connection module.
[0021] The acquisition module is used to acquire at least one response message sent by the server.
[0022] The processing module is used to parse the response message in the data processing unit to obtain a target response message.
[0023] The connection module is used to establish a connection with the server based on the target service information in the target response message.
[0024] The target response message refers to the reply information sent by the server to the client based on the client's request.
[0025] In a possible implementation, the processing module is further used to: filter the response message based on the preset filtering rule to obtain the response message that meets the preset filtering rule; and parse the response message that meets the preset filtering rule to obtain the target response message.
[0026] In another possible implementation, the processing module is further used to: capture a single response message from the link layer, and when the single response message meets the preset screening rules, treat the single response message as a response message that meets the preset screening rules.
[0027] In another possible implementation, the processing module is further used to: capture all response messages from the link layer, and filter out response messages that meet preset filtering rules from all response messages.
[0028] In another possible implementation, the preset screening rules include source port rules and message feature rules, wherein the source port rule is used to describe the source port of the response message sent by the server, and the message feature rule is used to describe the message content of the response message sent by the server.
[0029] In another possible implementation, the acquisition module is further configured to stop acquiring the response message when the target response message is obtained.
[0030] In another possible implementation, the processing module is further used to: parse the transport layer and / or application layer of the response message that meets the preset screening rules to obtain the transmission path and / or message data content corresponding to the response message that meets the preset screening rules. Based on the transmission path and / or message data content, filter and obtain the target response message containing the target service information.
[0031] In another possible implementation, the acquisition module is further used to: send a service discovery message to at least one server, where the service discovery message refers to a target service request sent by a client to a server.
[0032] In another possible implementation, the acquisition module is further used to send a service discovery message to at least one server via UDP.
[0033] In another possible implementation, the target service information includes a port and an address of the target service.
[0034] The technical effects corresponding to any one of the implementation methods in the second aspect can refer to the technical effects corresponding to any one of the implementation methods in the above-mentioned first aspect, and will not be repeated here.
[0035] In a third aspect, a computer device is provided, the computer device comprising: a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement the service discovery method in the above aspect.
[0036] In a fourth aspect, a computer-readable storage medium is provided, in which at least one computer program is stored, and the at least one computer program is loaded and executed by a processor to implement the service discovery method of the above aspect.
[0037] In a fifth aspect, a computer program product is provided. The computer program product includes a computer program or instructions. When the computer program or instructions are executed by a processor, the service discovery method of the above aspect is implemented.
[0038] The solutions provided in the third to fifth aspects are used to implement the method provided in the first aspect, and their specific implementations are not described one by one. The technical effects corresponding to any one of the implementations of the solutions provided in the third to fifth aspects can be referred to the technical effects corresponding to any one of the implementations in the first aspect, and are not described here.
[0039] It should be noted that various possible implementation methods of any of the above aspects can be combined under the premise that the solutions are not contradictory. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1A schematic diagram of an architecture of a service discovery method provided for an exemplary embodiment;
[0041] Figure 2 A schematic diagram of the architecture of a computer system provided for an exemplary embodiment;
[0042] Figure 3 A flowchart of a service discovery method provided for an exemplary embodiment;
[0043] Figure 4 A flowchart of another service discovery method provided for an exemplary embodiment;
[0044] Figure 5 A flowchart of another service discovery method provided for an exemplary embodiment;
[0045] Figure 6 A flowchart of another service discovery method provided for an exemplary embodiment;
[0046] Figure 7 A schematic diagram of the structure of a service discovery device provided for an exemplary embodiment;
[0047] Figure 8 A schematic diagram of the structure of a computer device is provided for an exemplary embodiment. DETAILED DESCRIPTION
[0048] In the embodiments of the present application, in order to clearly describe the technical solutions of the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially identical functions and effects. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different. There is no order of precedence or size between the technical features described by the "first" and "second".
[0049] In the embodiments of the present application, words such as "exemplarily" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplarily" or "for example" is intended to present related concepts in a concrete way for easy understanding.
[0050] In the embodiments of the present application, at least one can also be described as one or more, and multiple can be two, three, four or more, which is not limited in the present application.
[0051] In addition, the network architecture and scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art can appreciate that with the evolution of the network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0052] To facilitate understanding, the terms involved in the embodiments of the present application are first explained.
[0053] Service: refers to work performed for the benefit of a group (or individual) or for a cause, usually involving providing some form of help, support or satisfying needs. In the computer field, it specifically includes application services and computer technology services. For example, applications include client / server applications, database servers and other server-based applications. Computer technology services include software development and customization, hardware maintenance and support, data management and analysis, security services and network services, etc., which provide support and services for computer hardware, software, networks, etc.
[0054] Service discovery: refers to the process in which applications and services can automatically identify, obtain and access the location and status information of other services in a network environment. This process enables services to dynamically join or leave the network, and other services can perceive these changes, thereby achieving effective communication and collaboration between services. Specifically, when a new service instance is started, it will register its network address and other necessary information (such as service name, port, protocol, etc.) with the service registry. The service registry is responsible for storing and maintaining this information so that other services can obtain the network address of the service by querying the service registry when they need to communicate with the service. When a service needs to call another service, it will request the network address of the called service from the service registry, and communicate with the called service based on the network address returned by the service registry. The service discovery process usually queries and obtains the network address of the service through Domain Name System (DNS) or HyperText Transfer Protocol (HTTP) requests.
[0055] UDP: It is a protocol of the transport layer, which provides a connectionless service. UDP allows applications to send encapsulated Internet Protocol (IP) datagrams without establishing a connection. Each datagram is independent and does not guarantee order or reliability. User Datagram Protocol Socket (UDP Socket) is used to transmit data between the client and the server. When using UDP Socket to send data, the data is encapsulated into independent datagrams and sent to the target address through the network. After receiving the datagram, the receiver unpacks it and passes it to the corresponding application. Since DNS query requests and responses are usually small, UDP is usually used to meet its high real-time requirements when using DNS to implement the service discovery process.
[0056] Network security system: refers to a series of technologies and measures designed and deployed to protect computer networks from attacks and ensure the security of online information. It can protect the reliability and stability of network systems, as well as the confidentiality, integrity, availability, authenticity and controllability of information on the network. Network security systems usually include firewalls, intrusion detection systems (IDS), intrusion prevention systems (IPS), etc. Firewalls are set between internal trusted networks and external untrusted networks. They control the flow of information into trusted networks by implementing a wide range of security policies to prevent potential intrusion damage. IDS collects and analyzes key point information in computer networks or systems to find out whether there are any violations of security policies and signs of attacks in the network or system. As an active and intelligent intrusion detection, prevention and blocking system, IPS can not only detect the occurrence of intrusions, but also terminate the occurrence and development of intrusions in real time through certain response methods, and protect information systems from substantial attacks in real time.
[0057] It should be noted that the information (including but not limited to device information, subject personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application are all authorized by the subject or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards. For example, the service discovery message, service response message and target service information involved in this application are all obtained with full authorization.
[0058] The common service discovery methods in the industry are mainly implemented based on the transmission of messages such as messages and requests. The following is a brief description of several service discovery methods.
[0059] Method 1: If Figure 1In the client and server shown in , when the client needs to call a service and the server can support the service, the client directly sends a service discovery message to the server to request the network address of the service, and communicates with the called service based on the response message returned by the server.
[0060] Method 2: When performing service discovery between neighbor awareness networking (NAN) devices based on wireless broadband (Wi-Fi) technology, the second NAN device receives the first service discovery message for service discovery sent by the first NAN device, and the second NAN device, as a service transfer device for transferring the service discovery initiated by the first NAN device, generates and sends a second service discovery message for service discovery according to the first service discovery message. When the third NAN device receives the second service discovery message and determines that the service subscribed or published by the first NAN device for service discovery matches the service demand of the third NAN device, the third NAN device sends a service matching response message to the second NAN device to complete the service discovery process. The above process completes the search and matching of services through service discovery messages and service matching response messages.
[0061] Method 3: The first writer application parses the first service discovery message sent by the first reader application to obtain the target data topic subscribed by the first reader application. If the first writer application determines that it is the data provider of the target data topic through querying the service discovery gateway module, the first reader application is recorded as the data subscriber of the target data topic in the service discovery gateway module, and the first writer application sends the first service discovery response message to the first reader application. The above-mentioned first writer application identifies the service through the service discovery message, and then responds to the first reader application through the service discovery response message, completing the service discovery process of the data subscription service.
[0062] However, in method 1, when the client is a router or other device with a network security system (firewall) on the WAN side, the response message sent by the server to the client is blocked by the network security system on the WAN side, and the client cannot communicate with the called service based on the response message, and cannot complete the service discovery process. The service discovery process of methods 2 and 3 is based on the premise that the service matching response message and service discovery response message can be transmitted smoothly, and does not take into account the situation that the received messages and messages are blocked when the network security system is set up on the NAN device or the first reader application, and the required service cannot be discovered smoothly.
[0063] Based on this, the present application provides a service discovery method, which uses an additional data processing unit to parse the response message sent by the server, so that the response message can bypass the client's network security system to reach the data processing unit, and then enable the client to directly identify, access and connect to the target service provided by the server according to the message parsing result of the data processing unit, thereby providing the client with a new message transmission path to ensure the smooth progress of the service discovery process.
[0064] The solution provided by the embodiments of the present application is described in detail below in conjunction with the accompanying drawings.
[0065] The solution provided in this application can be applied to Figure 2 In the computer system shown, Figure 2 An architectural diagram of a computer system is shown.
[0066] For example, Figure 2 The computer system shown includes a client 200 and a server 210. The client 200 is a program or device that provides local services to users, usually installed on the user's computer, mobile device or other terminal device, and is used to communicate and exchange data with the server to achieve specific functions or services. The server 210 is a computer program or device that provides certain services or resources, usually running on dedicated servers, which can be physical servers or virtual servers. The server 210 is used to receive service discovery messages from the client 200, and send response messages to the client 200 based on the service discovery messages, so as to provide target services for the client 200.
[0067] Optionally, the client 200 can provide communication coverage for a specific geographical area and send a service discovery message to the server 210 to request a target service. Optionally, the client 200 can be a Long Term Evolution (LTE) system, an Evolutional Node B (eNB or eNodeB) in the LTE system, or a wireless controller in a Cloud Radio Access Network (CRAN), or a mobile switching center, a relay station, an access point, a vehicle-mounted device, a wearable device, a hub, a switch, a bridge, a router, etc. Optionally, the client 200 is a device that needs to request a service and is equipped with a network security system or the like that may block external messages.
[0068] Optionally, the server 210 is used to receive a service discovery message from the client 200, and send a response message to the client 200 based on the service discovery message, so as to provide the target service for the client 200. Optionally, the client 200 can be a server, a network device, or a storage device that can provide services. Among them, the above-mentioned server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud computing services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and cloud servers for basic cloud computing services such as big data. The embodiments of the present application are not limited to this. Figure 2 One client 200 and six servers 210 are shown by way of example, and the present application does not limit the number of clients 200 and servers 210 .
[0069] Figure 3 A flow chart of a service discovery method provided by an exemplary embodiment. The method can be executed by a client. The client can be Figure 2 The client 200 may also be other devices that require service discovery.
[0070] like Figure 3 As shown, the service discovery method provided in the embodiment of the present application may include:
[0071] S301: The client obtains at least one response message sent by the server.
[0072] The response message refers to the reply information sent by the server.
[0073] Exemplarily, the response message includes a status line, a response header, a blank line, and a response body.
[0074] The status line is used to provide summary information about the response message, including the protocol version, status code, and status message. For example, the status line "HTTP / 1.1200OK" means that the response message uses the HTTP / 1.1 protocol, the status code is 200, and OK means the request is successful.
[0075] The response header refers to the additional information that the server passes to the client, which is used to describe the content, format, caching strategy, etc. of the response message. For example, the response header includes the type of the response body (Content-Type), the length of the response body (Content-Length), the server information (Server), the response expiration time (Expires), and the entity tag (ETag) of the response body used for caching and conditional requests.
[0076] Response body: The response body is the data actually transmitted from the server to the client, such as text data, HTML pages, pictures, videos, etc. It may also be empty.
[0077] Empty lines are blank lines located between the response header and the response body, used to separate the response header and the response body.
[0078] Exemplarily, at least one means that the client obtains at least one response message sent by the same server, or at least one response message sent by different servers. For example, the client obtains 3 response messages sent by server a and 2 response messages sent by server b.
[0079] Exemplarily, the client refers to a client of a network security system configured to block response messages, such as a router, a switch, and other devices.
[0080] S302: The client parses the response message in the data processing unit to obtain a target response message.
[0081] The data processing unit is used to parse the response message sent by the server.
[0082] Exemplarily, the data processing unit is a hardware or software component capable of processing data, such as a central processing unit (CPU), a network processor (NP), and a dedicated data processing unit.
[0083] Optionally, the data processing unit is a processing unit in the client, or the data processing unit is a processing unit independent of the client and capable of communicating with the client.
[0084] Exemplarily, when the data processing unit is a processing unit independent of the client and capable of communicating with the client, information sent by the data processing unit to the client will not be intercepted by the client's network security system. For example, the client's firewall rules allow information sent by the data processing unit to pass.
[0085] Message parsing is used to filter response messages and obtain the target response message.
[0086] The target response message refers to the reply information sent by the server to the client based on the client's request.
[0087] Exemplarily, message parsing generally includes steps such as capturing messages, analyzing message structures, extracting key information, checking and verifying.
[0088] Capturing messages refers to capturing messages in a network communication process by using a network analysis tool, for example, capturing messages by using a network analyzer (Wireshark).
[0089] Analyzing the message structure means parsing the message according to the different structures of different types of messages and the specific communication protocols. For example, the HTTP request message includes the request line (requested resources, HTTP version, etc.), the request header and the optional request body; the HTTP response message includes the status line (HTTP version, status code, status message, etc.), the response header and the response body (document, image, etc.). The communication protocol of the HTTP message is an application layer protocol based on the Transmission Control Protocol / Internet Protocol (TCP / IP) protocol stack.
[0090] Extracting key information refers to extracting information such as the source address, destination address, port number, sequence number, confirmation number, etc. in the response message during the process of parsing the message.
[0091] Checksum verification refers to the checksum of the message header and the checksum of the message data part. If the checksum fails, it indicates that the message may have an error or damage during transmission. For example: set the checksum field of the IP message to zero, then group the remaining part of the message header into groups of 16 bits (i.e., two bytes) and sum these groups; add the high 16 bits and the low 16 bits of the sum. If the high 16 bits of the result are not zero, continue to add until the high 16 bits are zero; finally, negate the sum (i.e., calculate the complement of 1), and the final result is the checksum. When receiving an IP message, first extract its message header part, and in the same way as the above calculation of the checksum, group and sum the fields of the message header and negate them (i.e., calculate the complement of 1). If the result is all 1 (represented as -0 in binary), the checksum is successful, indicating that there is no error or tampering in the message header during transmission. If the result is not all 1, the checksum fails, indicating that there may be a problem with the message header.
[0092] Exemplarily, the target response message includes target service information, and the client can connect to a server that can provide the target service according to the target service information.
[0093] The target service refers to the service requested by the client, and the target service information refers to the service information corresponding to the request of the client.
[0094] Optionally, the target service information includes identification information, location information, metadata, status information, etc. of the target service.
[0095] Identification information is used to locate and identify services, such as service name and service identifier (ID).
[0096] The location information is used to enable the client to establish a connection with the target service, for example, the IP address and port number of the target service.
[0097] Metadata is used to describe the target service, such as the version number and function description of the target service.
[0098] Status information is used to describe the status or performance of a service, such as the status code and response time of the target service.
[0099] Exemplarily, the target service information in the target response message is obtained through the above message parsing process, so that the client can identify the target service.
[0100] S303: The client establishes a connection with the server based on the target service information in the target response message.
[0101] Exemplarily, the client initiates a connection request to the server through TCP / IP or other communication protocols based on the target service information, such as the port number of the target service. After the server accepts the connection, the client successfully establishes a connection with the server through the port number. The server can communicate with the target service through the port number and utilize the target service.
[0102] To summarize, by using an additional data processing unit, the response message sent by the server is parsed, so that the response message can bypass the client's network security system and reach the data processing unit, and then the client can directly identify, access and connect to the target service provided by the server according to the message parsing result of the data processing unit, providing the client with a new message transmission path to ensure the smooth progress of the service discovery process.
[0103] Figure 4 A flowchart of another service discovery method provided for an exemplary embodiment. The method can be executed by a client. The method includes:
[0104] S401: The client obtains at least one response message sent by the server.
[0105] In some embodiments, the client sends a service discovery message to at least one server, and receives a response message sent by the server based on the service discovery message.
[0106] The service discovery message refers to a target service request sent by the client to the server. Optionally, the service discovery message includes a service identifier (service name, service ID, etc.), service version, service type, authentication information, and client identification information of the target service requested by the client.
[0107] Exemplarily, the manner in which the client sends a service discovery message to at least one server includes at least one of the following manners, but is not limited thereto, and the embodiments of the present application do not specifically limit this:
[0108] Method 1: The client broadcasts a service discovery message.
[0109] Exemplarily, after the server receives the service discovery message broadcast by the client, the server that can provide the target service sends a response message to the client.
[0110] Method 2: The client sends a service discovery message to the server in the specified area.
[0111] Exemplarily, the client sends a service discovery message to a server within a distance threshold range, and receives a response message sent by the server to the client based on the service discovery message. Alternatively, the client sends a service discovery message to a server within a certain area range, and receives a response message sent by the server to the client based on the service discovery message. For example: the client sends a service discovery message to a server in its local area network.
[0112] Among them, a certain area range is a default value, or an artificially preset value, but is not limited to this, and the embodiments of the present application do not make specific limitations on this.
[0113] Exemplarily, the client creates a UDP Socket, and sends a service discovery message to the server through the UDP Socket.
[0114] For other descriptions of this step, please refer to step S301, which will not be described in detail here.
[0115] S402: The client screens the response message based on the preset screening rule to obtain the response message that meets the preset screening rule.
[0116] Among them, the preset screening rules include source port rules and message feature rules. The source port rule is used to describe the source port of the response message sent by the server, and the message feature rule is used to describe the message content of the response message sent by the server.
[0117] The source port is used to identify the server that sends the response message, so that the client can determine the source of the response message based on the source port. Exemplarily, the source port rule describes the length of the source port field, the message content, etc. For example: in a UDP message, the source port field occupies the first 16 bits of the UDP message header, and the source port rule is: the length of the source port field is the first 16 bits of the message header.
[0118] Exemplarily, based on the source port rule, a network protocol analyzer (Wireshark) or other tools are used to filter the response packets. For example, in the filter window of Wireshark, a filter command is entered: udp.srcport==1234, and UDP data packets with a source port of 1234 are filtered out.
[0119] Optionally, the message features include message type, message header information, etc., and response messages of specific type messages and specific message header information are filtered based on message feature rules.
[0120] Among them, the message types include IP messages, TCP messages, UDP messages, etc. The message header information includes the source address, destination address, protocol type, etc.
[0121] Exemplarily, the response message is filtered based on the message feature rules. For example: use the "ip.src == 192.168.1.1" or "ip.dst == 192.168.1.1" condition to filter out the message whose source IP address and destination IP address are 192.168.1.1. Another example: the message header of the response message contains a 2-byte field of magic number (Magic), which is used to identify the protocol or protocol version number. By judging this field in the message header, the protocol type corresponding to the field can be filtered out.
[0122] In some embodiments, the method of filtering the response message based on the preset filtering rule includes at least one of the following methods, but is not limited thereto, and the embodiments of the present application do not specifically limit this:
[0123] Method 1: The client captures a single response message from the link layer, and when the single response message meets the preset filtering rule, the single response message is regarded as a response message that meets the preset filtering rule.
[0124] Exemplarily, the response message is captured from the link layer according to the bypass mechanism of the link layer.
[0125] For example: configure the network interface in the link layer, use the network packet capture library (Packet Capture Library, Libpcap) and other capture tools to capture the response message. When a response message arrives at the client's network card, Libpcap obtains the bypass mechanism of the data packet of the response message from the link layer driver to capture it, and sends the response message to the Berkeley Packet Filter (BPF). The BPF filter filters the response message according to the preset filtering rules to obtain the response message that meets the preset filtering rules.
[0126] Exemplarily, the client captures the response message from the link layer, or the client captures the response message from a network structure such as the IP layer that transmits the response message.
[0127] Method 2: The client captures all response messages from the link layer, and filters out response messages that meet preset filtering rules from all response messages.
[0128] Exemplarily, Libpcap sends all captured messages to a data processing unit, or to other units with a screening function, and screens out response messages that meet preset screening rules from all response messages.
[0129] S403: The client parses the response message that meets the preset screening rule to obtain the target response message.
[0130] Exemplarily, the client parses the transport layer and / or application layer of the response message that meets the preset filtering rules, obtains the transmission path and / or message data content corresponding to the response message that meets the preset filtering rules, and based on the transmission path and / or message data content, filters to obtain the target response message containing the target service information.
[0131] Among them, the transport layer is located at the fourth layer of the Open Systems Interconnection Reference Model (OSI), which is used to provide reliable, end-to-end communication services between the source and the destination, transmit data from the application layer of the source to the application layer of the destination, and ensure the integrity, sequence and reliability of the data.
[0132] Optionally, the transport layer includes TCP protocol and UDP protocol, etc.
[0133] Exemplarily, the client parses the transport layer of the response message that meets the preset screening rules, specifically parses the message data content and / or transmission path in the response message, and determines the response message containing the target service information as the target response message. For example: the message data content in the response message includes the service identifier, service address and protocol information of the service provided by the server, and the data processing module parses the message content. When it is determined that the service identifier is consistent with the service identifier of the target service requested by the client, the response message containing the service identifier is determined as the target response message.
[0134] The application layer is at the highest level of the OSI model and is used to handle communication and data exchange between application programs.
[0135] Exemplarily, the client parses the application layer of the response message that meets the preset screening rules, specifically parses the message protocol and message data content in the response message, and determines the response message containing the target service information as the target response message.
[0136] In some embodiments, the client first determines the target response message and then parses the target service information from the target response message, or the client parses the target service information while parsing the transport layer and / or application layer of the response message that meets the preset filtering rules.
[0137] In some embodiments, when none of the response messages that meet the preset screening rules are target response messages, the client re-acquires the response messages.
[0138] Among them, re-obtaining the response message refers to the client re-obtaining at least one response message sent by the server; or, it refers to the client re-filtering the response message based on preset filtering rules to obtain the response message that meets the preset filtering rules.
[0139] In some embodiments, when the target response message is obtained, the acquisition of the response message is stopped. For example, the client stops grabbing the response message from the link layer.
[0140] S404: The client establishes a connection with the server based on the target service information in the target response message.
[0141] Exemplarily, the target service information includes the port and address of the target service. The client establishes a connection with the server based on the port and address of the target service. For example, the client constructs a connection request using a programming language and sends the connection request to the server. The connection request includes the port and address of the target service. After receiving the connection request, the server establishes a TCP connection with the client.
[0142] Among them, the TCP connection is established through a three-way handshake. The specific process is as follows:
[0143] First handshake: The client sends a synchronization sequence number message (SYN) to the server and enters the synchronization sequence sending state (SYN_SEND) state, waiting for the server to confirm.
[0144] Second handshake: After receiving the SYN message, the server will send a synchronization sequence number + confirmation message (SYN+ACK) as a response and enter the synchronous reception state (SYN_RECV) state.
[0145] Third handshake: After the client receives the SYN+ACK message from the server, it will send an ACK message as a response and enter the ESTABLISHED state. At this point, the TCP connection has been successfully established and the client and server can start transmitting data.
[0146] In summary, through the additional data processing unit, the response message sent by the server is parsed, so that the response message bypasses the client's network security system to reach the data processing unit, and then the client can directly identify, access and connect to the target service according to the message parsing result of the data processing unit, providing a new message transmission path for the client to ensure the smooth progress of the service discovery process. In addition, the client first filters the response message based on the preset screening rules to narrow the screening range, and then parses the response message that meets the preset screening rules, and obtains the target response message from the response message that meets the preset screening rules. The recognition accuracy of the target response message is improved through two screenings, thereby improving the accuracy of the target service provided by the server to the client.
[0147] Figure 5 A flowchart of another service discovery method provided for an exemplary embodiment.
[0148] The method includes:
[0149] S501: The client sends a service discovery message.
[0150] Among them, the service discovery message refers to the target service request sent by the client to the server.
[0151] Optionally, the service discovery message includes a service identifier (service name, service ID, etc.), service version, service type, authentication information, and identification information of the client, etc. of the target service requested by the client.
[0152] Exemplarily, the client sends a service discovery message through a UDP Socket, and the service discovery message passes through the outgoing message processing point LOCAL_OUT in the client TCP / IP protocol, the message sending queue processing, and the WAN side network card in sequence, and is sent to the server.
[0153] S502: The client receives a response message sent by the server.
[0154] The response message refers to the reply information sent by the server.
[0155] Exemplarily, the response message includes a status line, a response header, a blank line, and a response body.
[0156] For example, the response message sent by the server reaches the WAN side network card on the client side. When the response message is transmitted along the path of the WAN side network card, the message receiving queue processing, and the receiving message processing point LOCAL_IN, it will be intercepted by the firewall in the TCP / IP protocol stack.
[0157] S503: The client captures the response message that meets the preset screening rules and performs message parsing to obtain the target response message.
[0158] Among them, the preset screening rules include source port rules and message feature rules. The source port rule is used to describe the source port of the response message sent by the server, and the message feature rule is used to describe the message content of the response message sent by the server.
[0159] Message parsing is used to filter response messages and obtain the target response message.
[0160] Exemplarily, message parsing generally includes steps such as capturing messages, analyzing message structures, extracting key information, checking and verifying.
[0161] The target response message refers to the reply information sent by the server to the client based on the client's request. For example, the target response message includes target service information, and the client can connect to the server that can provide the target service according to the target service information.
[0162] Exemplarily, the client captures the response message sent by the server from the WAN side network card, sends it to the message receiving queue for processing, and parses the response message through the data processing unit to obtain the target response message.
[0163] The data processing unit is a hardware or software component that can process data, such as a central processing unit (CPU), a network processor (NP), and a dedicated data processing unit.
[0164] To summarize, the client sends a service discovery message, so that the response message returned by the server based on the service discovery message is more in line with the target service requested by the client, and then the response message is parsed through an additional data processing unit, so that the response message bypasses the client's network security system to reach the data processing unit, and then the client can directly identify, access and connect to the target service according to the message parsing result of the data processing unit, providing a new message transmission path for the client to ensure the smooth progress of the service discovery process.
[0165] Figure 6 A flowchart of another service discovery method provided for an exemplary embodiment.
[0166] S601: The client starts capturing messages and sets preset filtering rules.
[0167] Among them, the preset screening rules include source port rules and message feature rules. The source port rule is used to describe the source port of the response message sent by the server, and the message feature rule is used to describe the message content of the response message sent by the server.
[0168] Exemplarily, the client captures the response message from the link layer. For example, a network interface is configured in the link layer, and the response message capture is enabled using the Libpcap tool.
[0169] S602: The client creates a UDP Socket and broadcasts a service discovery message.
[0170] Among them, the service discovery message refers to the target service request sent by the client to the server.
[0171] Optionally, the service discovery message includes a service identifier (service name, service ID, etc.), service version, service type, authentication information, and identification information of the client, etc. of the target service requested by the client.
[0172] Exemplarily, the client broadcasts a service discovery message to servers within a certain area.
[0173] Among them, a certain area range is a default value, or an artificially preset value, but is not limited to this, and the embodiments of the present application do not make specific limitations on this.
[0174] S603: After receiving the service broadcast message, the server sends a response message to the client.
[0175] The response message refers to the reply information sent by the server.
[0176] Exemplarily, after the server receives the service discovery message broadcast by the client, the server that can provide the target service sends a response message to the client.
[0177] S604: The client captures the response message that meets the preset screening rules.
[0178] S605: The client parses the response message that meets the preset screening rule. If the parsing is successful, execute step S606; if the parsing fails, execute step S604.
[0179] Among them, message parsing is used to filter the response message and then obtain the target response message.
[0180] Successful parsing means that the client determines the target response message from the response messages that meet the preset filtering rules. Failed parsing means that the target response message does not exist in the response messages that meet the preset filtering rules, so it is necessary to re-capture the response messages that meet the preset filtering rules.
[0181] The target response message refers to the reply information sent by the server to the client based on the client's request. For example, the target response message includes target service information, and the client can connect to the server that can provide the target service according to the target service information.
[0182] S606: The client extracts the address and port of the target service.
[0183] Exemplarily, the client extracts target service information in the target response message, where the target service information includes the address and port of the target service, so that the client can identify, access and connect to the target service according to the address and port of the target service.
[0184] S607: The client closes message capture.
[0185] Exemplarily, after obtaining the target response message, or after the client is connected to the server where the target service is located, the client closes the capture of the response message.
[0186] In summary, the client directly captures the response message sent by the server, and then parses the captured response message, so that the response message bypasses the client's network security system to reach the data processing unit, and then the client can directly identify, access and connect to the target service according to the message parsing result of the data processing unit, providing a new message transmission path for the client to ensure the smooth progress of the service discovery process. In addition, after obtaining the target response message or the client successfully connects to the server, the client closes the capture, reducing energy consumption while preventing other subsequent messages from bypassing the network security system and entering the client.
[0187] like Figure 7 The service discovery device shown in FIG. 1 may include an acquisition module 700, a processing module 701, and a connection module 702. The acquisition module 700 is used to execute Figure 3 The operation of step S301 in the illustrated method is also used to perform Figure 4 In the operation of step S401 of the illustrated method, the processing module 701 is used to perform Figure 3 The operation of step S302 in the illustrated method is also used to perform Figure 4 In the steps S402 and S403 of the illustrated method, the connection module 702 is used to execute Figure 3 The operation of step S303 in the illustrated method is also used to perform Figure 4 The step S404 in the illustrated method.
[0188] In some embodiments, in order to implement the above functions, the service discovery device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0189] The embodiment of the present application can divide the functional modules of the service discovery device according to the above method embodiment. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. There may be other division methods in actual implementation.
[0190] like Figure 8 As shown, the computer device provided in the embodiment of the present application may include a processor 801, a bus 802, a communication interface 803, and a memory 804. The processor 801, the memory 804, and the communication interface 803 communicate with each other through the bus 802. It should be understood that the present application does not limit the number of processors and memories in the network device.
[0191] The bus 802 may be a PCI bus or an extended industry standard architecture (EISA) bus, or a USB bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 The bus 802 is represented by only one line, but it does not mean that there is only one bus or one type of bus. The bus 802 may include a path for transmitting information between various components of the computer device (for example, the memory 804, the processor 801, and the communication interface 803).
[0192] The processor 801 may include any one or more processors such as a CPU, a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0193] The memory 804 may include a volatile memory, such as a random access memory (RAM). The processor 801 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0194] The communication interface 803 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the network device and other devices or a communication network.
[0195] The memory 804 stores executable program codes, and the processor 801 executes the executable program codes to respectively implement the functions of the aforementioned method embodiments. That is, the memory 804 stores instructions for executing the aforementioned service discovery method.
[0196] On the other hand, a computer-readable storage medium is provided, in which at least one computer program is stored. The at least one computer program is loaded and executed by a processor to implement the service discovery method provided by the above-mentioned method embodiments.
[0197] On the other hand, a computer program product is provided. The computer program product includes a computer program or instructions. When the computer program or instructions are executed by a processor, the service discovery method as described above is implemented.
[0198] Through the description of the above implementation methods, technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the module is divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, module and unit described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0199] Since the service discovery module, computer-readable storage medium, and computer program product in the embodiments of the present invention can be applied to the above method, the technical effects that can be obtained can also refer to the above method embodiments, and the embodiments of the present invention will not be repeated here.
[0200] The method steps in this embodiment can be implemented by hardware or by a processor executing software instructions. The software instructions can be composed of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, mobile hard disks, CD-ROMs or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a network device. Of course, the processor and the storage medium can also exist in a network device as discrete components.
[0201] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer programs or instructions. When a computer program or instruction is loaded and executed on a computer, the process or function of the embodiment of the present application is executed in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device or other programmable module. The computer program or instruction can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer program or instruction can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired or wireless means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that integrates one or more available media. The available medium can be a magnetic medium, for example, a floppy disk, a hard disk, a tape; it can also be an optical medium, for example, a digital video disc (digital video disc, DVD); it can also be a semiconductor medium, for example, a solid state drive (solid statedrive, SSD). The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A service discovery method, characterized in that: The method is applied to a client, the client includes a data processing unit of an external device, and the data processing unit is used to perform message parsing on a response message sent by a server; the method includes: Obtaining at least one response message sent by the server; Parsing the response message in the data processing unit to obtain a target response message, wherein the target response message refers to reply information sent by the server to the client based on the request of the client; A connection is established with the server based on the target service information in the target response message, wherein the target service information refers to the service information corresponding to the request of the client.
2. The method according to claim 1, characterized in that The parsing the response message in the data processing unit to obtain a target response message includes: Filter the response messages based on preset filtering rules to obtain response messages that meet the preset filtering rules; The response message that meets the preset screening rule is parsed to obtain the target response message.
3. The method according to claim 2, characterized in that The step of screening the response message based on the preset screening rule to obtain the response message that meets the preset screening rule includes: Capture a single response message from the link layer, and when the single response message meets the preset screening rule, treat the single response message as a response message that meets the preset screening rule; Or, all response messages are captured from the link layer, and response messages that meet the preset screening rules are screened out from all the response messages.
4. The method according to claim 2, characterized in that: The preset screening rules include source port rules and message feature rules; The source port rule is used to describe the source port of the response message sent by the server, and the message feature rule is used to describe the message content of the response message sent by the server.
5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: When the target response message is obtained, stop obtaining the response message.
6. The method according to any one of claims 2 to 4, characterized in that: The performing message parsing on the response message that meets the preset screening rule to obtain the target response message includes: Parsing the transport layer and / or application layer of the response message that meets the preset screening rule to obtain the transmission path and / or message data content corresponding to the response message that meets the preset screening rule; Based on the transmission path and / or the message data content, a target response message containing target service information is screened and obtained.
7. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: A service discovery message is sent to at least one of the servers, where the service discovery message refers to a target service request sent by the client to the server.
8. The method according to claim 7, characterized in that The sending of a service discovery message to at least one of the servers includes: The service discovery message is sent to at least one of the servers via the datagram protocol UDP.
9. The method according to any one of claims 1 to 4, characterized in that: The target service information includes the port and address of the target service.
10. A service discovery device, characterized in that: The device includes: An acquisition module, used to acquire at least one response message sent by the server; A processing module, used for parsing the response message in a data processing unit to obtain a target response message, wherein the target response message refers to reply information sent by the server to the client based on the request of the client; A connection module is used to establish a connection with the server based on the target service information in the target response message, where the target service information refers to the service information corresponding to the request of the client.
11. A computer device, characterized in that: The computer comprises: a processor and a memory, wherein at least one computer program is stored in the memory, and the at least one computer program is loaded and executed by the processor to implement the service discovery method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer program, and the at least one computer program is loaded and executed by the processor to implement the service discovery method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises a computer program or instructions, and when the computer program or instructions are executed by a processor, the service discovery method according to any one of claims 1 to 9 is implemented.
Citation Information
Patent Citations
Wireless access device and data processing method thereof
CN111586199A
Service response methods, devices, equipment and storage media
CN114938395A
Message transmission method and device, equipment and storage medium
CN118785299A
Identifying threats in electronic messages
EP1877905A2