Address group traffic statistical method and device

By converting the address group into an IP network segment linked list and using the longest prefix matching rules and hash table, the performance consumption problems caused by multiple address groups and multiple network segments are solved, efficient traffic statistics are achieved, and equipment performance is improved.

CN118945111AActive Publication Date: 2024-11-12HANGZHOU MACH VALLEY TECHNOLOGY CO LTD

Patent Information

Application Number
CN202411419144.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-12
Publication Date
2024-11-12
Estimated Expiration
2044-10-12

AI Technical Summary

Technical Problem

In network communication devices, when there are many address groups and network segments, the prior art leads to a large number of search and matching work, which consumes equipment performance and leads to performance reduction.

Method used

By converting the address group to be counted into an IP network segment linked list set, the longest prefix matching rules and hash table are used to accelerate search, refresh the statistical items of the IP network segment linked list, reduce duplicate and inclusion network segments, and improve matching efficiency.

Benefits of technology

It greatly reduces multiple matching operations of IP addresses, reduces device performance consumption, and improves device performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118945111A_ABST
    Figure CN118945111A_ABST
Patent Text Reader

Abstract

The invention relates to an address group traffic statistical method and device. Comprising the steps of obtaining an IP network segment linked list set according to all to-be-counted address groups, obtaining an IP address of a flow data packet in response to a determined received flow data packet in a statistical period, refreshing statistical items of IP network segments in the IP network segment linked list set according to a longest prefix matching rule and the IP address of the flow data packet, and obtaining a statistical result of the flow data packet. And according to the IP network segments in the IP network segment linked list set and the longest parent network segment of each IP network segment, refreshing statistical items of the IP network segments in the IP network segment linked list set to obtain traffic statistical values of all the to-be-counted address groups in a statistical period. According to the invention, the problem that one IP address needs to be matched for multiple times is solved, the searching and matching work is greatly reduced, the consumption of equipment performance is reduced, and the equipment performance is improved. The invention also relates to a device and a storage medium.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network technology, and in particular to a method and device for counting address group traffic. Background Art

[0002] In network communication equipment, such as switches and firewalls, network address groups are a commonly used configuration. There may be complex situations such as overlapping, duplication, and inclusion of addresses in the user-configured address groups. The prior art uses the address of the traffic packet to traverse the network segments in the address group in sequence. An IP address needs to be matched multiple times and all the hit address groups are counted. This results in a large amount of search and matching work when there are many address groups and many network segments in the address groups, which will seriously consume the performance of the device and lead to reduced device performance. Summary of the invention

[0003] In order to solve the technical problem that a large amount of search and matching work seriously consumes device performance when there are many address groups and many network segments in the address groups, the present invention provides an address group traffic statistics method and device.

[0004] According to a first aspect, a method for counting traffic of an address group is provided. The method comprises: According to all the address groups to be counted, an IP network segment linked list set is obtained, wherein the address groups to be counted are configured by the customer, and the IP network segment linked list set is a set consisting of multiple IP network segment linked lists, and each IP network segment linked list is a linked list consisting of network segments belonging to the same mask; In a statistical cycle, in response to determining that a traffic data packet is received, an IP address of the traffic data packet is obtained, and according to a longest prefix matching rule and the IP address of the traffic data packet, a statistical item of the IP network segment in the IP network segment linked list is refreshed; According to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, the statistical items of the IP network segments in the IP network segment linked list are refreshed to obtain the traffic statistical values ​​of all the address groups to be counted in a statistical cycle.

[0005] In some embodiments, obtaining the IP network segment linked list set according to all the address groups to be counted specifically includes: Converting the group elements in each of the address groups to be counted into a representation of an IP network segment to obtain a corresponding IP network segment subset, and summarizing all IP network segment subsets to obtain a first IP network segment set; Remove duplicate IP network segments and IP network segments with inclusion relationships from the first IP network segment set to obtain a second IP network segment set; The second IP network segment set is classified according to the mask to obtain the IP network segment linked list set.

[0006] In some more specific embodiments, converting the group elements in each of the to-be-counted address groups into a representation of an IP network segment specifically includes: Converting the group elements in the address group to be counted, which are in the form of IP addresses, into group elements in the form of IP network segments; The group elements in the address group to be counted, which are in the form of IP ranges, are converted into group elements in the form of IP network segments.

[0007] The step of removing duplicate network segments and network segments with a containment relationship from the first IP network segment set to obtain a second IP network segment set specifically includes: Determine whether there is an inclusion relationship between the IP network segments in each of the IP network segment subsets; If so, remove the included IP network segment from the IP network segment subset; Determine whether there are duplicate IP network segments in all the IP network segment subsets; If so, remove the duplicate IP network segments from the IP network segment subset to obtain the second IP network segment set; Number each IP network segment in the second IP network segment set, and associate the number of the IP network segment with the address group to be counted.

