A conversation search method, device, electronic device and storage medium

By generating the target hash values ​​and differential or operational methods, the problem of low seminar search efficiency in existing technology has been solved, and the effect of fast positioning target session is achieved.

CN119052309BActive Publication Date: 2025-01-28BEIJING ANBOTONG TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411546830.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-01
Publication Date
2025-01-28
Estimated Expiration
2044-11-01

AI Technical Summary

Technical Problem

The prior art is inefficient in finding target sessions, mainly due to hash conflicts, and the session quintuplet search process is inefficient.

Method used

By generating the target hash value, determine the target hash barrel, and load the first 5 yuan group of the target pac The same goal of the five -yuan group is the 2nd 5th group, so as to quickly locate the target session.

Benefits of technology

By simplifying the searches of the conflict session, this method improves the determination efficiency of the target session, and significantly improves the search efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119052309B_ABST
    Figure CN119052309B_ABST
Patent Text Reader

Abstract

The present invention relates to a session search method, device, electronic device and storage medium, belonging to the technical field of session search, wherein the method comprises: obtaining a first quintuple of a target message, and generating a target hash value according to the first quintuple; determining a target hash bucket according to the target hash value; storing a plurality of second quintuples in the target hash bucket; a hash value generated according to the second quintuple in the target hash bucket is the same as the target hash value; loading the first quintuple and the second quintuple in the target hash bucket into two registers respectively; performing an XOR operation on the two registers to determine a target second quintuple that is the same as the first quintuple; determining the target session according to the mapping relationship between the target second quintuple and the target session. The present invention can simplify the search process of the conflicting session quintuple, i.e., the second quintuple, and can speed up the comparison speed through the comparison mode of the XOR operation, and more quickly determine the target second quintuple and the target session.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of session search, and in particular to a session search method, device, electronic device and storage medium. Background Art

[0002] Session management is a basic module of traffic processing equipment and plays a vital role in network devices such as firewalls and traffic analysis. All functions of network devices are basically dependent on session management. Therefore, improving the efficiency of session management can significantly reduce data delay and improve throughput.

[0003] The existing technologies are all based on hash to organize sessions and perform session search through hash. In the process of session search, due to hash conflicts, the sessions with hash conflicts (hereinafter referred to as "conflicting sessions") will be organized through a linked list or other data structure. In order to accurately find the target session from each session, it is necessary to traverse and compare the sessions in the linked list or other data structure to find the conflicting session, and then traverse and compare the five-tuples of each conflicting session to determine the target session from the conflicting sessions. This method of finding the target session is inefficient. Summary of the invention

[0004] In view of this, it is necessary to provide a session search method, device, electronic device and storage medium to solve the problem of low efficiency in searching for target sessions in the prior art.

[0005] In order to solve the above problem, in a first aspect, the present invention provides a session search method, comprising:

[0006] Obtain a first quintuple of the target message, and generate a target hash value according to the first quintuple;

[0007] Determine a target hash bucket according to the target hash value; the target hash bucket stores a plurality of second quintuples; the hash value generated according to the second quintuples in the target hash bucket is the same as the target hash value;

[0008] Loading the first quintuple and the second quintuple in the target hash bucket into two registers respectively;

[0009] performing an XOR operation on the two registers to determine a target second quintuple that is the same as the first quintuple;

[0010] The target session is determined according to a mapping relationship between the target second quintuple and the target session.

[0011] Optionally, the number of the second quintuples in the target hash bucket is less than or equal to a preset number threshold, and the preset number threshold is determined according to the data size of the second quintuple and the width of the register.

[0012] Optionally, determining a target hash bucket according to the target hash value includes:

[0013] Searching in a first-level hash table of a preset hash table according to the target hash value to determine a target first node; the first-level hash table includes at least one first node, the first node is connected to a hash bucket, the first node stores a hash value of the hash bucket, the hash value of the hash bucket is the same as a hash value generated according to the second quintuple in the hash bucket; the hash value stored in the target first node is the same as the target hash value;

