Data packet sending method and device, storage medium and electronic equipment
By performing parameter detection and parsing on data packets, the problem of unsuccessful data transmission caused by the coupling between the connection component and the business component was solved, realizing reliable data transmission and flexible distribution, and improving the reliability and adaptability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- QINGDAO HAIER TECH
- Filing Date
- 2023-04-06
- Publication Date
- 2026-06-23
Smart Images

Figure CN116436991B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart home technology, and more specifically, to a method and apparatus for transmitting data packets, a storage medium, and an electronic device. Background Technology
[0002] In related technologies, two business components complete data interaction through a connection component. In other words, in existing technologies, the connection component usually sends the received data directly to the business component. When the connection component and the business component are coupled, if the business component is unable to process the data, the data transmission will fail, which will reduce the reliability of the system.
[0003] In related technologies, when the connection component and the business component are coupled, data transmission may fail when the business component is unable to process data, leading to a decrease in system reliability. No effective solution has yet been proposed. Summary of the Invention
[0004] This application provides a data packet sending method and apparatus, storage medium and electronic device to at least solve the problems in the related art, such as the failure of data sending when the service component is unable to process data due to the coupling between the connection component and the service component, which leads to the reduction of system reliability.
[0005] According to one embodiment of this application, a method for sending a data packet is provided, comprising: performing parameter detection on a first data packet to obtain first identification information carried in the first data packet, wherein the first identification information is used to indicate a connection for transmitting the first data packet, and the connection is used to realize data transmission between service components; determining a target service component subscribing to the first data packet according to the first identification information; obtaining a first parsing method corresponding to the target service component, and parsing the first data packet according to the first parsing method; and sending the parsed first data packet to the target service component.
[0006] In an exemplary embodiment, obtaining the first parsing method corresponding to the target service component includes: obtaining second identification information of the target service component, wherein the second identification information uniquely identifies the target service component; determining a connection table corresponding to the second identification information, wherein the connection table is used to indicate the correspondence between the second identification information and the first parsing method; and determining the first parsing method corresponding to the target service component based on the connection table.
[0007] In an exemplary embodiment, determining the first parsing method corresponding to the target service component based on the connection table includes at least one of the following: determining the decryption method of the first data packet based on the connection table; determining the parsing protocol header function of the first data packet based on the connection table; and determining the parsing data function of the first data packet based on the connection table.
[0008] In an exemplary embodiment, after determining the first parsing method corresponding to the target service component based on the connection table, the method further includes: if the decryption method of the first data packet is determined based on the connection table, decrypting the first data packet according to the decryption method; if the parsing protocol header function of the first data packet is determined based on the connection table, invoking the parsing protocol header function to obtain the protocol header information of the first data packet; and if the parsing data function of the first data packet is determined based on the connection table, invoking the parsing data function to decapsulate the first data packet.
[0009] In an exemplary embodiment, decrypting the first data packet according to the decryption method includes: calling a decryption function and a decryption pointer corresponding to the decryption method in a security component, wherein the security component and the target service component are located in the same system; and decrypting the first data packet using the decryption function and the decryption pointer.
[0010] In an exemplary embodiment, obtaining a first parsing method corresponding to the target service component and parsing the first data packet according to the first parsing method includes: determining a protocol used to encapsulate the first data packet; when there are multiple protocols, performing the parsing steps: determining the outermost protocol used to encapsulate the first data packet; determining a second parsing method for the data packet corresponding to the outermost protocol and parsing the data packet corresponding to the outermost protocol according to the second parsing method, wherein the first parsing method includes: the second parsing method; and repeatedly executing the parsing steps until the data packet corresponding to the innermost protocol is parsed according to the innermost protocol used to encapsulate the first data packet.
[0011] In an exemplary embodiment, before determining the target service component to subscribe to the first data packet based on the first identification information, the method further includes: receiving a registration request from the target service component, wherein the registration request is used to instruct the target service component to subscribe to the data packet transmitted through the connection; and storing the correspondence between the first identification information of the connection and the second identification information of the target service component in a command distribution table based on the registration request.
[0012] According to another embodiment of this application, a data packet sending apparatus is also provided, comprising: an acquisition module, configured to perform parameter detection on a first data packet to acquire first identification information carried in the first data packet, wherein the first identification information is used to indicate a connection for transmitting the first data packet, and the connection is used to realize data transmission between service components; a determination module, configured to determine a target service component subscribing to the first data packet based on the first identification information; a parsing module, configured to acquire a first parsing method corresponding to the target service component and parse the first data packet according to the first parsing method; and a sending module, configured to send the parsed first data packet to the target service component.
[0013] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the above-described method for sending data packets when it is run.
[0014] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the above-described data packet transmission method through the computer program.
[0015] In this embodiment, parameter detection is performed on the first data packet to obtain the first identification information carried in the first data packet. The first identification information indicates the connection transmitting the first data packet, and the connection is used to realize data transmission between business components. A target business component subscribing to the first data packet is determined based on the first identification information. A first parsing method corresponding to the target business component is obtained, and the first data packet is parsed according to the first parsing method. The parsed first data packet is sent to the target business component. This technical solution solves the problem that when the connection component and business component are coupled, data transmission fails when the business component cannot process data, leading to reduced system reliability. This embodiment of the invention uses a general command distribution mechanism to flexibly distribute commands. When a user registers their own user information, the data is parsed based on the user information, and the parsed data is sent to the corresponding business component, improving system reliability. Attached Figure Description
[0016] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of the hardware environment for a data packet sending method according to an embodiment of this application;
[0019] Figure 2 This is a flowchart of a data packet transmission method according to an embodiment of this application;
[0020] Figure 3 This is a flowchart of a method for sending data packets according to an optional embodiment of this application;
[0021] Figure 4 This is a schematic diagram of a data packet transmission method according to an optional embodiment of this application;
[0022] Figure 5 This is a structural block diagram of a data packet sending apparatus according to an embodiment of this application. Detailed Implementation
[0023] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present application.
[0024] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0025] According to one aspect of the embodiments of this application, a method for sending data packets is provided. This method for sending data packets is widely applicable to whole-house intelligent digital control application scenarios such as smart homes, smart home ecosystems, and intelligence house ecosystems. Optionally, in this embodiment, the above-mentioned method for sending data packets can be applied to, for example... Figure 1 The hardware environment shown consists of terminal device 102 and server 104. For example... Figure 1 As shown, server 104 is connected to terminal device 102 via a network and can be used to provide services (such as application services) to the terminal or clients installed on the terminal. A database can be set up on the server or independently of the server to provide data storage services for server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data processing services for server 104.
[0026] The aforementioned network may include, but is not limited to, at least one of the following: wired network, wireless network. The aforementioned wired network may include, but is not limited to, at least one of the following: wide area network, metropolitan area network, local area network. The aforementioned wireless network may include, but is not limited to, at least one of the following: Wi-Fi (Wireless Fidelity), Bluetooth. The terminal device 102 may not be limited to PC, mobile phone, tablet computer, smart air conditioner, smart range hood, smart refrigerator, smart oven, smart stove, smart washing machine, smart water heater, smart washing equipment, smart dishwasher, smart projector, smart TV, smart clothes rack, smart curtains, smart audio-visual equipment, smart socket, smart speaker, smart speaker box, smart fresh air equipment, smart kitchen and bathroom equipment, smart bathroom equipment, smart robot vacuum cleaner, smart window cleaning robot, smart mopping robot, smart air purifier, smart steam oven, smart microwave oven, smart water heater, smart air purifier, smart water dispenser, smart door lock, etc.
[0027] This embodiment provides a method for sending data packets, applied to the aforementioned terminal device. Figure 2 This is a flowchart of a data packet transmission method according to an embodiment of this application, the process including the following steps:
[0028] Step S202: Perform parameter detection on the first data packet to obtain the first identification information carried in the first data packet, wherein the first identification information is used to indicate the connection for transmitting the first data packet, and the connection is used to realize data transmission between service components.
[0029] Step S204: Determine the target service component that subscribes to the first data packet based on the first identification information;
[0030] Step S206: Obtain the first parsing method corresponding to the target service component, and parse the first data packet according to the first parsing method;
[0031] Step S208: Send the parsed first data packet to the target service component.
[0032] Through the above steps, parameter detection is performed on the first data packet to obtain the first identification information carried in the first data packet. The first identification information indicates the connection transmitting the first data packet, and the connection is used to realize data transmission between business components. The target business component subscribing to the first data packet is determined based on the first identification information. A first parsing method corresponding to the target business component is obtained, and the first data packet is parsed according to the first parsing method. The parsed first data packet is sent to the target business component. This solves the problem in related technologies where, when the connection component and business component are coupled, data transmission fails when the business component cannot process the data, leading to reduced system reliability. In this embodiment of the invention, a general command distribution mechanism flexibly distributes commands. Even when a user registers their own user information, the data is parsed based on the user information, and the parsed data is sent to the corresponding business component, improving system reliability.
[0033] Optionally, step S206 above can be implemented in the following way: obtaining the second identification information of the target service component, wherein the second identification information uniquely identifies the target service component; determining the connection table corresponding to the second identification information, wherein the connection table is used to indicate the correspondence between the second identification information and the first parsing method; and determining the first parsing method corresponding to the target service component according to the connection table.
[0034] It should be noted that when a target business component needs to subscribe to certain data, the target business component registers its second identification information and the parsing method for parsing the data in the connection table. When the command distribution component receives the first data packet sent by the connection component, it parses the first data packet according to the parsing method in the connection table corresponding to the target business component.
[0035] Through the above embodiments, a general command distribution mechanism is adopted to flexibly distribute commands. When the target business component registers its own business component information, the data is parsed according to the parsing method registered by the user, and the parsed data is sent to the corresponding business component, thereby improving system reliability.
[0036] In an exemplary embodiment, determining the first parsing method corresponding to the target service component based on the connection table includes at least one of the following: determining the decryption method of the first data packet based on the connection table; determining the parsing protocol header function of the first data packet based on the connection table; and determining the parsing data function of the first data packet based on the connection table.
[0037] It should be noted that the parsing method for registering the target business component includes at least one of the following: decryption method, parsing protocol header function, and parsing data function.
[0038] It should be noted that if the target business component has not registered a parsing method, the connection management component will forward the first data packet it receives to the target business component, and the connection management component will not parse the first data packet.
[0039] Through the above embodiments, the target business component independently registers the corresponding parsing method, and processes the first data packet flexibly according to the corresponding parsing method registered by the target business component, thereby meeting the needs of the target business component to a greater extent.
[0040] In an exemplary embodiment, after determining the first parsing method corresponding to the target service component based on the connection table, the method further includes: if the decryption method of the first data packet is determined based on the connection table, decrypting the first data packet according to the decryption method; if the parsing protocol header function of the first data packet is determined based on the connection table, invoking the parsing protocol header function to obtain the protocol header information of the first data packet; and if the parsing data function of the first data packet is determined based on the connection table, invoking the parsing data function to decapsulate the first data packet.
[0041] Specifically, when the parsing method registered by the target service component includes a decryption method, the first data packet is decrypted according to the registered decryption method; when the parsing method registered by the target service component includes a protocol header parsing function, the command distribution component calls the protocol header parsing function to obtain the protocol header information of the first data packet, and sends the protocol header information and other information in the first data packet except for the protocol header to the target service component; when the parsing method registered by the target service component includes a data parsing function, the command distribution component calls the data parsing function, decapsulates the first data packet, and sends the decapsulated data packet.
[0042] Through the above embodiments, the target business component independently registers the corresponding parsing method, and processes the first data packet flexibly according to the corresponding parsing method registered by the target business component, thereby meeting the needs of the target business component to a greater extent.
[0043] In an exemplary embodiment, decrypting the first data packet according to the decryption method includes: calling a decryption function and a decryption pointer corresponding to the decryption method in a security component, wherein the security component and the target service component are located in the same system; and decrypting the first data packet using the decryption function and the decryption pointer.
[0044] It should be noted that, when it is determined from the connection table that the first data packet needs to be decrypted, the security component calls the decryption function and decryption pointer corresponding to the decryption method, and decrypts the first data packet through the decryption function and the decryption pointer.
[0045] In an exemplary embodiment, obtaining a first parsing method corresponding to the target service component and parsing the first data packet according to the first parsing method includes: determining a protocol used to encapsulate the first data packet; when there are multiple protocols, performing the parsing steps: determining the outermost protocol used to encapsulate the first data packet; determining a second parsing method for the data packet corresponding to the outermost protocol and parsing the data packet corresponding to the outermost protocol according to the second parsing method, wherein the first parsing method includes: the second parsing method; and repeatedly executing the parsing steps until the data packet corresponding to the innermost protocol is parsed according to the innermost protocol used to encapsulate the first data packet.
[0046] It should be noted that there can be multiple protocols encapsulating the first data packet. When there are multiple protocols encapsulating the first data packet, the first data packet needs to be parsed in a loop until the data packet corresponding to the innermost protocol is parsed according to the parsing method corresponding to the innermost protocol. That is to say, each protocol includes a corresponding parsing method.
[0047] For example, the parsing method corresponding to the outermost protocol is: decryption method, parsing protocol header function, and parsing data function; the parsing method corresponding to the next layer protocol can be: parsing protocol header function, parsing data function, and so on, and the parsing method corresponding to the innermost protocol can be: parsing protocol header function. This embodiment of the invention does not limit the parsing method corresponding to each layer protocol.
[0048] In an exemplary embodiment, before determining the target service component to subscribe to the first data packet based on the first identification information, the method further includes: receiving a registration request from the target service component, wherein the registration request is used to instruct the target service component to subscribe to the data packet transmitted through the connection; and storing the correspondence between the first identification information of the connection and the second identification information of the target service component in a command distribution table based on the registration request.
[0049] In other words, when a target service component needs to subscribe to certain data, the target service component registers its second identification information in the command distribution table, and then sends the first data packet to the target service component according to the information stored in the command distribution table.
[0050] In an exemplary embodiment, sending the parsed first data packet to the target service component includes: determining a corresponding command dispatch function in a command dispatch table based on the protocol type of the first data packet and the first identification information; and calling the command dispatch function to send the parsed first data packet to the target service component.
[0051] To better understand the process of sending the above data packets, the implementation flow of sending the above data packets will be described below in conjunction with optional embodiments, but this is not intended to limit the technical solutions of the embodiments of this application.
[0052] This embodiment provides a method for sending data packets. Figure 3 This is a schematic diagram of a data packet sending system according to an optional embodiment of this application, such as... Figure 3 As shown, the data packet sending system includes:
[0053] A business component, a command distribution component connected to the business component, a connection component connected to the command distribution component, a connection management component connected to the connection component, and a security component connected to the command distribution component.
[0054] The connection component is used to send and receive data packets;
[0055] Connection management component, used to manage connections (create, delete, etc.);
[0056] The command distribution component is used to send the data from the connection to the corresponding business component;
[0057] The business component is used to receive data distributed by the command distribution component, process business logic, and send data to the connection component.
[0058] Security components are used to encrypt and decrypt data.
[0059] Figure 4 This is a flowchart of a data packet transmission method according to an optional embodiment of this application, such as... Figure 4 As shown, the specific steps are as follows:
[0060] Step S401: The command distribution component receives the data packet sent by the connection component;
[0061] Step S402: Detect the parameters of the data packet and determine whether the first identification information conn-id carried by the data packet is obtained. The first identification information is used to indicate the connection for transmitting the first data packet. The connection is used to realize data transmission between service components. If the conn-id is obtained, proceed to step S403; otherwise, proceed to step S412.
[0062] Step S403: Determine the corresponding join table based on the conn-id;
[0063] Step S404: Determine whether the data packet corresponding to the Nth layer protocol needs to be decrypted according to the connection table. If it is determined that decryption is required, proceed to step S405; otherwise, proceed to step S406.
[0064] Step S405: Decrypt the data packet corresponding to the Nth layer protocol;
[0065] Step S406: Determine whether a protocol header parsing function exists in the connection table. If a protocol header parsing function exists, proceed to step S407; otherwise, proceed to step S408.
[0066] Step S407: Call the protocol header parsing function to obtain the protocol header information of the data packet corresponding to the Nth layer protocol;
[0067] Step S408: Determine whether a data parsing function exists in the join table. If a data parsing function exists, proceed to step S409; otherwise, proceed to step S410.
[0068] Step S409: Call the data parsing function to obtain the data information of the data packet corresponding to the Nth layer protocol;
[0069] Step S410: Determine whether a layer N-1 protocol exists. If a layer N-1 protocol exists, execute steps S404-S409; otherwise, execute step S411.
[0070] Step S411: Call the innermost cmd to query the command distribution table, determine the target business component based on the command distribution table, and send the parsed data to the target business component;
[0071] Step S412: Return the sending result.
[0072] The above technical solution solves the problem in related technologies where, when the connection component and the business component are coupled, data transmission fails when the business component cannot process the data, leading to a decrease in system reliability. The embodiment of the present invention provides a general command distribution mechanism that flexibly distributes commands. When a user registers their own user information, the system parses the data based on the user information and sends the parsed data to the corresponding business component, thereby improving system reliability.
[0073] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods of the various embodiments of this application.
[0074] Figure 5 This is a structural block diagram of a data packet sending apparatus according to an embodiment of this application; as shown... Figure 4 As shown, it includes:
[0075] The acquisition module 52 is used to perform parameter detection on the first data packet to obtain the first identification information carried in the first data packet, wherein the first identification information is used to indicate the connection for transmitting the first data packet, and the connection is used to realize data transmission between business components.
[0076] The determining module 54 is used to determine the target service component that subscribes to the first data packet based on the first identification information;
[0077] The parsing module 56 is used to obtain the first parsing method corresponding to the target business component, and parse the first data packet according to the first parsing method;
[0078] The sending module 58 is used to send the parsed first data packet to the target service component.
[0079] The above-described device performs parameter detection on a first data packet to obtain first identification information carried in the first data packet. The first identification information indicates the connection transmitting the first data packet, and the connection is used to realize data transmission between service components. A target service component subscribing to the first data packet is determined based on the first identification information. A first parsing method corresponding to the target service component is obtained, and the first data packet is parsed according to the first parsing method. The parsed first data packet is sent to the target service component. This solves the problem in related technologies where, when the connection component and service component are coupled, data transmission fails when the service component cannot process the data, leading to reduced system reliability. In this embodiment of the invention, a general command distribution mechanism flexibly distributes commands. Even when a user registers their own user information, the data is parsed based on the user information, and the parsed data is sent to the corresponding service component, improving system reliability.
[0080] In an exemplary embodiment, the parsing module 56 is configured to obtain second identification information of the target service component, wherein the second identification information uniquely identifies the target service component; determine a connection table corresponding to the second identification information, wherein the connection table is used to indicate the correspondence between the second identification information and the first parsing method; and determine the first parsing method corresponding to the target service component based on the connection table.
[0081] It should be noted that when a target business component needs to subscribe to certain data, the target business component registers its second identification information and the parsing method for parsing the data in the connection table. When the command distribution component receives the first data packet sent by the connection component, it parses the first data packet according to the parsing method in the connection table corresponding to the target business component.
[0082] Through the above embodiments, a general command distribution mechanism is adopted to flexibly distribute commands. When the target business component registers its own business component information, the data is parsed according to the parsing method registered by the user, and the parsed data is sent to the corresponding business component, thereby improving system reliability.
[0083] In one exemplary embodiment, the parsing module 56 is configured to perform at least one of the following: determine the decryption method of the first data packet according to the connection table; determine the parsing protocol header function of the first data packet according to the connection table; and determine the parsing data function of the first data packet according to the connection table.
[0084] It should be noted that the parsing method for registering the target business component includes at least one of the following: decryption method, parsing protocol header function, and parsing data function.
[0085] It should be noted that if the target business component has not registered a parsing method, the connection management component will forward the first data packet it receives to the target business component, and the connection management component will not parse the first data packet.
[0086] Through the above embodiments, the target business component independently registers the corresponding parsing method, and processes the first data packet flexibly according to the corresponding parsing method registered by the target business component, thereby meeting the needs of the target business component to a greater extent.
[0087] In an exemplary embodiment, the parsing module 56 is further configured to: decrypt the first data packet according to the decryption method determined according to the connection table; invoke the parsing protocol header function to obtain the protocol header information of the first data packet if the parsing protocol header function of the first data packet is determined according to the connection table; and call the parsing data function to decapsulate the first data packet if the parsing data function of the first data packet is determined according to the connection table.
[0088] Specifically, when the parsing method registered by the target service component includes a decryption method, the first data packet is decrypted according to the registered decryption method; when the parsing method registered by the target service component includes a protocol header parsing function, the command distribution component calls the protocol header parsing function to obtain the protocol header information of the first data packet, and sends the protocol header information and other information in the first data packet except for the protocol header to the target service component; when the parsing method registered by the target service component includes a data parsing function, the command distribution component calls the data parsing function, decapsulates the first data packet, and sends the decapsulated data packet.
[0089] Through the above embodiments, the target business component independently registers the corresponding parsing method, and processes the first data packet flexibly according to the corresponding parsing method registered by the target business component, thereby meeting the needs of the target business component to a greater extent.
[0090] In an exemplary embodiment, the parsing module 56 is further configured to call the decryption function and decryption pointer corresponding to the decryption method in the security component, wherein the security component and the target service component are located in the same system; and to decrypt the first data packet through the decryption function and the decryption pointer.
[0091] It should be noted that, when it is determined from the connection table that the first data packet needs to be decrypted, the security component calls the decryption function and decryption pointer corresponding to the decryption method, and decrypts the first data packet through the decryption function and the decryption pointer.
[0092] In an exemplary embodiment, the parsing module 56 is further configured to determine the protocol used to encapsulate the first data packet; when there are multiple protocols, the parsing steps are performed: determining the outermost protocol used to encapsulate the first data packet; determining a second parsing method for the data packet corresponding to the outermost protocol, and parsing the data packet corresponding to the outermost protocol according to the second parsing method, wherein the first parsing method includes: the second parsing method; and repeatedly executing the parsing steps until the data packet corresponding to the innermost protocol is parsed according to the innermost protocol used to encapsulate the first data packet.
[0093] It should be noted that there can be multiple protocols encapsulating the first data packet. When there are multiple protocols encapsulating the first data packet, the first data packet needs to be parsed in a loop until the data packet corresponding to the innermost protocol is parsed according to the parsing method corresponding to the innermost protocol. That is to say, each protocol includes a corresponding parsing method.
[0094] For example, the parsing method corresponding to the outermost protocol is: decryption method, parsing protocol header function, and parsing data function; the parsing method corresponding to the next layer protocol can be: parsing protocol header function, parsing data function, and so on, and the parsing method corresponding to the innermost protocol can be: parsing protocol header function. This embodiment of the invention does not limit the parsing method corresponding to each layer protocol.
[0095] In an exemplary embodiment, the acquisition module 52 is further configured to receive a registration request from the target service component, wherein the registration request is used to instruct the target service component to subscribe to data packets transmitted through the connection; and to store in a command distribution table the correspondence between the first identification information of the connection and the second identification information of the target service component according to the registration request.
[0096] In other words, when a target service component needs to subscribe to certain data, the target service component registers its second identification information in the command distribution table, and then sends the first data packet to the target service component according to the information stored in the command distribution table.
[0097] Embodiments of this application also provide a storage medium including a stored program, wherein the program executes any of the methods described above when it is run.
[0098] Optionally, in this embodiment, the storage medium may be configured to store program code for performing the following steps:
[0099] S1, Perform parameter detection on the first data packet to obtain the first identification information carried in the first data packet, wherein the first identification information is used to indicate the connection for transmitting the first data packet, and the connection is used to realize data transmission between service components;
[0100] S2, determine the target service component that subscribes to the first data packet based on the first identification information;
[0101] S3, obtain the first parsing method corresponding to the target service component, and parse the first data packet according to the first parsing method;
[0102] The parsed first data packet is sent to the target service component.
[0103] Embodiments of this application also provide an electronic device including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0104] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0105] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0106] S1, Perform parameter detection on the first data packet to obtain the first identification information carried in the first data packet, wherein the first identification information is used to indicate the connection for transmitting the first data packet, and the connection is used to realize data transmission between service components;
[0107] S2, determine the target service component that subscribes to the first data packet based on the first identification information;
[0108] S3, obtain the first parsing method corresponding to the target service component, and parse the first data packet according to the first parsing method;
[0109] The parsed first data packet is sent to the target service component.
[0110] Optionally, in this embodiment, the storage medium may include, but is not limited to, various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0111] Optionally, specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated here.
[0112] Obviously, those skilled in the art should understand that the modules or steps of this application described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those presented here, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, this application is not limited to any particular combination of hardware and software.
[0113] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for sending data packets, characterized in that, include: The first data packet is subjected to parameter detection to obtain the first identification information carried in the first data packet, wherein the first identification information is used to indicate the connection for transmitting the first data packet, and the connection is used to realize data transmission between business components; The target service component that subscribes to the first data packet is determined based on the first identification information; Obtain the first parsing method corresponding to the target business component, and parse the first data packet according to the first parsing method; The parsed first data packet is sent to the target service component; The step of obtaining the first parsing method corresponding to the target business component includes: obtaining the second identification information of the target business component, wherein the second identification information uniquely identifies the target business component; determining the connection table corresponding to the second identification information, wherein the connection table is used to indicate the correspondence between the second identification information and the first parsing method, and the target business component registers its second identification information and the parsing method for parsing data to the connection table through a registration method; and determining the first parsing method corresponding to the target business component based on the connection table.
2. The method for sending data packets according to claim 1, characterized in that, The first resolution method corresponding to the target business component is determined based on the join table, including at least one of the following: The decryption method of the first data packet is determined according to the connection table; The parsing protocol header function of the first data packet is determined according to the connection table; The parsing data function for the first data packet is determined based on the connection table.
3. The method for sending data packets according to claim 2, characterized in that, After determining the first parsing method corresponding to the target business component based on the connection table, the method further includes: If the decryption method of the first data packet is determined according to the connection table, the first data packet is decrypted according to the decryption method. If the protocol header parsing function of the first data packet is determined according to the connection table, the protocol header parsing function is invoked to obtain the protocol header information of the first data packet; If the parsing function for the first data packet is determined based on the connection table, the parsing function is invoked to decapsulate the first data packet.
4. The method for sending data packets according to claim 3, characterized in that, Decrypting the first data packet according to the decryption method includes: The security component calls the decryption function and decryption pointer corresponding to the decryption method, wherein the security component and the target business component are located in the same system; The first data packet is decrypted using the decryption function and the decryption pointer.
5. The method for sending data packets according to claim 1, characterized in that, Obtain the first parsing method corresponding to the target service component, and parse the first data packet according to the first parsing method, including: Determine the protocol used to encapsulate the first data packet; When there are multiple protocols, the following parsing steps are performed: determine the outermost protocol used to encapsulate the first data packet; determine the second parsing method for the data packet corresponding to the outermost protocol, and parse the data packet corresponding to the outermost protocol according to the second parsing method, wherein the first parsing method includes: the second parsing method; The parsing steps are executed repeatedly until the data packet corresponding to the innermost protocol is parsed according to the innermost protocol used to encapsulate the first data packet.
6. The method for sending data packets according to claim 1, characterized in that, Before determining the target service component subscribing to the first data packet based on the first identification information, the method further includes: Receive the registration request of the target service component, wherein the registration request is used to instruct the target service component to subscribe to data packets transmitted through the connection; Based on the registration request, the command distribution table stores the correspondence between the first identification information of the connection and the second identification information of the target business component.
7. A data packet sending apparatus, characterized in that, include: The acquisition module is used to perform parameter detection on the first data packet to obtain the first identification information carried in the first data packet, wherein the first identification information is used to indicate the connection for transmitting the first data packet, and the connection is used to realize data transmission between business components. The determination module is used to determine the target service component that subscribes to the first data packet based on the first identification information; The parsing module is used to obtain the first parsing method corresponding to the target business component, and parse the first data packet according to the first parsing method; The sending module is used to send the parsed first data packet to the target service component; The parsing module is configured to: obtain second identification information of the target business component, wherein the second identification information uniquely identifies the target business component; determine a connection table corresponding to the second identification information, wherein the connection table indicates the correspondence between the second identification information and the first parsing method, wherein the target business component registers its second identification information and the parsing method for parsing data to the connection table through a registration method; and determine the first parsing method corresponding to the target business component based on the connection table.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program, when executed, performs the method according to any one of claims 1 to 7.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 7 through the computer program.