Service discovery methods, apparatus, devices and storage media
By parsing the server response message in the client's data processing unit, the target response message can be obtained by bypassing the network security system. This solves the problem of network security systems blocking response messages in devices such as routers, and enables the smooth progress of the service discovery process.
Patent Information
- Application Number
- CN202411942918.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-10-31
- Estimated Expiration
- 2044-12-26
AI Technical Summary
Clients with network security systems, such as routers, cannot receive response messages from the server, causing the service discovery process to fail.
By using an additional data processing unit to parse the response messages sent by the server, the client's network security system can be bypassed to obtain the target response message.
It provides a new message transmission path for clients, ensuring the smooth progress of the service discovery process and improving the accuracy of response message identification and processing efficiency.
Smart Images

Figure CN119854148B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a service discovery method, apparatus, device, and storage medium. Background Technology
[0002] Service discovery is a method for automatically identifying and accessing devices and services on a network, enabling services in a system to communicate and connect without needing to know the specific location of other services, only their names.
[0003] In related technologies, 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 then uses the response message to perform operations such as communication and access to the target service.
[0004] However, for clients such as routers that have network security systems (firewall rules) in place, 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, so that the client cannot receive response messages and thus cannot complete the service discovery process. Summary of the Invention
[0005] This application provides a service discovery method, apparatus, device, and storage medium, which provides a new message transmission path for the client, enabling the client to reliably receive response messages sent by the server.
[0006] To achieve the above objectives, this application adopts the following technical solution:
[0007] In a first aspect, this application provides a service discovery method, which is applied to a client, the client including a data processing unit of an external device, the method comprising:
[0008] The system acquires at least one response message sent by the server, parses the response message in the data processing unit to obtain the target response message, and establishes a connection 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 messages sent by the server. The target response message refers to the reply information sent by the server to the client based on the client's request.
[0010] The solution provided in this application uses an additional data processing unit to parse the response messages sent by the server, enabling the response messages to bypass the client's network security system and reach the data processing unit. This allows the client to directly identify, access, and connect to the target service provided by the server based on the message parsing results from the data processing unit, providing the client with a new message transmission path and ensuring the smooth progress of the service discovery process.
[0011] One possible implementation involves parsing the response messages in the data processing unit to obtain the target response message. Specifically, this can be achieved by: filtering response messages based on preset filtering rules to obtain response messages that conform to the preset filtering rules; and then parsing the response messages that conform to the preset filtering rules to obtain the target response message. First, response messages are filtered based on preset filtering rules to narrow down the filtering range. Then, response messages that conform to the preset filtering rules are parsed to select the target response message from among the response messages that conform to the preset filtering rules. This two-stage filtering improves the accuracy of identifying the target response message.
[0012] Another possible implementation involves filtering response packets based on preset filtering rules to obtain those that match. Specifically, this can be achieved by capturing individual response packets from the link layer. If a single response packet matches the preset filtering rules, it is treated as a matching response packet. Capturing response packets from the link layer bypasses the client's network security system and yields more complete and detailed response packets compared to capturing them from other network structures. Furthermore, filtering individual response packets based on preset rules reduces computational complexity. Once a matching response packet is found, subsequent operations can be performed directly on that packet, improving processing efficiency.
[0013] Another possible implementation involves filtering response packets based on preset filtering rules to obtain those that meet the rules. Specifically, this can be achieved by: capturing all response packets from the link layer and filtering those that match the preset rules. Simultaneously capturing all response packets and performing unified filtering avoids omissions during the filtering process, thus preventing subsequent redundant filtering and reducing unnecessary consumption of computing resources.
[0014] Another possible implementation involves pre-setting filtering rules including source port rules and message feature rules. The source port rules describe the source port from which the server sends the response message, while the message feature rules describe the message content of the response message. Source port rules can initially filter the source of response messages, eliminating other types of messages and messages that may pose security risks. Message feature rules further filter response messages based on their content, selecting those that match the characteristics of the target response message.
[0015] Another possible implementation involves obtaining at least one response message sent by the server. Specifically, this can be achieved by stopping the acquisition of response messages once the target response message is received. After successfully obtaining the target response message, the service discovery process is initially completed. Stopping the acquisition of response messages at this point reduces client power consumption and prevents unauthorized messages from entering the client.
[0016] Another possible implementation involves parsing response messages that conform to preset filtering rules to obtain target response messages. Specifically, this can be achieved by parsing the transport and / or application layers of response messages that conform to the preset filtering rules to obtain the corresponding transport path and / or message data content. Based on the transport path and / or message data content, target response messages containing target service information are selected. Parsing the transport and application layers of response messages directly yields service information such as message data content and transport path, facilitating the determination of whether a response message is a target response message based on service information, and also directly parsing the target service information within the target response message.
[0017] Another possible implementation, the service discovery method provided in this 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 sending the service discovery message enables the server to 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 involves sending service discovery messages to at least one server. Specifically, this can be achieved by sending service discovery messages to at least one server via the User Datagram Protocol (UDP). The client does not need to establish a connection with the server to send service discovery messages via UDP, thus completing the service discovery process. Furthermore, due to the connectionless nature of UDP messages, the latency for establishing connections and acknowledging data is reduced, resulting in lower latency and higher efficiency in sending service discovery messages.
[0019] Another possible implementation involves including the target service's port and address in the target service information. The client connects to the server using the target service's port and address, ensuring the accuracy of the connection process and avoiding connection failures or data loss due to incorrect ports or addresses, thus improving 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 the 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 one possible implementation, the aforementioned processing module is further configured to: filter response messages based on preset filtering rules to obtain response messages that conform to the preset filtering rules; and parse the response messages that conform to the preset filtering rules to obtain the target response message.
[0026] In another possible implementation, the above processing module is also used to: capture a single response packet from the link layer, and if the single response packet meets the preset filtering rules, treat the single response packet as a response packet that meets the preset filtering rules.
[0027] In another possible implementation, the above processing module is also used to: capture all response packets from the link layer and filter out response packets that meet the preset filtering rules from all response packets.
[0028] Another possible implementation involves pre-setting filtering rules that include source port rules and message characteristic rules. The source port rules describe the source port from which the server sends the response message, while the message characteristic rules describe the message content of the response message sent by the server.
[0029] In another possible implementation, the above-mentioned acquisition module is also used to: stop acquiring response messages when the target response message is obtained.
[0030] In another possible implementation, the aforementioned processing module is further configured to: parse the transport layer and / or application layer of response messages that conform to preset filtering rules to obtain the transmission path and / or message data content corresponding to the response messages that conform to the preset filtering rules; and, based on the transmission path and / or message data content, filter to obtain target response messages containing target service information.
[0031] In another possible implementation, the aforementioned acquisition module is also used to: send a service discovery message to at least one server, where the service discovery message refers to the target service request sent by the client to the server.
[0032] In another possible implementation, the aforementioned acquisition module is also used to: send a service discovery message to at least one server via UDP.
[0033] Another possible implementation is that the target service information includes the port and address of the target service.
[0034] The technical effects of any implementation method in the second aspect can be found in the technical effects of any implementation method in the first aspect mentioned above, and will not be repeated here.
[0035] Thirdly, a computer device is provided, comprising: a processor and a memory, wherein the memory 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 described above.
[0036] Fourthly, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by a processor to implement the service discovery method of the above.
[0037] Fifthly, a computer program product is provided, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the service discovery method described above is implemented.
[0038] The solutions provided in aspects three through five above are used to implement the method provided in aspect one above, and their specific implementations will not be described in detail here. The technical effects corresponding to any implementation method of the solutions provided in aspects three through five above can be found in the technical effects corresponding to any implementation method in aspect one above, and will not be described in detail here.
[0039] It should be noted that any of the possible implementations of any of the above aspects can be combined, provided that the solutions do not contradict each other. Attached Figure Description
[0040] Figure 1An architectural diagram of a service discovery method provided as an exemplary embodiment;
[0041] Figure 2 A schematic diagram of the architecture of a computer system provided as an exemplary embodiment;
[0042] Figure 3 A flowchart illustrating a service discovery method provided as an exemplary embodiment;
[0043] Figure 4 A flowchart illustrating another service discovery method provided as an exemplary embodiment;
[0044] Figure 5 A flowchart illustrating another service discovery method provided as an exemplary embodiment;
[0045] Figure 6 A flowchart illustrating another service discovery method provided as an exemplary embodiment;
[0046] Figure 7 A schematic diagram of a service discovery apparatus provided as an exemplary embodiment;
[0047] Figure 8 A schematic diagram of the structure of a computer device provided for an exemplary embodiment. Detailed Implementation
[0048] In the embodiments of this application, in order to clearly describe the technical solutions of the embodiments of this application, the terms "first" and "second" are used to distinguish identical or similar items with essentially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different. The technical features described by "first" and "second" have no sequential or size order.
[0049] In the embodiments of this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design described as "exemplarily" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner to facilitate understanding.
[0050] In the embodiments of this application, at least one can also be described as one or more, and multiple can be two, three, four or more, and this application does not impose any restrictions.
[0051] Furthermore, the network architecture and scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0052] To facilitate understanding, the terms used in the embodiments of this application will be explained first.
[0053] Service refers to work performed for the benefit of a group (or an individual) or for a cause, typically involving activities that provide some form of assistance, support, or fulfillment of needs. In the computer field, this 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—support and services provided for computer hardware, software, and networks.
[0054] Service discovery refers to the process by which applications and services in a network environment automatically identify, obtain, and access the location and status information of other services. This process enables services to dynamically join or leave the network, while other services are aware of these changes, thereby achieving effective communication and collaboration between services. Specifically, when a new service instance starts, it registers its network address and other necessary information (such as service name, port, protocol, etc.) with a service registry. The service registry is responsible for storing and maintaining this information so that other services can obtain the service's network address by querying the service registry when they need to communicate with that service. When a service needs to call another service, it requests the network address of the called service from the service registry and communicates with the called service based on the network address returned by the service registry. The service discovery process typically uses Domain Name System (DNS) or Hypertext Transfer Protocol (HTTP) requests to query and obtain the service's network address.
[0055] UDP is a transport layer protocol that provides a connectionless service. UDP allows applications to send encapsulated Internet Protocol (IP) datagrams without establishing a connection. Each datagram is independent and its order or reliability is not guaranteed. User Datagram Protocol Sockets (UDP Sockets) are used to transmit data between clients and servers. When sending data using a UDP Socket, the data is encapsulated into individual datagrams and sent over the network to the target address. The receiver, upon receiving the datagram, unpacks it and forwards it to the appropriate application. Because DNS query requests and responses are typically small, UDP is often used to meet the high real-time requirements when implementing service discovery using DNS.
[0056] Network security systems refer to a series of technologies and measures designed and deployed to protect computer networks from attacks and ensure online information security. They 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 typically include firewalls, intrusion detection systems (IDS), and intrusion prevention systems (IPS). Firewalls are positioned between trusted internal networks and untrusted external networks, implementing broad security policies to control the flow of information into trusted networks and prevent potential intrusions and damage. IDS collects and analyzes key information within computer networks or systems to detect violations of security policies and signs of attack. IPS, as a proactive and intelligent intrusion detection, prevention, and blocking system, not only detects intrusions but also terminates their occurrence and development in real time through specific response methods, protecting information systems from substantial attacks.
[0057] It should be noted that all information (including but not limited to device information, personal information of the target, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.) and signals involved in this application have been authorized by the target or fully authorized by all parties, and the collection, use and processing of related data must comply with relevant laws, regulations and standards. For example, the service discovery messages, service response messages and target service information involved in this application were all obtained with full authorization.
[0058] The industry's commonly used service discovery methods are mainly based on the transmission of messages such as packets and requests. The following is a brief explanation of several service discovery methods.
[0059] Method 1: For example Figure 1As shown in the client and server diagram, 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 service discovery occurs between Neighbor Awareness Networking (NAN) devices based on Wi-Fi technology, the second NAN device receives a first service discovery message from the first NAN device. Acting as a service relay device for the service discovery initiated by the first NAN device, the second NAN device generates and sends a second service discovery message based on the first service discovery message. The third NAN device receives the second service discovery message and, if it determines that the services subscribed to or published by the first NAN device match its service requirements, sends a service matching response message to the second NAN device, completing the service discovery process. This process utilizes service discovery messages and service matching response messages to find and match services.
[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 to by the first reader application. If the first writer application determines from the service discovery gateway module that it is the data provider of the target data topic, it records the first reader application as the data subscriber of the target data topic in the service discovery gateway module, and sends a first service discovery response message to the first reader application. In this process, the 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 for 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 WAN-side network security system. The client cannot communicate with the called service based on the response message, and the service discovery process cannot be completed. Methods 2 and 3, on the other hand, rely on the successful transmission of service matching and service discovery response messages. They do not consider the possibility of blocked messages and packets when NAN devices or first-reader applications have network security systems, thus also failing to successfully discover the required service.
[0063] Based on this, this application provides a service discovery method that uses an additional data processing unit to parse the response messages sent by the server, enabling the response messages to bypass the client's network security system and reach the data processing unit. This allows the client to directly identify, access, and connect to the target service provided by the server based on the message parsing results from the data processing unit, providing the client with a new message transmission path and ensuring the smooth progress of the service discovery process.
[0064] The solutions provided by the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0065] The solution provided in this application can be applied to Figure 2 In the computer system shown, such as Figure 2 The diagram shows the architecture of the computer system.
[0066] For example, Figure 2 The illustrated computer system includes a client 200 and a server 210. The client 200 is a program or device that provides local services to a user, typically installed on the user's computer, mobile device, or other terminal device, 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 a certain service or resource, typically running on a dedicated server, which can be a physical server or a virtual server. The server 210 is used to receive service discovery messages from the client 200 and, based on the service discovery messages, send response messages to the client 200, providing the target service to the client 200.
[0067] Optionally, client 200 can provide communication coverage for a specific geographical area by sending a service discovery message to server 210 to request the target service. Optionally, client 200 can be a Long Term Evolution (LTE) system, an Evolutionary Node B (eNB or eNodeB) in an LTE system, a radio controller in a Cloud Radio Access Network (CRAN), or a mobile switching center, relay station, access point, vehicle-mounted equipment, wearable device, hub, switch, bridge, router, etc. Optionally, client 200 can be a device that needs to request the service and is equipped with a network security system or other means that may block external messages.
[0068] Optionally, the server 210 receives service discovery messages from the client 200 and sends response messages to the client 200 based on the service discovery messages, providing the target service to the client 200. Optionally, the client 200 can be a server, network device, or storage device capable of providing services. The aforementioned server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and basic cloud computing services such as big data. This application embodiment does not limit this aspect. Figure 2 An example is shown with one client 200 and six servers 210. This application does not limit the number of clients 200 and servers 210.
[0069] Figure 3 This is a flowchart illustrating a service discovery method provided for an exemplary embodiment. The method can be executed by a client. The client can be... Figure 2 The client 200 can also be used for other devices that require service discovery.
[0070] like Figure 3 As shown, the service discovery method provided in this application embodiment 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] For example, the response message includes a status line, response headers, a blank line, and a response body.
[0074] The status line provides summary information about the response message, including the protocol version, status code, and status message. For example, a status line "HTTP / 1.1 200 OK" indicates that the response message uses the HTTP / 1.1 protocol, has a status code of 200, and OK indicates that the request was successful.
[0075] Response headers are additional information passed from the server to the client, describing the content, format, and caching strategy of the response message. For example, response headers include the response body type (Content-Type), response body length (Content-Length), server information (Server), response expiration time (Expires), and entity tags (ETag) used for caching and conditional requests in the response body.
[0076] Response body: The response body is the data that the server actually transmits to the client, such as text data, HTML pages, images, videos, etc., and may also be empty.
[0077] A blank line is placed between the response header and the response body to separate them.
[0078] For example, "at least one" means that the client obtains at least one response message sent by the same server, or it means that the client obtains at least one response message sent by different servers. For example, the client obtains 3 response messages sent by server a, and also obtains 2 response messages sent by server b.
[0079] For example, a client refers to a client of a network security system configured to block response messages. Examples include devices such as routers and switches.
[0080] S302: The client parses the response message in the data processing unit to obtain the target response message.
[0081] The data processing unit is used to parse the response messages sent by the server.
[0082] For example, the data processing unit is a hardware or software component capable of processing data. Examples include: 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 but capable of communicating with the client.
[0084] For example, when the data processing unit is a processing unit independent of the client but capable of communicating with the client, the information sent by the data processing unit to the client will not be intercepted by the client's network security system. For instance, the client's firewall rules may allow the information sent by the data processing unit to pass through.
[0085] Message parsing is used to filter response messages to obtain the target response message.
[0086] A target response message refers to the reply information sent by the server to the client based on the client's request.
[0087] For example, message parsing typically includes steps such as capturing the message, analyzing the message structure, extracting key information, and verification.
[0088] Among them, packet capture refers to capturing packets during network communication using network analysis tools, such as network analyzers (Wireshark).
[0089] Analyzing message structure refers to parsing messages based on their different structures and specific communication protocols. For example, an HTTP request message includes a request line (requested resource, HTTP version, etc.), request headers, and an optional request body; an HTTP response message includes a status line (HTTP version, status code, status message, etc.), response headers, and a response body (document, image, etc.). The communication protocol for HTTP messages 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 source address, destination address, port number, sequence number, and acknowledgment number from the response message during the message parsing process.
[0091] Checksum verification refers to the verification of the message header and the message data. If the verification fails, it indicates that the message may have been corrupted or tampered with during transmission. For example: Set the checksum field of the IP message to zero. Then, group the remaining part of the header into 16-bit (two-byte) groups and sum these groups. Add the high 16 bits of the sum to the low 16 bits. If the high 16 bits of the result are not zero, continue adding until the high 16 bits are zero. Finally, invert the sum (i.e., calculate the two's complement). The final result is the checksum. When an IP message is received, its header is extracted first. Following the same method as calculating the checksum, the header fields are grouped, summed, and inverted (i.e., calculated the two's complement). If the result is all 1s (represented as -0 in binary), the verification is successful, indicating that the message header has not been corrupted or tampered with during transmission. If the result is not all 1s, the verification fails, indicating that there may be a problem with the message header.
[0092] For example, the target response message contains target service information, and the client can connect to the server that can provide the target service based on the target service information.
[0093] Here, the target service refers to the service requested by the client, and the target service information refers to the service information corresponding to the client's request.
[0094] Optionally, the target service information includes the target service's identification information, location information, metadata, status information, etc.
[0095] Identification information is used to locate and identify services, such as service name and service identifier (ID).
[0096] Location information is used to enable the client to establish a connection with the target service, such as the target service's IP address and port number.
[0097] Metadata is used to describe the target service, such as the version number and feature 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] For example, the target service information in the target response message is obtained through the above message parsing process, enabling the client to 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] For example, the client initiates a connection request to the server via TCP / IP or other communication protocols based on target service information, such as the target service's port number. After the server accepts the connection, the client successfully establishes a connection with the server through the port number, and the server can communicate with the target service through the port number and utilize the target service.
[0102] In summary, by using an additional data processing unit to parse the response messages sent by the server, the response messages can bypass the client's network security system and reach the data processing unit. This allows the client to directly identify, access, and connect to the target services provided by the server based on the message parsing results from the data processing unit. This provides the client with a new message transmission path and ensures the smooth progress of the service discovery process.
[0103] Figure 4 A flowchart illustrating another service discovery method provided for an exemplary embodiment. This method can be executed by a client. The method includes:
[0104] S401: The client receives 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 the target service request sent by the client to the server. Optionally, the service discovery message includes the 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] For example, the client may send a service discovery message to at least one server in at least one of the following ways, but is not limited thereto, and the embodiments of this application do not specifically limit this:
[0108] Method 1: Client broadcasts service discovery messages.
[0109] For example, after receiving a service discovery message broadcast by the client, the server that is capable of providing 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] For example, the client sends a service discovery message to a server within a distance threshold range and receives a response message from the server based on the service discovery message. Alternatively, the client sends a service discovery message to a server within a certain area and receives a response message from the server based on the service discovery message. For instance, the client sends a service discovery message to a server within its local area network.
[0112] The specified range may be a default value or a preset value, but is not limited to this. This application does not impose any specific limitations on this.
[0113] For example, the client creates a UDP socket and sends a service discovery message to the server through the UDP socket.
[0114] For further details on this step, please refer to step S301; it will not be elaborated upon here.
[0115] S402: The client filters response messages based on preset filtering rules to obtain response messages that meet the preset filtering rules.
[0116] The preset filtering rules include source port rules and message feature rules. The source port rules describe the source port from which the server sends the response message, and the message feature rules describe the message content of the response message sent by the server.
[0117] The source port is used to identify the server that sent the response message, allowing the client to determine the source of the response message based on the source port. For example, the source port rule describes the length of the source port field, the message content, etc. For instance, in a UDP message, the source port field occupies the first 16 bits of the UDP header, and the source port rule is: the source port field length is the first 16 bits of the header.
[0118] For example, response packets can be filtered using tools such as a network protocol analyzer (Wireshark) based on source port rules. For instance, in the Wireshark filter window, enter the filter command: udp.srcport==1234, which will filter out UDP packets with source port 1234.
[0119] Optionally, message features include message type, message header information, etc., and response messages of specific types and specific message header information are filtered based on message feature rules.
[0120] The message types include IP messages, TCP messages, UDP messages, etc. The message header information includes the source address, destination address, and protocol type.
[0121] For example, response packets can be filtered based on packet characteristic rules. For instance, using the condition "ip.src==192.168.1.1" or "ip.dst==192.168.1.1" will filter packets with both source and destination IP addresses of 192.168.1.1. Another example: the response packet header contains a 2-byte "Magic" field, which identifies the protocol or protocol version number. By judging this field in the packet header, the corresponding protocol type can be obtained.
[0122] In some embodiments, the method of filtering response messages based on preset filtering rules includes at least one of the following methods, but is not limited thereto, and the embodiments of this application do not specifically limit this:
[0123] Method 1: The client captures a single response packet from the link layer. If the single response packet meets the preset filtering rules, the single response packet is treated as a response packet that meets the preset filtering rules.
[0124] For example, response messages are captured from the link layer based on the link layer's bypass mechanism.
[0125] For example, in the link layer, network interfaces are configured, and network packet capture tools such as the Packet Capture Library (Libpcap) are used to capture response packets. When a response packet arrives at the client's network card, Lippcap obtains the bypass mechanism of the packet from the link layer driver and captures it. At the same time, the response packet is sent to the Berkeley Packet Filter (BPF). The BPF filter filters the response packets according to preset filtering rules and obtains response packets that meet the preset filtering rules.
[0126] For example, the client retrieves the response message from the link layer, or the client retrieves the response message from the network structure that transmits the response message, such as the IP layer.
[0127] Method 2: The client captures all response packets from the link layer and filters out response packets that meet the preset filtering rules.
[0128] For example, Lippcap sends all captured messages to the data processing unit or other units with filtering functions to filter out response messages that meet the preset filtering rules from all response messages.
[0129] S403: The client parses response messages that meet the preset filtering rules to obtain the target response message.
[0130] For example, the client parses the transport layer and / or application layer of response messages that conform to the preset filtering rules to obtain the transport path and / or message data content corresponding to the response messages that conform to the preset filtering rules. Based on the transport path and / or message data content, the client filters out the target response messages that contain the target service information.
[0131] The transport layer, located at the fourth layer of the Open Systems Interconnection Reference Model (OSI), provides reliable, end-to-end communication services between the source and destination, transmitting data from the application layer at the source to the application layer at the destination, and ensuring the integrity, order, and reliability of the data.
[0132] Optionally, the transport layer includes protocols such as TCP and UDP.
[0133] For example, the client parses the transport layer of response messages that conform to preset filtering rules. Specifically, this involves parsing the message data content and / or transmission path in the response message, and identifying the response message containing the target service information as the target response message. For instance, if the message data content in the response message includes the service identifier, service address, and protocol information provided by the server, the data processing module parses the message content and determines that if the service identifier matches the service identifier of the target service requested by the client, then the response message containing that service identifier is identified as the target response message.
[0134] The application layer is located at the highest layer of the OSI model and is used to handle communication and data exchange between applications.
[0135] For example, the client parses the application layer of response messages that meet the preset filtering rules, specifically by parsing the message protocol and message data content in the response message, and determining 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; alternatively, the client parses the target service information while parsing the transport layer and / or application layer of response messages that meet preset filtering rules.
[0137] In some embodiments, if none of the response messages that meet the preset filtering rules are the target response message, the client re-acquires the response message.
[0138] Here, "reacquiring response messages" means that the client reacquires at least one response message sent by the server; or, it means that the client re-filters the response messages based on preset filtering rules to obtain response messages that meet the preset filtering rules.
[0139] In some embodiments, upon receiving the target response message, the acquisition of response messages is stopped. For example, the client stops capturing response messages 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] For example, 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 instance, the client uses a programming language to construct a connection request and sends it 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] A TCP connection is established through a three-way handshake, the specific process of which 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), waiting for the server's confirmation.
[0144] Second handshake: After receiving the SYN packet, the server will send a synchronization sequence number + acknowledgment packet (SYN+ACK) as a response and enter the synchronization receive state (SYN_RECV).
[0145] The third handshake: After receiving the SYN+ACK packet from the server, the client sends an ACK packet in response and enters the ESTABLISHED state. At this point, the TCP connection has been successfully established, and the client and server can begin transmitting data.
[0146] In summary, by using an additional data processing unit to parse the response messages sent by the server, the response messages bypass the client's network security system and reach the data processing unit. This allows the client to directly identify, access, and connect to the target service based on the parsing results from the data processing unit, providing the client with a new message transmission path and ensuring the smooth progress of the service discovery process. Furthermore, the client first filters response messages based on preset filtering rules to narrow down the selection range, and then parses the response messages that match the preset filtering rules to obtain the target response message. This two-stage filtering improves the accuracy of target response message identification, thereby improving the accuracy of the target service provided by the server to the client.
[0147] Figure 5 A flowchart illustrating another service discovery method provided as 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 may include the 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.
[0152] For example, the client sends a service discovery message via a UDP socket. The service discovery message passes through the client's TCP / IP protocol's message processing point LOCAL_OUT, the message sending queue processing, and the WAN-side network card in sequence before being sent to the server.
[0153] S502: The client receives the response message sent by the server.
[0154] The response message refers to the reply information sent by the server.
[0155] For example, the response message includes a status line, response headers, a blank line, and a response body.
[0156] For example, the response message sent by the server arrives at the WAN-side network interface card (NIC) on the client side. As the response message is passed along the path of the WAN-side NIC, message receiving queue processing, and the LOCAL_IN message receiving processing point, it will be intercepted by the firewall in the TCP / IP protocol stack.
[0157] S503: The client captures response messages that match the preset filtering rules, parses the messages, and obtains the target response message.
[0158] The preset filtering rules include source port rules and message feature rules. The source port rules describe the source port from which the server sends the response message, and the message feature rules describe the message content of the response message sent by the server.
[0159] Message parsing is used to filter response messages to obtain the target response message.
[0160] For example, message parsing typically includes steps such as capturing the message, analyzing the message structure, extracting key information, and verification.
[0161] A target response message is a reply message sent by the server to the client based on the client's request. For example, a target response message may contain target service information, allowing the client to connect to a server that can provide the target service.
[0162] For example, the client captures the response message sent by the server from the network card on the WAN side, sends it to the message receiving queue for processing, and then 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 capable of processing data. Examples include: Central Processing Unit (CPU), Network Processor (NP), and dedicated data processing units.
[0164] In summary, the client sends a service discovery message, which makes the response message returned by the server more closely match the target service requested by the client. Then, through an additional data processing unit, the response message is parsed, allowing it to bypass the client's network security system and reach the data processing unit. This enables the client to directly identify, access, and connect to the target service based on the parsing results of the data processing unit, providing the client with a new message transmission path and ensuring the smooth progress of the service discovery process.
[0165] Figure 6 A flowchart illustrating another service discovery method provided as an exemplary embodiment.
[0166] S601: The client enables packet capture and sets preset filtering rules.
[0167] The preset filtering rules include source port rules and message feature rules. The source port rules describe the source port from which the server sends the response message, and the message feature rules describe the message content of the response message sent by the server.
[0168] For example, the client captures response packets from the link layer. For instance, the network interface is configured at the link layer, and response packet 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 may include the 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.
[0172] For example, the client broadcasts a service discovery message to a server within a certain area.
[0173] The specified range may be a default value or a preset value, but is not limited to this. This application does not impose any 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] For example, after receiving a service discovery message broadcast by the client, the server that is capable of providing the target service sends a response message to the client.
[0177] S604: The client captures response messages that match the preset filtering rules.
[0178] S605: The client parses the response messages that meet the preset filtering rules. If the parsing is successful, proceed to step S606; if the parsing fails, proceed to step S604.
[0179] Among them, message parsing is used to filter response messages and then obtain the target response message.
[0180] Successful parsing means the client has identified the target response message from the response messages that match the preset filtering rules. Parsing failure means the target response message is not found among the response messages that match the preset filtering rules, therefore it is necessary to re-capture response messages that match the preset filtering rules.
[0181] A target response message is a reply message sent by the server to the client based on the client's request. For example, a target response message may contain target service information, allowing the client to connect to a server that can provide the target service.
[0182] S606: The client extracts the address and port of the target service.
[0183] For example, the client extracts the target service information from the target response message. The target service information includes the address and port of the target service, enabling the client to identify, access, and connect to the target service based on the address and port of the target service.
[0184] S607: Client disables message capture.
[0185] For example, after receiving the target response message, or after the client connects 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 messages sent by the server and then parses them, allowing the response messages to bypass the client's network security system and reach the data processing unit. This enables the client to directly identify, access, and connect to the target service based on the parsing results from the data processing unit, providing a new message transmission path and ensuring the smooth progress of the service discovery process. Furthermore, after receiving the target response message or successfully connecting with the server, the client stops capturing messages, reducing energy consumption and preventing subsequent messages from bypassing the network security system and entering the client.
[0187] like Figure 7 The schematic diagram shown illustrates the structure of a service discovery device, which may include an acquisition module 700, a processing module 701, and a connection module 702. The acquisition module 700 is used to perform... Figure 3 The operation of step S301 in the illustrated method is also used to perform Figure 4 In the illustrated method, step S401 is executed by the processing module 701. Figure 3 The operation of step S302 in the illustrated method is also used to perform Figure 4 In the illustrated method, steps S402 and S403 are executed by the connection module 702. Figure 3 The operation of step S303 in the illustrated method is also used to perform Figure 4 The illustrated method is step S404.
[0188] In some embodiments, the service discovery apparatus includes hardware structures and / or software modules corresponding to the execution of each function in order to achieve the above-described functions. Those skilled in the art will readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0189] This application embodiment can divide the service discovery device into functional modules according to the above method embodiment. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0190] like Figure 8 As shown, the computer device provided in this application embodiment may include a processor 801, a bus 802, a communication interface 803, and a memory 804. The processor 801, memory 804, and communication interface 803 communicate with each other via the bus 802. It should be understood that this application does not limit the number of processors and memories in the network device.
[0191] The 802 bus can be a PCI bus, an Extended Industry Standard Architecture (EISA) bus, or a UB bus, etc. Buses can be divided into address buses, data buses, control buses, etc. For ease of representation, Figure 8 The bus 802 may be represented by a single line, but this 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 a computer device (e.g., memory 804, processor 801, communication interface 803).
[0192] Processor 801 may include any one or more processors such as CPU, graphics processing unit (GPU), microprocessor (MP), or digital signal processor (DSP).
[0193] The memory 804 may include volatile memory, such as random access memory (RAM). The processor 801 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0194] The communication interface 803 uses transceiver modules, such as, but not limited to, network interface cards and transceivers, to enable communication between network devices and other devices or communication networks.
[0195] The memory 804 stores executable program code, which the processor 801 executes to implement the functions of the aforementioned method embodiments. That is, the memory 804 stores instructions for executing the aforementioned service discovery method.
[0196] In another aspect, a computer-readable storage medium is provided, wherein at least one computer program is stored in the computer-readable storage medium, and the at least one computer program is loaded and executed by a processor to implement the service discovery method as provided in the above-described method embodiments.
[0197] On the other hand, a computer program product is provided, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the service discovery method described above is implemented.
[0198] Through the above description of the implementation methods, those skilled in the art will clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In practical applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the module can be divided into different functional modules to complete all or part of the functions described above. The specific working process of the system, modules, and units described above can be referred to the corresponding process in the foregoing method embodiments, 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 methods, the technical effects obtained can also be referred 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 in hardware or by a processor executing software instructions. The software instructions can consist of corresponding software modules, which can be stored in random access memory (RAM), flash memory, read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), registers, hard disks, portable hard disks, CD-ROMs, or any other form of storage medium known in the art. One exemplary embodiment couples a storage medium to a processor, enabling the processor to read information from and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and storage medium can reside in an ASIC. Alternatively, the ASIC can reside in a network device. Of course, the processor and storage medium can also exist as discrete components in the network device.
[0201] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a computer program product. A 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 processes or functions of the embodiments of this application are performed, 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 equipment, or other programmable module. The computer program or instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another. For example, a computer program or instructions can be transferred from one website, computer, server, or data center to another website, computer, server, or data center via 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 or data center that integrates one or more available media. The available medium can be a magnetic medium, such as a floppy disk, hard disk, or magnetic tape; it can also be an optical medium, such as a digital video disc (DVD); or it can be a semiconductor medium, such as a solid-state drive (SSD). The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A service discovery method, characterized in that, The method is applied to a client, which includes a data processing unit of an external device. The data processing unit is used to parse response messages sent by the server. The method includes: Obtain at least one of the response messages sent by the server; The response messages are filtered based on preset filtering rules to obtain response messages that conform to the preset filtering rules; wherein, the preset filtering rules include source port rules and message feature rules, the source port rules are used to describe the source port from which the server sends the response messages, and the message feature rules are used to describe the message content from which the server sends the response messages. The transport layer and / or application layer of the response message that conforms to the preset filtering rules are parsed to obtain the transmission path and / or message data content corresponding to the response message that conforms to the preset filtering rules. Based on the transmission path and / or the message data content, a target response message containing target service information is obtained; the target response message refers to the reply information sent by the server to the client based on the client's request. Based on the target service information in the target response message, a connection is established with the server. The target service information refers to the service information corresponding to the client's request.
2. The method according to claim 1, characterized in that, The step of filtering the response messages based on preset filtering rules to obtain response messages that conform to the preset filtering rules includes: Capture a single response message from the link layer. If the single response message meets the preset filtering rules, then treat the single response message as a response message that meets the preset filtering rules. Alternatively, capture all response messages from the link layer, and filter out response messages that meet the preset filtering rules from all response messages.
3. The method according to claim 1 or 2, characterized in that, The method further includes: If the target response message is received, stop acquiring the response message.
4. The method according to claim 1 or 2, characterized in that, The method further includes: Send a service discovery message to at least one of the servers, wherein the service discovery message refers to a target service request sent by the client to the server.
5. The method according to claim 4, characterized in that, Sending 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).
6. The method according to claim 1 or 2, characterized in that, The target service information includes the port and address of the target service.
7. A service discovery device, characterized in that, The device includes: The acquisition module is used to acquire at least one response message sent by the server. The processing module is used to filter the response messages based on preset filtering rules to obtain response messages that conform to the preset filtering rules. It is also used to parse the transport layer and / or application layer of the response message that conforms to the preset filtering rules to obtain the transport path and / or message data content corresponding to the response message that conforms to the preset filtering rules; it is also used to filter and obtain target response messages containing target service information based on the transport path and / or the message data content; wherein, the preset filtering rules include source port rules and message feature rules, the source port rules are used to describe the source port of the server sending the response message, and the message feature rules are used to describe the message content of the server sending the response message; the target response message refers to the reply information sent by the server to the client based on the client's request; The connection module is used to establish a connection 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 client's request.
8. A computer device, characterized in that, The computer includes 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 as described in any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores at least one computer program, which is loaded and executed by a processor to implement the service discovery method as described in any one of claims 1 to 6.
10. A computer program product, characterized in that, The computer program product includes a computer program or instructions that, when executed by a processor, implement the service discovery method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Wireless access device and data processing method thereof
CN111586199A
Message transmission method and device, equipment and storage medium
CN118785299A