Serial plugging method and device based on deep data packet detection, and medium

By using the packet receiving and forwarding module and the business blocking module in the serial blocking equipment, the data packet information group is processed according to the preset rules, which solves the problem of difficulty in achieving low-latency forwarding with traditional technology and improves the blocking efficiency and real-time service sex.

CN118784358APending Publication Date: 2024-10-15EVERSEC BEIJING TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411096200.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-09
Publication Date
2024-10-15

AI Technical Summary

Technical Problem

While traditional serial blocking technology ensures network security, it is difficult to achieve low-latency traffic forwarding and cannot meet some application scenarios that require high real-time performance.

Method used

By introducing the packet receiving and forwarding module and the business blocking module into the serial blocking device, the data packet information group in the network card is generated, and detected and processed according to the preset blocking rules, and multiple blocking threads are used to improve blocking efficiency. , Reduce the processing and forwarding response time of network data packets.

Benefits of technology

It improves the parsing efficiency and blocking efficiency of data packets, ensures the real-time nature of the business, and meets the requirements for low-latency forwarding.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118784358A_ABST
    Figure CN118784358A_ABST
Patent Text Reader

Abstract

The invention discloses a serial blocking method and device based on deep data packet detection and a medium. The method is applied to the serial plugging equipment, the serial plugging equipment at least comprises a network card, a packet receiving and forwarding module and a service plugging module, and the method comprises the following steps: generating a data packet information group of at least two flow packets in the network card according to the packet receiving and forwarding module; determining at least one piece of data packet information detected by a preset blocking rule in the data packet information group based on the packet receiving and forwarding module; and blocking a target traffic packet according to a blocking thread of the service blocking module, the target traffic packet corresponding to the data packet information passing the inspection. According to the embodiment of the invention, the response time for processing and forwarding the network data packet can be reduced, the flow processing efficiency is improved, and the real-time performance of the service can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security technology, and in particular to a serial blocking method, device and medium based on deep data packet inspection. Background Art

[0002] As a network security technology, deep packet inspection can identify and handle various complex network applications and threats by deeply analyzing data packets in network traffic. At present, it is combined with blocking technology to block network traffic and prevent bad traffic from entering the network. Blocking methods can include sending specific blocking packets or not forwarding specific access traffic to protect the network from malicious attacks or illegal access. With the advancement of technology, serial blocking has emerged. Serial blocking needs to achieve low-latency traffic forwarding while ensuring network security, requiring an average forwarding delay of less than 200 microseconds. However, traditional serial blocking traffic processing logic often involves multiple steps, including packet reception, flow table establishment, protocol failure, blocking rule matching, packet loss, blocking log output, and normal traffic forwarding. The process is long, resulting in low traffic processing efficiency. Traditional serial blocking technology can no longer meet some application scenarios with high real-time requirements. Summary of the invention

[0003] The present invention provides a serial blocking method, device and medium based on deep data packet inspection to reduce the response time of processing and forwarding network data packets, improve flow processing efficiency, and ensure the real-time performance of services.

[0004] According to one aspect of the present invention, a serial blocking method based on deep data packet inspection is provided, the method is applied to a serial blocking device, the serial blocking device at least includes a network card, a packet receiving and forwarding module and a service blocking module, the method includes:

[0005] Generate a data packet information group of at least two traffic packets in the network card according to the packet receiving and forwarding module;

[0006] Determine at least one data packet information in the data packet information group that has been detected by a preset blocking rule based on the packet receiving and forwarding module;

[0007] The target traffic packet is blocked according to the blocking thread of the service blocking module, wherein the target traffic packet corresponds to the data packet information that has passed the inspection.

[0008] According to another aspect of the present invention, there is provided an electronic device, the electronic device comprising:

[0009] at least one processor; and

[0010] a memory communicatively connected to the at least one processor; wherein,

[0011] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the serial blocking method based on deep data packet inspection described in any embodiment of the present invention.

[0012] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the serial blocking method based on deep data packet inspection described in any embodiment of the present invention when executed.

[0013] The technical solution of the embodiment of the present invention generates data packet information corresponding to at least two traffic packets in the network card through a packet receiving and forwarding module, detects the data packet information group according to the preset blocking rules to determine at least one data packet information that passes the detection, forwards the target traffic packet corresponding to the data packet information to the business blocking module, and performs blocking processing on the target traffic packet based on the blocking thread of the business blocking module. The embodiment of the present invention batch extracts the data packet information of the traffic packet through the packet receiving and forwarding module, which can improve the parsing efficiency of the data packet, and processes the data packet information according to the preset blocking rules in the packet receiving and forwarding module, which can reduce the response time of processing and forwarding of network data packets, and by calling multiple blocking threads in the business blocking module to block the data packet, the blocking efficiency is improved, the flow processing speed can be increased, and the real-time nature of the business can be guaranteed.

[0014] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0016] Figure 1 This is a logic example diagram of an existing serial blocking implementation process provided according to an embodiment of the present invention;

[0017] Figure 2 is a flow chart of a serial blocking method based on deep data packet inspection provided according to an embodiment of the present invention;

