Data processing method, device, electronic device and computer readable storage medium

By using a combination of network filters and lock-free loop queues in data processing equipment, the problems of high CPU resource consumption and UDP packet loss rate during data transmission and processing are solved, and more efficient CPU resource utilization and lower packet loss rate are achieved.

CN115550004BActive Publication Date: 2025-05-02BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211145674.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-20
Publication Date
2025-05-02
Estimated Expiration
2042-09-20

AI Technical Summary

Technical Problem

During the data transmission and processing process, existing data processing equipment needs to perform memory copy of the protocol stack and switch between the kernel state and the user state, resulting in a large amount of CPU resources consumed, weak application layer processing capabilities, and high packet loss rate of UDP.

Method used

The target data is received through the network filter in the kernel protocol stack. If the transmission conditions are met, the data is stored in a lock-free loop queue and the transmission to the protocol stack is stopped. The application layer directly obtains and processes data from the data queue.

Benefits of technology

It reduces the CPU resource consumption and UDP packet loss rate, and improves the application layer's processing power and UDP throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115550004B_ABST
    Figure CN115550004B_ABST
Patent Text Reader

Abstract

The present application belongs to the field of data processing technology, and discloses a method, device, electronic device and computer-readable storage medium for data processing, the method comprising: receiving target data sent by a network layer through a network filter in a kernel protocol stack; the kernel protocol stack also includes a network layer and a protocol stack, and the target data is UDP data; if it is determined that the target data meets the set transmission conditions, the target data is stored in a data queue through the network filter, and the target data is stopped from being transmitted to the protocol stack; the target data in the data queue is processed through the application layer. In this way, the consumed CPU resources and the packet loss rate are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device and computer-readable storage medium for data processing. Background Art

[0002] The kernel protocol stack in the data processing device includes kernel space (kernel state) and user space (user state). Kernel space usually includes device drivers, network layer and protocol stack. User space includes application layer.

[0003] In the prior art, a data processing device usually receives data sent by other devices through a device driver, and transmits the data to an application layer through a network layer and a protocol stack in sequence, so as to process the data through the application layer.

[0004] However, in this process, it is usually necessary to copy the memory of the protocol stack and switch between kernel state and user state, which will consume a lot of central processing unit (CPU) resources. The application layer will have weaker data processing capabilities due to fewer CPU resources, which will lead to a higher packet loss rate of the User Datagram Protocol (UDP). Summary of the invention

[0005] The purpose of the embodiments of the present application is to provide a data processing method, device, electronic device and computer-readable storage medium, so as to reduce the consumed CPU resources and data packet loss rate in the process of transmitting and processing received data.

[0006] In one aspect, a method for data processing is provided, comprising:

[0007] Receive the target data sent by the network layer through the network filter in the kernel protocol stack; the kernel protocol stack also includes the network layer and protocol stack, and the target data is UDP data;

[0008] If it is determined that the target data meets the set transmission conditions, the target data is stored in the data queue through the network filter, and the transmission of the target data to the protocol stack is stopped;

[0009] The target data in the data queue is processed through the application layer.

[0010] In the above implementation process, the consumed CPU resources and packet loss rate are reduced.

[0011] In one implementation, the data queue is a lock-free circular queue;

[0012] The storage space of the data queue is shared memory.

[0013] In one implementation, if it is determined that the target data meets the set transmission condition, the target data is stored in the data queue through the network filter, and the transmission of the target data to the protocol stack is stopped, including:

[0014] If the network filter determines that the target data is data to be processed by the local application, the callback function is called to store the target data in a lock-free circular queue. The callback function is registered in the local entry node in the network filter, and the local entry node is used to receive the data to be processed by the local application;

[0015] If it is determined that the data blocking success notification returned by the callback function is received, the interrupt task for the target data is ended, and the interrupt task is a task for transmitting the target data to the protocol stack.

[0016] In the above implementation process, data is truncated from the network filter and transferred to the data queue so that the application layer can directly obtain and process it, thereby reducing the packet loss rate.

[0017] In one implementation, processing the target data in the data queue includes:

[0018] When it is determined that the trigger condition is met, it is determined whether there is target data in the data queue;

[0019] If so, get the target data from the data queue;