[0008] In some more specific embodiments, performing IP classification on the second IP network segment set according to the mask to obtain the IP network segment linked list set specifically includes: Putting the IP network segments with the same mask in the second IP network segment set into an IP network segment linked list, thereby obtaining a plurality of the IP network segment linked lists with different masks; Each of the IP network segment linked lists is put into a hash table, and the hash table is used to accelerate the search for the longest parent network segment of each IP network segment in the IP network segment linked list.

[0009] In some embodiments, refreshing the statistical items of the IP network segments in the IP network segment linked list according to the longest prefix matching rule and the IP address of the traffic data packet specifically includes: According to the longest prefix matching rule and the IP address of the traffic data packet, the IP network segment to which the IP address of the traffic data packet belongs is obtained by matching the IP network segment linked list set using the longest prefix matching rule; Refresh the statistical items of the IP network segment in the IP network segment linked list.

[0010] In some more specific embodiments, refreshing the statistical items of the IP network segments in the IP network segment linked list according to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, and obtaining the traffic statistical values ​​of all the address groups to be counted in a statistical cycle, specifically includes: Find the longest parent network segment of each IP network segment in the IP network segment linked list to obtain the longest parent network segment of each IP network segment; Adding the statistical items of each of the IP network segments to the statistical items of the longest parent IP network segment of the IP network segment; According to the association between the IP network segment number and each of the address groups to be counted, the statistical items of the IP network segment in the IP network segment linked list are refreshed to the statistical items of the corresponding group elements of each of the address groups to be counted, thereby obtaining the statistical items of each of the address groups to be counted.

[0011] In some more specific embodiments, searching the longest parent network segment of each IP network segment in the IP network segment linked list to obtain the longest parent network segment of each IP network segment specifically includes: According to the order of the masks of the IP network segment chain list from long to short, the first IP network segment of the IP network segment chain list with the longest mask in the IP network segment chain list set is used as the sub-IP network segment, and the longest parent network segment of the sub-IP network segment is retrieved from the first IP network segment of the next IP network segment chain list of the IP network segment chain list to which the sub-IP network segment belongs, to obtain the longest parent network segment of the sub-IP network segment; Record the longest parent network segment number of the sub-IP network segment to the sub-IP network segment.

[0012] According to a second aspect, a device for counting traffic of an address group is provided, the device comprising: A first processing module is used to obtain an IP network segment linked list set according to all the address groups to be counted, wherein the address groups to be counted are configured by the customer, the IP network segment linked list set is a set consisting of multiple IP network segment linked lists, and each IP network segment linked list is a linked list consisting of network segments belonging to the same mask; A second processing module is used for, in a statistical cycle, in response to determining that a received traffic data packet is received, obtaining an IP address of the traffic data packet, and refreshing the statistical items of the IP network segment in the IP network segment linked list according to the longest prefix matching rule and the IP address of the traffic data packet; The third processing module is used to refresh the statistical items of the IP network segments in the IP network segment linked list according to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, so as to obtain the traffic statistical values ​​of all the address groups to be counted in a statistical cycle.

[0013] In some embodiments, the first processing module is specifically used to convert the group elements in each of the address groups to be counted into a representation of an IP network segment, obtain a corresponding IP network segment subset, and aggregate all IP network segment subsets to obtain a first IP network segment set; Remove duplicate IP network segments and IP network segments with inclusion relationships from the first IP network segment set to obtain a second IP network segment set; The second IP network segment set is classified according to the mask to obtain the IP network segment linked list set.

[0014] In some more specific embodiments, the first processing module is specifically used to convert the group elements in the address group to be counted, which are represented by IP addresses, into group elements in the form of IP network segments; The group elements in the address group to be counted, which are in the form of IP ranges, are converted into group elements in the form of IP network segments.

[0015] In some more specific embodiments, the first processing module is specifically used to determine whether there is an inclusion relationship between the IP network segments in each of the IP network segment subsets; If so, remove the included IP network segment from the IP network segment subset; Determine whether there are duplicate IP network segments in all the IP network segment subsets; If so, remove the duplicate IP network segments from the IP network segment subset to obtain the second IP network segment set; Number each IP network segment in the second IP network segment set, and associate the number of the IP network segment with the address group to be counted.

[0016] In some more specific embodiments, the first processing module is specifically used to put the IP network segments with the same mask in the second IP network segment set into an IP network segment linked list, thereby obtaining a plurality of the IP network segment linked lists with different masks; Each of the IP network segment linked lists is put into a hash table, and the hash table is used to accelerate the search for the longest parent network segment of each IP network segment in the IP network segment linked list.

