Method, system, intelligent terminal and storage medium for searching key negotiation session

By using red-black trees and session key values ​​for session search in the massive traffic monitoring system, the performance problems caused by hash conflicts are solved, the efficiency of fast search and insertion of sessions is achieved, and the system performance and concurrency are improved.

CN115622698BActive Publication Date: 2024-10-18BEIJING ZHONGHAI WENDA INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211234012.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-10
Publication Date
2024-10-18
Estimated Expiration
2042-10-10

AI Technical Summary

Technical Problem

In a massive traffic monitoring system, the existing technology uses a hash table to store TCP sessions, resulting in a large number of hash conflicts, resulting in a serious decline in session search performance and affecting system performance.

Method used

By obtaining the client port and server port, determine the same customer service port session group, and use the red-black tree to perform session search, use the client IP and server IP to form the session key value, and directly locate the corresponding red-black tree, reducing Find time.

Benefits of technology

Significantly shortens session lookup time, improves system performance, reduces lock granularity, reduces memory consumption, and improves system concurrency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115622698B_ABST
    Figure CN115622698B_ABST
Patent Text Reader

Abstract

The present application relates to a method, system, intelligent terminal and storage medium for searching for a key negotiation session, wherein the method comprises obtaining a client port and a server port, and determining a corresponding same customer service port session group according to the client port and the server port, wherein the same customer service port session group comprises a lock, a number of sessions and a red-black tree pointer; determining whether the number of sessions in the same customer service port session group is zero; if not, calling the client IP corresponding to the client port and the server IP corresponding to the server port; determining a session key value according to the client IP and the server IP; searching a red-black tree in the same customer service port session group corresponding to the session key value to obtain a session capable of placing a data packet. The present application has the effect of reducing the time for searching for a session.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communications, and in particular to a method, system, intelligent terminal and storage medium for searching a key negotiation session. Background Art

[0002] In order to monitor the password negotiation process of the network communication process, it is first necessary to restore the session in the communication process and capture the complete interaction process. Each data packet in the TCP and UDP session has a source IP, source port, destination IP, and destination port. These four elements are used to find their corresponding sessions. Data packets are the data units transmitted in the TCP / IP protocol communication process. An IP data packet is usually up to 1500 bytes, but when we visit a web page or make a phone call to someone, it is often not 1500 bytes. Therefore, a communication session on the network will be split into multiple packets for transmission. The communication traffic between multiple clients and multiple servers is scattered and disordered to the monitoring system. For example, the communication traffic between A and B may be interspersed with the communication between C and D, and at the same time, it may be interspersed with the communication between E and F. There may be more than 100,000 communications between parties in one second. In the massive traffic monitoring system, at least hundreds of thousands of data packets need to be processed in real time every second, and each data packet must perform a session search and insert the data packet into the corresponding session operation. Therefore, shortening the time to find the session as much as possible is an important part of improving system performance.

[0003] Currently, TCP sessions are directly stored in a hash table. First, hashId is calculated and then hashIndex = hashId% hash table size. Since the size of the hash table is limited and for massive data application scenarios, a large number of hash conflicts will inevitably occur. For sessions with hashIndex, the method of searching for corresponding sessions degenerates into sequential matching search, which seriously affects the search performance. Summary of the invention

[0004] In order to reduce the time of searching for a session, the present application provides a method, system, intelligent terminal and storage medium for searching for a key negotiation session.

[0005] The above-mentioned application objective 1 of the present application is achieved through the following technical solutions:

[0006] Methods for finding key negotiation sessions include:

[0007] Obtain the client port and the server port, and determine a corresponding same-client service port session group according to the client port and the server port, wherein the same-client service port session group includes a lock, a number of sessions, and a red-black tree pointer;

[0008] Determine whether the number of sessions in the same customer service port session group is zero;

[0009] If not, call the client IP corresponding to the client port, and call the server IP corresponding to the server port;

[0010] Determine a session key value according to the client IP and the server IP;

[0011] Find the red-black tree in the same customer service port session group corresponding to the session key value, and get the session that can place the data packet.