[0014] The hash bucket connected to the target first node is used as the target hash bucket.

[0015] Optionally, the preset hash table further includes a second-level hash table, the second-level hash table includes at least one second node, a second quintuple and a hash value are stored in the second node, the hash value in the second node is the same as the hash value generated according to the second quintuple in the second node; the hash value in the second node is the same as the hash value in the first node; then the method further includes:

[0016] When the target second quintuple does not exist in the target hash bucket, searching in the second-level hash table according to the target hash value to determine the target second node; the hash value in the target second node is the same as the target hash value;

[0017] Determining whether the second quintuple in the target second node is the same as the first quintuple;

[0018] If the second quintuple in the target second node is the same as the first quintuple, the second quintuple in the target second node is used as the target second quintuple.

[0019] Optionally, determining whether the second quintuple in the target second node is the same as the first quintuple includes:

[0020] Loading the first quintuple and the second quintuple in the target second node into the two registers respectively;

[0021] An XOR operation is performed on the two registers to determine whether the second quintuple in the target second node is the same as the first quintuple.

[0022] Optionally, when the target second quintuple does not exist in the target hash bucket, searching in the second-level hash table according to the target hash value includes:

[0023] Determine whether the number of second quintuples in the target hash bucket is equal to a preset number threshold;

[0024] If the number of the second quintuples in the target hash bucket is not equal to the preset number threshold, then when the target second quintuple does not exist in the target hash bucket, no search is performed in the second-level hash table according to the target hash value;

[0025] If the number of the second quintuples in the target hash bucket is equal to the preset number threshold, then when the target second quintuple does not exist in the target hash bucket, a search is performed in the second-level hash table according to the target hash value.

[0026] Optionally, the target hash value is calculated according to the first quintuple and a first hash function; and the method further includes:

[0027] If the second quintuple in the target second node is different from the first quintuple, generating a new target hash value according to the first quintuple and a second hash function; the second hash function is different from the first hash function;

[0028] Searching in the second-level hash table according to the new target hash value to determine a new target second node;

[0029] Determining whether the second quintuple in the new target second node is the same as the first quintuple;

[0030] If the second quintuple in the new target second node is the same as the first quintuple, the second quintuple in the new target second node is used as the target second quintuple.

[0031] In a second aspect, the present invention further provides a session search device, comprising:

[0032] A first five-tuple acquisition module, used to acquire a first five-tuple of a target message and generate a target hash value according to the first five-tuple;

[0033] a target hash bucket determining module, configured to determine a target hash bucket according to the target hash value; the target hash bucket stores a plurality of second quintuples; a hash value generated according to the second quintuples in the target hash bucket is the same as the target hash value;

[0034] A loading module, used to load the first quintuple and the second quintuple in the target hash bucket into two registers respectively;

[0035] a comparison module, configured to perform an XOR operation on the two registers to determine a target second quintuple that is identical to the first quintuple;

[0036] The target session determination module is used to determine the target session according to the mapping relationship between the target second quintuple and the target session.

[0037] In a third aspect, the present invention also provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a program; and the processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps in any one of the above-mentioned session search methods.

[0038] In a fourth aspect, the present invention further provides a computer-readable storage medium for storing a computer-readable program, wherein the program or instructions, when executed by a processor, can implement the steps in any one of the above-mentioned session search methods.

[0039] The beneficial effects of the present invention are:

[0040] The present invention uniformly stores the quintuples of conflicting sessions with the same hash value in a hash bucket. Then, when a target message is obtained and the target session needs to be searched according to the target message, the target hash value can be obtained according to the target message, and the target hash bucket can be searched according to the target hash value, thereby simplifying the search process of the conflicting session quintuple (multiple second quintuples in the target hash bucket). Afterwards, the first quintuple of the target message and the second quintuple in the target hash bucket are loaded into a register, and an XOR operation is performed on the register, so that the target second quintuple that is the same as the first quintuple can be compared and determined at one time. Then, the target session is determined according to the mapping relationship between the target second quintuple and the target session, thereby improving the efficiency of determining the target session. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 A flowchart of an embodiment of a session search method provided by the present invention;