[0018] Figure 3is a flow chart of a serial blocking method based on deep data packet inspection provided according to an embodiment of the present invention;

[0019] Figure 4 is a flow chart of a serial blocking method based on deep data packet inspection provided according to an embodiment of the present invention;

[0020] Figure 5 is a flow chart of a serial blocking method based on deep data packet inspection provided according to an embodiment of the present invention;

[0021] Figure 6 is an example diagram of a rule loading process provided according to an embodiment of the present invention;

[0022] Figure 7 is a structural schematic diagram of a serial plugging device provided according to an embodiment of the present invention;

[0023] Figure 8 is an example diagram of a serial blocking process based on deep data packet inspection provided according to an embodiment of the present invention;

[0024] Fig. 9 This is an example diagram of functional interaction of a serial blocking device provided according to an embodiment of the present invention;

[0025] Fig.10 It is a software and hardware environment configuration structure diagram of a serial blocking device provided according to an embodiment of the present invention;

[0026] Fig.11 is a flow chart of a serial blocking method based on deep data packet inspection provided according to an embodiment of the present invention;

[0027] Fig.12 is a diagram showing an example format of a network data packet provided according to an embodiment of the present invention;

[0028] Fig.13 is a flow chart of extracting an offset position according to an embodiment of the present invention;

[0029] Fig.14 is a logical example diagram of a hash table processing provided according to an embodiment of the present invention;

[0030] Fig.15 It is a structural schematic diagram of an electronic device for implementing a serial blocking method based on deep data packet inspection according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0032] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0033] In the embodiment of the present invention, the serial blocking technology reduces the forwarding delay of network traffic packets by optimizing the hardware architecture and improving the data processing speed. These solutions are often difficult to reduce the delay forwarding while maintaining high performance, or need to make compromises in terms of cost or load type. See Figure 1 The existing DPI serial blocking traffic processing logic mainly includes packet forwarding, flow table establishment, protocol identification, blocking rule matching, packet loss, blocking log output, and normal traffic forwarding. Under this processing logic, how to efficiently implement the blocking function and maintain low-latency forwarding becomes a challenge.

[0034] Figure 2 This is a flowchart of a serial blocking method based on deep data packet inspection according to the first embodiment of the present invention. This embodiment is applicable to the case of blocking traffic packets. The method can be executed by a serial blocking device, which includes at least a network card, a packet receiving and forwarding module, and a service blocking module. The serial blocking device can be implemented in the form of hardware and / or software. Figure 2 As shown, the method includes:

[0035] Step 110: Generate a data packet information group of at least two traffic packets in the network card according to the packet receiving and forwarding module.

[0036] Among them, the packet receiving and forwarding module is a software and hardware module for forwarding traffic packets. The packet receiving and forwarding module can forward one or more traffic packets to the service blocking module through a queue, a tree or other temporary storage structure. The packet receiving and forwarding module can be configured with rules for parsing traffic packets. The packet receiving and forwarding module can extract data packet information from the traffic packet. The data packet information group can be a data packet information set. The data packet information group can include one or more data packet information. Each data packet information can be extracted from the traffic packet by the packet receiving and forwarding module. The network card can have the function of encapsulating and decapsulating traffic packets, can encode and decode traffic packets, and can receive traffic packets input from the outside. The traffic packet can be a data transmission unit packaged by a communication protocol. The traffic packet can exist in the form of a data message. The traffic packet can include a data block sent once. The data packet information can be information extracted from the traffic packet. The data packet information can at least include five-tuple information such as source network address, destination network address, source port, destination port and protocol type. The data packet information of multiple traffic packets can constitute the traffic packet information.

[0037] In an embodiment of the present invention, when the network card receives at least two traffic packets, the packet receiving and forwarding module can extract information from the at least two traffic packets received in the network card, and the extracted data packet information can be formed into a data packet information group. It can be understood that the packet receiving and forwarding module can process the information extraction process of the traffic packet simultaneously to reduce the processing delay of the data packet.

[0038] Step 120: Determine at least one data packet in the data packet information group that has been detected by a preset blocking rule based on the packet receiving and forwarding module.

[0039] The preset blocking rule may be a rule configured by the packet receiving and forwarding module, the preset blocking rule may match the data packet information group, the preset blocking rule may specifically match the five-tuple of each data packet information in the data packet information group, and the preset blocking rule may also discard the flow packet of the corresponding data packet information when the match is successful. The preset blocking rule may specifically be a blocking rule set, the preset blocking rule may include one or more blocking rules, each blocking rule may have different matching conditions for data packet information, and operations for processing data packet information, the operations may include packet discard operations, blocking packet data source operations, etc. The data packet information may be information that identifies the characteristics of the flow packet, and the data packet information may include but is not limited to five-tuples and keywords in the regular matching load, etc.

[0040] In an embodiment of the present invention, the packet receiving and forwarding module can be called to obtain the configured preset blocking rules, the preset blocking rules can be matched to each data packet information in the data packet information group, it can be determined whether each data packet information has its corresponding preset blocking rule, and it can be determined whether the five-tuple information or keywords in each data packet information meet the matching conditions of the preset blocking rules.