[0012] In a preferred example, the present application may be further configured as follows: before obtaining the client port and the server port, it also includes:

[0013] Create a session command, the session command includes a client port array and a client port array subscript, the client port array subscript represents a different client port;

[0014] Traverse the client port array to obtain a traversal result;

[0015] Create a corresponding service port array according to the traversal result and the client port array, and generate a service port array subscript;

[0016] The red-black tree pointer of the same customer service port conversation group of the client port in the client port array is pointed to the same customer service port conversation group of the corresponding server port in the server port array.

[0017] In a preferred example, the present application may be further configured as follows: before determining whether the number of sessions of the same customer service port session group is zero, it also includes:

[0018] The client port and the corresponding server port are locked.

[0019] In a preferred example, the present application may be further configured to: further include inserting a new session;

[0020] Create a new red-black tree, and point the red-black tree pointer of the same customer service port session group to the new red-black tree;

[0021] Create a new session, and put the session key and the new session into a new red-black tree.

[0022] In a preferred example, the present application can be further configured as follows: the session key value is an integer value of uint64.

[0023] In a preferred example, the present application can be further configured as follows: the size of the client port array subscript and the size of the server port array subscript are both 65535.

[0024] The second purpose of this application is to provide a system for searching key negotiation sessions.

[0025] The second application objective of the present application is achieved through the following technical solutions:

[0026] Find the system for the key negotiation session, including;

[0027] Acquisition module, used to obtain the client port and server port;

[0028] A judging module, used for judging whether the number of sessions in the same customer service port session group is zero;

[0029] The calling module is used to call the client IP corresponding to the client port and the server IP corresponding to the server port;

[0030] A determination module, used to determine a session key value according to the client IP and the server IP;

[0031] The search module is used to search the red-black tree in the same customer service port session group corresponding to the session key value to obtain the session where the data packet can be placed.

[0032] The third purpose of this application is to provide a smart terminal.

[0033] The third application objective of this application is achieved through the following technical solutions:

[0034] An intelligent terminal comprises a memory and a processor, wherein the memory stores a computer program which can be loaded by the processor and execute the method for quickly searching for a session.

[0035] The fourth objective of this application is to provide a computer storage medium capable of storing corresponding programs.

[0036] The fourth application objective of this application is achieved through the following technical solutions:

[0037] A computer-readable storage medium stores a computer program that can be loaded by a processor and execute any of the above methods for searching for a key negotiation session.

[0038] In summary, this application includes the following beneficial technical effects:

[0039] First, the red-black tree in the same customer service port session group can be directly located through the client port and the server port. Because the address of the client port and the server port are known, it can be directly located in one step, so the time to locate the corresponding red-black tree can be ignored. Therefore, the search time is the time to find the corresponding session from the red-black tree in the same customer service port session group. The embodiment of the present application combines the client IP and the server IP into a session key value that can open the red-black tree. This session key value is a uint64 integer value, so the matching time between the session key value and the red-black tree is the shortest time, which is greatly shortened compared to the byte-by-byte matching time of objects, strings, etc. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a flowchart of a method for searching a key negotiation session according to an embodiment of the present application.

[0041] Figure 2 It is a system diagram of a system for searching a key negotiation session according to an embodiment of the present application.

[0042] Figure 3 It is a structural diagram of a smart terminal according to an embodiment of the present application.

[0043] Explanation of the accompanying drawings: 21. Acquisition module; 22. Judgment module; 23. Retrieval module; 24. Determination module; 25. Search module; 301. CPU; 302. ROM; 303. RAM; 304. Bus; 305. I / O interface; 306. Input part; 307. Output part; 308. Storage part; 309. Communication part; 310. Drive; 311. Removable medium. DETAILED DESCRIPTION

[0044] The present application is further described in detail below in conjunction with the accompanying drawings.

[0045] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.