[0042] Figure 2 A flowchart of another embodiment of the session search method provided by the present invention;

[0043] Figure 3 A schematic diagram of a preset hash table provided by the present invention;

[0044] Figure 4 A hash bucket storage schematic diagram provided by the present invention;

[0045] Figure 5 A schematic diagram of a session data mapping relationship provided by the present invention;

[0046] Figure 6 A schematic diagram of the structure of an embodiment of the session search device provided by the present invention. DETAILED DESCRIPTION

[0047] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying 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 those skilled in the art without creative work are within the scope of protection of the present invention.

[0048] In the description of the embodiments of the present invention, unless otherwise specified, "multiple" means two or more than two. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" may mean: A exists alone, A and B exist at the same time, and B exists alone.

[0049] The descriptions of "first", "second", etc. involved in the embodiments of the present invention are only for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the technical features defined as "first" and "second" may explicitly or implicitly include at least one of the features.

[0050] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present invention. The appearance of the phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0051] Network devices can communicate and interact through messages, and the process of communication and interaction between network devices is recorded through sessions. Therefore, the five-tuple of the message will be recorded in the session. The five-tuple includes: source Internet Protocol (IP) address, destination IP address, source port, destination port and network communication protocol number. The interaction content will also be recorded in the session.

[0052] The prior art usually calculates the hash value of a session based on the five-tuple of the session, and the hash value of the session is used to index and search the session. The five-tuples of different sessions are different, but the hash values ​​may be the same. Therefore, when the hash values ​​of two sessions are the same but the five-tuples are different, the two sessions are conflicting sessions, and there can be two or more conflicting sessions.

[0053] In view of the fact that in the prior art, the process of searching for conflicting sessions and determining a target session from conflicting sessions is inefficient, the present invention proposes a session management method to solve this problem.

[0054] Reference Figure 1, shows a flow chart of an embodiment of a session search method provided by the present invention, the method comprising:

[0055] S101, obtaining a first quintuple of a target message, and generating a target hash value according to the first quintuple.

[0056] When a network device communicates and interacts through a message, it is necessary to find a corresponding session based on the message to record the interactive content in the message into the corresponding session and / or find the context of the interactive content from the corresponding session. The target message may be a message of a to-be-determined corresponding session, and the quintuple in the target message is the first quintuple. The process of generating a target hash value based on the first quintuple is prior art and will not be described in detail herein.

[0057] S102, determining a target hash bucket according to the target hash value; the target hash bucket stores a plurality of second quintuples; and a hash value generated according to the second quintuples in the target hash bucket is the same as the target hash value.

[0058] The hash bucket may be indexed and searched according to the target hash value to determine the target hash bucket from the hash buckets.

[0059] The target hash bucket stores multiple second quintuples of sessions, and multiple hash values ​​can be obtained by performing hash calculations on the multiple second quintuples, and the multiple hash values ​​are all the same as the target hash value. That is, the target hash bucket stores multiple quintuples of conflicting sessions, and the hash values ​​of the multiple conflicting sessions are the same as the target hash value.

[0060] S103, load the first quintuple and the second quintuple in the target hash bucket into two registers respectively.

[0061] The register may be a Z-Register Memory Management Unit (ZMM) register or a NEON register (a register in the ARM architecture). The first quintuple and the second quintuple in the target hash bucket may be loaded into two ZMM registers respectively through the AVX512 instruction set, or the first quintuple and the second quintuple in the target hash bucket may be loaded into two NEON registers respectively through the NEON instruction set.

[0062] S104, performing an XOR operation on the two registers to determine a target second quintuple that is the same as the first quintuple.

[0063] An XOR operation can be performed on two ZMM registers through the AVX512 instruction set, or an XOR operation can be performed on two NEON registers through the NEON instruction set to obtain an XOR operation result, which includes the similarities and differences between the first quintuple and each second quintuple in the target hash bucket.