[0041] Step 130: Perform blocking processing on the target traffic packet according to the blocking thread of the service blocking module, wherein the target traffic packet corresponds to the data packet information that has passed the inspection.

[0042] Among them, the target traffic packet can be the traffic packet corresponding to the data packet information matched by the preset blocking rule of the packet receiving and forwarding module, that is, the data packet information of the target traffic packet does not match the corresponding preset blocking rule in the packet receiving and forwarding module.

[0043] In an embodiment of the present invention, the packet receiving and forwarding module can forward the target traffic packet to different blocking threads of the business blocking module. In the blocking thread, the rules stored locally in the business blocking module, or the rules of the blocking rule server, can be obtained, and the traffic packet can be matched with the above rules. The matching can include matching the quintuple of the traffic packet with the parameters in the rule. If the match is successful, the blocking rule can call the corresponding processing operation in the rule to block the target traffic packet. If the match is not successful, it can be determined that there is no need to block the target traffic packet. Among them, blocking can be specifically achieved by discarding the target traffic packet or not forwarding the target traffic packet.

[0044] In the embodiment of the present invention, the packet receiving and forwarding module generates data packet information corresponding to at least two traffic packets in the network card, detects the data packet information group according to the preset blocking rules to determine at least one data packet information that passes the detection, forwards the target traffic packet corresponding to the data packet information to the service blocking module, and performs blocking processing on the target traffic packet based on the blocking thread of the service blocking module. In the embodiment of the present invention, the packet receiving and forwarding module extracts the data packet information of the traffic packet in batches, which can improve the parsing efficiency of the data packet, and processes the data packet information according to the preset blocking rules in the packet receiving and forwarding module, which can reduce the response time of processing and forwarding of network data packets, and by calling multiple blocking threads in the service blocking module to block the data packet, the blocking efficiency is improved, the flow processing speed can be increased, and the real-time nature of the service can be guaranteed.

[0045] Figure 3 is a flowchart of a serial blocking method based on deep data packet inspection according to an embodiment of the present invention. The embodiment of the present invention is a specific embodiment of the above invention, and describes the process of batch extraction of traffic packets. Figure 3 The method provided in the embodiment of the present invention specifically includes the following steps:

[0046] Step 210: Read the traffic packet in the direct memory access queue of the network card according to the packet receiving and forwarding module.

[0047] Among them, the direct memory access queue can be a buffer queue for receiving multiple traffic packets. The network card can receive traffic packets by setting a direct memory access queue. The purpose of the direct memory access queue is to establish a large buffer. The data received by the network card is stored in the buffer using a circular queue.

[0048] In an embodiment of the present invention, a direct memory access queue may be configured in the network card, and the network card may store one or more received traffic packets in the direct memory access queue. The packet receiving and forwarding module may extract the direct memory access queue of the network card to read the multiple traffic packets stored therein.

[0049] Step 220: Based on the packet receiving and forwarding module, the number of virtual local area network layers is determined according to the virtual local area network information of the traffic packet, and the information reading offset of the data packet information in the traffic packet is determined according to the number of virtual local area network layers.

[0050] Among them, the virtual local area network (VLAN) information can be information that identifies the traffic packet as a virtual local area network traffic packet. The virtual local area network information can specifically include protocol ID information, CFI information, and VID information, etc. The protocol ID can indicate the type of communication protocol used by the traffic packet, the CFI information can indicate whether the MAC address of the traffic packet is in a standard format, and the VID information can indicate the VLAN to which the traffic packet belongs. The virtual local area network information can reflect the message format of the traffic data packet, and the location of the corresponding data packet information can be determined through the virtual local area network information. The location can be represented by the information reading offset. The information reading offset can indicate the offset of the data packet information from the start position or the end position of the traffic packet. The information reading offset can include one or more. The virtual local area network layer number can indicate the information that identifies the working layer number of the traffic packet, indicating whether the traffic packet is a layer 2 communication data packet or a layer 3 communication traffic packet.

[0051] In an embodiment of the present invention, virtual LAN information of a traffic packet can be extracted. For example, virtual LAN information such as protocol ID information, CFI information, and VID information can be determined. The number of virtual LAN layers of a data packet can be determined through the virtual LAN information. Whether the virtual LAN layer number is a data packet for layer 2 communication or a traffic packet for layer 3 communication can be determined. Based on the virtual LAN information and the number of virtual LAN layers, the message protocol format corresponding to the traffic packet can be determined, and the corresponding information reading offset can be determined by the position of the data packet information in the message protocol format.

[0052] Step 230: For each traffic packet, call the packet receiving and forwarding module to read the data packet information according to the corresponding information reading offset, and merge the data packet information into a data packet information group.

[0053] In an embodiment of the present invention, the packet receiving and forwarding module can read information directly in the corresponding field of the traffic packet according to the information reading offset corresponding to each traffic packet for all traffic packets obtained in the network card, and can merge the data packet information of each traffic packet read into a data packet information group.