[0020] According to the network address information in the target data, obtain the connection matching the target data;

[0021] Call the data operation function corresponding to the connection and perform the corresponding data processing operation on the target data.

[0022] In the above implementation process, the application layer can perform data processing through data matching data operation functions.

[0023] In one implementation, when it is determined that the trigger condition is met, determining whether there is target data in the data queue includes:

[0024] When at least one of the following conditions is met, it is determined whether the target data exists in the data queue:

[0025] Determining that a set duration has been reached; and determining that a data processing instruction has been received.

[0026] In the above implementation process, the application layer can process data periodically or when receiving corresponding instructions.

[0027] In one aspect, a data processing device is provided, comprising:

[0028] The receiving unit is used to receive the target data sent by the network layer through the network filter in the kernel protocol stack; the kernel protocol stack also includes the network layer and the protocol stack, and the target data is UDP data;

[0029] The storage unit is used to store the target data in the data queue through the network filter and stop transmitting the target data to the protocol stack if it is determined that the target data meets the set transmission condition;

[0030] The processing unit is used to process the target data in the data queue through the application layer.

[0031] In one implementation, the data queue is a lock-free circular queue;

[0032] The storage space of the data queue is shared memory.

[0033] In one embodiment, the storage unit is used to:

[0034] If the network filter determines that the target data is data to be processed by the local application, the callback function is called to store the target data in a lock-free circular queue. The callback function is registered in the local entry node in the network filter, and the local entry node is used to receive the data to be processed by the local application;

[0035] If it is determined that the data blocking success notification returned by the callback function is received, the interrupt task for the target data is ended, and the interrupt task is a task for transmitting the target data to the protocol stack.

[0036] In one implementation, the processing unit is used to:

[0037] When it is determined that the trigger condition is met, it is determined whether there is target data in the data queue;

[0038] If so, get the target data from the data queue;

[0039] According to the network address information in the target data, obtain the connection matching the target data;

[0040] Call the data operation function corresponding to the connection and perform the corresponding data processing operation on the target data.

[0041] In one implementation, the processing unit is used to:

[0042] When at least one of the following conditions is met, it is determined whether the target data exists in the data queue:

[0043] Determining that a set duration has been reached; and determining that a data processing instruction has been received.

[0044] On the one hand, an electronic device is provided, including a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the method provided in any of the various optional implementations of the above-mentioned data processing are executed.

[0045] On the one hand, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method provided in any of the various optional implementations of data processing described above are executed.

[0046] On the one hand, a computer program product is provided. When the computer program product is run on a computer, the computer is caused to execute the steps of the method provided in any of the various optional implementations of the above data processing.

[0047] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0049] Figure 1 A schematic diagram of the architecture of a data processing device provided in an embodiment of the present application;

[0050] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;

[0051] Figure 3 A schematic diagram of the architecture of a network filter provided in an embodiment of the present application;

[0052] Figure 4 A flowchart of a method for data loop processing provided in an embodiment of the present application;

[0053] Figure 5 A structural block diagram of a data processing device provided in an embodiment of the present application;

[0054] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0055] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0056] First, some terms involved in the embodiments of the present application are explained to facilitate understanding by those skilled in the art.

[0057] Terminal device: can be a mobile terminal, a fixed terminal or a portable terminal, such as a mobile phone, a station, a unit, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system device, a personal navigation device, a personal digital assistant, an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an electronic book device, a gaming device or any combination thereof, including accessories and peripherals of these devices or any combination thereof. It is also foreseeable that the terminal device can support any type of interface for the user (such as a wearable device), etc.

[0058] Server: It can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, and big data and artificial intelligence platforms.

[0059] Under traditional technology, a data processing device usually receives data sent by other devices through a device driver, and transmits the data to the application layer through the network layer and the protocol stack in sequence, so as to process the data through the application layer.