[0017] In some embodiments, the second processing module is specifically used to obtain the IP network segment to which the IP address of the traffic data packet belongs according to the longest prefix matching rule and the IP address of the traffic data packet, wherein the IP network segment is the IP network segment to which the IP address of the traffic data packet belongs obtained by matching the longest prefix matching rule in the IP network segment linked list set; Refresh the statistical items of the IP network segment in the IP network segment linked list.

[0018] In some embodiments, the third processing module is specifically used to find the longest parent network segment of each IP network segment in the IP network segment linked list to obtain the longest parent network segment of each IP network segment; Adding the statistical items of each of the IP network segments to the statistical items of the longest parent IP network segment of the IP network segment; According to the association between the IP network segment number and each of the address groups to be counted, the statistical items of the IP network segment in the IP network segment linked list are refreshed to the statistical items of the corresponding group elements of each of the address groups to be counted, thereby obtaining the statistical items of each of the address groups to be counted.

[0019] In some more specific embodiments, the third processing module is specifically used to, in the order of the masks of the IP network segment chain list from long to short, take the first IP network segment of the IP network segment chain list with the longest mask in the IP network segment chain list as the sub-IP network segment, and retrieve the longest parent network segment of the sub-IP network segment from the first IP network segment of the next IP network segment chain list of the IP network segment chain list to which the sub-IP network segment belongs, to obtain the longest parent network segment of the sub-IP network segment; Record the longest parent network segment number of the sub-IP network segment to the sub-IP network segment.

[0020] In a third aspect, the present invention further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements an address group traffic statistics method described in any one of the above technical solutions when executing the computer program.

[0021] In a fourth aspect, the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, an address group traffic statistics method described in any one of the above technical solutions is implemented.

[0022] The present invention provides a method and device for address group traffic statistics. The method comprises obtaining an IP network segment linked list set according to all address groups to be counted, obtaining the IP address of the traffic data packet in response to determining the received traffic data packet in a statistical cycle, refreshing the statistical items of the IP network segment in the IP network segment linked list set according to the longest prefix matching rule and the IP address of the traffic data packet, and obtaining the traffic statistical values ​​of all address groups to be counted in a statistical cycle according to the statistical items of the IP network segment in the IP network segment linked list set. The present invention solves the problem that an IP address needs to be matched multiple times, greatly reduces the search and matching work, reduces the consumption of device performance, and improves device performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings: Figure 1 It is a flow chart of a method for collecting traffic statistics of an address group provided by an embodiment of the present invention; Figure 2 A flow chart of a method for collecting traffic statistics of an address group provided by an embodiment of the present invention; Figure 3 A flow chart of a method for collecting traffic statistics of an address group provided by an embodiment of the present invention; Figure 4 A schematic diagram of an address group in an address group traffic statistics method provided by an embodiment of the present invention; Figure 5 A schematic diagram of address group preprocessing in an address group traffic statistics method provided by an embodiment of the present invention; Figure 6 A schematic diagram of address group preprocessing in an address group traffic statistics method provided by an embodiment of the present invention; Figure 7 A schematic diagram of address group preprocessing in an address group traffic statistics method provided by an embodiment of the present invention; Figure 8 A schematic diagram of arranging network segments in a method for counting traffic of an address group provided by an embodiment of the present invention; Fig. 9 A schematic diagram of summarizing statistical values ​​of address groups in a method for collecting traffic statistics of address groups provided in an embodiment of the present invention; Fig.10 A schematic diagram of summarizing statistical values ​​of address groups in a method for collecting traffic statistics of address groups provided in an embodiment of the present invention; Fig.11 A schematic diagram of summarizing statistical values ​​of address groups in a method for collecting traffic statistics of address groups provided in an embodiment of the present invention; Fig.12 A schematic diagram of a module of an address group traffic statistics device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0024] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other without conflict.

[0025] The following detailed description is an exemplary description, which is intended to provide further detailed description of the present invention. Unless otherwise specified, all technical terms used in the present invention have the same meaning as those generally understood by those skilled in the art to which the present invention belongs. The terms used in the present invention are only for describing specific embodiments, and are not intended to limit the exemplary embodiments according to the present invention.

[0026] In network communication equipment such as switches and firewalls, the hardware architecture of the equipment is designed to quickly forward network messages, and the statistics of network traffic indicators will affect the performance of the equipment. At the same time, the large number of network addresses configured by customers will have a significant impact on the performance of network communication equipment.

[0027] For example, in order to collect statistics on network traffic indicators such as the number of packets, bandwidth, and number of new sessions, traffic statistics are usually collected by address group and reported to the database at regular statistical intervals.