[0064] S105: Determine the target session according to the mapping relationship between the target second quintuple and the target session.

[0065] If the XOR operation result indicates that among the second quintuples in the target hash bucket, there is a target second quintuple that is the same as the first quintuple, the target session may be determined according to the mapping relationship between the target second quintuple and the target session.

[0066] The present invention uniformly stores quintuples of conflicting sessions with the same hash value in a hash bucket. When a target message is obtained and a target session needs to be searched according to the target message, a target hash value can be obtained according to the target message, and a target hash bucket can be searched according to the target hash value, thereby simplifying the search process of the conflicting session. Afterwards, the first quintuple of the target message and the second quintuple in the target hash bucket are loaded into a register, and an XOR operation is performed on the register, so that the target second quintuple and the target session corresponding to the target second quintuple can be compared and determined at one time, thereby improving the determination efficiency of the target session.

[0067] In one embodiment, the number of the second quintuples in the target hash bucket is less than or equal to a preset number threshold, and the preset number threshold is determined according to the data size of the second quintuple and the width of the register.

[0068] Register width refers to the number of binary bits that a register can store, usually in bits. The width of a register determines the amount of data that the register can store and its processing power. Different processor architectures and instruction sets have different register widths.

[0069] In an example of this embodiment, if the message is an IPv4 message, the quintuple of the IPv4 message occupies a total of 13 bytes; the register is a ZMM register, and the width of the ZMM register is 512 bits (64 bytes), that is, one AVX512 operation can load 64 bytes of data into the ZMM register. Then the preset quantity threshold can be 4, that is, a maximum of 4 second quintuples can be stored in the target hash bucket, totaling 52 bytes. This embodiment limits the number of second quintuples stored in the target hash bucket, so that when the second quintuple in the target hash bucket is loaded into the ZMM register, it can be loaded all at once.

[0070] In this example, when the preset quantity threshold is 4, 4 session storage spaces can be set in the target hash bucket, and the size of each session storage space is set to 16 bytes, of which 13 bytes are used to store the quintuple of the IPv4 message, and 3 bytes are reserved for other dimensions, such as interface number, link number, etc.

[0071] In this example, the process of loading and determining the target second 5-tuple may include:

[0072] (1) Store the value of the first quintuple into four 512-bit ZMM registers.

[0073] __m512i tuple = _mm512_set_epi64( tuple_high, tuple_high, tuple_high,tuple_high, tuple_low, tuple_low, tuple_low, tuple_low, tuple_high, tuple_high, tuple_high, tuple_high, tuple_low, tuple_low, tuple_low, tuple_low );

[0074] Since AVX512 cannot handle 128-bit values, the 128-bit value is split into high 64 bits and low 64 bits.

[0075] (2) Load the second quintuple from the four session storage spaces of the target hash bucket into another ZMM register at one time.

[0076] __m512i hash_bucket = hashtable[h]; / / h is the hash value, hashtable[h] is the address of the corresponding bucket

[0077] (3) Perform an XOR operation.

[0078] __m512i result = _mm512_xor_si512(tuple, hash_bucket)

[0079] If the two values ​​are exactly the same, the result of the XOR operation is 0, otherwise it is non-zero.

[0080] (4) Obtain the result of the XOR operation.

[0081] There are 4 128 bits in the XOR operation result. If the XOR operation result corresponding to one of the 128 bits is 0, it means that the target second quintuple is found.

[0082] In this example, the 4 second quintuples in the target hash bucket can be loaded into the AVX512 register (ZMM register) at one time through the AVX512 instruction, and then the first quintuple of the IPv4 packet (target packet) is also loaded into the ZMM register. By performing an XOR operation on the two ZMM registers, the first quintuple can be compared with the 4 second quintuples at one time with a single instruction, while the traditional method requires 4×5=20 comparisons (4 sessions, 5 tuples for each session).

[0083] In an embodiment, the preset quantity threshold may not be determined according to the data size of the second quintuple and the width of the register.