[0054] Step 240: Determine at least one data packet in the data packet information group that has been detected by a preset blocking rule based on the packet receiving and forwarding module.

[0055] Step 250: Perform blocking processing on the target traffic packet according to the blocking thread of the service blocking module, wherein the target traffic packet corresponds to the data packet information that has passed the inspection.

[0056] In the embodiment of the present invention, a packet receiving and forwarding module is used to read a flow packet in a direct memory access queue of a network card, and the packet receiving and forwarding module is called to determine the virtual local area network information of the flow packet, and the virtual local area network layer number of the flow packet is determined according to the virtual local area network information, and the information reading offset of the corresponding flow packet is determined according to the virtual local area network layer number, and the data packet information is extracted in the corresponding flow packet according to each information reading offset, and each data packet information is merged into a data packet information group, and the data packet information group is detected according to a preset blocking rule to determine at least one data packet information that passes the detection, and the target flow packet corresponding to the data packet information is forwarded to the service blocking module, and the target flow packet is blocked based on the blocking thread of the service blocking module. In the embodiment of the present invention, the packet receiving and forwarding module extracts the data packet information of the flow packet in batches based on the virtual local area network information, which can improve the parsing efficiency of the data packet, and the packet receiving and forwarding module processes the data packet information according to the preset blocking rule, which can reduce the response time of processing and forwarding of the network data packet, and by calling multiple blocking threads in the service blocking module to block the data packet, the blocking efficiency is improved, the flow processing speed can be improved, and the real-time performance of the service can be guaranteed.

[0057] Figure 4 is a flowchart of a serial blocking method based on deep data packet inspection according to an embodiment of the present invention. The embodiment of the present invention is a specific embodiment of the above invention, and describes the process of the packet receiving and forwarding module detecting the blocking rule. Figure 4 The method provided in the embodiment of the present invention specifically includes the following steps:

[0058] Step 310: Generate a data packet information group of at least two traffic packets in the network card according to the packet receiving and forwarding module.

[0059] Step 320: Read the hash rule table storing the preset blocking rules based on the packet receiving and forwarding module.

[0060] Among them, the hash rule table can be a rule table in which preset blocking rules are organized according to a hash structure. The hash rule table can include multiple preset blocking rules, each hash value can correspond to a group of blocking rules, and each group of blocking rules can include at least one blocking rule.

[0061] Specifically, the packet receiving and forwarding module is configured with preset blocking rules, and the preset blocking rules are organized in the structure of a hash table. The hash rule table may include multiple preset blocking rules, each hash value may correspond to a group of blocking rules, each group of blocking rules may include at least one blocking rule, and the hash value in the hash rule table may be obtained by calculating the data packet information. It can be understood that the corresponding blocking rule can be quickly found in the hash rule table by performing hash calculation on the data packet information.

[0062] Step 330: According to the packet receiving and forwarding module, each data packet information in the data packet information group is matched with the preset blocking rules in the hash rule table.

[0063] In an embodiment of the present invention, a packet receiving and forwarding module can simultaneously perform hash calculations on each data packet information in a data packet information group to determine a hash value corresponding to each data packet information. A search can be performed in a hash rule table to determine whether there is a preset blocking rule corresponding to the hash value. If so, the data packet information can be matched with the preset blocking rule. If there is no preset blocking rule corresponding to the hash value of the traffic packet, it can be considered that the traffic packet information has been verified by the packet receiving and forwarding module and can continue to be processed in the service blocking module.

[0064] Step 340: If there is target data packet information that matches the preset blocking rule, the traffic packet corresponding to the target data packet information is discarded.

[0065] The target data packet information may be data packet information for which there is a matching preset blocking rule.

[0066] In an embodiment of the present invention, if there is data packet information with a matching preset blocking rule, the data packet information can be marked as target data packet information, and the traffic packet corresponding to the target data packet information can be discarded, thereby achieving blocking of the target data packet information.

[0067] Step 350: Determine the missed data packet information that does not match the preset blocking rule, and transmit the traffic packet corresponding to the missed data packet information as the target traffic packet to the service blocking module.

[0068] The missed data packet information may be data packet information that does not have a matching preset blocking rule.

[0069] In an embodiment of the present invention, if the hash value corresponding to the data packet information does not find the corresponding preset blocking rule, or the preset blocking rule associated with the hash value corresponding to the data packet information does not match the data packet information, the data packet information can be marked as missed data packet information, the traffic packet corresponding to the missed data packet information can be recorded as the target traffic packet, the target traffic packet can be sent to the service blocking module through the packet receiving and forwarding module, and the service blocking module can perform blocking processing on the target traffic packet.

[0070] Step 360: Perform blocking processing on the target traffic packet according to the blocking thread of the service blocking module, wherein the target traffic packet corresponds to the data packet information that has passed the inspection.