[0060] However, in this process, it is usually necessary to copy the memory of the protocol stack, switch between kernel state and user state, and perform input and output (IO) system calls, which will consume a lot of central processing unit (CPU) resources, resulting in less CPU resources for the application layer, and thus weaker data processing capabilities. The UDP protocol has no link state and does not guarantee data reliability. When the above problems occur, the UDP message will not actively reduce the throughput to ensure data reliability, resulting in a high UDP packet loss rate. Furthermore, the socket buffer area for receiving data in the application layer is small. Therefore, when the application processing capability is weak, the socket buffer area basically does not play a caching role, resulting in packet loss problems. Even if the application layer chooses a high-performance nginx architecture, it only improves some throughput but cannot fundamentally change the problem. In addition, in the one-way network gate scenario, due to the particularity of the one-way network gate, data is not allowed to be lost when passing through the one-way network gate. Therefore, a large number of packet losses under high throughput conditions cannot meet actual needs.

[0061] Among them, the one-way optical gate (also known as a one-way network gate) is deployed between networks with different security levels. Through a one-way non-feedback transmission physical environment, data is transmitted from a low-security domain to a high-security domain. The hardware architecture of the one-way optical gate usually adopts a 2+1 architecture, that is, it consists of an external terminal, an internal terminal, and a one-way isolation component. The one-way isolation component is composed of two one-way isolation cards connected by a one-way optical fiber. The network agent program and the security engine run on the external terminal and the internal terminal to form a software architecture. The hardware architecture and software architecture form a secure host, and finally the secure host provides data one-way transmission services.

[0062] It can be seen that the reason for the low UDP throughput is that a large amount of CPU resources are consumed in memory copying in the protocol stack, switching between kernel state and user state, and I / O system calls, which makes the application obtain too few CPU resources, resulting in weak processing capabilities and packet loss. Therefore, it is necessary to reduce the data processing flow as much as possible, reduce the switching between user state and kernel state, and reduce I / O calls, etc., to achieve the purpose of saving CPU resources.

[0063] In order to reduce the consumed CPU resources and the packet loss rate of data in the process of transmitting and processing the received data, and improve the UDP performance in the Linux environment, in the embodiments of the present application, the embodiments of the present application provide a method, device, electronic device and computer-readable storage medium for data processing. Specifically, a shared memory + lock-free circular queue method is selected to form a transmission queue (i.e., a data queue), and the queue memory space is a shared memory, which can be directly accessed by the application layer process. The lock-free circular queue meets the needs of producers and consumers in various situations. Through the architecture of Netfilter+nginx+transmission queue, the role of the fast channel is realized, and the target data in the kernel protocol stack is directly passed to the application layer (i.e., the user layer), saving a lot of CPU resources, increasing the processing power of the application layer, increasing the throughput of UDP, and can also increase the data queue to alleviate the packet loss to a certain extent.

[0064] See also Figure 1 , which is a schematic diagram of the architecture of a data processing device provided in an embodiment of the present application. Figure 1 In the data processing device, the data processing device can be a server or a terminal device.

[0065] The data processing device includes a kernel protocol stack, a data queue and an application layer. The kernel protocol stack includes a network card driver (ie, a device driver), a link layer, a network layer, a network filter (Netfilter), and a protocol stack.

[0066] It should be noted that Netfilter is a subsystem that comes with Linux and has been adapted to the Linux protocol stack. To operate Netfilter, you only need to find the corresponding hook point and register the callback function there.

[0067] In one implementation, the data processing device may be a device equipped with a one-way optical shutter.

[0068] See also Figure 2 FIG. 1 is a flowchart of a data processing method provided in an embodiment of the present application, which is applied to Figure 1 Data processing equipment in Figure 1 right Figure 2 The data processing method in is described, and the specific implementation process of the method is as follows:

[0069] Step 200: Receive target data sent by the network layer through the network filter in the kernel protocol stack.

[0070] The target data is UDP data transmitted using the UDP protocol; the kernel protocol stack also includes a network layer and a protocol stack.

[0071] Among them, the UDP protocol is a simple data packet-oriented transport layer protocol that provides non-fully connected, non-secure data stream transmission.

[0072] In one implementation, the target data is transmitted to the network filter through the network card driver and the network layer in sequence.

[0073] Step 201: If it is determined that the target data meets the set transmission condition, the target data is stored in the data queue through the network filter, and the transmission of the target data to the protocol stack is stopped.

[0074] As an example, the data queue is a lock-free circular queue, and the storage space of the data queue is a shared memory.

[0075] In one implementation, when executing step 201, the following steps may be used:

[0076] S2011: If the network filter determines that the target data is data to be processed by the local application, the callback function is called to store the target data in a lock-free circular queue.

[0077] The callback function is registered in a local entry node in the network filter, and the local entry node is used to receive data to be processed by a local application.

[0078] S2012: If it is determined that the data blocking success notification returned by the callback function is received, then the interrupt task for the target data is terminated, where the interrupt task is a task for transmitting the target data to the protocol stack.

[0079] Netfilter is a subsystem under Linux that provides a complete set of hook function management mechanisms. It is seamlessly integrated with the network layer and can filter, modify, and translate data packets.

[0080] In one embodiment, a local entry node is provided in the network filter (the local entry node can adopt the NF_IP_LOCAL_IN node), then the callback function is pre-registered in the local entry node, and when the callback function is called for the first time, a shared memory is applied for, and a lock-free circular queue is used to initialize the applied shared memory. When the target data (such as a UDP data packet) passes through the local entry node, the callback function performs data judgment on the target data, and when it is determined that the calling conditions are met (that is, the target data is data to be processed by the local application), the target data is stored in the lock-free circular queue, and a data blocking success notification (such as NF_DROP) is returned. After the kernel protocol stack determines that the data blocking success notification has been received, it will be considered that the data is blocked, and the interrupt processing for the target data is terminated.

[0081] See also Figure 3, which is a schematic diagram of the architecture of a network filter. The network filter includes a data receiving node, a data triggering node (e.g., NF_IP_PRE_ROUTE node), a first routing decision node, a local entry node (e.g., F_IP_LOCAL_IN node), a message forwarding node (e.g., NF_IP_FORWARD), a second routing decision node, a data sending node (e.g., NF_IP_LOCAL_OUT), a data sent node (e.g., NF_IP_POST_ROUTIN), and a message sending node.

[0082] Among them, the data trigger node is the node where data enters the protocol stack. The local entry node is the node that transmits data to be processed by the local application. The forwarding message node is the node that transmits data to be forwarded to other devices (such as the host). The data sending node is the node that transmits data to be sent. The data sent node is the node for transmitting data that has been sent. A function can be registered in any of the above five nodes so that the corresponding registered function can be called when the data passes through the hook corresponding to any registered function.

[0083] In this way, the NF_IP_LOCAL_IN node is registered in the Netfilter located after the network layer, so that the complete UDP data can be transferred to the data queue for subsequent data matching and other processing.

[0084] Furthermore, the size of the data queue may be adjusted according to the running status of the application layer.

[0085] As an example, when the upper layer application is blocked or the sending is slower than the receiving, the lock-free circular queue can be increased.

[0086] In this way, the data can be stored in the data queue, thereby caching the data and effectively alleviating the packet loss problem.

[0087] Step 202: Process the target data in the data queue through the application layer.

[0088] In one implementation, when executing step 202, the following steps may be used:

[0089] S2021: When it is determined that the trigger condition is met, determine whether there is target data in the data queue.

[0090] In one implementation, it is determined whether target data exists in the data queue when at least one of the following conditions is met: it is determined that a set duration has been reached; and it is determined that a data processing instruction has been received.

[0091] In actual applications, the set duration can be set according to the actual application scenario, such as 5s.

[0092] S2022: If yes, obtain the target data from the data queue.

[0093] In this way, a fast transmission channel is constructed through the architecture of Netfilter+nginx+data queue, so that the application layer can directly obtain the target data of the kernel protocol stack through the fast transmission channel, simplifying the tedious operation steps of data processing.

[0094] S2023: Obtain a connection matching the target data according to the network address information in the target data.

[0095] Optionally, the network address information may be a four-tuple, including: a destination IP address, a destination port, a source IP address, and a source port.

[0096] S2024: Call the data operation function corresponding to the connection and perform corresponding data processing operations on the target data.

[0097] In one implementation, an nginx process is provided in the application layer, and the nginx process can periodically read and process data from a data queue.