[0084] For example, if the message is an IPv6 message, the quintuple of the IPv6 message occupies a total of 37 bytes; the register is a ZMM register, the width of the ZMM register is 512 bits (64 bytes), and the preset quantity threshold can also be set to 4, but the second quintuple in the target hash bucket needs to be loaded into the ZMM register in sequence, and the 4 second quintuples in the target hash bucket cannot be loaded into the ZMM register at one time. However, after loading the second quintuple in the target hash bucket into the ZMM register in sequence, the first quintuple is loaded into another ZMM register, and the two ZMM registers are XORed to determine the target second quintuple and the target session corresponding to the target second quintuple, which is still much faster than the traditional method of comparing session by session and field by field. However, compared with the above example of IPv4 message, there are several times more instruction cycles, and the efficiency improvement is not as obvious as the above example.

[0085] Reference Figure 2 , shows a flow chart of another embodiment of the session search method provided by the present invention, the method comprising:

[0086] S201, obtaining a first quintuple of a target message, and generating a target hash value according to the first quintuple.

[0087] S202, searching in a first-level hash table of a preset hash table according to the target hash value to determine a target first node.

[0088] The preset hash table may include a first-level hash table and a second-level hash table.

[0089] The first-level hash table may include at least one first node, each first node is connected to a hash bucket, and the hash value of the hash bucket may be stored in the first node. A plurality of second quintuples may be stored in each hash bucket, and the hash value of the hash bucket is the same as the hash value generated according to the second quintuple in the hash bucket. The number of second quintuples in the hash bucket may be less than or equal to a preset number threshold, and the preset number threshold is determined according to the data size of the second quintuple and the width of the register.

[0090] The hash value stored in the target first node is the same as the target hash value.

[0091] The second-level hash table may include at least one second node, each of which may store a second five-tuple and a hash value, the hash value in the second node being the same as the hash value generated according to the second five-tuple in the second node. The hash value in the second node is the same as the hash value in the first node;

[0092] Because the number of second quintuples that can be stored in a hash bucket is limited, if the hash bucket has already stored 4 second quintuples, reaching the preset number threshold, then the new hash conflict session cannot be stored in the hash bucket. Therefore, in this embodiment, a second-level hash table is set, which is located at the bottom of the preset hash table. When the hash bucket is full, the second quintuple of the new conflicting session is stored in the second-level hash table. According to actual network traffic experience, in most cases there will be no more than 4 conflicting sessions, and most queries will end at the first-level hash table, which has extremely high query efficiency.

[0093] S203: Use the hash bucket connected to the target first node as the target hash bucket.

[0094] S204, load the first quintuple and the second quintuple in the target hash bucket into two registers respectively.

[0095] S205 , performing an XOR operation on the two registers to determine a target second quintuple that is the same as the first quintuple.

[0096] The first quintuple and the second quintuple in the target second node may be loaded into two registers respectively; an XOR operation is performed on the two registers to determine whether the second quintuple in the target second node is the same as the first quintuple. Alternatively, the first quintuple and the second quintuple in the target second node may be compared without loading into the registers according to the comparison method of the prior art.

[0097] S206: When the target second quintuple does not exist in the target hash bucket, search in the second-level hash table according to the target hash value to determine the target second node.

[0098] The hash value in the target second node is the same as the target hash value.

[0099] S207, determining whether the second quintuple in the target second node is the same as the first quintuple.

[0100] S208: If the second quintuple in the target second node is the same as the first quintuple, the second quintuple in the target second node is used as the target second quintuple.

[0101] S209: Determine the target session according to the mapping relationship between the target second quintuple and the target session.

[0102] This embodiment can ensure the reasonable setting of the hash bucket size by setting the second-level hash table, so that the storage space of the hash bucket is more efficiently utilized. At the same time, if a new conflicting session exceeds the storage space of the hash bucket, the second quintuple of the new conflicting session can be stored in the second-level hash table to avoid missing the conflicting session.