[0071] According to an embodiment of the present invention, a traffic packet of a network card is obtained based on a packet receiving and forwarding module, and a data packet information group of the traffic packet is determined, a hash rule table configured by the packet receiving and forwarding module is extracted, and the hash rule table includes at least one preset blocking rule. The data packet information in the data packet information group is respectively matched with the hash rule table, and the preset blocking rule matched by the data packet information is determined. If the data packet information matches the preset blocking rule, the data packet information is used as the target data packet information, and the traffic packet of the target data packet information is discarded. If the data packet information does not match the preset blocking rule, the data packet information is used as the missed data packet information, and the traffic packet of the missed data packet information is transmitted to the business blocking module as the target traffic packet, and the target traffic packet is blocked based on the blocking thread of the business blocking module. The embodiment of the present invention can improve the parsing efficiency of data packets by batch extracting data packet information of traffic packets through the packet receiving and forwarding module, and realize the matching of multiple data packet information with preset blocking rules in parallel through the hash table, thereby improving the matching efficiency of blocking rules, and reducing the response time of network data packet processing and forwarding. By calling multiple blocking threads in the business blocking module to block the data packets, the blocking efficiency is improved, the flow processing speed can be increased, and the real-time nature of the business can be guaranteed.

[0072] Further, based on the above-mentioned embodiment of the invention, after determining the missed data packet information that does not match the preset blocking rule, it also includes:

[0073] The reference count of the packet receiving and forwarding module is updated according to the number of the missed data packet information.

[0074] The reference count may be count information of a traffic packet used for blocking processing in a service blocking module, and the cache of the network card may be cleared when the reference count is cleared.

[0075] In an embodiment of the present invention, the packet receiving and forwarding module can increment the reference count each time it needs to forward a traffic packet to the service blocking module. Specifically, the packet receiving and forwarding module can count the number of traffic packets that need to be forwarded, that is, the number of traffic packets corresponding to the missed data packet information, at regular intervals, and update the reference count according to the number. It can be understood that the shorter the time interval for counting the number of traffic packets, the more even the rate at which the packet receiving and forwarding module forwards traffic packets, which helps to alleviate the instantaneous pressure of the packet receiving and forwarding module in sending traffic packets and can improve the stability of the packet receiving and forwarding module.

[0076] Based on the above-mentioned embodiment of the invention, when it is determined that the reference count is zero, the data packet memory resource of the network card is released.

[0077] In the embodiment of the present invention, when the reference count in the packet receiving and forwarding module is zero, the data packet memory resource of the network card can be identified, thereby ensuring the stability of the network card.

[0078] Figure 5 is a flowchart of a serial blocking method based on deep data packet inspection according to an embodiment of the present invention. The embodiment of the present invention is a specific embodiment of the above invention, and describes the process of the packet receiving and forwarding module detecting the blocking rule. Figure 5 The method provided in the embodiment of the present invention specifically includes the following steps:

[0079] Step 410: Generate a data packet information group of at least two traffic packets in the network card according to the packet receiving and forwarding module.

[0080] Step 420: Determine at least one data packet in the data packet information group that has been detected by a preset blocking rule based on the packet receiving and forwarding module.

[0081] Step 430: Transmit the target traffic packet forwarded by the packet receiving and forwarding module to the blocking thread.

[0082] In an embodiment of the present invention, the service blocking module can receive the target traffic packet sent by the packet receiving and forwarding module, and assign the target traffic packet to a blocking thread for processing. It can be understood that the service blocking module can adopt a load balancing strategy to distribute the target traffic packet, ensuring the consistency of the target traffic packet processing volume of each blocking thread, thereby improving the processing performance of the service blocking module.

[0083] Step 440: parse the data packet protocol of the target traffic packet based on the blocking thread.

[0084] Among them, the data packet protocol can be the communication protocol of the target traffic packet, and the data packet protocol can be implemented in the blocking thread through protocol identification technology. The protocol identification technology matches the keyword features in the target traffic packet to identify the protocol type used by the target traffic packet.

[0085] In the embodiment of the present invention, the blocking thread may be controlled to perform data packet analysis on the target traffic packet, and the data packet protocol corresponding to the target traffic packet may be identified through keywords included in the data packet.

[0086] Step 450, match the blocking rules corresponding to the data packet protocol with the target traffic packet according to the blocking thread; if the match is successful, call the blocking rules to block the target traffic packet, and send the blocking rules to the hash rule table added to the preset blocking rules; if the match fails, wait for the next target traffic packet to be blocked.

[0087] In an embodiment of the present invention, after identifying the data packet protocol corresponding to the target traffic packet, one or more blocking rules can be matched according to the data packet protocol. The blocking rule can be configured with a service blocking module or server. If there is a blocking rule that matches the target traffic packet, that is, the data packet protocol of the traffic packet meets the conditions in the blocking rule, the blocking rule can be called to block the target traffic packet. The implementation method of the blocking can include but is not limited to: sending a specific blocking packet or not forwarding the traffic packet, etc. If there is no blocking rule corresponding to the target traffic packet, the blocking thread can receive the next target traffic packet, and match and process the blocking rule for the target traffic packet. Specifically, for the blocking rule that successfully matches the target traffic packet, in order to further improve the blocking efficiency, the blocking rule can be added to the hash rule table.

