Session management method and device
By receiving and processing session messages in the session management module within the FPGA, calculating hash values and indexes, the problem of low SoC processing performance is solved, efficient session management is achieved, and the performance of network equipment is improved and hardware costs is reduced.
Patent Information
- Application Number
- CN202310015924.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-06
- Publication Date
- 2025-09-02
- Estimated Expiration
- 2043-01-06
AI Technical Summary
The low processing performance of SoC leads to low performance of new session creation and deletion, and the hardware cost is high when selecting FPGAs, so you can only choose chips with SoC.
Implement the session management module in the FPGA. By receiving session messages sent by the CPU, calculate the hash value and hash index, apply for locks, judge hash table entries, and perform session new creation, update or delete processes.
It improves the performance of session management, improves the throughput and concurrency performance of network devices, reduces hardware costs, and reduces FPGA selection restrictions.
Smart Images

Figure CN116389539B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a session management method and device. Background Art
[0002] Session management is a common function abstracted to implement session-based services such as Network Address Translation (NAT), Advanced Stateful Packet Filtering (ASPF), and attack detection and prevention. This function abstracts the interaction between transport layer messages into sessions and performs session status updates and timeouts based on message information from the initiator or responder.
[0003] Session management primarily inspects packets based on transport layer protocols. Essentially, it tracks connection status by inspecting transport layer protocol information (i.e., common TCP and UDP protocols) and centrally maintains and manages this information for all connections. In practice, session management, combined with ASPF, dynamically determines whether packets are allowed through the firewall into the internal zone based on connection status information, thereby preventing malicious intrusions.
[0004] Currently, session management can be performed using a system-on-chip (SoC) based on field programmable gate array (FPGA). This involves dividing the process into corresponding branch processes based on functionality. However, using SoCs for session management also has the following drawbacks: 1) Low SoC processing performance results in poor performance for creating and deleting sessions; 2) When selecting an FPGA, only chips with SoCs can perform session management, resulting in high hardware costs. Summary of the Invention
[0005] In view of this, the present application provides a session management method and device to solve the problem that when SoC is currently used for session management, the processing performance of SoC is low, resulting in low performance of session creation and deletion, and when selecting FPGA, only chips with SoC can be selected for session management, resulting in high hardware costs.
[0006] In a first aspect, the present application provides a session management method, which is applied to a session management module, wherein the session management module is located in an FPGA, and the method includes:
[0007] Receive a session message sent by the CPU, wherein the session message includes a message type, forward message information, and reverse message information;
[0008] Calculating a forward hash value and a reverse hash value according to the forward message information and the reverse message information, respectively, wherein the forward hash value includes a forward hash index and the reverse hash value includes a reverse hash index;
[0009] If the forward hash index is different from the reverse hash index, apply for a forward lock;
[0010] When a forward lock is applied for, determine whether there is a forward hash table entry in the forward hash table that matches the forward hash value;
[0011] If the forward hash table entry does not exist, start a new session process;
[0012] If the forward hash table entry exists, the forward session ID is obtained from the forward hash table entry, and when the reverse lock is applied for, it is determined whether there is a reverse hash table entry in the reverse hash table that matches the reverse hash value;
[0013] If the reverse hash table entry exists, obtaining the reverse session ID from the reverse hash table entry, and determining whether the forward session ID is the same as the reverse session ID;
[0014] If they are the same, obtaining a session table entry that matches either the forward session ID or the reverse session ID from the session table according to either the forward session ID or the reverse session ID;
[0015] If the message type is a session update type, then starting the process of updating the session entry;
[0016] If the message type is a session deletion type, a process of deleting the session entry is started.
[0017] In a second aspect, the present application provides a session management device, the device being applied to a session management module, the session management module being located in an FPGA, the device comprising:
[0018] A receiving unit, configured to receive a session message sent by the CPU, wherein the session message includes a message type, forward message information, and reverse message information;
[0019] a calculation unit, configured to calculate a forward hash value and a reverse hash value according to the forward message information and the reverse message information, respectively, wherein the forward hash value includes a forward hash index and the reverse hash value includes a reverse hash index;
[0020] If the forward hash index is different from the reverse hash index, apply for a forward lock;
[0021] A first judging unit is configured to, when a forward lock is applied for, judge whether there is a forward hash table entry matching the forward hash value in the forward hash table;
[0022] a starting unit, configured to start a new session process if the forward hash table entry does not exist;
[0023] a second determining unit configured to obtain a forward session ID from the forward hash table entry if the forward hash table entry exists, and to determine whether a reverse hash table entry matching the reverse hash value exists in the reverse hash table when a reverse lock is applied for;
[0024] a third determining unit, configured to obtain a reverse session ID from the reverse hash table entry if the reverse hash table entry exists, and determine whether the forward session ID is the same as the reverse session ID;
[0025] an acquiring unit, configured to acquire, from a session table, a session entry matching either the forward session ID or the reverse session ID, if the two are the same;
[0026] The starting unit is further configured to start a process of updating the session entry if the message type is a session update type;
[0027] The starting unit is further configured to start a process of deleting the session entry if the message type is a session deletion type.
[0028] In a third aspect, the present application provides a network device comprising a processor and a machine-readable storage medium, wherein the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to execute the method provided in the first aspect of the present application.
[0029] Therefore, using the session management method and device provided by the present application, the session management module receives a session message sent by the CPU, and the session message includes a message type, forward message information, and reverse message information; the session management module calculates a forward hash value and a reverse hash value based on the forward message information and the reverse message information, respectively, the forward hash value includes a forward hash index, and the reverse hash value includes a reverse hash index; if the forward hash index is different from the reverse hash index, the session management module applies for a forward lock; when the forward lock is applied for, the session management module determines whether there is a forward hash table entry that matches the forward hash value in the forward hash table; if there is no forward hash table entry, the session management module starts a new session process; if there is a forward hash table entry , the session management module obtains the forward session ID from the forward hash table item, and when applying for the reverse lock, determines whether there is a reverse hash table item that matches the reverse hash value in the reverse hash table; if there is a reverse hash table item, the session management module obtains the reverse session ID from the reverse hash table item and determines whether the forward session ID is the same as the reverse session ID; if they are the same, the session management module obtains a session table item that matches either the forward session ID or the reverse session ID from the session table based on either the forward session ID or the reverse session ID; if the message type is a session update type, the session management module starts the session table item update process; if the message type is a session delete type, the session management module starts the session table item deletion process.
[0030] This enables session management through the session management module. This addresses the current issues with SoCs, which suffer from low SoC processing performance, resulting in poor session creation and deletion performance, and high hardware costs, as only FPGAs with SoCs are suitable for session management. This improves session management capabilities, thereby boosting network device throughput and concurrency, while also reducing FPGA selection constraints and hardware costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A flowchart of a session management method provided in an embodiment of the present application;
[0032] Figure 2 A schematic diagram of the session management module structure provided in an embodiment of the present application;
[0033] Figure 3 A structural diagram of a session management device provided in an embodiment of the present application;
[0034] Figure 4 The network device hardware structure provided in the embodiment of the present application. DETAILED DESCRIPTION
[0035] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0036] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the corresponding listed items.
[0037] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0038] The following is a detailed description of a session management method provided by an embodiment of the present application. Figure 1 , Figure 1 Flowchart of the session management method provided in the embodiment of the present application. The method is applied to the session management module. The session management method provided in the embodiment of the present application may include the following steps.
[0039] Step 101: Receive a session message sent by the CPU, where the session message includes a message type, forward message information, and reverse message information.
[0040] Specifically, the session management module is located in the FPGA, and receives a session message sent by a central processing unit (CPU). The session message includes a message type, forward message information, and reverse message information.
[0041] Message types include session creation, session update, and session deletion. Forward message information can be specifically a five-tuple or seven-tuple message sent from network device A to network device B. Reverse message information can be specifically a five-tuple or seven-tuple message sent from network device B to network device A.
[0042] Step 102: Calculate a forward hash value and a reverse hash value based on the forward message information and the reverse message information, respectively. The forward hash value includes a forward hash index, and the reverse hash value includes a reverse hash index.
[0043] Specifically, after obtaining the forward message information and the reverse message information, the session management module calculates a forward hash value and a reverse hash value based on the forward message information and the reverse message information, respectively. The forward hash value includes a forward hash index, and the reverse hash value includes a reverse hash index.
[0044] The process of calculating the hash value based on the message information can refer to the existing calculation process and will not be repeated here. The hash value includes multiple bits, 27 of which can be used as the hash index.
[0045] After obtaining the forward hash index and the reverse hash index, the session management module determines whether the forward hash index and the reverse hash index are the same.
[0046] If the forward hash index and the reverse hash index are different, the session management module executes step 103; if the forward hash index and the reverse hash index are the same, the session management module stops this process.
[0047] Step 103: If the forward hash index is different from the reverse hash index, apply for a forward lock;
[0048] Specifically, according to the determination in step 102 , if the forward hash index is different from the reverse hash index, the session management module applies for a forward lock and determines whether the forward lock is successfully obtained.
[0049] If the forward lock is applied for, the session management module executes step 104; if the forward lock is not applied for, the session management module stops this process.
[0050] Among them, the lock is used to protect the hash table. The lock function is added to prevent the data in the table from being updated, that is, the table cannot be written during the table reading process.
[0051] Step 104: When a forward lock is applied for, determine whether there is a forward hash table entry in the forward hash table that matches the forward hash value;
[0052] Specifically, according to the determination in step 103 , if the session management module applies for the forward lock, the session management module first reads the forward hash table, and then determines whether there is a forward hash table entry in the forward hash table that matches the forward hash value.
[0053] If the forward hash table does not contain the forward hash entry configured with the forward hash value, the session management module executes step 105 ; if the forward hash table contains the forward hash entry configured with the forward hash value, the session management module executes step 106 .
[0054] It is understandable that the forward hash table entry stores the ID of the session table, ie, the forward session ID.
[0055] Step 105: If the forward hash table entry does not exist, start a new session process;
[0056] Specifically, according to the judgment in step 104 , if the forward hash table does not contain a forward hash entry configured with the forward hash value, the session management module starts a new session process.
[0057] In the subsequent description, the process of starting a new session by the session management module will be explained and will not be repeated here.
[0058] Step 106: If the forward hash table entry exists, obtain the forward session ID from the forward hash table entry, and when the reverse lock is applied for, determine whether there is a reverse hash table entry in the reverse hash table that matches the reverse hash value;
[0059] Specifically, according to the judgment in step 104, if the forward hash table contains a forward hash entry configured with the forward hash value, the session management module obtains the forward session ID from the forward hash entry. Then, the session module applies for a reverse lock and determines whether the reverse lock is successfully applied for.
[0060] If the reverse lock is applied for, the session management module first reads the reverse hash table and then determines whether there is a reverse hash table entry that matches the reverse hash value. If the reverse lock is not applied for, the session management module stops this process.
[0061] If a reverse hash table entry configured with the reverse hash value exists in the reverse hash table, the session management module executes step 107 .
[0062] Optionally, if the reverse hash table does not contain a reverse hash entry configured with the forward hash value, the session management module determines whether the reverse hash bucket position is calculated in the reverse hash table. If the reverse hash bucket position is calculated in the reverse hash table, the session management module obtains the assigned reverse session ID and determines whether the forward session ID is the same as the assigned reverse session ID. If the reverse hash bucket position is not calculated in the reverse hash table, the session management module releases the forward lock and the reverse lock and terminates the current process.
[0063] If the forward session ID is the same as the assigned reverse session ID, the session management module updates the reverse hash table and the session table. The above-mentioned updating of the reverse hash table is to add a reverse hash table entry at the reverse hash bucket position calculated according to the assigned reverse session ID, and the reverse hash table entry includes the reverse session ID.
[0064] The session management module releases the forward lock and the reverse lock.
[0065] It should be noted that the reverse hash bucket position is used to indicate the position of the reverse hash table entry in the reverse hash table. If there is still space in the reverse hash table, the reverse hash bucket position can be calculated, that is, the position of the new reverse hash table entry subsequently created in the reverse hash table.
[0066] Step 107: If the reverse hash table entry exists, obtain the reverse session ID from the reverse hash table entry, and determine whether the forward session ID is the same as the reverse session ID;
[0067] Specifically, according to the judgment in step 106, if there is a reverse hash table entry configured with the reverse hash value in the reverse hash table, the session management module passes the reverse session ID from the reverse hash table entry. Then, the session management module determines whether the forward session ID is the same as the reverse session ID.
[0068] If the forward session ID is the same as the reverse session ID, the session management module executes step 108; if the forward session ID is different from the reverse session ID, the session management module stops this process.
[0069] It is understood that the reverse hash table entry stores the session table ID, also known as the reverse session ID. If the forward and reverse session IDs are the same, the forward and reverse message information correspond to the same session. Subsequently, the session management module can retrieve the corresponding session entry from the session table based on either the forward or reverse session ID and perform corresponding processing on the session entry.
[0070] Step 108: If they are the same, then according to either the forward session ID or the reverse session ID, obtain a session table entry that matches either the forward session ID or the reverse session ID from the session table;
[0071] Specifically, according to the fragment of step 107, if the forward session ID is the same as the reverse session ID, the session management module obtains a session table entry matching either the forward session ID or the reverse session ID from the session table.
[0072] Step 109: If the message type is a session update type, start the process of updating the session entry;
[0073] Specifically, the session management module identifies the message type. If the message type is a session update type, the session management module starts a process of updating the session table entry.
[0074] In the subsequent description, the process of starting the session table update by the session management module will be explained and will not be repeated here.
[0075] Step 110: If the message type is a session deletion type, start a process of deleting the session entry.
[0076] Specifically, the session management module identifies the message type. If the message type is a session deletion type, the session management module starts a process of deleting the session entry.
[0077] In the subsequent description, the process of initiating the session entry deletion by the session management module will be explained, which will not be repeated here.
[0078] Therefore, using the session management method and device provided by the present application, the session management module receives a session message sent by the CPU, and the session message includes a message type, forward message information, and reverse message information; the session management module calculates a forward hash value and a reverse hash value based on the forward message information and the reverse message information, respectively, the forward hash value includes a forward hash index, and the reverse hash value includes a reverse hash index; if the forward hash index is different from the reverse hash index, the session management module applies for a forward lock; when the forward lock is applied for, the session management module determines whether there is a forward hash table entry that matches the forward hash value in the forward hash table; if there is no forward hash table entry, the session management module starts a new session process; if there is a forward hash table entry , the session management module obtains the forward session ID from the forward hash table item, and when applying for the reverse lock, determines whether there is a reverse hash table item that matches the reverse hash value in the reverse hash table; if there is a reverse hash table item, the session management module obtains the reverse session ID from the reverse hash table item and determines whether the forward session ID is the same as the reverse session ID; if they are the same, the session management module obtains a session table item that matches either the forward session ID or the reverse session ID from the session table based on either the forward session ID or the reverse session ID; if the message type is a session update type, the session management module starts the session table item update process; if the message type is a session delete type, the session management module starts the session table item deletion process.
[0079] This enables session management through the session management module. This addresses the current issues with SoCs, which suffer from low SoC processing performance, resulting in poor session creation and deletion performance, and high hardware costs, as only FPGAs with SoCs are suitable for session management. This improves session management capabilities, thereby boosting network device throughput and concurrency, while also reducing FPGA selection constraints and hardware costs.
[0080] Optionally, the specific process of the session management module starting the new session process is:
[0081] If the forward hash table does not contain a forward hash entry, the session management module determines whether the forward hash bucket position is calculated in the forward hash table. If the forward hash bucket position is calculated in the forward hash table, the reverse lock is applied; if the forward hash bucket position is not calculated in the forward hash table, the session management module releases the forward lock and stops the current process.
[0082] It should be noted that the forward hash bucket position is used to indicate the position of the forward hash table entry in the forward hash table. If there is still space in the forward hash table, the forward hash bucket position can be calculated, which is the position of the new forward hash table entry created subsequently in the forward hash table.
[0083] When a reverse lock is obtained, the session management module determines whether there is a reverse hash entry in the reverse hash table that matches the reverse hash value. If there is no reverse hash entry in the reverse hash table, the session management module determines whether the reverse hash bucket position is calculated in the reverse hash table. If there is a reverse hash entry in the reverse hash table, the session management module stops the current process.
[0084] If the reverse hash bucket position is calculated in the reverse hash table, the session management module applies for a session ID; if the reverse hash bucket position is not calculated in the reverse hash table, the session management module releases the reverse lock and stops this process.
[0085] If the session ID application is successful, the session management module updates the forward hash table, reverse hash table, and session table and releases the forward lock and reverse lock.
[0086] Optionally, the session message sent by the CPU also includes session update content (session update content includes but is not limited to session port, delay, session negotiation content, etc.). The specific process of the above-mentioned session management module starting the process of updating the session table entry is as follows:
[0087] The session management module determines whether the forward and reverse message information matches the session corresponding to the session ID. If so, the session management module updates the session entry using the session update content. If not, the session management module terminates the process and releases the forward and reverse locks.
[0088] Optionally, the specific process of the session management module initiating the session deletion process is as follows:
[0089] The session management module determines whether the forward and reverse message information matches the session corresponding to the session ID. If so, the session management module clears the valid bits in the forward and reverse hash table entries and deletes them. If the forward and reverse message information do not match the session corresponding to the session ID, the session management module terminates the process, deletes the session table entry, and releases the session ID. The session management module releases the forward and reverse locks.
[0090] Optionally, in the embodiment of the present application, the session management module may include multiple functional modules. Figure 2 As shown, Figure 2 A schematic diagram of the session management module structure provided in an embodiment of the present application.
[0091] exist Figure 2 In the session management module, there are seven functional modules, which are as follows:
[0092] The tpu_rd_sess_hash_c module parses session messages sent by the CPU; applies for a forward lock by calculating the forward hash value and reading the forward hash table; and determines whether the session message type is a new session, an update session, or a delete session.
[0093] The tpu_rd_sess_hash_c module can be connected to the PCIE_TOP module in the CPU to receive session messages sent by the CPU.
[0094] The tpu_rd_sess_hash_s module is used to determine whether the forward hash table match is hit; if so, it starts the update session process or the delete session process; if not, it creates a new forward session; applies for a reverse lock by calculating the reverse hash value, reads the reverse hash, and releases the forward hash lock;
[0095] The tpu_rd_sess module is used to determine whether the reverse hash table match is hit; if it is hit, it starts the update session process or the delete session process; if it is not hit, it creates a new reverse session; if it hits the session hash table, it sends a read session table command based on the sessionID in the table; and releases the reverse session hash lock.
[0096] The tpu_wr_sess module is used to create new sessions, including: applying for new session IDs, refreshing and updating hash tables and session tables, deleting hash tables and session tables, releasing session IDs, and releasing locks.
[0097] The lock_manager module is used to manage the lock application and release of hash tables. The lock function of hash tables is added to prevent the data in the table from being updated, that is, the table cannot be written during the table reading process;
[0098] The sess_id_manager module is used to apply for and release session IDs. It applies for a session ID when creating a new session and releases the session ID when deleting a session.
[0099] The sch_top module is used to read and write forward and reverse hash tables and session table scheduling management.
[0100] The sess_id_manager module and the sch_top module can be connected to the memory module (blade_dd4_sch) respectively to store the session ID, the forward and reverse hash tables, and the session table in the memory module or delete them from the memory module.
[0101] It is understandable that the mutual interaction of the above-mentioned multiple functional modules can implement the various steps performed by the session management module in the above-mentioned embodiment, which will not be repeated here.
[0102] Optionally, in an embodiment of the present application, the session message sent by the CPU includes forward message information and reverse message information, that is, message information for both the forward and reverse links. In actual applications, the session message may include forward message information, that is, message information for the forward link; or reverse message information, that is, message information for the reverse link. If the session message includes one type of message information, during the execution of the aforementioned embodiment, the session management module retains steps consistent with the direction of the message information, while steps in the opposite direction of the message information are no longer executed.
[0103] Based on the same inventive concept, the embodiment of the present application also provides a session management device corresponding to the session management method. Figure 3 , Figure 3A session management device provided in an embodiment of the present application is applied to a session management module, wherein the session management module is located in an FPGA, and the device includes:
[0104] The receiving unit 310 is configured to receive a session message sent by the CPU, wherein the session message includes a message type, forward message information, and reverse message information;
[0105] a calculating unit 320, configured to calculate a forward hash value and a reverse hash value according to the forward message information and the reverse message information, respectively, wherein the forward hash value includes a forward hash index and the reverse hash value includes a reverse hash index;
[0106] An applying unit 330 is configured to apply for a forward lock if the forward hash index is different from the reverse hash index;
[0107] The first judgment unit 340 is used to judge whether there is a forward hash table entry matching the forward hash value in the forward hash table when a forward lock is applied for;
[0108] The starting unit 350 is configured to start a new session process if the forward hash table entry does not exist;
[0109] The second determining unit 360 is configured to obtain a forward session ID from the forward hash table entry if the forward hash table entry exists, and determine whether there is a reverse hash table entry matching the reverse hash value in the reverse hash table when a reverse lock is applied for;
[0110] The third determining unit 370 is configured to obtain a reverse session ID from the reverse hash table entry if the reverse hash table entry exists, and determine whether the forward session ID is the same as the reverse session ID;
[0111] an acquiring unit 380 configured to acquire, from a session table, a session entry that matches either the forward session ID or the reverse session ID, if the two are the same;
[0112] The starting unit 350 is further configured to start a process of updating the session entry if the message type is a session update type;
[0113] The starting unit 350 is further configured to start a process of deleting the session entry if the message type is a session deletion type.
[0114] Optionally, the starting unit 350 is specifically configured to, if the forward hash table entry does not exist, determine whether a forward hash bucket position is calculated in the forward hash table;
[0115] If the forward hash bucket position is calculated in the forward hash table, a reverse lock is requested;
[0116] When the reverse lock is applied for, determining whether there is a reverse hash table entry in the reverse hash table that matches the reverse hash value;
[0117] If the reverse hash table entry does not exist, determining whether a reverse hash bucket position is calculated in the reverse hash table;
[0118] If the reverse hash bucket position is calculated in the reverse hash table, apply for a session ID;
[0119] If the session ID application is successful, the forward hash table, the reverse hash table and the session table are updated;
[0120] Release the forward lock and the reverse lock.
[0121] Optionally, the device further comprises:
[0122] a fourth determining unit (not shown in the figure), configured to determine whether a reverse hash bucket position is calculated in the reverse hash table if the reverse hash table entry does not exist;
[0123] a fifth determination unit (not shown in the figure), configured to obtain the assigned reverse session ID if the reverse hash bucket position is calculated in the reverse hash table, and determine whether the forward session ID is the same as the assigned reverse session ID;
[0124] an updating unit (not shown in the figure), configured to update the reverse hash table and the session table if the two are the same;
[0125] A release unit (not shown in the figure) is used to release the forward lock and the reverse lock.
[0126] Optionally, the session message also includes session update content;
[0127] The starting unit 350 is specifically configured to determine whether the forward message information and the reverse message information match the session corresponding to the session ID;
[0128] If there is a match, updating the session table entry using the session update content;
[0129] Release the forward lock and the reverse lock.
[0130] Optionally, the starting unit 350 is specifically configured to determine whether the forward message information and the reverse message information match the session corresponding to the session ID;
[0131] If they match, clearing the valid bits in the forward hash table entry and the reverse hash table entry, and deleting the forward hash table entry and the reverse hash table entry;
[0132] Deleting the session table entry and releasing the session ID;
[0133] Release the forward lock and the reverse lock.
[0134] Therefore, using the session management device provided by the present application, the session management module receives a session message sent by the CPU, the session message including the message type, forward message information and reverse message information; the session management module calculates a forward hash value and a reverse hash value according to the forward message information and the reverse message information respectively, the forward hash value including a forward hash index, and the reverse hash value including a reverse hash index; if the forward hash index is different from the reverse hash index, the session management module applies for a forward lock; when the forward lock is applied for, the session management module determines whether there is a forward hash table entry in the forward hash table that matches the forward hash value; if no forward hash table entry exists, the session management module starts a new session process; if a forward hash table entry exists, The session management module obtains the forward session ID from the forward hash table entry, and when applying for the reverse lock, determines whether there is a reverse hash table entry that matches the reverse hash value in the reverse hash table; if there is a reverse hash table entry, the session management module obtains the reverse session ID from the reverse hash table entry and determines whether the forward session ID is the same as the reverse session ID; if they are the same, the session management module obtains a session table entry that matches either the forward session ID or the reverse session ID from the session table based on either the forward session ID or the reverse session ID; if the message type is a session update type, the session management module starts the session table entry update process; if the message type is a session delete type, the session management module starts the session table entry deletion process.
[0135] This enables session management through the session management module. This addresses the current issues with SoCs, which suffer from low SoC processing performance, resulting in poor session creation and deletion performance, and high hardware costs, as only FPGAs with SoCs are suitable for session management. This improves session management capabilities, thereby boosting network device throughput and concurrency, while also reducing FPGA selection constraints and hardware costs.
[0136] Based on the same inventive concept, the embodiment of the present application further provides a network device, such as Figure 4 As shown, it includes a processor 410, a transceiver 420 and a machine-readable storage medium 430. The machine-readable storage medium 430 stores machine-executable instructions that can be executed by the processor 410. The processor 410 is prompted by the machine-executable instructions to execute the data acquisition method provided in the embodiment of the present application. Figure 3 The session management device shown can be used as Figure 4 The network device hardware structure shown is implemented.
[0137] The computer-readable storage medium 430 may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Alternatively, the computer-readable storage medium 430 may be at least one storage device located remotely from the processor 410.
[0138] The processor 410 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0139] In the embodiment of the present application, the processor 410 reads the machine-executable instructions stored in the machine-readable storage medium 430, and the machine-executable instructions enable the processor 410 itself and the transceiver 420 to execute the session management method described in the aforementioned embodiment of the present application.
[0140] In addition, an embodiment of the present application provides a machine-readable storage medium 430, which stores machine-executable instructions. When called and executed by the processor 410, the machine-executable instructions prompt the processor 410 itself and the calling transceiver 420 to execute the session management method described in the aforementioned embodiment of the present application.
[0141] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0142] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to the partial description of the method embodiments. The device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.
[0143] As for the session management device and machine-readable storage medium embodiments, since the method contents involved are basically similar to the aforementioned method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0144] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A session management method, characterized in that: The method is applied to a session management module, the session management module being located in an FPGA, and the method comprises: Receive a session message sent by the CPU, wherein the session message includes a message type, forward message information, and reverse message information; Calculating a forward hash value and a reverse hash value according to the forward message information and the reverse message information, respectively, wherein the forward hash value includes a forward hash index and the reverse hash value includes a reverse hash index; If the forward hash index is different from the reverse hash index, apply for a forward lock; When a forward lock is applied for, determine whether there is a forward hash table entry in the forward hash table that matches the forward hash value; If the forward hash table entry does not exist, start a new session process; If the forward hash table entry exists, the forward session ID is obtained from the forward hash table entry, and when the reverse lock is applied for, it is determined whether there is a reverse hash table entry in the reverse hash table that matches the reverse hash value; If the reverse hash table entry exists, obtaining the reverse session ID from the reverse hash table entry, and determining whether the forward session ID is the same as the reverse session ID; If they are the same, obtaining a session table entry that matches either the forward session ID or the reverse session ID from the session table according to either the forward session ID or the reverse session ID; If the message type is a session update type, then starting the process of updating the session entry; If the message type is a session deletion type, a process of deleting the session entry is started.
2. The method according to claim 1, characterized in that If the forward hash table entry does not exist, a new session process is started, specifically including: If the forward hash table entry does not exist, determining whether a forward hash bucket position is calculated in the forward hash table; If the forward hash bucket position is calculated in the forward hash table, a reverse lock is requested; When the reverse lock is applied for, determining whether there is a reverse hash table entry in the reverse hash table that matches the reverse hash value; If the reverse hash table entry does not exist, determining whether a reverse hash bucket position is calculated in the reverse hash table; If the reverse hash bucket position is calculated in the reverse hash table, apply for a session ID; If the session ID application is successful, the forward hash table, the reverse hash table and the session table are updated; Release the forward lock and the reverse lock.
3. The method according to claim 1, characterized in that The method further comprises: If the reverse hash table entry does not exist, determining whether a reverse hash bucket position is calculated in the reverse hash table; If the reverse hash bucket position is calculated in the reverse hash table, obtaining the assigned reverse session ID and determining whether the forward session ID is the same as the assigned reverse session ID; If they are the same, then update the reverse hash table and the session table; Release the forward lock and the reverse lock.
4. The method according to claim 1, wherein The session message also includes session update content; If the message type is a session update type, then starting a process for updating the session entry, specifically including: Determine whether the forward message information and the reverse message information match the session corresponding to the session ID; If there is a match, updating the session table entry using the session update content; Release the forward lock and the reverse lock.
5. The method according to claim 1, characterized in that If the message type is a session deletion type, the process of deleting the session entry is started, specifically including: Determine whether the forward message information and the reverse message information match the session corresponding to the session ID; If they match, clearing the valid bits in the forward hash table entry and the reverse hash table entry, and deleting the forward hash table entry and the reverse hash table entry; Deleting the session table entry and releasing the session ID; Release the forward lock and the reverse lock.
6. A session management device, characterized in that: The device is applied to a session management module, the session management module is located in an FPGA, and the device includes: A receiving unit, configured to receive a session message sent by the CPU, wherein the session message includes a message type, forward message information, and reverse message information; a calculation unit, configured to calculate a forward hash value and a reverse hash value according to the forward message information and the reverse message information, respectively, wherein the forward hash value includes a forward hash index and the reverse hash value includes a reverse hash index; an application unit, configured to apply for a forward lock if the forward hash index is different from the reverse hash index; A first judging unit is configured to, when a forward lock is applied for, judge whether there is a forward hash table entry matching the forward hash value in the forward hash table; a starting unit, configured to start a new session process if the forward hash table entry does not exist; a second determining unit configured to obtain a forward session ID from the forward hash table entry if the forward hash table entry exists, and to determine whether a reverse hash table entry matching the reverse hash value exists in the reverse hash table when a reverse lock is applied for; a third determining unit, configured to obtain a reverse session ID from the reverse hash table entry if the reverse hash table entry exists, and determine whether the forward session ID is the same as the reverse session ID; an acquiring unit, configured to acquire, from a session table, a session entry matching either the forward session ID or the reverse session ID, if the two are the same; The starting unit is further configured to start a process of updating the session entry if the message type is a session update type; The starting unit is further configured to start a process of deleting the session entry if the message type is a session deletion type.
7. The device according to claim 6, characterized in that The startup unit is specifically configured to, if the forward hash table entry does not exist, determine whether a forward hash bucket position is calculated in the forward hash table; If the forward hash bucket position is calculated in the forward hash table, a reverse lock is requested; When the reverse lock is applied for, determining whether there is a reverse hash table entry in the reverse hash table that matches the reverse hash value; If the reverse hash table entry does not exist, determining whether a reverse hash bucket position is calculated in the reverse hash table; If the reverse hash bucket position is calculated in the reverse hash table, apply for a session ID; If the session ID application is successful, the forward hash table, the reverse hash table and the session table are updated; Release the forward lock and the reverse lock.
8. The device according to claim 6, characterized in that The device further comprises: a fourth determining unit, configured to determine whether a reverse hash bucket position is calculated in the reverse hash table if the reverse hash table entry does not exist; a fifth determining unit, configured to obtain the allocated reverse session ID if the reverse hash bucket position is calculated in the reverse hash table, and determine whether the forward session ID is the same as the allocated reverse session ID; an updating unit, configured to update the reverse hash table and the session table if the two are the same; A release unit is used to release the forward lock and the reverse lock.
9. The device according to claim 6, characterized in that The session message also includes session update content; The starting unit is specifically used to determine whether the forward message information and the reverse message information match the session corresponding to the session ID; If there is a match, updating the session table entry using the session update content; Release the forward lock and the reverse lock.
10. The device according to claim 6, characterized in that The starting unit is specifically used to determine whether the forward message information and the reverse message information match the session corresponding to the session ID; If they match, clearing the valid bits in the forward hash table entry and the reverse hash table entry, and deleting the forward hash table entry and the reverse hash table entry; Deleting the session table entry and releasing the session ID; Release the forward lock and the reverse lock.
Citation Information
Patent Citations
Network flow monitoring method based on Hash compression algorithm
CN105515919A
Method of managing user session in mobile communication network
KR1020140075846A