[0046] The embodiment of the present application provides a method for finding a key negotiation session, which is mainly used to restore a session in the communication process and capture the complete interaction process. A communication session on the network will be split into multiple packets for sending. The communication traffic between multiple clients and multiple servers to the monitoring system is scattered and disordered. For example, the communication traffic between A and B may be interspersed with the communication between C and D, and the communication between E and F may be interspersed. There may be more than 100,000 traffic between communicating parties in one second. In a massive traffic monitoring system, there will be at least hundreds of thousands of data packets that need to be processed in real time every second, and each data packet must perform a session search and insert the data packet into the corresponding session operation, so shortening the time to find the session as much as possible is an important part of improving system performance.

[0047] Currently, TCP sessions are directly stored in a hash table. First, hashId is calculated and then hashIndex = hashId% hash table size. Since the size of the hash table is limited and for massive data application scenarios, a large number of hash conflicts will inevitably occur. For sessions with hashIndex, the method of searching for corresponding sessions degenerates into sequential matching search, which seriously affects the search performance.

[0048] In order to reduce the time of searching for a session, an embodiment of the present application discloses a method for searching for a key negotiation session.

[0049] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.

[0050] like Figure 1 As shown;

[0051] Step S100, obtaining the client port and the server port, and determining a corresponding same client service port session group according to the client port and the server port.

[0052] Before getting the client port and server port, you need to create a data structure called session command to store all sessions through the new operator. The session command contains a client port array of 65535 elements, that is, 0 to 65535 are the subscripts of the client port array. The elements are the session groups with the same client service port. The session groups with the same client service port include locks, session numbers and red-black tree pointers.

[0053] The client port array index is traversed from 0 to 65535 in sequence to obtain the traversal result, and the corresponding service port array is created according to the traversal result and the client port array, and the service port array index is generated, that is, service port data with a size of 65535 elements are created through the new operator, and the service port data index is also 0 to 65535, and the elements are also the same customer service port session group. The red-black tree pointer of the same customer service port session group in the client port array is pointed to the same customer service port session group in the corresponding service port array.

[0054] The session information of the client port and the server port is stored in a red-black tree. The client port array index and the service port array index are both 0 to 65535 because they can cover all ports. After knowing the client port and the server port, we can know that they correspond to the same customer service port session group. Storing the client port and the server port in the corresponding array indexes is equivalent to directly finding the session information of the same customer service port session group.

[0055] For example, to find the same customer service port conversation group with the client port being 60575 and the server port being 443, simply output

[60575]

[443] to directly locate the same customer service port conversation group for both.

[0056] At the same time, after obtaining the client port and the server port, the same customer service port session group of the client port and the same customer service port session group of the server port need to be locked to prevent other threads from modifying the session information in the same client port session.

[0057] This can reduce the lock granularity, because only sessions with the same client port and server port are placed in a red-black tree. Each red-black tree has only one lock, which can greatly reduce the probability of affecting other threads.

[0058] Step S200, determining whether the number of sessions in the same customer service port session group is zero.

[0059] If not, the number of sessions in the same customer service port session group is not zero, indicating that the same customer service port session group stores sessions for placing data packets, then the client IP corresponding to the client port is retrieved, and the server IP corresponding to the server port is retrieved.

[0060] The session key is determined based on the client IP and the server IP. Since both the client IP and the server IP are uint32 integer values, the session key is a uint64 integer value.

[0061] If so, the number of sessions in the same customer service port session group is zero, indicating that there is no session in the same customer service port session group that can place the data packet, and the search ends.

[0062] Step S300, searching the red-black tree in the same customer service port session group corresponding to the session key value to obtain a session capable of placing a data packet.

[0063] Since the session key value is a uint64 integer value, it is specifically understood as a numerical value; and the red-black tree within the same customer service port session group can be understood as multiple numerical values ​​distributed in a tree shape, and each of the multiple numerical values ​​is a session; you only need to compare the uint64 integer value and the numerical value in the red-black tree to know the session where the data packet is placed.

[0064] For example, the session key value is an integer value of uint64, and the value of the integer value is 8; the structure of the red-black tree in the same customer service port session group has a highest point of 7, one branch is 7-8-5, and the other branch is 7-9-10, then the value of the integer value is 8 and corresponds to node 8 of the red-black tree, and the data packet is placed in the session represented by node 8.

[0065] After the data packet is placed in the session, the locks of the same customer service port session group of the client port and the same customer service port session group of the server port are unlocked, so that other threads can modify the session information in the same customer service port session group.