[0088] In an embodiment of the present invention, data packet information corresponding to at least two traffic packets in a network card is generated through a packet receiving and forwarding module, a data packet information group is detected according to a preset blocking rule to determine at least one data packet information that passes the detection, a target traffic packet corresponding to the data packet information is forwarded to a business blocking module, a data packet protocol of the traffic packet is identified according to a blocking thread of the business blocking module, the traffic packet is matched and processed according to the blocking rule of the data packet protocol, for the traffic packet that has been matched successfully, the blocking rule is called to block the traffic packet, and the blocking rule is sent to the hardware rule table of the smart network card; if there is no matching blocking rule for the traffic packet, the traffic packet continues to be waited for processing, and the blocking rules are classified by the data packet protocol, which can reduce the workload of matching the data packet with the blocking rule, and further improve the blocking efficiency of the traffic packet.

[0089] Based on the above-mentioned embodiment of the invention, the serial blocking device further includes a rule management module, and the method further includes:

[0090] Receive and save the first blocking rule issued by the preset rule server according to the rule management module;

[0091] The calling rule management module sends the first blocking rule to the business blocking module;

[0092] Based on the business blocking module, a rule matching handle is created according to the first blocking rule, and the first blocking rule is loaded;

[0093] It is determined that the first blocking rule has been loaded, and the service blocking module is controlled to switch the main rule matching handle to the rule matching handle.

[0094] In an embodiment of the present invention, the preset rule server can send the first blocking rule that needs to be added to the rule management module, the rule management module can send the first blocking rule to the business blocking module, and create a rule matching handle for calling the first blocking rule in the business blocking module. The business blocking module can call the rule matching handle to load the first blocking rule, and after determining that the first blocking rule has been loaded by the business blocking module, the rule matching handle of the business blocking rule can be switched to the rule matching handle, so that the business blocking module can add the first blocking rule according to the rule matching handle.

[0095] In an exemplary embodiment, see Figure 6 , the rule loading process may include:

[0096] 1. The policy server sends blocking rules to the DPI serial blocking device. The rule types are not limited to: blocking strategies such as quintuple, Host, Url and random keywords;

[0097] 2. The rule management module of the DPI blocking device saves the strategy and generates a rule file;

[0098] 3. The rule management module notifies the blocking module to reload the blocking rules;

[0099] 4. The blocking module creates a new rule matching handle and loads all new rules;

[0100] 5. After the blocking module loads the rules, switch the master and slave rule matching handles.

[0101] On the basis of the above-mentioned embodiments of the invention, it also includes: registering the rule release callback function of the preset blocking rule to the rule management module; in response to a deletion request of the preset blocking rule, triggering the rule release callback function according to the rule management module, and deleting the preset blocking rule from the hash rule table.

[0102] In an exemplary embodiment, Figure 7is a schematic diagram of the structure of a serial plugging device provided according to an embodiment of the present invention, see Figure 7 The serial blocking device may include a network card, a rule management module, a packet receiving / forwarding module, a business thread, and a log thread. The serial blocking device may also be connected to an external policy server and a log server, and may obtain blocking rules from an external policy server, and report the log of the blocking process to the log server. The serial blocking program includes two types of rules. One is the native blocking rule, which includes five-tuple blocking and HOST, URL, and random keyword blocking rules. It is managed by the rule management module and sent to the blocking engine. It is used by the blocking engine to match the five-tuple in the data packet and use regular expressions to match keywords in the load and other information. One is the five-tuple blocking rule, which is saved based on the hash algorithm and is used to match the five-tuple information in the traffic. Once a match is made, the packet is directly dropped. After the former is matched, it is converted to the latter. See Figure 8 , the interaction between the functional modules in the serial blocking device can include the following processes:

[0103] 1. The packets received by the packet receiving module are forwarded immediately to achieve low-latency serial forwarding. Otherwise, after a series of business processing such as protocol identification, blocking engine matching, blocking logs, etc., the forwarding delay cannot meet the average forwarding requirement of 200 microseconds.

[0104] 2. The present invention does not rely on a specific network card, and any common 25GE / 100GE / 200GE network card of any manufacturer can be used.

[0105] 3. The packet receiving / forwarding module implements hash fast query rule table without unpacking, and implements matching operation based on five-tuple rules. Once the five-tuple rule is matched, the data packet can be discarded, which greatly saves the pressure of processing data packets on the upper-layer application and improves performance. Not unpacking means that there is no need to parse the IP header, TCP header, and UDP header of the data packet, and there is no need to analyze the specific offsets of these protocol headers. Because the packet receiving / sending module needs to receive, forward, and asynchronously queue very quickly, if the data packet is complicatedly parsed and memory is read and written, it will reduce business processing performance and increase latency.

[0106] 4. The blocking rule matching engine can realize regular expression matching of random keywords, HOST, URL, etc. in data packet payload, which greatly improves the blocking identification capability, while the traditional ACL only supports five-tuple matching.