[0103] In one embodiment, S206 may specifically include: determining whether the number of second quintuples in the target hash bucket is equal to a preset number threshold; if the number of second quintuples in the target hash bucket is not equal to the preset number threshold, then when the target second quintuple does not exist in the target hash bucket, no longer searching in the second-level hash table according to the target hash value; if the number of second quintuples in the target hash bucket is equal to the preset number threshold, then when the target second quintuple does not exist in the target hash bucket, searching in the second-level hash table according to the target hash value.

[0104] If the number of the second five-tuple in the target hash bucket is equal to the preset number threshold, it means that the target hash bucket is full, and it is necessary to further search the second-level hash table; if the number of the second five-tuple in the target hash bucket is not equal to the preset number threshold, it means that there are empty spaces in the target hash bucket and it is not full. At this time, there is no need to further search the second-level hash table, because only when the session bits in the corresponding hash bucket are full will they be stored in the second-level hash table.

[0105] In one embodiment, the target hash value is calculated based on the first quintuple and the first hash function; the method also includes: if the second quintuple in the target second node is different from the first quintuple, a new target hash value is generated based on the first quintuple and the second hash function; the second hash function is different from the first hash function; searching in the second-level hash table according to the new target hash value to determine the new target second node; judging whether the second quintuple in the new target second node is the same as the first quintuple; if the second quintuple in the new target second node is the same as the first quintuple, the second quintuple in the new target second node is used as the target second quintuple; if the second quintuple in the new target second node is different from the first quintuple, hash calculation and search can be performed again, and a maximum of 3 hash searches can be performed. If the session is still not found, the query ends.

[0106] In this embodiment, in order to ensure efficiency, after recalculation, the search is no longer performed in the first-level hash table, but directly in the conflict area.

[0107] To ensure reliability, you can add another level of hash table. When the session is not found after querying the second level hash table three times, you can query the traditional session management table.

[0108] Reference Figure 3 , showing a schematic diagram of a preset hash table provided by the present invention. The first column is a preset hash table, the preset hash table has n+m nodes, the first n nodes are the first-level hash table, and the last m nodes are the second-level hash table. Each node of the first-level hash table is connected to a hash bucket, and each hash bucket has 4 conflicting session storage bits. This embodiment improves the session query efficiency several times on the same device compared to the traditional hash+linked list method through a reorganized session storage structure, a multi-level hash table, and full use of AVX512.

[0109] Reference Figure 4 , showing a hash bucket storage schematic diagram provided for the present invention. Since the size of each hash bucket is determined, a connected memory space is directly applied for according to the size of the hash bucket. Since this is a continuous memory space, each hash bucket is also aligned with 128 bits. The total memory size is (16 bytes × 4) × n + 16 × m, where n is the number of hash buckets and m is the number of nodes in the second-level hash table. Apply at one time, so that the addresses of all hash buckets are aligned, and the memory in the hash bucket is also continuous, which is conducive to AVX512 instruction set operations.

[0110] Specifically, it can be achieved through the following code:

[0111] uin64_t total_mem = ; / / Total memory space required

[0112] = aligned_alloc(64, total_mem); / / Apply for total memory, aligned to 64 bytes

[0113] char hashtable[n][4]; / / session table

[0114] char hashcolllision[m]; / / Conflict table

[0115] hashtalbe = mem; / /

[0116] hashcollission = mem + ; / / The memory after the session table is the conflict table

[0117] The session table is the first-level hash table, and the conflict table is the second-level hash table.

[0118] In one embodiment, the process of creating a preset hash table is as follows:

[0119] (1) If there is free space in the hash bucket, the session is written directly.

[0120] (2) If there is no free position in the hash bucket, the same hash value is used to locate the hash conflict table. If the position is free, the session is written. If it is not free, hash calculation is performed again. A maximum of three hash calculations are performed to find a free position.

[0121] (3) To ensure reliability, one more level of hashing can be added, namely the traditional session management hashing structure. If no free position is found after three hashing operations in the hash conflict area, the session will be written into the traditional session management table.