[0066] At the same time, when the number of sessions in the same customer service port session group is zero, if a data packet is sent, a new session needs to be created to place the data packet.

[0067] First, a new red-black tree is created through the new operator, and the red-black tree pointer of the same customer service port session group points to the new red-black tree.

[0068] Then create a new session through the new operator, and put the session key value and the new session into the new red-black tree.

[0069] The embodiment of the present application does not create a red-black tree for all client ports and server ports in advance, but determines whether there is a session by observing the number of sessions in the same client service port session group. On the one hand, it allows the search session thread to quickly understand the session information and prevent system abnormalities caused by obtaining an empty red-black tree, and on the other hand, it also reduces memory consumption. The corresponding red-black tree will only be created when there is a session between the corresponding client port and the server port.

[0070] Through experiments conducted by staff, it is known that when the number of sessions in the same customer service port session group of the same client port and the same customer service port session group of the server port is one, single-threaded search and insertion only takes one microsecond or less; when the number of sessions in the same customer service port session group is multiple, single-threaded search and insertion only takes two microseconds or one microsecond. In the scenario of restoring massive data sessions, program performance will no longer be affected by time.

[0071] In summary, the embodiment of the present application can first directly locate the red-black tree in the same customer service port conversation group through the client port and the server port, because the address of the client port and the server port are known, it can be directly located in one step, so the time to locate the corresponding red-black tree can be ignored. Therefore, the search time is the time to find the corresponding session from the red-black tree in the same customer service port conversation group, and the embodiment of the present application forms a session key value that can open the red-black tree with the client IP and the server IP, and this session key value is an integer value of uint64, so the matching time of the session key value and the red-black tree is the shortest time, which is greatly shortened relative to the byte-by-byte matching time of objects, strings, etc. At the same time, each identical client port and server port corresponds to a red-black tree, which makes the size of the red-black tree extremely reduced, further reducing the search time, and searching and inserting sessions for this red-black tree will not affect other red-black trees, and will not affect threads that operate other red-black trees at the same time, thereby greatly improving the concurrency of the system.

[0072] Figure 2 A system diagram of a system for searching a key negotiation session provided in an embodiment of the present application.

[0073] like Figure 2 The system for searching for a key negotiation session shown includes an acquisition module 21, a judgment module 22, a retrieval module 23, a determination module 24 and a search module 25, wherein:

[0074] An acquisition module 21 is used to acquire a client port and a server port;

[0075] A judgment module 22, used for judging whether the number of sessions of the same customer service port session group is zero according to the traversal result;

[0076] The calling module 23 is used to call the client IP corresponding to the client port, and is used to call the server IP corresponding to the server port;

[0077] A determination module 24, configured to determine a session key value according to the client IP and the server IP;

[0078] The search module 25 is used to search the red-black tree in the same customer service port session group corresponding to the session key value to obtain a session capable of placing a data packet.

[0079] Figure 3 A schematic diagram of the structure of an intelligent terminal suitable for implementing the embodiments of the present application is shown.

[0080] like Figure 3 As shown, the intelligent terminal includes a central processing unit (CPU) 301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 302 or the program loaded from the storage part to the random access memory (RAM) 303. In the RAM 303, various programs and data required for system operation are also stored. The CPU 301, ROM 302 and RAM 303 are connected to each other through a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.

[0081] The following components are connected to the I / O interface 305: an input section 306 including a keyboard, a mouse, etc.; an output section 307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 308 including a hard disk, etc.; and a communication section 309 including a network interface card such as a LAN card, a modem, etc. The communication section 309 performs communication processing via a network such as the Internet. A drive 310 is also connected to the I / O interface 305 as needed. A removable medium 311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 310 as needed, so that a computer program read therefrom is installed into the storage section 308 as needed.

[0082] In particular, according to an embodiment of the present application, the above reference flow chart Figure 1 The described process can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a machine-readable medium, and the computer program contains program code for executing the method shown in the flow chart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 309, and / or installed from the removable medium 311. When the computer program is executed by the central processing unit (CPU) 301, the above-mentioned functions defined in the system of the present application are executed.