[0107] For details, see Fig. 9The DPI serial blocking program has three core business threads: packet receiving / sending thread, business processing thread, and blocking rule management thread. The packet receiving / sending thread is responsible for receiving data packets and then checking the blocking rule table. If a match is found, the packet is directly discarded. If a match is found, the packet is directly forwarded. The business processing thread is responsible for data packet parsing, protocol identification, blocking rule matching, and blocking log output. When the blocking rule is matched, it is converted into a five-tuple rule and added to a ring queue. The purpose of adding to the ring queue is to allow the addition and deletion of hashes to be implemented in the blocking rule management thread, thereby realizing the lock-free operation of the hash table. This lock-free operation greatly improves the efficiency of hash parallel processing. The blocking rule management thread is responsible for taking out the rules from the ring queue and adding them to the hash table of the corresponding port.

[0108] In the embodiments of the present invention, see Fig.10 The hardware platform of the present invention can cover: X86-32, X86-64, ARMv7, ARMv8, LoongArch64, Power8 and other hardware platforms. The operating system of the present invention can support: Linux (CentOS, Federa, Ubuntu, Debian, OpenEuler and other mainstream distributions), OpenBSD and the like.

[0109] Specifically, Fig.11 is a flowchart of a serial blocking method based on deep packet inspection according to an embodiment of the present invention, see Fig.11 , the process includes:

[0110] 1. Network card hardware receives packets;

[0111] 2. The application reads a set of packets from the DMA queue;

[0112] 3. Based on this group of data packets, quickly generate and synthesize a group of five-tuple information;

[0113] 4. Match the hash result corresponding to this set of five-tuple information once;

[0114] 5. Process this group of matching results at a time and determine the matching results;

[0115] 6. If it matches, discard it directly;

[0116] 7. If there is no match, the reference count increases by 1;

[0117] 8. Forward data packets;

[0118] 9. Asynchronously go to the business thread for business processing;

[0119] 10. The business thread decodes the data packet;

[0120] 11. The business thread performs protocol identification;

[0121] 12. The business thread matches the blocking rules;

[0122] 13. If the rule is matched, the five-tuple hardware rule is sent to the network card;

[0123] 14. If the rule is matched, the blocking log is output;

[0124] 15. If no match is found, continue to process subsequent messages.

[0125] In the embodiment of the present invention, no matter the deployment scenario of the serial blocking device is an enterprise network, a metropolitan area network or an IDC room, the VLAN level of the message received by the same physical interface is the same, that is, all messages received by an interface either have no VLAN, only one VLAN layer, or two VLAN layers. Based on this assumption, we can easily know the offset of a message's five-tuple in the data packet. See Fig.12 If the packet type is determined to be IPv4 / IPv6 and the number of VLAN layers is determined, the specific position offset of the quintuple extraction can be known. This determination process can be done by Fig.13 The given process determines that when a data packet is received, it is determined whether the interface offset information flag corresponding to the data packet is set. If yes, subsequent operations are performed; if not, the vlan information of the data packet is read; the vlan layer number is analyzed to obtain the offset of the IPv4 / IPv6 quintuple, and the interface is called to set the offset information flag.

[0126] In the embodiment of the present invention, the five-tuple matches the blocking rule through a hash table. Since the algorithm complexity of the HASH search is O(1), it can be ensured that the hash can quickly find the corresponding blocking rule without affecting the forwarding delay of the data packet. There are two core logics involved here, one is the management of the hash table, the addition and deletion of hash table items; the other is the hash batch query. Fig.14 , the overall logical flow can include the following processes:

[0127] 1. The hash table maintenance module registers the flow timeout deletion callback function with the flow management component, so that when the flow times out, the business thread can trigger the deletion operation of the five-tuple blocking rule.

[0128] 2. The packet receiving / forwarding module receives a group of messages from the network card, up to 64 messages, for example, 64 messages are received.

[0129] 3. The packet receiving / forwarding module constructs 64 five-tuple query keys for these 64 messages using the five-tuple position offset extraction method described above, and then performs a hash search to obtain which of these 64 messages hit the blocking rules and which do not hit the blocking rules.

[0130] 4. The messages that match the blocking rules are directly discarded, and reference counts are added to the messages that do not match the rules, and then they are directly forwarded through the network card.

[0131] 5. Send the packets that are not blocked asynchronously to the business thread for DPI deep business analysis. The business thread goes through flow management, data packet decoding, protocol identification, blocking engine rule matching, blocking log processing and other process operations.

[0132] 6.1 If the blocking engine hits the HOST, URL, random keyword strategy, etc., it constructs a new node for the session's five-tuple and asynchronously queues it, preparing to add the five-tuple rule to the hash table.

[0133] 6.2 Flow management module, when deleting the flow table, triggers the callback registered by the hash table maintenance module. If it is found that the session is blocked, the five-tuple of the session is constructed into a deletion node and asynchronously queued to prepare to delete the five-tuple rule from the hash table.

[0134] 7. The blocking rule management thread takes out the added rule nodes from the queue first, adds them to the hash table first, and then takes out the deleted nodes from the queue and deletes them from the hash table. This order of processing is to make the blocking rules take effect first.