[0028] An address group can contain a single IP address such as 10.0.0.5, an IP network segment such as 10.0.0.0 / 16, and an IP range such as 10.0.0.4-10.0.0.10. At the same time, the device supports the configuration of a large number of address groups, and the address network segments involved in a large number of address groups may be repeated, overlapped, or included.

[0029] The usual practice is to use the IP address of the traffic data packet to traverse the network segments in all address groups. Multiple matches may be required to count all the hit IP address groups.

[0030] For example, if an IP address hits both address group A and address group B, the statistics of the IP address will be counted for both address group A and address group B. When there are many address groups and many network segments in the address groups, a large amount of search and matching work will seriously consume device performance, resulting in reduced device performance.

[0031] The following will be combined with the attached Figures 1 to 3 , a method for counting traffic of an address group provided by an embodiment of the present invention is described. The method comprises: 110. According to all the address groups to be counted, an IP network segment linked list set is obtained, wherein the address groups to be counted are configured by the customer, and the IP network segment linked list set is a collection of multiple IP network segment linked lists, and each IP network segment linked list is a linked list composed of network segments belonging to the same mask.

[0032] Specifically, the address group to be counted is configured by the customer. There are multiple representation forms of the address group configured by the customer, such as a single address 10.1.0.1, 10.1.0.0 / 16 and 10.0.0.4-10.0.0.10.

[0033] In some embodiments, step 110 specifically includes: 111. Convert the group elements in each address group to be counted into a representation of an IP network segment to obtain a corresponding IP network segment subset, and aggregate all IP network segment subsets to obtain a first IP network segment set; 112. Remove duplicate IP network segments and IP network segments with inclusion relationships from the first IP network segment set to obtain a second IP network segment set; 113. Classify the second IP network segment set according to the mask to obtain an IP network segment linked list set.

[0034] In some more specific embodiments, step 111 specifically includes: Convert the group elements in the address group to be counted, which are in the form of IP addresses, into group elements in the form of IP network segments; The group elements in the address group to be counted, which are in the form of IP range, are converted into group elements in the form of IP network segment.

[0035] In some more specific embodiments, step 112 specifically includes: Determine whether there is an inclusion relationship between the IP segments in each IP segment subset; If it exists, remove the included IP segment from the IP segment subset; Determine whether there are duplicate IP network segments in all IP network segment subsets; If so, remove the duplicate IP network segments from the IP network segment subset to obtain a second IP network segment set; Each IP network segment in the second IP network segment set is numbered, and the number of the IP network segment is associated with the address group to be counted.

[0036] In some more specific embodiments, step 113 specifically includes: Put the IP network segments with the same mask in the second IP network segment set into an IP network segment linked list, thereby obtaining multiple IP network segment linked lists with different masks; Each IP network segment linked list is put into a hash table, and the hash table is used to speed up the search for the longest parent network segment of each IP network segment in the IP network segment linked list.

[0037] 120. In a statistical cycle, in response to determining that a traffic data packet is received, an IP address of the traffic data packet is obtained, and according to a longest prefix matching rule and the IP address of the traffic data packet, a statistical item of the IP network segment in the IP network segment linked list is refreshed.

[0038] In some more specific embodiments, step 120 specifically includes: 121. According to the longest prefix matching rule and the IP address of the traffic data packet, obtain the IP network segment to which the IP address of the traffic data packet belongs, wherein the IP network segment is the IP network segment to which the IP address of the traffic data packet belongs obtained by matching the longest prefix matching rule in the IP network segment linked list set.

[0039] Specifically, the longest prefix matching rule is used in this application to match the IP address of the traffic data packet and extract the IP address of the traffic data packet. The IP address includes the IP address of the sender, the IP address of the receiver, or the IP address in the message payload.

[0040] The extracted IP address is compared with all entries in the IP segment linked list set to find the best match.

[0041] Each entry contains a network address and a subnet mask. The subnet mask defines the length of the network address, which is the prefix length. For example, for the IPv4 address 192.0.2.0 / 24, the prefix length is 24 bits, which means that the first 24 bits are the network portion.

[0042] Find the entry with the longest matching prefix. If there are multiple entries with the same prefix, choose the one with the longest prefix length.

[0043] The longest prefix match can be implemented using different data structures and technologies, such as Trie tree (dictionary tree), binary search tree, PATRICIA tree (Prefix Tree with Compressed Interior Nodes), etc. This application does not impose any restrictions.

[0044] 122. Refresh the statistics items of IP network segments in the IP network segment linked list.

[0045] 130. According to the IP segments in the IP segment linked list and the longest parent segment of each IP segment, the statistical items of the IP segments in the IP segment linked list are refreshed to obtain the traffic statistics of all the address groups to be counted in a statistical cycle.