[0098] It should be noted that the principle of Nginx middle-layer application design is as follows: nginx itself triggers responses through epoll. For example, the Transmission Control Protocol (TCP) protocol data can directly find the corresponding connection through the epoll event. However, since the UDP protocol has no connection status, it is impossible to respond to UDP message data (i.e., target data) with nginx. You can only find the corresponding listening structure listen first. In the listen structure, there is a red-black tree to save the connection information corresponding to the data. Therefore, the corresponding connection can be found through the four-tuple matching of the UDP message data, and the corresponding read and write events (i.e., data operation functions) can be called back through the matching connection.

[0099] Since the target data is transmitted through a fast transmission channel (i.e., data queue), the target data will not be placed in the socket buffer and the epoll event will not be triggered. Therefore, the triggering method of nginx is modified, that is, the data queue is queried through timed polling to see whether there is target data to be processed. If so, the original processing flow is used for subsequent data processing.

[0100] The modification of the nginx middle layer is as follows: During the initialization process of the worker, the data queue is obtained and a timer is added. The timer is used to periodically poll to detect whether there is target data to be processed in the data queue. If it is determined that there is no target data to be processed, the timer is added again to perform the next round of data query and processing. If it is determined that there is target data to be processed, the quadruple of the target data is extracted, and a matching connection is obtained through the structure, and the original nginx processing flow is reused through the connection to perform data processing.

[0101] It should be noted that Nginx is a high-performance Hyper Text Transport Protocol (HTTP) and reverse proxy server architecture, which has the characteristics of small memory usage and strong concurrency capability, and is adapted to a variety of asynchronous IO mechanisms, such as epoll and poll.

[0102] As an example, the data operation function may be a read / write event, and the data processing operation may be a read / write operation.

[0103] In this way, the native epoll triggering method in the nginx process is not adopted, but an intermediate layer is added to the nginx process, and data processing is performed through the intermediate layer.

[0104] See also Figure 4 The following is a flowchart of a method for data cycle processing. Figure 4 right Figure 2 A method of processing data at the application layer is described below.

[0105] Step 400: Determine whether a trigger condition is met according to the timer.

[0106] Specifically, it is determined that a set duration is reached.

[0107] Step 401: Determine whether there is target data to be processed in the lock-free circular queue. If so, execute step 402; otherwise, execute step 405.

[0108] Step 402: extract target data from the lock-free circular queue.

[0109] Step 403: Determine the connection matching the target data according to the quadruple of the target data.

[0110] Step 404: Call the data operation function corresponding to the connection and perform corresponding data processing operations on the target data.

[0111] Step 405: Set a timer and execute step 400.

[0112] In this way, the timer can be used to continuously obtain and process the data in the lock-free circular queue.

[0113] In the embodiment of the present application, the architecture of Netfilter+nginx+data queue is designed, the target data is intercepted at the NF_IP_LOCAL_IN node in Netfilter, and the target data is put into the data queue, the kernel protocol stack ends the processing of the target data, and a fast channel is constructed for the target data, so that the nginx process of the application layer collects data from the data queue regularly for processing. In this process, the target data is only processed by the device driver, link layer and network layer, and then transferred to the data queue, and then can be quickly passed to the user program, skipping the processing of subsequent layers in the kernel protocol stack, avoiding the copy of the target data from the kernel space to the user space, and under the multi-core architecture, the CPU processing the kernel does not need to switch the state, the application can get the data, skipping a large number of switches between the kernel state and the user state, saving a lot of CPU resources.

[0114] Based on the same inventive concept, a data processing device is also provided in the embodiment of the present application. Since the principle of solving the problem by the above-mentioned device and equipment is similar to a data processing method, the implementation of the above-mentioned device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0115] like Figure 5 As shown, it is a structural schematic diagram of a data processing device provided in an embodiment of the present application, including:

[0116] The receiving unit 501 is used to receive the target data sent by the network layer through the network filter in the kernel protocol stack; the kernel protocol stack also includes the network layer and the protocol stack, and the target data is UDP data;

[0117] The storage unit 502 is used to store the target data in the data queue through the network filter and stop transmitting the target data to the protocol stack if it is determined that the target data meets the set transmission condition;

[0118] The processing unit 503 is used to process the target data in the data queue through the application layer.

[0119] In one implementation, the data queue is a lock-free circular queue;

[0120] The storage space of the data queue is shared memory.

[0121] In one implementation, the storage unit 502 is used to:

[0122] If the network filter determines that the target data is data to be processed by the local application, the callback function is called to store the target data in a lock-free circular queue. The callback function is registered in the local entry node in the network filter, and the local entry node is used to receive the data to be processed by the local application;

[0123] If it is determined that the data blocking success notification returned by the callback function is received, the interrupt task for the target data is ended, and the interrupt task is a task for transmitting the target data to the protocol stack.

[0124] In one implementation, the processing unit 503 is configured to:

[0125] When it is determined that the trigger condition is met, it is determined whether there is target data in the data queue;

[0126] If so, get the target data from the data queue;

[0127] According to the network address information in the target data, obtain the connection matching the target data;

[0128] Call the data operation function corresponding to the connection and perform the corresponding data processing operation on the target data.

[0129] In one implementation, the processing unit 503 is configured to:

[0130] When at least one of the following conditions is met, it is determined whether the target data exists in the data queue:

[0131] Determining that a set duration has been reached; and determining that a data processing instruction has been received.

[0132] In the data processing method, device, electronic device and computer-readable storage medium provided by the embodiment of the present application, the target data sent by the network layer is received through the network filter in the kernel protocol stack; the kernel protocol stack also includes the network layer and the protocol stack, and the target data is UDP data; if it is determined that the target data meets the set transmission conditions, the target data is stored in the data queue through the network filter, and the transmission of the target data to the protocol stack is stopped; the target data in the data queue is processed through the application layer. In this way, the consumed CPU resources and the packet loss rate are reduced.

[0133] Figure 6 FIG. 6 is a schematic diagram showing the structure of an electronic device 6000. Figure 6 As shown, the electronic device 6000 includes: a processor 6010 and a memory 6020, and optionally, may also include a power supply 6030, a display unit 6040, and an input unit 6050.

[0134] The processor 6010 is the control center of the electronic device 6000. It connects various components using various interfaces and lines, and performs various functions of the electronic device 6000 by running or executing software programs and / or data stored in the memory 6020, thereby monitoring the electronic device 6000 as a whole.

[0135] In the embodiment of the present application, the processor 6010 executes the various steps in the above embodiment when calling the computer program stored in the memory 6020.

[0136] Optionally, the processor 6010 may include one or more processing units; preferably, the processor 6010 may integrate an application processor and a modem processor, wherein the application processor mainly processes an operating system, a user interface, and applications, and the modem processor mainly processes wireless communications. It is understandable that the modem processor may not be integrated into the processor 6010. In some embodiments, the processor and the memory may be implemented on a single chip, and in some embodiments, they may also be implemented separately on separate chips.

[0137] The memory 6020 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, various applications, etc.; the data storage area may store data created according to the use of the electronic device 6000, etc. In addition, the memory 6020 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices, etc.

[0138] The electronic device 6000 also includes a power source 6030 (such as a battery) for supplying power to various components. The power source can be logically connected to the processor 6010 through a power management system, thereby managing functions such as charging, discharging, and power consumption through the power management system.

[0139] The display unit 6040 may be used to display information input by the user or information provided to the user and various menus of the electronic device 6000, and in the embodiment of the present invention, is mainly used to display the display interface of each application in the electronic device 6000 and objects such as text and pictures displayed in the display interface. The display unit 6040 may include a display panel 6041. The display panel 6041 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0140] The input unit 6050 may be used to receive information such as numbers or characters input by the user. The input unit 6050 may include a touch panel 6051 and other input devices 6052. The touch panel 6051, also known as a touch screen, may collect touch operations of the user on or near it (such as operations of the user using a finger, a stylus, or any other suitable object or accessory on or near the touch panel 6051).

[0141] Specifically, the touch panel 6051 can detect the user's touch operation, detect the signal brought by the touch operation, convert these signals into touch point coordinates, send them to the processor 6010, and receive and execute the command sent by the processor 6010. In addition, the touch panel 6051 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. Other input devices 6052 can include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, a joystick, etc.

[0142] Of course, the touch panel 6051 can cover the display panel 6041. When the touch panel 6051 detects a touch operation on or near it, it is transmitted to the processor 6010 to determine the type of touch event. Then the processor 6010 provides corresponding visual output on the display panel 6041 according to the type of touch event. Figure 6 In the embodiment, the touch panel 6051 and the display panel 6041 are used as two independent components to realize the input and output functions of the electronic device 6000, but in some embodiments, the touch panel 6051 and the display panel 6041 can be integrated to realize the input and output functions of the electronic device 6000.