[0135] The serial blocking device provided by the embodiment of the present invention has three groups of threads: a packet receiving thread, a business thread, and a blocking rule management thread; these three threads all operate around the five-tuple rule table, the packet receiving thread is responsible for querying the five-tuple hash table, and the business thread adds / deletes the five-tuple information, but does not directly add / delete the hash table, but asynchronously sends the five-tuple information to a lock-free queue, and then the blocking rule management thread uniformly adds / deletes the hash table. The advantage of doing this is that the hash table can be processed without locks. The packet receiving module does not need to lock when querying the hash table, and the blocking rule management thread does not need to lock when adding / deleting the hash table. Lock-free addition and deletion of hash tables can greatly improve the efficiency of concurrent searches.

[0136] Fig.15It is a structural schematic diagram of an electronic device for implementing a serial blocking method based on deep packet inspection of an embodiment of the present invention. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.

[0137] like Fig.15 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.

[0138] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0139] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a serial blocking method based on deep packet inspection.

[0140] In some embodiments, the serial blocking method based on deep packet inspection can be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the operation specification review method described above can be performed. Alternatively, in other embodiments, the processor 11 can be configured to perform the serial blocking method based on deep packet inspection in any other appropriate manner (for example, by means of firmware).

[0141] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0142] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0143] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0144] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).

[0145] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.

[0146] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.

[0147] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.

[0148] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A serial blocking method based on deep data packet inspection, characterized in that: The method is applied to a serial blocking device, which includes at least a network card, a packet receiving and forwarding module, and a service blocking module. The method includes: Generate a data packet information group of at least two traffic packets in the network card according to the packet receiving and forwarding module; Determine at least one data packet information in the data packet information group that has been detected by a preset blocking rule based on the packet receiving and forwarding module; The target traffic packet is blocked according to the blocking thread of the service blocking module, wherein the target traffic packet corresponds to the data packet information that has passed the inspection.

2. The method according to claim 1, characterized in that: The step of generating a data packet information group of at least two traffic packets in the network card according to the packet receiving and forwarding module includes: Reading the traffic packet in the direct memory access queue of the network card according to the packet receiving and forwarding module; Determine the number of virtual local area network layers according to the virtual local area network information of the traffic packet based on the packet receiving and forwarding module, and determine the information reading offset of the data packet information in the traffic packet according to the number of virtual local area network layers; For each of the traffic packets, the packet receiving and forwarding module is called to read the data packet information according to the corresponding information reading offset, and each of the data packet information is merged into the data packet information group.

3. The method according to claim 1, characterized in that: The determining, based on the packet receiving and forwarding module, at least one packet information in the packet information group that has been detected by a preset blocking rule includes: Reading a hash rule table storing the preset blocking rule based on the packet receiving and forwarding module; According to the packet receiving and forwarding module, each of the data packet information in the data packet information group is matched with the preset blocking rule in the hash rule table; If there is target data packet information that matches the preset blocking rule, discard the traffic packet corresponding to the target data packet information; Determine the missed data packet information that does not match the preset blocking rule, and transmit the traffic packet corresponding to the missed data packet information as the target traffic packet to the service blocking module.

4. The method according to claim 1, characterized in that: The blocking process of the target traffic packet according to the blocking thread of the service blocking module includes: Transmitting the target traffic packet forwarded by the packet receiving and forwarding module to the blocking thread; Parsing the data packet protocol of the target traffic packet based on the blocking thread; Matching the blocking rule corresponding to the data packet protocol with the target traffic packet according to the blocking thread; If the match is successful, the blocking rule is called to block the target traffic packet, and the blocking rule is sent to the hash rule table added to store the preset blocking rule; If the match fails, wait for the next target traffic packet to be blocked.

5. The method according to claim 3, characterized in that: After determining the missed data packet information that does not match the preset blocking rule, the method further includes: The reference count of the packet receiving and forwarding module is updated according to the number of the missed data packet information.

6. The method according to claim 5, characterized in that: Also includes: When it is determined that the reference count is zero, the data packet memory resource of the network card is released.

7. The method according to claim 1, characterized in that: The serial blocking device further includes a rule management module, and the method further includes: Receive and save the first blocking rule issued by the preset rule server according to the rule management module; Calling the rule management module to send the first blocking rule to the service blocking module; Creating a rule matching handle based on the service blocking module according to the first blocking rule, and loading the first blocking rule; Determine that the first blocking rule is loaded completely, and control the service blocking module to switch the main rule matching handle to the rule matching handle.

8. The method according to claim 7, characterized in that: Also includes: Registering the rule release callback function of the preset blocking rule to the rule management module; In response to a request to delete the preset blocking rule, the rule release callback function is triggered according to the rule management module to delete the preset blocking rule from the hash rule table.

9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the serial blocking method based on deep packet inspection as described in any one of claims 1-8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the serial blocking method based on deep data packet inspection according to any one of claims 1 to 8 when executed.

Citation Information

Cited By

  • Data traffic transmission method and device, computer equipment, readable storage medium and program product

    CN119583462A