[0083] It should be noted that the computer-readable medium shown in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0084] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the aforementioned module, a program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0085] The units or modules involved in the embodiments described in the present application may be implemented by software or hardware. The units or modules described may also be set in a processor, for example, they may be described as: a processor comprising an acquisition module 21, a judgment module 22, a call module 23, a determination module 24, and a search module 25. The names of these units or modules do not, in some cases, constitute limitations on the units or modules themselves, for example, the acquisition module 21 may also be described as a "module for acquiring client ports and server ports."

[0086] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium stores one or more programs, and when the above programs are used by one or more processors to execute the data encryption transmission method described in the present application.

[0087] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of application involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the aforementioned application concept. For example, the above features are replaced with (but not limited to) technical features with similar functions applied in the present application.

Claims

1. A method for finding a key negotiation session, characterized in that: include; Obtain the client port and the server port, and determine a corresponding same-client service port session group according to the client port and the server port, wherein the same-client service port session group includes a lock, a number of sessions, and a red-black tree pointer; Determine whether the number of sessions in the same customer service port session group is zero; If not, call the client IP corresponding to the client port, and call the server IP corresponding to the server port; Determine a session key value according to the client IP and the server IP; Find the red-black tree in the same customer service port session group corresponding to the session key value, and obtain the session that can place the data packet; Before obtaining the client port and the server port, it also includes: Create a session command, the session command includes a client port array and a client port array subscript, the client port array subscript represents a different client port; Traverse the client port array to obtain a traversal result; Create a corresponding service port array according to the traversal result and the client port array, and generate a service port array subscript; Point the red-black tree pointer of the same customer service port conversation group of the client port in the client port array to the same customer service port conversation group of the corresponding server port in the server port array; Determining the corresponding same customer service port session group according to the client port and the server port includes: The client port and the server port are stored in corresponding array indexes respectively, and the same client service port conversation group of the two is directly located according to the indexes.

2. The method for searching a key negotiation session according to claim 1, wherein: Before determining whether the number of sessions of the same customer service port session group is zero, the method further includes: The client port and the corresponding server port are locked.

3. The method for searching a key negotiation session according to claim 1, wherein: It also includes inserting new sessions; Create a new red-black tree, and point the red-black tree pointer of the same customer service port session group to the new red-black tree; Create a new session, and put the session key and the new session into a new red-black tree.

4. The method for searching a key negotiation session according to claim 1, wherein: The session key value is a uint64 integer value.

5. The method for searching a key negotiation session according to claim 1, characterized in that: The client port array subscript size and the server port array subscript size are both 65535.

6. A system for finding a key negotiation session, characterized in that: include; An acquisition module (21) is used to acquire a client port and a server port, and determine a corresponding same-client service port session group according to the client port and the server port, wherein the same-client service port session group includes a lock, a number of sessions and a red-black tree pointer; A judgment module (22), used to judge whether the number of sessions in the same customer service port session group is zero; A calling module (23) is used to call the client IP corresponding to the client port, and is used to call the server IP corresponding to the server port; A determination module (24), configured to determine a session key value according to the client IP and the server IP; A search module (25) is used to search the red-black tree in the same customer service port session group corresponding to the session key value to obtain a session capable of placing a data packet; Before obtaining the client port and the server port, it also includes: Create a session command, the session command includes a client port array and a client port array subscript, the client port array subscript represents a different client port; Traverse the client port array to obtain a traversal result; Create a corresponding service port array according to the traversal result and the client port array, and generate a service port array subscript; Point the red-black tree pointer of the same customer service port conversation group of the client port in the client port array to the same customer service port conversation group of the corresponding server port in the server port array; Determining the corresponding same customer service port session group according to the client port and the server port includes: The client port and the server port are stored in corresponding array indexes respectively, and the same client service port conversation group of the two is directly located according to the indexes.

7. An intelligent terminal, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executes any one of the methods of claims 1 to 5.

8. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method for recording message of conversation based on instant communication mode, and instant communication client end

    CN101094195A

  • Method and system for managing sessions

    CN103856462A