[0122] The default hash table deletion process is as follows:

[0123] The deletion process is exactly the same as the search process. After finding the session, just set all the session positions to 0.

[0124] Reference Figure 5 , showing a session data mapping relationship diagram provided by the present invention. A session table with only five tuples has no practical use significance. It is necessary to establish a pointer array, in which the pointers point to the session data stored in the session. The session table and the pointer array are associated through array subscripts, and the session data can be obtained through simple mapping. For example, for the session table, the hash value × 4 + the position number in the bucket can be used to obtain the subscript of the session in the session data array; for the conflict table, n + hash value can be used to obtain the subscript of the session in the data array.

[0125] Reference Figure 6 , shows a schematic diagram of the structure of an embodiment of a session search device provided by the present invention, wherein the device 30 comprises:

[0126] A first quintuple acquisition module 301, configured to acquire a first quintuple of a target message and generate a target hash value according to the first quintuple;

[0127] The target hash bucket determining module 302 is used to determine the target hash bucket according to the target hash value; the target hash bucket stores a plurality of second quintuples; the hash value generated according to the second quintuples in the target hash bucket is the same as the target hash value;

[0128] A loading module 303, used to load the first quintuple and the second quintuple in the target hash bucket into two registers respectively;

[0129] A comparison module 304, configured to perform an XOR operation on the two registers to determine a target second quintuple that is identical to the first quintuple;

[0130] The target session determination module 305 is configured to determine the target session according to the mapping relationship between the target second quintuple and the target session.

[0131] It should be noted that the implementation principle or implementation process of the above modules can refer to the embodiment of the above-mentioned method for determining the measurement error of the mutual inductor, and will not be described one by one here.

[0132] In one embodiment, the present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of any of the above-mentioned session search methods are implemented.

[0133] In one embodiment, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by the processor, the steps of any one of the above-mentioned session search methods are implemented.

[0134] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.

[0135] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.

Claims

1. A session search method, characterized in that: include: Obtain a first quintuple of the target message, and generate a target hash value according to the first quintuple; Determine a target hash bucket according to the target hash value; The target hash bucket stores a plurality of second quintuples; the hash value generated according to the second quintuples in the target hash bucket is the same as the target hash value; Loading the first quintuple and the second quintuple in the target hash bucket into two registers respectively; performing an XOR operation on the two registers to determine a target second quintuple that is the same as the first quintuple; Determine the target session according to the mapping relationship between the target second quintuple and the target session; Wherein, determining the target hash bucket according to the target hash value includes: Searching in a first-level hash table of a preset hash table according to the target hash value to determine a target first node; the first-level hash table includes at least one first node, the first node is connected to a hash bucket, the first node stores a hash value of the hash bucket, the hash value of the hash bucket is the same as a hash value generated according to the second quintuple in the hash bucket; the hash value stored in the target first node is the same as the target hash value; The hash bucket connected to the target first node is used as the target hash bucket; The preset hash table also includes a second-level hash table, the second-level hash table includes at least one second node, the second node stores a second quintuple and a hash value, the hash value in the second node is the same as the hash value generated according to the second quintuple in the second node; the hash value in the second node is the same as the hash value in the first node; the target hash value is calculated according to the first quintuple and the first hash function; the method further includes: When the target second quintuple does not exist in the target hash bucket, searching in the second-level hash table according to the target hash value to determine the target second node; the hash value in the target second node is the same as the target hash value; Determining whether the second quintuple in the target second node is the same as the first quintuple; If the second quintuple in the target second node is the same as the first quintuple, taking the second quintuple in the target second node as the target second quintuple; If the second quintuple in the target second node is different from the first quintuple, generating a new target hash value according to the first quintuple and a second hash function; the second hash function is different from the first hash function; Searching in the second-level hash table according to the new target hash value to determine a new target second node; Determining whether the second quintuple in the new target second node is the same as the first quintuple; If the second quintuple in the new target second node is the same as the first quintuple, the second quintuple in the new target second node is used as the target second quintuple.