[0046] In some more specific embodiments, step 130 specifically includes: 131. Find the longest parent network segment of each IP network segment in the IP network segment linked list, and obtain the longest parent network segment of each IP network segment; 132. Add the statistics of each IP network segment to the statistics of the longest parent IP network segment of the IP network segment; 133. According to the association between the IP network segment number and each address group to be counted, the statistical items of the IP network segment in the IP network segment linked list are refreshed to the statistical items of the group elements of the corresponding address groups to be counted, thereby obtaining the statistical items of each address group to be counted.

[0047] In some more specific embodiments, step 131 specifically includes: According to the order of the masks of the IP network segment chain list from long to short, the first IP network segment of the IP network segment chain list with the longest mask in the IP network segment chain list is used as the sub-IP network segment, and the longest parent network segment of the sub-IP network segment is retrieved from the first IP network segment of the next IP network segment chain list of the IP network segment chain list to which the sub-IP network segment belongs, to obtain the longest parent network segment of the sub-IP network segment; Record the longest parent network segment number of the sub-IP network segment to the sub-IP network segment.

[0048] The above embodiment involves a method for counting traffic of an address group, including obtaining an IP network segment linked list set according to all address groups to be counted, obtaining the IP address of the traffic data packet in response to determining the received traffic data packet in a statistical cycle, refreshing the statistical items of the IP network segment in the IP network segment linked list set according to the longest prefix matching rule and the IP address of the traffic data packet, and obtaining the traffic statistical values ​​of all address groups to be counted in a statistical cycle according to the statistical items of the IP network segment in the IP network segment linked list set.

[0049] The present invention solves the problem that an IP address needs to be matched multiple times, greatly reduces the search and matching work, reduces the consumption of device performance, and improves device performance.

[0050] The following will be combined with the attached Figure 4 , a method for counting traffic of an address group provided by an embodiment of the present invention is described, including an address group processing module, a network segment sorting module, an IP address matching module, and a module for summarizing the statistical value of the address group, each of which is briefly described as follows.

[0051] Address group preprocessing mainly splits the address group into IP segments. Arrange the segments, classify the segments with the same mask, and create an LPM table. Use the LPM algorithm to determine the segment that the IP address hits. Aggregate the statistical values ​​of each segment under the address group to the address group.

[0052] 1. The address group preprocessing module includes the following steps: 1.1 Convert the IP addresses, IP network segments and IP ranges contained in the address group into IP network segments.

[0053] like Figure 2 As shown in the figure, address group A includes 10.1.0.1, 10.1.0.0 / 16 and 10.0.0.4-10.0.0.10, which is converted into the following network segments: 10.1.0.1 / 32, 10.1.0.0 / 16, 10.0.0.4 / 30, 10.0.0.8 / 31, 10.0.0.10 / 32.

[0054] Specifically, different forms of address representation in the address group are converted into a network segment form, and may also be converted into an IP address representation form or an IP range representation form.

[0055] 1.2 Within each address group, if there are network segments with inclusion relationships, remove the included network segments.

[0056] like Figure 5 , the network segments obtained through the conversion in step 1.1, because 10.1.0.0 / 16 contains 10.1.0.1 / 32, 10.1.0.1 / 32 is removed. The following network segments are obtained: 10.1.0.0 / 16, 10.0.0.4 / 30, 10.0.0.8 / 31, 10.0.0.10 / 32.

[0057] Specifically, it can be determined whether there are network segments with an inclusion relationship based on mask operation, and the included network segments can be removed. The specific mask operation method is prior art and will not be described in detail in this embodiment.

[0058] 1.3. Summarize all network segments of all address groups and remove duplicates.

[0059] like Figure 6 , address group A includes 10.1.0.0 / 16, 10.0.0.4 / 30, 10.0.0.8 / 31, 10.0.0.10 / 32; After processing in steps 1 and 2, address group B includes 10.2.0.0 / 16, 10.0.0.4 / 30, and 10.0.0.9 / 32. After being processed in steps 1 and 2, address group C includes 10.0.0.8 / 30 and 9.8.0.0 / 16.

[0060] The duplicate network segment of address group A and address group B is 10.0.0.4 / 30. After removing the duplicate network segments in address group A or address group B, the network segments of address groups A, B and C after aggregation are: 10.1.0.0 / 16, 10.0.0.4 / 30, 10.0.0.8 / 31, 10.0.0.10 / 32, 10.2.0.0 / 16, 10.0.0.9 / 32, 10.0.0.8 / 30, 9.8.0.0 / 16.

[0061] Therefore, it can be concluded that after processing in steps 1.1-1.3, in the generated network segments, two network segments with a containment relationship must belong to different address groups.

