Session information statistical method and device based on dynamic memory
By adopting dynamic and static memory collaborative management in large network environments, the problem of excessive memory resource usage or data loss in session information statistics is solved, and efficient memory utilization and accurate statistical data are achieved.
Patent Information
- Application Number
- CN202510233330.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-28
- Publication Date
- 2025-05-30
AI Technical Summary
The prior art is difficult to effectively manage dynamically changing session information in session information statistics in large network environments, resulting in excessive memory resource usage or data loss, affecting traffic analysis and network management.
Through dynamic and static memory management, dynamic memory cache pools and static memory pools are used to dynamically allocate and recycle memory resources to ensure the storage and statistics of session information.
It improves the memory utilization rate of session information storage, reduces the overhead of memory allocation and release, and ensures the integrity and accuracy of statistical data.
Smart Images

Figure CN120075177A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer information processing, and more particularly, to a method and apparatus for session information statistics based on dynamic memory. Background Art
[0002] In a large-scale network environment, devices need to count session information of multi-tuples, including key metrics such as connection count and concurrency count, in order to achieve traffic monitoring and network management. However, since the number of session information in the network is dynamically changing and cannot be accurately predicted in advance, a reasonable storage scheme is needed to ensure the integrity and accuracy of the statistical data.
[0003] Currently, the common session information storage and statistics schemes mainly include the following two:
[0004] Ultra-large-scale memory pre-allocation scheme:
[0005] This scheme pre-allocates a large amount of memory to cover all possible session information. For example, seven-tuple session information (source IP, destination IP, source port, destination port, protocol, service, interface information) requires a huge storage space to ensure complete statistics. This method can provide the most comprehensive data statistics, but due to the extremely large memory resources occupied, it is difficult to meet the resource limit requirements in practical applications. Although the ultra-large-scale memory pre-allocation scheme guarantees data integrity, the memory resources occupied are too large to meet the actual application requirements.
[0006] Fixed memory allocation scheme based on device specifications: This scheme pre-sets the upper limit of memory usage according to the maximum session number specification of the device. For example, if the device supports 20 million sessions, 20 million × 20 bytes of memory needs to be reserved. The advantage of this method is that the memory occupancy is controllable, but if the number of sessions in the actual network exceeds the preset specification, the session information beyond the range cannot be stored, resulting in data loss and inaccurate statistics, which in turn affects traffic analysis and network management. The fixed specification memory allocation scheme has a small memory occupancy, but when the number of sessions exceeds the preset range, it will cause data loss and affect the accuracy of statistics.
[0007] Therefore, a new method and apparatus for session information statistics based on dynamic memory are needed.
[0008] The above information disclosed in the background art section is only used to enhance the understanding of the background of the present application, and thus it may include information that does not constitute the prior art known to those of ordinary skill in the art. Summary of the Invention
[0009] In view of this, the present application provides a session information statistics method and apparatus based on dynamic memory, which can improve the memory utilization rate of session information storage, reduce the overhead of memory allocation and release, and ensure the integrity and accuracy of statistical data through the collaborative management of dynamic and static memory.
[0010] Other features and advantages of the present application will become apparent from the following detailed description, or will be learned in part through the practice of the present application.
[0011] According to an aspect of the present application, a session information statistics method based on dynamic memory is proposed. The method includes: obtaining new session information, where the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information; when there is no remaining static memory and there is remaining dynamic cache pool, obtaining a block of memory from the dynamic memory cache pool; saving the address corresponding to the memory in the dynamic memory pool; storing the session information in the address; and performing session information statistics through the session information in the static memory and the dynamic memory pool.
[0012] In an exemplary embodiment of the present application, it further includes: creating static memory and dynamic memory; where the static memory is used to store session information for long-term use, the dynamic memory includes a dynamic cache pool and a dynamic memory pool, the dynamic cache pool is used to store reusable memory blocks, and the dynamic memory pool is used to store temporary session information.
[0013] In an exemplary embodiment of the present application, it further includes: when there is remaining static memory, storing the session information in the static memory.
[0014] In an exemplary embodiment of the present application, it further includes: when there is no remaining static memory and no remaining dynamic cache pool, allocating memory through the malloc function; saving the address corresponding to the memory in the dynamic memory pool; and storing the session information in the address.
[0015] In an exemplary embodiment of the present application, storing the session information in the address further includes: storing the most recent use time corresponding to the session information in the address.
[0016] In an exemplary embodiment of the present application, it further includes: periodically checking the session information in the dynamic memory pool through a timer; removing the expired session information from the dynamic memory pool; and putting the memory block corresponding to the removed session information into the dynamic memory cache pool for subsequent reuse.
[0017] In an exemplary embodiment of the present application, it further includes: regularly checking memory blocks in the dynamic memory cache pool through a timer; releasing memory blocks whose unused time exceeds the usage threshold to reclaim memory resources.
[0018] In an exemplary embodiment of the present application, it includes: regularly checking session information in the static memory through a timer; moving session information whose update time exceeds the update threshold from the static memory to the dynamic memory pool.
[0019] In an exemplary embodiment of the present application, session information statistics is performed through the session information in the static memory and the dynamic memory pool, including: performing session information statistics through the session information in the static memory and the dynamic memory pool, and the statistics includes the number of connections, the number of concurrent sessions, and session traffic information.
[0020] According to one aspect of the present application, a session information statistics device based on dynamic memory is proposed. The device includes: an information module for obtaining new session information, where the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information; a memory module for obtaining a block of memory from the dynamic memory cache pool when there is no remaining space in the static memory and there is remaining space in the dynamic cache pool; a saving module for saving the address corresponding to the memory in the dynamic memory pool; a storage module for storing the session information into the address; a statistics module for performing session information statistics through the session information in the static memory and the dynamic memory pool.
[0021] According to one aspect of the present application, an electronic device is proposed. The electronic device includes: one or more processors; a storage device for storing one or more programs; when the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.
[0022] According to one aspect of the present application, a computer-readable medium is proposed, on which a computer program is stored, and when the program is executed by a processor, it implements the method as described above.
[0023] The session information statistics method and device based on dynamic memory according to the present application obtain new session information, where the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information; when there is no remaining static memory and there is remaining dynamic cache pool, obtain a block of memory from the dynamic memory cache pool; save the address corresponding to the memory in the dynamic memory pool; store the session information in the address; by the way of performing session information statistics through the session information in the static memory and the dynamic memory pool, it is possible to improve the memory utilization rate of session information storage, reduce the overhead of memory allocation and release, and ensure the integrity and accuracy of statistical data through the collaborative management of dynamic and static memory.
[0024] It should be understood that the above general description and the following detailed description are only exemplary and do not limit the present application. Brief Description of the Drawings
[0025] By referring to the accompanying drawings and describing its exemplary embodiments in detail, the above and other objects, features, and advantages of the present application will become more apparent. The following described drawings are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0026] Figure 1 is a flowchart of a method for statistics of session information based on dynamic memory shown according to an exemplary embodiment.
[0027] Figure 2 is a flowchart of a method for statistics of session information based on dynamic memory shown according to an exemplary embodiment.
[0028] Figure 3 is a flowchart of a method for statistics of session information based on dynamic memory shown according to another exemplary embodiment.
[0029] Figure 4 is a block diagram of a device for statistics of session information based on dynamic memory shown according to an exemplary embodiment.
[0030] Figure 5 is a block diagram of a device for statistics of session information based on dynamic memory shown according to an exemplary embodiment.
[0031] Figure 6 is a block diagram of an electronic device shown according to an exemplary embodiment.
[0032] Figure 7 is a block diagram of a computer-readable medium shown according to an exemplary embodiment Detailed Description of the Embodiments
[0033] Example embodiments will now be described more fully with reference to the accompanying drawings. However, the example embodiments can be implemented in various forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this application will be thorough and complete, and will fully convey the concept of the example embodiments to those skilled in the art. Like reference numerals in the figures denote like or similar parts, and thus their repetitive description will be omitted.
[0034] In addition, the described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of the embodiments of this application. However, those skilled in the art will realize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be used. In other cases, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of this application.
[0035] The block diagrams shown in the drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0036] The flowcharts shown in the drawings are merely illustrative and do not necessarily include all the content and operations / steps, nor are they necessarily executed in the order described. For example, some operations / steps can be decomposed, while some operations / steps can be combined or partially combined, so the actual execution order may change according to the actual situation.
[0037] It should be understood that although terms such as first, second, and third may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another. Thus, the first component discussed below can be referred to as the second component without departing from the teachings of the concept of this application. As used herein, the term "and / or" includes any one and all combinations of one or more of the associated listed items.
[0038] Those skilled in the art can understand that the drawings are only schematic diagrams of the example embodiments, and the modules or processes in the drawings are not necessarily essential for implementing this application, and thus cannot be used to limit the protection scope of this application.
[0039] The technical abbreviations related to this application are explained as follows:
[0040] IP (Internet Protocol): The Internet Protocol is responsible for addressing and transmitting data packets in a network.
[0041] TCP (Transmission Control Protocol): The Transmission Control Protocol provides a reliable, connection-oriented data transmission service.
[0042] UDP (User Datagram Protocol): The User Datagram Protocol provides connectionless, unreliable but efficient data transmission.
[0043] Seven - Tuple (7 - Tuple): Seven key parameters used to uniquely identify a session, including source IP, destination IP, source port, destination port, protocol, service, and interface information.
[0044] Session: Refers to a data interaction connection established between two communication entities, such as a TCP connection or a UDP data stream.
[0045] Concurrent Connections: Refers to the number of active sessions that exist simultaneously on a device within the same time period.
[0046] Traffic Statistics: Analyzes the data traffic transmitted over a network, including metrics such as the number of sessions, concurrent connection numbers, and packet sizes.
[0047] Dynamic Memory: Memory space dynamically allocated according to requirements during the running of a program, which can be adjusted as the data changes.
[0048] Static Memory: A fixed - size memory space pre - allocated during program runtime, which does not change with data.
[0049] Dynamic Memory Pool: A memory pool used to store short - term session data, capable of dynamically allocating and releasing memory to improve memory utilization.
[0050] Dynamic Cache Pool: Used to store short - term unused but potentially reusable memory blocks to reduce frequent memory allocation and release operations.
[0051] Load Balancing: Reasonably distributes session data between static memory and dynamic memory, optimizes storage resources, and improves system performance.
[0052] malloc (Memory Allocation): A dynamic memory allocation function in the C language used to allocate memory space during program execution.
[0053] Timer: Triggers certain operations within a set time interval, such as cleaning up expired session information, releasing memory in the cache pool, etc.
[0054] Timeout Recycling: Releases session information that has not been used for a long time to optimize memory usage efficiency.
[0055] Traffic Analysis: Analyzes user behavior, abnormal activities, and potential security threats by monitoring network traffic patterns.
[0056] Figure 1 is a flowchart of a method for statistically analyzing session information based on dynamic memory shown according to an exemplary embodiment. The method 10 for statistically analyzing session information based on dynamic memory at least includes steps S102 to S110.
[0057] As Figure 1 shown, in S102, new session information is obtained. The session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information. The seven-tuple information can be used to uniquely identify a session and serve as the basic data for session management.
[0058] In S104, when there is no remaining static memory and there is remaining dynamic cache pool, a block of memory is obtained from the dynamic memory cache pool.
[0059] In one embodiment, it further includes: regularly checking memory blocks in the dynamic memory cache pool through a timer; releasing memory blocks whose unused time exceeds the usage threshold to recycle memory resources.
[0060] In S106, the address corresponding to the memory is saved in the dynamic memory pool. More specifically, after successfully allocating memory in the dynamic memory pool or cache pool, the address of the memory block can be recorded in the management structure to ensure correct access to the session data later.
[0061] In S108, the session information is stored in the address. The most recently used time corresponding to the session information can also be stored in the address. Recording the most recently used time (Last Used Time) of the session is used for subsequent session expiration detection and memory recycling policies.
[0062] In one embodiment, it further includes: regularly checking session information in the dynamic memory pool through a timer; removing expired session information from the dynamic memory pool; and putting the memory block corresponding to the removed session information into the dynamic memory cache pool for subsequent reuse.
[0063] In S110, session information statistics are performed through the session information in the static memory and the dynamic memory pool. For example, session information statistics are performed through the session information in the static memory and the dynamic memory pool, and the statistics include the number of connections, the number of concurrent sessions, and session traffic information.
[0064] After storing the session information, session information statistics are performed based on the static memory and the dynamic memory pool, and the statistical metrics include but are not limited to:
[0065] Number of connections: Count the number of sessions established in the current system.
[0066] Number of concurrent sessions: Count the number of active sessions at the same moment.
[0067] Session traffic information: Record the data traffic of each session and calculate the upload and download rates.
[0068] Protocol distribution statistics: Calculate the proportion of sessions of different protocol types, such as TCP / UDP / ICMP, etc.
[0069] Historical session analysis: Analyze session activity based on a time window and identify abnormal behaviors.
[0070] Combining static and dynamic storage to statistically analyze session data ensures the integrity and real-time nature of the statistical information and adapts to high-concurrency traffic environments.
[0071] According to the session information statistical method based on dynamic memory of the present application, by obtaining new session information, the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information; when there is no remaining space in the static memory and there is remaining space in the dynamic cache pool, obtain a block of memory from the dynamic memory cache pool; save the address corresponding to the memory in the dynamic memory pool; store the session information in the address; through the method of performing session information statistics through the session information in the static memory and the dynamic memory pool, it is possible to improve the memory utilization rate of session information storage through the collaborative management of dynamic and static memory, reduce the overhead of memory allocation and release, and ensure the integrity and accuracy of the statistical data.
[0072] It should be clearly understood that the present application describes how to form and use specific examples, but the principles of the present application are not limited to any details of these examples. On the contrary, based on the teachings disclosed in the present application, these principles can be applied to many other embodiments.
[0073] In one embodiment, as Figure 2 shown, static memory and dynamic memory can be created; among them, the static memory is used to store session information for long-term use, and the dynamic memory includes a dynamic cache pool and a dynamic memory pool. The dynamic cache pool is used to store reusable memory blocks, and the dynamic memory pool is used to store temporary session information.
[0074] Static memory management: This part of the memory is dedicated to storing session information that is long-term active, characterized by a long life cycle and frequent data access. Since such sessions continuously occupy resources during system operation, they are not suitable for dynamic recycling or release, but instead adopt a fixed allocation strategy to ensure the stability of critical sessions.
[0075] Dynamic memory management: This part of the memory is used to store session information with a short life cycle or high uncertainty, such as temporary TCP connections, UDP sessions, etc. Due to the strong dynamics of seven-tuple sessions in the network, a large number of sessions are only valid for a short time, so a dynamic allocation and recycling mechanism is adopted to release resources in a timely manner after the session fails or times out, and a cache pool strategy is combined to optimize memory reuse, so as to reduce system overhead and improve overall storage efficiency.
[0076] In one embodiment, it further includes: regularly checking the session information in the static memory through a timer; moving the session information whose update time exceeds the update threshold from the static memory to the dynamic memory pool.
[0077] When the device receives new session information, it first tries to store it in the static memory. If the data in the static memory is full, it dynamically allocates memory for this information and puts the memory node into the dynamic memory pool. Whether in the static memory or in the dynamic memory pool, this information also needs to store a time field indicating the most recent use time of this memory, which is convenient for memory adjustment.
[0078] To solve the problems of dynamic changes in seven-tuple information and limited memory resources in the live network environment, this application proposes a hierarchical memory management mechanism that divides the memory into two parts: static memory and dynamic memory, in order to improve memory utilization and optimize the session information storage strategy.
[0079] This application effectively balances the storage requirements of session information through the stability guarantee of static memory and the flexible adaptation of dynamic memory, and improves the memory utilization and system performance of the device in high-concurrency scenarios.
[0080] Figure 3 It is a flowchart of a method for statistical analysis of session information based on dynamic memory shown according to another exemplary embodiment. Figure 3 The process 30 shown is a supplementary description of the Figure 1 process shown.
[0081] As shown Figure 3 In S302, the new session information statistics entry point.
[0082] In S304, check if there is any remaining space in the static pool.
[0083] In S306, store the information in the static pool.
[0084] Since the session information stored in the static memory is in a long-term occupied state, every time new seven-tuple information comes, memory is dynamically allocated each time, greatly consuming the device performance. In this application, the memory in the dynamic cache pool of the dynamic recycling mechanism is used to store information. In this way, when receiving new seven-tuple data, there is no need to dynamically allocate memory every time. Instead, first check if there is available memory in the dynamic cache pool. If there is available memory, take out a block of memory from the dynamic cache pool, store the session traffic information, and put this memory into the dynamic memory pool, thus achieving the technology of reusing dynamic memory.
[0085] Since every time new seven-tuple data is stored, a memory block is first obtained from the static memory, there may be a lot of session data that may belong to the dynamic type in the static memory. At this time, it is necessary to adjust the data in the static memory. In this application, a timer can be designed to regularly check the data in the static memory. If there is seven-tuple data in the static memory that has not been updated for a long time, move the data of this seven-tuple to the dynamic memory, and let the new and relatively stable session information use this memory block, so as to ensure that the session data stored in the static memory is relatively stable.
[0086] In S308, check if there is any remaining space in the dynamic cache pool.
[0087] In the dynamic memory cache pool, the stored memory is all memory that was previously dynamically allocated and has not been used for a long time. If there are a lot of memory blocks here, it means there is a large amount of expired memory and it has not been occupied by new data. At this time, a timer can be used to regularly check the data in the dynamic memory cache pool. If some memory has been in the cache pool for a long time, it means that the current number of dynamic sessions is less than before, and some memory blocks in the cache pool can be released.
[0088] In S310, allocate memory.
[0089] In S312, obtain memory from the dynamic cache pool.
[0090] In S314, save the memory address in the dynamic memory pool.
[0091] In S316, save the session information to this address.
[0092] In S318, it ends.
[0093] Those skilled in the art can understand that all or part of the steps to implement the above embodiments are implemented as a computer program executed by a CPU. When the computer program is executed by the CPU, the above functions defined by the above method provided in this application are executed. The program can be stored in a computer-readable storage medium, which can be a read-only memory, a magnetic disk, an optical disk, etc.
[0094] In addition, it should be noted that the above drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of this application, rather than for limiting purposes. It is easy to understand that the processes shown in the above drawings do not indicate or limit the time sequence of these processes. Additionally, it is also easy to understand that these processes can be executed synchronously or asynchronously in, for example, multiple modules.
[0095] The following is an embodiment of the device of this application, which can be used to execute the embodiment of the method of this application. For details not disclosed in the embodiment of the device of this application, please refer to the embodiment of the method of this application.
[0096] Figure 4 is a block diagram of a session information statistics device based on dynamic memory shown according to an exemplary embodiment. As Figure 4 shown, the session information statistics device 40 based on dynamic memory includes: an information module 402, a memory module 404, a saving module 406, a storage module 408, and a statistics module 410.
[0097] The information module 402 is used to obtain new session information, where the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information;
[0098] The memory module 404 is used to obtain a block of memory from the dynamic memory cache pool when there is no remaining static memory and there is remaining dynamic cache pool;
[0099] The saving module 406 is used to save the address corresponding to the memory in the dynamic memory pool;
[0100] The storage module 408 is used to store the session information into the address;
[0101] The statistics module 410 is used to perform session information statistics through the session information in the static memory and the dynamic memory pool. The statistics module 410 is also used to perform session information statistics through the session information in the static memory and the dynamic memory pool, and the statistics include the number of connections, the number of concurrent connections, and session traffic information
[0102] Figure 5It is a block diagram of a session information statistics device based on dynamic memory shown according to an exemplary embodiment. As Figure 5 shown, the session information statistics device 50 based on dynamic memory includes: a creation module 502, a static module 504, an allocation module 506, a time module 508, a first timing module 510, a second timing module 512, and a third timing module 514.
[0103] The creation module 502 is used to create static memory and dynamic memory; among them, the static memory is used to store session information for long-term use, the dynamic memory includes a dynamic cache pool and a dynamic memory pool, the dynamic cache pool is used to store reusable memory blocks, and the dynamic memory pool is used to store temporary session information.
[0104] The static module 504 is used to store the session information into the static memory when there is remaining space in the static memory.
[0105] The allocation module 506 is used to allocate memory through the malloc function when there is no remaining space in the static memory and no remaining space in the dynamic cache pool; save the address corresponding to the memory in the dynamic memory pool; store the session information into the address.
[0106] The time module 508 is used to store the most recent usage time corresponding to the session information into the address.
[0107] The first timing module 510 is used to periodically check the session information in the dynamic memory pool through a timer; remove the expired session information from the dynamic memory pool; put the memory block corresponding to the removed session information into the dynamic memory cache pool for subsequent reuse.
[0108] The second timing module 512 is used to periodically check the memory blocks in the dynamic memory cache pool through a timer; release the memory blocks whose unused time exceeds the usage threshold to recycle memory resources.
[0109] The third timing module 514 is used to periodically check the session information in the static memory through a timer; move the session information whose update time exceeds the update threshold from the static memory to the dynamic memory pool.
[0110] A session information statistics device based on dynamic memory according to the present application obtains new session information, where the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information; when there is no remaining static memory and there is remaining dynamic cache pool, a block of memory is obtained from the dynamic memory cache pool; the address corresponding to the memory is saved in the dynamic memory pool; the session information is stored in the address; by the method of performing session information statistics through the session information in the static memory and the dynamic memory pool, it is possible to improve the memory utilization rate of session information storage, reduce the overhead of memory allocation and release, and ensure the integrity and accuracy of statistical data through the collaborative management of dynamic and static memory.
[0111] Figure 6 is a block diagram of an electronic device shown according to an exemplary embodiment.
[0112] Next, refer to Figure 6 to describe the electronic device 600 according to this embodiment of the present application. Figure 6 The shown electronic device 600 is only an example and should not bring any limitation to the functions and usage scope of the embodiments of the present application.
[0113] As Figure 6 shown, the electronic device 600 is presented in the form of a general computing device. The components of the electronic device 600 may include but are not limited to: at least one processing unit 610, at least one storage unit 620, a bus 630 connecting different system components (including the storage unit 620 and the processing unit 610), a display unit 640, etc.
[0114] Among them, the storage unit stores program code, and the program code can be executed by the processing unit 610, so that the processing unit 610 executes the steps according to various exemplary embodiments of the present application described in this specification. For example, the processing unit 610 can execute steps as Figure 1 , Figure 3 shown.
[0115] The storage unit 620 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 6201 and / or a cache storage unit 6202, and may further include a read-only storage unit (ROM) 6203.
[0116] The storage unit 620 may also include a program / utilities 6204 having a set (at least one) of program modules 6205. Such program modules 6205 include, but are not limited to: an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment.
[0117] The bus 630 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus structures.
[0118] The electronic device 600 may also communicate with one or more external devices 600' (such as a keyboard, a pointing device, a Bluetooth device, etc.), devices that enable a user to interact with the electronic device 600, and / or any device that enables the electronic device 600 to communicate with one or more other computing devices (such as a router, a modem, etc.). Such communication may be through the input / output (I / O) interface 650. Also, the electronic device 600 may communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the network adapter 660. The network adapter 660 may communicate with other modules of the electronic device 600 through the bus 630. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, etc.
[0119] Through the description of the above embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by a combination of software and necessary hardware. Therefore, as Figure 7 shown, the technical solution according to the embodiments of the present application can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (which may be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which may be a personal computer, a server, or a network device, etc.) to execute the above method according to the embodiments of the present application.
[0120] The software product may employ any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable 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 disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0121] The computer-readable storage medium may include a data signal propagated in a baseband or as part of a carrier wave, in which the readable program code is carried. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. The readable medium may also be any readable medium other than the readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0122] The program code for performing the operations of this application may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computing device, partially on the user's device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., by using an Internet service provider to connect through the Internet).
[0123] The above computer-readable medium carries one or more programs, which, when executed by the device, cause the computer-readable medium to implement the following functions: obtaining new session information, where the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service, and interface information; when there is no remaining static memory and there is remaining dynamic cache pool, obtaining a block of memory from the dynamic memory cache pool; saving the address corresponding to the memory in the dynamic memory pool; storing the session information into the address; and performing session information statistics through the session information in the static memory and the dynamic memory pool.
[0124] Those skilled in the art can understand that the above-mentioned modules can be distributed in the device according to the description of the embodiments, or can be correspondingly changed and distributed in one or more devices that are uniquely different from this embodiment. The modules of the above embodiments can be combined into one module, or can be further split into multiple sub-modules.
[0125] Through the description of the above embodiments, those skilled in the art can easily understand that the exemplary embodiments described here can be implemented by software, or can be implemented by a combination of software and necessary hardware. Therefore, the technical solution according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the embodiments of the present application.
[0126] The above specifically shows and describes the exemplary embodiments of the present application. It should be understood that the present application is not limited to the detailed structure, setting method, or implementation method described here; on the contrary, the present application intends to cover various modifications and equivalent settings included in the spirit and scope of the appended claims.
Claims
1. A session information statistics method based on dynamic memory, characterized in that: include: Acquire new session information, wherein the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service and interface information; When there is no remaining static memory and there is remaining dynamic cache pool, a piece of memory is obtained from the dynamic memory cache pool; Saving the address corresponding to the memory in the dynamic memory pool; storing the session information at the address; Session information statistics are performed using the session information in the static memory and the dynamic memory pool.
2. The method according to claim 1, characterized in that Also includes: Create static memory and dynamic memory; The static memory is used to store long-term session information, and the dynamic memory includes a dynamic cache pool and a dynamic memory pool. The dynamic cache pool is used to store reusable memory blocks, and the dynamic memory pool is used to store temporary session information.
3. The method according to claim 1, characterized in that Also includes: When there is some remaining space in the static memory, the session information is stored in the static memory.
4. The method according to claim 1, characterized in that Also includes: When there is no remaining static memory and no remaining dynamic cache pool, memory is allocated through the malloc function; Saving the address corresponding to the memory in the dynamic memory pool; The session information is stored in the address.
5. The method according to claim 1, characterized in that Storing the session information at the address further includes: The most recent usage time corresponding to the session information is stored in the address.
6. The method according to claim 5, characterized in that Also includes: Regularly check the session information in the dynamic memory pool through a timer; Remove expired session information from the dynamic memory pool; The memory block corresponding to the removed session information is placed in the dynamic memory cache pool for subsequent reuse.
7. The method according to claim 1, characterized in that Also includes: Regularly check the memory blocks in the dynamic memory cache pool through a timer; Memory blocks that have not been used for a period of time exceeding the usage threshold are released to reclaim memory resources.
8. The method according to claim 1, characterized in that include: Regularly check the session information in static memory through a timer; Move session information whose update time exceeds the update threshold from the static memory to the dynamic memory pool.
9. The method according to claim 1, characterized in that Performing session information statistics using the session information in the static memory and the dynamic memory pool includes: Session information statistics are performed through the session information in the static memory and dynamic memory pools, and the statistics include the number of connections, the number of concurrent connections, and session traffic information.
10. A session information statistics device based on dynamic memory, characterized in that: include: An information module, used to obtain new session information, wherein the session information includes seven-tuple information, and the seven-tuple information includes source IP address, destination IP address, source port, destination port, protocol, service and interface information; A memory module, used for obtaining a piece of memory from the dynamic memory cache pool when there is no remaining static memory and there is remaining dynamic cache pool; A storage module, used for storing the address corresponding to the memory in the dynamic memory pool; A storage module, used for storing the session information in the address; The statistics module is used to perform session information statistics through the session information in the static memory and the dynamic memory pool.