2. The session search method according to claim 1, characterized in that: The number of the second quintuples in the target hash bucket is less than or equal to a preset number threshold, and the preset number threshold is determined according to the data size of the second quintuple and the width of the register.

3. The session search method according to claim 1, characterized in that: The determining whether the second quintuple in the target second node is the same as the first quintuple includes: Loading the first quintuple and the second quintuple in the target second node into the two registers respectively; An XOR operation is performed on the two registers to determine whether the second quintuple in the target second node is the same as the first quintuple.

4. The session search method according to claim 1, characterized in that: When the target second quintuple does not exist in the target hash bucket, searching in the second-level hash table according to the target hash value includes: Determine whether the number of second quintuples in the target hash bucket is equal to a preset number threshold; If the number of the second quintuples in the target hash bucket is not equal to the preset number threshold, then when the target second quintuple does not exist in the target hash bucket, no search is performed in the second-level hash table according to the target hash value; If the number of the second quintuples in the target hash bucket is equal to the preset number threshold, then when the target second quintuple does not exist in the target hash bucket, a search is performed in the second-level hash table according to the target hash value.

5. A session search device, characterized in that: include: A first five-tuple acquisition module, used to acquire a first five-tuple of a target message and generate a target hash value according to the first five-tuple; A target hash bucket determination module, used to determine a target hash bucket according to the target hash value; The target hash bucket stores a plurality of second quintuples; The hash value generated according to the second quintuple in the target hash bucket is the same as the target hash value; A loading module, used to load the first quintuple and the second quintuple in the target hash bucket into two registers respectively; a comparison module, configured to perform an XOR operation on the two registers to determine a target second quintuple that is identical to the first quintuple; a target session determination module, configured to determine the target session according to a mapping relationship between the target second quintuple and the target session; The target hash bucket determination module is further used to search in a first-level hash table of a preset hash table according to the target hash value to determine a target first node; the first-level hash table includes at least one first node, the first node is connected to a hash bucket, the first node stores a hash value of the hash bucket, the hash value of the hash bucket is the same as the hash value generated according to the second quintuple in the hash bucket; the hash value stored in the target first node is the same as the target hash value; the hash bucket connected to the target first node is used as the target hash bucket; The preset hash table also includes a second-level hash table, the second-level hash table includes at least one second node, the second node stores a second quintuple and a hash value, the hash value in the second node is the same as the hash value generated according to the second quintuple in the second node; the hash value in the second node is the same as the hash value in the first node; the target hash value is calculated according to the first quintuple and the first hash function; the device is also used to: When the target second quintuple does not exist in the target hash bucket, searching in the second-level hash table according to the target hash value to determine the target second node; the hash value in the target second node is the same as the target hash value; Determining whether the second quintuple in the target second node is the same as the first quintuple; If the second quintuple in the target second node is the same as the first quintuple, taking the second quintuple in the target second node as the target second quintuple; If the second quintuple in the target second node is different from the first quintuple, generating a new target hash value according to the first quintuple and a second hash function; the second hash function is different from the first hash function; Searching in the second-level hash table according to the new target hash value to determine a new target second node; Determining whether the second quintuple in the new target second node is the same as the first quintuple; If the second quintuple in the new target second node is the same as the first quintuple, the second quintuple in the new target second node is used as the target second quintuple.

6. An electronic device, characterized in that: comprising a memory and a processor, wherein: The memory is used to store programs; The processor is coupled to the memory and is used to execute the program stored in the memory to implement the steps of the session search method described in any one of claims 1 to 4 above.

7. A computer-readable storage medium, characterized in that: Used to store a computer-readable program, wherein when the program or instruction is executed by a processor, the steps of the session search method described in any one of claims 1 to 4 can be implemented.

Citation Information

Patent Citations

  • Method, device and apparatus for message forwarding of firewall equipment, and storage medium

    CN109361609A

  • Data packet forwarding system

    CN116723150A