[0062] 1.4. If Figure 7 As shown in the figure, each network segment is given an integer ID, and a structure is allocated to record the ID and statistical items; and the network segments and corresponding IDs of each address group are recorded.

[0063] 2. Arrange the network segment module 2.1 For IPv4 addresses, there are 32-bit masks in total. Classify the network segments with the same mask in each address group together. Connect the network segments with the same mask together to form linked lists, namely List1, List2, Liste3...List32.

[0064] like Figure 8 As shown, in order to facilitate subsequent searches, network segments with the same mask can also be added to the same HASH table.

[0065] 2.2 Add all IP network segments to the longest prefix match rule LPM, and the next hop of LPM is the ID of the network segment.

[0066] Specifically, the longest prefix match rule LPM is a common network technology and will not be described in detail.

[0067] 3. IP address matching module When collecting statistics on a flow-by-flow basis, obtain the IP address in each data flow, perform an LPM query on the IP address, obtain the network segment ID, and update the statistics value of the network segment.

[0068] 4. Module for summarizing the statistics of address groups In a network segment set, if there is an inclusion relationship between two network segments, for example, network segment 1 includes network segment 2, then network segment 1 is called the parent network segment and network segment 2 is called the child network segment. Assuming that network segment 3 is the parent network segment with the longest mask of network segment 2, network segment 3 is called the longest parent network segment of network segment 2.

[0069] After a statistical period, the statistical values ​​within this statistical period need to be summarized and reported. Because if an IP address belongs to a subnet segment, it must also belong to the parent network segment, and the LPM algorithm will hit the subnet segment, so the statistical values ​​of the subnet segment need to be summarized to the statistical values ​​of the parent network segment. Then the statistical values ​​of all network segments are summarized to the corresponding address group.

[0070] First, process the network segments in List32. A network segment in List32 is recorded as net32. Search for the longest parent network segment from List31, List30, and List1 in turn. If found, aggregate the statistical values ​​of net32 to the longest parent network segment.

[0071] like Fig. 9 As shown in the figure, for the network segment 10.0.0.9 / 32, the network segment 10.0.0.8 / 31 is found in List31 as its longest parent network segment, and the statistical values ​​of the network segment 10.0.0.9 / 32 are aggregated to 10.0.0.8 / 31.

[0072] Process the network segments in List31, List30, ... List1 in turn, find their longest parent network segment, and aggregate the statistical values ​​to the longest parent network segment.

[0073] like Fig.10 As shown in the figure, the network segment 10.0.0.8 / 31 in List31 is found in List30 to be its longest parent network segment, and the statistical values ​​of the network segment 10.0.0.8 / 31 are aggregated into the statistical values ​​of 10.0.0.8 / 30.

[0074] After all the network segments from List32 to List1 are processed, the statistical value of each network segment includes the statistical value of its sub-network segment.

[0075] In addition, to avoid repeated searches for the parent network segment each time statistics are performed, the integer ID of the longest parent network segment of each sub-segment can be recorded in the network segment sorting module. When summarizing, the statistical values ​​of the sub-segments can be directly summarized to the longest parent network segment.

[0076] like Fig.11 As shown, for each address group, the statistical values ​​of all network segments included in the address group are finally summarized to obtain the statistical value of the address group.

[0077] like Fig.12 As shown, a device for counting traffic of an address group is provided, the device comprising: A first processing module is used to obtain an IP network segment linked list set according to all the address groups to be counted, wherein the address groups to be counted are configured by the customer, the IP network segment linked list set is a set consisting of multiple IP network segment linked lists, and each IP network segment linked list is a linked list consisting of network segments belonging to the same mask; A second processing module is used for, in a statistical cycle, in response to determining that a received traffic data packet is received, obtaining an IP address of the traffic data packet, and refreshing the statistical items of the IP network segment in the IP network segment linked list according to the longest prefix matching rule and the IP address of the traffic data packet; The third processing module is used to refresh the statistical items of the IP network segments in the IP network segment linked list according to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, so as to obtain the traffic statistical values ​​of all the address groups to be counted in a statistical cycle.

[0078] In some embodiments, the first processing module is specifically used to convert the group elements in each of the address groups to be counted into a representation of an IP network segment, obtain a corresponding IP network segment subset, and aggregate all IP network segment subsets to obtain a first IP network segment set; Remove duplicate IP network segments and IP network segments with inclusion relationships from the first IP network segment set to obtain a second IP network segment set; The second IP network segment set is classified according to the mask to obtain the IP network segment linked list set.

[0079] In some more specific embodiments, the first processing module is specifically used to convert the group elements in the address group to be counted, which are represented by IP addresses, into group elements in the form of IP network segments; The group elements in the address group to be counted, which are in the form of IP ranges, are converted into group elements in the form of IP network segments.