[0143] The electronic device 6000 may also include one or more sensors, such as a pressure sensor, a gravity acceleration sensor, a proximity light sensor, etc. Of course, according to the needs of specific applications, the electronic device 6000 may also include other components such as a camera. Since these components are not the key components used in the embodiments of the present application, Figure 6 It is not shown and will not be described in detail.

[0144] Those skilled in the art will understand that Figure 6 The electronic device is merely an example and does not limit the electronic device, and may include more or less components than those shown in the figure, or may combine certain components, or may include different components.

[0145] In an embodiment of the present application, a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, a communication device can perform each step in the above embodiment.

[0146] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.

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

[0148] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0149] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0150] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0151] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0152] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A method for data processing, characterized in that: include: Receive the target data sent by the network layer through the network filter in the kernel protocol stack; The kernel protocol stack also includes the network layer and the protocol stack, and the target data is user datagram protocol UDP data; If it is determined that the target data meets the set transmission condition, the target data is stored in the data queue through the network filter, and the transmission of the target data to the protocol stack is stopped; wherein the data queue is a lock-free circular queue; and the storage space of the data queue is a shared memory; Processing the target data in the data queue through the application layer; If it is determined that the target data meets the set transmission condition, the target data is stored in the data queue through the network filter, and the transmission of the target data to the protocol stack is stopped, including: If the network filter determines that the target data is data to be processed by the local application, a callback function is called to store the target data in the lock-free circular queue, and the callback function is registered in a local entry node in the network filter, and the local entry node is used to receive the data to be processed by the local application; If it is determined that the data blocking success notification returned by the callback function is received, the interrupt task for the target data is terminated, and the interrupt task is a task for transmitting the target data to the protocol stack.

2. The method according to claim 1, characterized in that The processing of the target data in the data queue includes: When it is determined that the trigger condition is met, determining whether the target data exists in the data queue; If yes, obtaining the target data from the data queue; According to the network address information in the target data, obtaining a connection matching the target data; The data operation function corresponding to the connection is called to perform corresponding data processing operations on the target data.

3. The method according to claim 2, characterized in that When the trigger condition is met, judging whether the target data exists in the data queue includes: When it is determined that at least one of the following conditions is met, it is determined whether the target data exists in the data queue: Determining that a set duration has been reached; and determining that a data processing instruction has been received.

4. A data processing device, characterized in that: include: A receiving unit, used for receiving target data sent by the network layer through a network filter in the kernel protocol stack; The kernel protocol stack also includes the network layer and the protocol stack, and the target data is user datagram protocol UDP data; A storage unit, for storing the target data in a data queue through the network filter and stopping the transmission of the target data to the protocol stack if it is determined that the target data meets the set transmission condition; wherein the data queue is a lock-free circular queue; and the storage space of the data queue is a shared memory; A processing unit, configured to process the target data in the data queue through an application layer; The storage unit is specifically used for: If the network filter determines that the target data is data to be processed by the local application, a callback function is called to store the target data in the lock-free circular queue, and the callback function is registered in a local entry node in the network filter, and the local entry node is used to receive the data to be processed by the local application; If it is determined that the data blocking success notification returned by the callback function is received, the interrupt task for the target data is terminated, and the interrupt task is a task for transmitting the target data to the protocol stack.

5. The device according to claim 4, characterized in that The processing unit is used for: When it is determined that the trigger condition is met, determining whether the target data exists in the data queue; If yes, obtaining the target data from the data queue; According to the network address information in the target data, obtaining a connection matching the target data; The data operation function corresponding to the connection is called to perform corresponding data processing operations on the target data.

6. The device according to claim 5, characterized in that The processing unit is used for: When it is determined that at least one of the following conditions is met, it is determined whether the target data exists in the data queue: Determining that a set duration has been reached; and determining that a data processing instruction has been received.

7. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 3 is executed.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 3 is executed.

Citation Information

Patent Citations

  • Method and device for realizing high-performance DNS service, computer equipment and storage medium

    CN114401245A