[0080] In some more specific embodiments, the first processing module is specifically used to determine whether there is an inclusion relationship between the IP network segments in each of the IP network segment subsets; If so, remove the included IP network segment from the IP network segment subset; Determine whether there are duplicate IP network segments in all the IP network segment subsets; If so, remove the duplicate IP network segments from the IP network segment subset to obtain the second IP network segment set; Number each IP network segment in the second IP network segment set, and associate the number of the IP network segment with the address group to be counted.

[0081] In some more specific embodiments, the first processing module is specifically used to put the IP network segments with the same mask in the second IP network segment set into an IP network segment linked list, thereby obtaining a plurality of the IP network segment linked lists with different masks; Each of the IP network segment linked lists is put into a hash table, and the hash table is used to accelerate the search for the longest parent network segment of each IP network segment in the IP network segment linked list.

[0082] In some embodiments, the second processing module is specifically used to obtain the IP network segment to which the IP address of the traffic data packet belongs according to the longest prefix matching rule and the IP address of the traffic data packet, wherein the IP network segment is the IP network segment to which the IP address of the traffic data packet belongs obtained by matching the longest prefix matching rule in the IP network segment linked list set; Refresh the statistical items of the IP network segment in the IP network segment linked list.

[0083] In some embodiments, the third processing module is specifically used to find the longest parent network segment of each IP network segment in the IP network segment linked list to obtain the longest parent network segment of each IP network segment; Adding the statistical items of each of the IP network segments to the statistical items of the longest parent IP network segment of the IP network segment; According to the association between the IP network segment number and each of the address groups to be counted, the statistical items of the IP network segment in the IP network segment linked list are refreshed to the statistical items of the corresponding group elements of each of the address groups to be counted, thereby obtaining the statistical items of each of the address groups to be counted.

[0084] In some more specific embodiments, the third processing module is specifically used to, in the order of the masks of the IP network segment chain list from long to short, take the first IP network segment of the IP network segment chain list with the longest mask in the IP network segment chain list as the sub-IP network segment, and retrieve the longest parent network segment of the sub-IP network segment from the first IP network segment of the next IP network segment chain list of the IP network segment chain list to which the sub-IP network segment belongs, to obtain the longest parent network segment of the sub-IP network segment; Record the longest parent network segment number of the sub-IP network segment to the sub-IP network segment.

[0085] The above embodiment involves an address group traffic statistics device. It includes obtaining an IP network segment linked list set according to all address groups to be counted, obtaining the IP address of the traffic data packet in response to determining the received traffic data packet in a statistical cycle, refreshing the statistical items of the IP network segment in the IP network segment linked list set according to the longest prefix matching rule and the IP address of the traffic data packet, and obtaining the traffic statistics of all address groups to be counted in a statistical cycle according to the statistical items of the IP network segment in the IP network segment linked list set. The present invention solves the problem that an IP address needs to be matched multiple times, greatly reduces the search and matching work, reduces the consumption of equipment performance, and improves equipment performance.

[0086] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, an address group traffic statistics method described in any one of the above technical solutions is implemented.

[0087] The present invention also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, an address group traffic statistics method described in any one of the above technical solutions is implemented.

[0088] The functional blocks shown in the structural block diagram described above can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier. "Machine-readable medium" may include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROMs, flash memories, erasable ROMs (EROMs), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0089] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.

[0090] The above reference is made to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present application, and describe various aspects of the present application. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the functions / actions specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0091] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.

Claims

1. A method for collecting traffic statistics of an address group, characterized in that: The method comprises: According to all the address groups to be counted, an IP network segment linked list set is obtained, wherein the address groups to be counted are configured by the customer, and the IP network segment linked list set is a set consisting of multiple IP network segment linked lists, and each IP network segment linked list is a linked list consisting of network segments belonging to the same mask; In a statistical cycle, in response to determining that a traffic data packet is received, an IP address of the traffic data packet is obtained, and according to a longest prefix matching rule and the IP address of the traffic data packet, a statistical item of the IP network segment in the IP network segment linked list is refreshed; According to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, the statistical items of the IP network segments in the IP network segment linked list are refreshed to obtain the traffic statistical values ​​of all the address groups to be counted in a statistical cycle.

2. The method according to claim 1, characterized in that: The method of obtaining an IP network segment linked list set according to all the address groups to be counted specifically includes: Converting the group elements in each of the address groups to be counted into a representation of an IP network segment to obtain a corresponding IP network segment subset, and summarizing all IP network segment subsets to obtain a first IP network segment set; Remove duplicate IP network segments and IP network segments with inclusion relationships from the first IP network segment set to obtain a second IP network segment set; The second IP network segment set is classified according to the mask to obtain the IP network segment linked list set.

3. The method according to claim 2, characterized in that The converting of the group elements in each of the address groups to be counted into a representation of an IP network segment specifically includes: Converting the group elements in the address group to be counted, which are in the form of IP addresses, into group elements in the form of IP network segments; Converting the group elements in the address group to be counted, which are in the form of IP range, into group elements in the form of IP network segment; The step of removing duplicate network segments and network segments with a containment relationship from the first IP network segment set to obtain a second IP network segment set specifically includes: Determine whether there is an inclusion relationship between the IP network segments in each of the IP network segment subsets; If so, remove the included IP network segment from the IP network segment subset; Determine whether there are duplicate IP network segments in all the IP network segment subsets; If so, remove the duplicate IP network segments from the IP network segment subset to obtain the second IP network segment set; Number each IP network segment in the second IP network segment set, and associate the number of the IP network segment with the address group to be counted.

4. The method according to claim 2, characterized in that: The step of performing IP classification on the second IP network segment set according to the mask to obtain the IP network segment linked list set specifically includes: Putting the IP network segments with the same mask in the second IP network segment set into an IP network segment linked list, thereby obtaining a plurality of the IP network segment linked lists with different masks; Each of the IP network segment linked lists is put into a hash table, and the hash table is used to accelerate the search for the longest parent network segment of each IP network segment in the IP network segment linked list.

5. The method according to claim 1, characterized in that The step of refreshing the statistical items of the IP network segments in the IP network segment linked list according to the longest prefix matching rule and the IP address of the traffic data packet specifically includes: According to the longest prefix matching rule and the IP address of the traffic data packet, the IP network segment to which the IP address of the traffic data packet belongs is obtained by matching the IP network segment linked list set using the longest prefix matching rule; Refresh the statistical items of the IP network segment in the IP network segment linked list.

6. The method according to claim 1, characterized in that The method of refreshing the statistical items of the IP network segments in the IP network segment linked list according to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, and obtaining the traffic statistical values ​​of all the address groups to be counted in a statistical cycle, specifically includes: Find the longest parent network segment of each IP network segment in the IP network segment linked list to obtain the longest parent network segment of each IP network segment; Adding the statistical items of each of the IP network segments to the statistical items of the longest parent IP network segment of the IP network segment; According to the association between the IP network segment number and each of the address groups to be counted, the statistical items of the IP network segment in the IP network segment linked list are refreshed to the statistical items of the corresponding group elements of each of the address groups to be counted, thereby obtaining the statistical items of each of the address groups to be counted.

7. The method according to claim 6, characterized in that The searching for the longest parent network segment of each IP network segment in the IP network segment linked list to obtain the longest parent network segment of each IP network segment specifically includes: According to the order of the masks of the IP network segment chain list from long to short, the first IP network segment of the IP network segment chain list with the longest mask in the IP network segment chain list set is used as the sub-IP network segment, and the longest parent network segment of the sub-IP network segment is retrieved from the first IP network segment of the next IP network segment chain list of the IP network segment chain list to which the sub-IP network segment belongs, to obtain the longest parent network segment of the sub-IP network segment; Record the longest parent network segment number of the sub-IP network segment to the sub-IP network segment.

8. An address group traffic statistics device, characterized in that: The device comprises: A first processing module is used to obtain an IP network segment linked list set according to all the address groups to be counted, wherein the address groups to be counted are configured by the customer, the IP network segment linked list set is a set consisting of multiple IP network segment linked lists, and each IP network segment linked list is a linked list consisting of network segments belonging to the same mask; A second processing module is used for, in a statistical cycle, in response to determining that a received traffic data packet is received, obtaining an IP address of the traffic data packet, and refreshing the statistical items of the IP network segment in the IP network segment linked list according to the longest prefix matching rule and the IP address of the traffic data packet; The third processing module is used to refresh the statistical items of the IP network segments in the IP network segment linked list according to the IP network segments in the IP network segment linked list and the longest parent network segment of each IP network segment, so as to obtain the traffic statistical values ​​of all the address groups to be counted in a statistical cycle.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, an address group traffic statistics method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, an address group traffic statistics method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Checking method and checking device

    CN102739520A

  • Traffic statistic method and device

    CN103685057A

  • Message processing method and device and computer readable storage medium

    CN107707477A

  • Auxiliary flow prediction control method, storage medium and electronic equipment

    CN109831320A

  • IP address matching method and device

    CN109905413A

Cited By

  • Rapid rule matching method and device for flow analysis

    CN122160315A

  • A fast rule matching method and device for traffic analysis

    CN122160315B