A flow record counting method and system based on programmable switch
By using multi-hashed Bloom record tables and cascade Bloom record tables on programmable switches, combined with the loopback mechanism, the accuracy and load problems of flow record counting are solved, and accurate counting and flow IDs independent of flow size are achieved. Recording, providing efficient traffic monitoring capabilities.
Patent Information
- Application Number
- CN202211358713.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-01
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2042-11-01
AI Technical Summary
The existing flow recording and counting solution based on P4 programmable switches has problems such as low accuracy, inability to record flow IDs, inability to cope with heavier loads, and the inability to predict whether counting errors will occur.
Adopt a flow record counting method based on programmable switches, use bloom record tables of multiple hash functions to record flow IDs, resolve conflicts through cascaded bloom record tables and loopback mechanisms, and provide conflict resolution strategies and error detection , ensuring the accuracy and traceability of flow counts.
It achieves accurate flow counting regardless of flow size, can record flow IDs, maintain high performance under high load conditions, and provides error detection functions to ensure the reliability of counting results.
Smart Images

Figure CN115766600B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of programmable switches and flow monitoring and measurement, and in particular to a flow record counting method and system based on a programmable switch. Background Art
[0002] With the continuous development of information technology, the number of flows needs to be counted in many scenarios. Accurate and traceable flow record counting is very necessary. It is the basic work for many tasks to be carried out and can be used in many scenarios, such as gateway flow record counting, traffic monitoring on network middleware, network measurement tasks, etc. This type of method can also be used for distributed machine learning, consistency protocols within the network, token bucket mechanisms, etc., and has a wide range of applications. However, as the speed and complexity of network traffic continue to increase, the challenges faced by flow record counting are also increasing. Flow record counting must keep up with the ultra-high speed of network traffic. For example, on a 100Gbps link in a backbone network, a single switch needs to support Tb-level traffic, and the processing time left for a single data packet may be only tens of nanoseconds.
[0003] In this case, traditional software switches will have major performance issues and cannot process ultra-high-speed traffic at line speed. In order to increase the processing speed of data packets, some switch manufacturers use ASIC chips instead of traditional CPU-based software solutions to speed up the processing of data packets. However, the development of ASIC chips is difficult and time-consuming, and the cost of personalized customization for a specific task is extremely high, which greatly restricts the development of network technology.
[0004] With the emergence of software-defined networks (SDNs) and the separation of control plane and data plane functions, P4 technology for programming the data plane has gradually emerged. Data plane programming technology allows the parsing, processing, and forwarding of data packets to be controlled through control plane programming, and achieves higher performance by leveraging the advantages of programmable ASICs (application-specific integrated circuits). Some work that was originally placed on the server can be transferred to the P4 switch to achieve performance improvements. Therefore, some researchers hope to implement the flow statistics function using the P4 programmable switch, and some work on flow statistics based on programmable switches has emerged.
[0005] Currently, there are three main flow record counting solutions based on P4 programmable switches:
[0006] ① Sampling-recovery scheme. The basic idea of this type of scheme is: when a high-speed data stream arrives, although we cannot count every data stream, we can extract a part of the data stream from the data stream according to a certain probability ratio (such as a ratio of p) for statistics, and then restore the original result with a probability of (1 / p) after the statistics are completed. This is the earliest, most traditional, and simplest scheme, but their biggest problem is that there are errors, and the results will be greatly different depending on the flow distribution.
[0007] ② Sketch-based flow counting scheme: Sketch uses a compact data structure and a fixed calculation method to record traffic information. Common ones include Count-Min (CM) Sketch, Conservative-Update (CU) Sketch, CountSketch, etc. Taking the most common Count-Min (CM) Sketch as an example, it consists of d rows of counters, each of which contains r counters and has an independent hash function associated with it. When a data packet arrives, it is hashed to a counter and the counter is increased by 1 in each row of the sketch. Finally, given a flow, we get the counter corresponding to the flow ID in each row and take the minimum value as the estimated size of the flow. This scheme can be traced back to the last century, but it has ushered in great development again after the emergence of programmable switches. However, this is also a probabilistic solution and flow ID recording is not possible.
[0008] ③Solutions that can maintain flow IDs: This type of solution is relatively scattered and has its own characteristics. These solutions can record flow IDs, but most of them focus on the statistics of "elephant flows" and some also have some performance issues.
[0009] Currently, there are three main flow record counting solutions based on P4 programmable switches:
[0010] Problems with the "sampling-recovery" scheme: It is a highly random scheme: first, there will be deviations when sampling, and it is unknown whether errors have occurred; second, the recovery of the complete flow count from the sampling results is basically based on certain statistical properties. When the flow characteristics are not stable and constantly changing, its accuracy will be very poor. Although some work has been done to enhance this process, information loss is still inevitable. Moreover, this method cannot maintain the flow ID, and it is impossible to trace which flows have been counted. This type of scheme is sensitive to the size of the flow, and has a better counting effect for large flows, but a poorer counting effect for small flows.
[0011] Problems with sketch-based flow counting schemes: Sketch uses a compact data structure and a fixed calculation method to record traffic information. Like the "sampling-recovery" scheme, sketch is also a type of probabilistic scheme. They also have certain probabilistic deviations in traffic counting, and it is unknown whether the deviation occurs; and different sketch algorithms may bring positive or negative deviations. More importantly, not all sketch algorithms can be implemented on switches, and sketch-based algorithms cannot maintain flow IDs, which means that although counting is performed, it is impossible to trace which flows are counted. Most schemes of this type are sensitive to the size of the flow, and the counting effect is better for large flows, but poorer for small flows.
[0012] Problems with other solutions that can maintain flow IDs: These solutions can record flow IDs, but most of these methods focus on the statistical problem of "elephant flows" and do not study the general flow record counting problem; the current sketch method is more accurate in counting large flows, but the accuracy of counting small flows is not high. The data structure used will also destroy the accuracy of flow estimation, and the accuracy cannot be estimated. Some work has studied the general flow record counting problem, but when they use a probability-based flow record counting structure, the decoding success rate will decrease when the load becomes high, resulting in unusable results. Summary of the invention
[0013] The purpose of the present invention is to solve some common problems that may occur when different schemes are currently used to implement flow record counting on a P4 programmable switch (such as low accuracy, inability to record flow IDs, inability to cope with heavier loads, inability to predict whether counting errors will occur, etc.), and propose a method that is independent of flow size and can accurately count flows and record flow IDs at the same time.
[0014] Specifically, the present invention proposes a flow record counting method based on a programmable switch, which includes:
[0015] Step 1: The programmable switch parses each data packet sent by the sender within the counting period to obtain the flow ID of the data packet, inputs the flow ID into multiple hash functions in the first hash group at the same time, and uses the hash value output by each hash function as the address index of the first Bloom record table;
[0016] Step 2: Determine whether the position of the address index in the first Bloom record table is empty. If so, record the stream ID at the position and give a flag indicating that the stream has been recorded, and add 1 to the counter value of the stream count; otherwise, determine whether the content recorded in the position is the same as the stream ID. If so, skip the subsequent recording steps directly. Otherwise, a record conflict occurs and execute step 3;
[0017] Step 3: Execute the conflict resolution strategy. If there is still a record conflict, a flag indicating a record error is given, and the error detection counter value is increased by 1.
[0018] Step 4: At any time or at the end of the counting cycle, the counter value of the flow count is output as the flow record counting result, and the counter value of the error detection is output as the error reference.
[0019] The flow record counting method based on a programmable switch, wherein the conflict resolution strategy includes: deploying multiple cascaded Bloom record tables to form a linked list, judging step by step whether the flow ID can be recorded in the current level record table, if so, recording the flow ID in the current level record table to resolve the conflict; if the flow ID already exists, skipping the subsequent recording steps; otherwise, there is still a record conflict.
[0020] The programmable switch-based flow record counting method, wherein the conflict resolution strategy includes: if the conflict is not resolved after the data packet passes through the cascaded Bloom record table for the first time, the data packet is looped back a custom number of times and the Bloom record table is reused; each loopback simultaneously inputs the flow ID into multiple hash functions in the hash group corresponding to the loopback, and the hash value output by each hash function is used as the new address index of the cascaded Bloom record table, and the values of these positions are judged step by step. If they are empty, the flow ID is recorded at the new address index position to resolve the conflict; if the flow ID already exists, the subsequent recording step is skipped; otherwise, there is still a record conflict.
[0021] The present invention also proposes a flow record counting system based on a programmable switch, comprising:
[0022] A parsing module, used for parsing each data packet sent by the sender within the counting period, obtaining a flow ID of the data packet, inputting the flow ID into multiple hash functions in the first hash group at the same time, and using the hash value output by each hash function as the address index of the first Bloom record table;
[0023] A judgment module is used to judge whether the position of the address index in the first Bloom record table is empty. If so, the stream ID is recorded at the position and a flag representing that the stream has been recorded is given, and the counter value of the stream count is increased by 1; otherwise, it is judged whether the content recorded in the position is the same as the stream ID. If so, the subsequent record is directly skipped, otherwise a record conflict occurs and the detection module is called;
[0024] The detection module is used to execute the conflict resolution strategy. If there is still a record conflict, a flag indicating a record error is given, and the error detection counter value is increased by 1;
[0025] The output module is used to output the counter value of the flow count as the flow record counting result and output the counter value of the error detection as the error reference at any time or at the end of the counting cycle.
[0026] The flow record counting system based on a programmable switch, wherein the conflict resolution strategy includes: deploying multiple cascaded Bloom record tables to form a linked list, judging step by step whether the flow ID can be recorded in the current level record table, if so, recording the flow ID in the current level record table to resolve the conflict; if the flow ID already exists, skipping the subsequent recording steps; otherwise, there is still a record conflict.
[0027] The programmable switch-based flow record counting system, wherein the conflict resolution strategy includes: if the conflict is not resolved after the data packet passes through the cascaded Bloom record table for the first time, the data packet is looped back a custom number of times and the Bloom record table is reused; each loopback simultaneously inputs the flow ID into multiple hash functions in the hash group corresponding to the loopback, and the hash value output by each hash function is used as the new address index of the cascaded Bloom record table, and the values of these positions are judged step by step. If they are empty, the flow ID is recorded at the new address index position to resolve the conflict; if the flow ID already exists, the subsequent recording steps are skipped; otherwise, there is still a record conflict.
[0028] The present invention also proposes a storage medium for storing a program for executing any of the flow size-independent flow record counting methods on a programmable switch.
[0029] The present invention also proposes a programmable switch, comprising the storage medium. When a processor of the programmable switch calls and executes a program in the storage medium, the programmable switch performs flow record counting.
[0030] The present invention also proposes a client, which is used for implementing a flow record counting system that is independent of flow size on any of the programmable switches.
[0031] It can be seen from the above scheme that the advantages of the present invention are:
[0032] like Figure 1 As shown in the schematic diagram of the application scenario, the use environment of the present invention can be that two servers are used as the sending end and the receiving end respectively, and the flow is recorded and counted through the switch in the middle.
[0033] In order to test the performance of the present invention, we constructed multiple different test data sets. We used the specific 32-bit field in the data packet as the distinguishing object, constructed 20,000 flows, and formed a pcap file. Based on these data sets, we conducted the following tests:
[0034] Test 1: Sequential stream record count test: The stream is arranged in order of ID
[0035] Test 2: Out-of-order stream record count test: the order of the stream is randomly disrupted
[0036] Test 3: Counting flow records with continuous heavy hitters: Some flows appear multiple times and are continuous, such as the flow numbers [1,5,3,3,3,7,4,9,6]. The size of the largest flow is more than 300 times that of a normal flow.
[0037] Test 4: Flow record counting test with out-of-order heavy hitters: Some flows appear multiple times but not continuously, such as the flow numbers [1,3,5,3,7,4,9,3,6]. Among them, the size of the largest flow is more than 300 times that of the general flow.
[0038] Test 5-1: Multi-packet flow test: The length of each flow is 2 data packets, and they are randomly shuffled.
[0039] Test 5-2: Multi-packet flow test: The length of each flow is 5 data packets, which are randomly shuffled.
[0040] Test 5-3: Multi-packet flow test: The length of each flow is 10 data packets, which are randomly shuffled.
[0041] Effect 1: The accuracy of flow record counting in this solution is high. When the target flow number is about 10,000, the accuracy can be maintained at more than 99%. In addition, this solution has the function of recovering flow ID. We let this solution run on the switch and count the first 10,000 flows (stop when the count reaches 10,000); at the same time, we run a detection program to detect the running error of the algorithm. After testing, the flow counting accuracy of this method is more than 99%, and the ID of the recorded flow can be successfully recovered.
[0042]
[0043]
[0044] Effect 2: As the number of target flows decreases, the accuracy can basically reach 100%. We tested the flow counting accuracy when the target flow numbers were 500, 1000, 2000, 5000 and 10000, using out-of-order requests. The results are as follows: Figure 2 shown.
[0045] From the experimental results, we can see that the accuracy of our method can basically reach 100% as the number of target flows decreases.
[0046] Effect 3: This solution has good statistical properties:
[0047] 1) Although this scheme is a probabilistic method, the flow count error generated by this scheme is a "unilateral error", that is, it can only be smaller than the actual flow number. This statistical property is very useful in some probabilistic algorithms.
[0048] 2) This solution can determine whether a flow counting error has occurred, and can support the use of subsequent procedures.
[0049] 3) The performance of this solution is independent of the flow size, and it has the same recording and counting effect for both large and small flows. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a schematic diagram of the application scenario;
[0051] Figure 2 This is the test effect diagram;
[0052] Figure 3 This is a schematic diagram of the record format of the first record linked list;
[0053] Figure 4 This is a schematic diagram of the record format of the second record linked list;
[0054] Figure 5 It is an overall schematic diagram of the present invention;
[0055] Figure 6 This is a diagram of the recording process of network flow A in an embodiment of the present invention;
[0056] Figure 7 1 is a diagram of the recording process of network flow B in an embodiment of the present invention;
[0057] Figure 8 1 is a diagram of the recording process of network flow C in an embodiment of the present invention;
[0058] Fig. 9 1 is a diagram of the recording process of network flow D in an embodiment of the present invention;
[0059] Fig.10 1 is a diagram of the recording process of network flow E in an embodiment of the present invention;
[0060] Fig.11 This is a recording process diagram when network flow B arrives again in an embodiment of the present invention;
[0061] Fig.12 This is a recording process diagram when network flow F arrives in an embodiment of the present invention;
[0062] Fig.13 This is a process diagram of a first method of solving a conflict in network flow F records in an embodiment of the present invention;
[0063] Fig.14 This is a process diagram of a second method of solving the conflict of network flow F records in an embodiment of the present invention;
[0064] Fig.15 This is a process diagram of a third method for resolving a network flow F record conflict in an embodiment of the present invention;
[0065] Fig.16 2 is a diagram of the error detection process in an embodiment of the present invention. DETAILED DESCRIPTION
[0066] It is very necessary to do accurate and traceable flow record counting based on switches. It is the basic work for many works to be carried out and can be used in many scenarios, such as gateways, traffic monitoring, network measurement, consistency protocols within the network, token bucket mechanism, etc. However, the current solutions for implementing flow record counting are basically probabilistic, and the accuracy needs to be improved; and more importantly, when they produce errors, they will not explicitly notify the user, resulting in unpredictable errors. In these solutions, either the counted traffic ID cannot be recorded, resulting in no traceability, or only the "elephant flow" is probabilistically counted, and all traffic cannot be processed in detail, or the data structure is unavailable when the traffic load is high, resulting in practical difficulties in the application.
[0067] Based on this, the inventors have proposed a flow record counting method running on a programmable switch, which can accurately count the flow while recording the flow ID, can cope with heavier flow loads, and has the ability to count a given number of flows. When the flow record counting process is completed, an explicit prompt of "whether there is a counting error" can be given. This solution is insensitive to the size of the flow, and the recording and counting effects are the same for both large and small flows. The main goal of the flow counting of the present invention is to monitor how many different flows there are in the network traffic on a link, and the final output is "how many different flows are attributed to these data packets received on the switch". Therefore, the counting unit is the number of flows, which represents how many data flows have merged into the total traffic on the link during the measurement period.
[0068] In order to achieve the above technical effects, the present invention includes the following key technical points:
[0069] Key point 1: Bloom recorder that enables flow ID recording. The Bloom recorder data structure is based on the basic idea of Bloom filter (i.e., "using multiple hashes can reduce the probability of collision"), but it is quite different in specific structure and operation. The Bloom recorder consists of a set of hash functions and a register table, and the hash values of each hash function are different. Its specific operation is: when a flow arrives, we use different hash functions to hash the flow ID to obtain a set of different subscripts, so as to obtain the record position of the flow in this record table; if these positions are empty or part of them are empty, the flow ID is inserted into these empty positions, and an identification field (for error detection) is inserted into the corresponding position of the data packet. The technical effect is: on the basis of being able to give the judgment of "whether the flow is a new flow", while using multiple hashes to reduce the probability of collision, a single register table (register) on the programmable switch can be used to record the new flow ID. At the same time, this data structure realizes collaborative work by combining itself or with other data structures, further improving the effect of flow statistics and recording.
[0070] Key point 2: Two forms of "Bloom record linked lists" used to resolve Bloom record table conflicts. Although the multi-hash function solution adopted by the Bloom record table can reduce the probability of conflicts, it is not foolproof. Therefore, we proposed the structure of the "Bloom record linked list". Its operation is: we arrange multiple "Bloom record tables" on different stages of the same data packet processing pipeline, and associate them step by step to form a filter mesh structure. The technical effect is that the flow IDs that conflict in the same "Bloom record table" can be stored vertically in multiple "Bloom record linked lists" in the form of a linked list, thereby improving the elasticity of ID records and enhancing performance when dealing with heavier loads. There are two forms of this record linked list. In actual deployment, you can choose according to the expected traffic load and available device resources.
[0071] Key point 3: Use "conflict flow locality" to build "linked list soft links" to further enhance the performance of "Bloom record linked list".
[0072] Implementation idea: One of our key observations is the statistical property of "conflict flow locality", that is, the proportion of flows that conflict after hashing is not high in all flows. Note that the performance of the switch's traffic loopback is about 1 / 8 of the normal forwarding performance. Therefore, we can better match the "conflict flow locality" with the physical properties of the switch and further solve the ID recording problem of conflicting flows through loopback without worrying about a large performance loss. Implementation method: When multiple flows conflict and have occupied all the "Bloom record tables" at the corresponding positions in the same pipeline, the last level of the "Bloom record table" will generate a flag, which means "the 'Bloom record chain table' in a single cycle has been 'penetrated'". A judgment module will be placed after these "Bloom record chains". If it detects a "breakdown" phenomenon, the data packet will be looped back (sent back to the receiving port). The looped data packet will use a different hash function, so the data packet will find an idle position to insert again after looping back. Technical effect: The "linked list soft link" constructed through the loopback mechanism can continue to improve the flow record counting capability based on the "Bloom record table" and "Bloom record linked list", further improving the adaptability under high load and the efficiency of data structure resource utilization. Due to the "conflict flow locality", the number of looped packets is only a small part of the total flow. Each time the loop is made, the probability of conflict is greatly reduced, and the number of packets is reduced many times. Therefore, it can greatly increase the tolerance for conflicts without having a significant impact on the performance of flow record counting.
[0073] Key point 4: Data structures that can provide explicit hints when counting errors occur.
[0074] In the existing mechanism, when a conflict occurs, no explicit prompt can be given, resulting in users not knowing whether these probability-based flow record counting schemes have produced errors. Implementation method: Based on the "link list soft link", we can allow users to customize the length of the "link list soft link" (number of loops) as the loop stop condition according to traffic characteristics and business needs. When the loop stop condition is not met, the data flow will loop. When the loop stop condition is met, it will be checked whether the flow has been stored in the "Bloom record table". If all flows within a time window have been recorded in the "Bloom record table", the result of "no error has occurred" is given; otherwise, the result of "an error has occurred" is given. Technical effect: If all data flows are recorded in the "Bloom filter linked list" within the customized number of loops, then it can be guaranteed from the mechanism that these flows have been accurately counted. At this time, we can give the judgment that "the count is accurate". If there is a data flow that cannot be recorded in the "Bloom filter linked list" within the customized number of loops, we can give the judgment that "the count is inaccurate". The user can use this judgment as a known condition to predict whether errors will occur in the flow record count, thereby saving post-processing time.
[0075] In order to make the above features and effects of the present invention more clearly understood, embodiments are given below and described in detail with reference to the accompanying drawings.
[0076] 1. Bloom recorder that enables flow ID recording: The Bloom recorder data structure is proposed based on the basic idea of Bloom filter (i.e., "using multiple hashes can reduce the probability of collision"), but it is quite different in specific structure and operation. The Bloom recorder consists of a group of hash functions and a register table, and the hash values of each hash function in the group are different. Its specific operation is: when a flow arrives, we use different hash functions to perform hash operations on the flow ID to obtain a group of different subscripts, thereby obtaining the record position of the flow in this record table; if these positions are empty or part of them are empty, the flow ID is inserted into these empty positions, and an identification field for recording whether a counting error occurs is inserted in the corresponding position of the data packet. This field will be deleted in the final stage of data packet processing, or sent to the control plane for processing. Among them, the embodiment of the present invention uses two hash functions. However, the number of hash functions is not limited to this. The more hash functions there are, the more accurate the result will be. Similarly, the more loops there are, the more accurate the result will be.
[0077] 2. "Bloom record linked list" to resolve Bloom record table conflicts: Although the multi-hash function solution used by the Bloom record table can reduce the probability of conflicts, it is not foolproof. Therefore, we proposed the structure of the "Bloom record linked list". Its operation is: we arrange multiple "Bloom record tables" on different stages of the same data packet processing pipeline, and associate them step by step to form a filter mesh structure. There are two forms of this record linked list. In actual deployment, you can choose according to the expected traffic load and available device resources:
[0078] ① Different "Bloom Record Tables" use different hash functions. Its concept Figure 3 As follows. The hash box in the figure represents a group of hash functions, which may consist of 2 or more hash functions. Each group of hash functions uses the same record table. When a Bloom record table conflicts, the ID can be stored in a random position of another Bloom record table.
[0079] ② Different "Bloom's Record Tables" use the same set of hash functions. The conceptual diagram is as follows. When a conflict occurs in the first Bloom's Record Table, the ID can be stored in the same position in the second Bloom's Record Table.
[0080] The expected traffic load can be obtained from business characteristics or preset manually. If the number of flows in the current usage environment may be several thousand, not too many resources are needed; on the contrary, if the number of flows is tens of thousands or even hundreds of thousands, more hash functions and Bloom records need to be deployed.
[0081] Similarly, "available device resources" will also affect my resource deployment. Generally speaking, different switches have different numbers of stages when processing pipelines. The more stages there are in the processing pipeline, the more hash functions and record tables can be deployed.
[0082] The advantage of the above form ① is that multiple sets of hash functions can be used to hash the ID, which can reduce the probability of conflict to a certain extent. However, this form will occupy more hash and stage number resources. The advantage of form ② is that different registers can share the same set of hashes, which will save certain hash and stage number resources. However, its disadvantage is that compared with the solution using different hash functions, its hash effect is not as good as ①, that is, the hash is not very scattered, and the performance may be unstable). Therefore, different forms can be selected according to the specific available resources of the device and the desired counting accuracy.
[0083] 3. Use "conflict flow locality" to build "linked list soft link" to further enhance the performance of "Bloom record linked list": One of our key observations is the statistical property of "conflict flow locality", that is, the proportion of flows that conflict after hashing is not high in all flows. Note that the performance of the switch's traffic loopback is about 1 / 8 of the normal forwarding performance. Therefore, we can better match "conflict flow locality" with the physical properties of the switch and further solve the ID record problem of conflicting flows through loopback without worrying about a large performance loss. When multiple flows conflict and have filled all the "Bloom record tables" at the corresponding positions in the same pipeline, the last level of the "Bloom record table" will generate a flag, which means "the 'Bloom record linked list' in a single cycle has been 'penetrated'". A judgment module will be placed after these "Bloom record linked lists". If it detects a "breakdown" phenomenon, the data packet will be looped back (sent back to the receiving port). The looped data packet will use a different hash function, so the data packet will find an idle position for insertion after looping back.
[0084] 4. Data structure that can explicitly give prompts when counting errors occur: Based on the "link list soft link", we can allow users to customize the length of the "link list soft link" (number of loops) as the loop stop condition according to traffic characteristics and business needs. When the loop stop condition is not met, the data flow will circulate. When the loop stop condition is met, it will be checked whether the flow has been stored in the "Bloom record table". If all flows in a time window have been recorded in the "Bloom record table", the result of "no error has occurred" is given, the monitoring of the current time window is ended, the operation is ended or the Bloom record table is cleared, and the measurement of the next time window is carried out; otherwise, the result of "an error has occurred" is given. If all data flows are recorded in the "Bloom filter link table" within the customized number of loops, then it can be guaranteed from a mechanism that these flows have been accurately counted. At this point, we can give the judgment that "the count is accurate". If there are data flows that cannot be recorded in the "Bloom filter link table" within the customized number of loops, we can give the judgment that "the count is inaccurate".
[0085] The overall system design is as follows Figure 5 As shown:
[0086] 1. KEY. That is, the flow ID. For example, in general measurement tasks, a five-tuple (source IP, destination IP, source port, destination port, version number) is usually used as the key. The source of these tuples is obtained by parsing the packet header. Parsing the packet is a basic function on the switch.
[0087] 2. HASH module. Here we use HASHx_y to represent a specific set of hashes (hash groups). Their function is to use KEY as the input of this set of hash functions to obtain a set of hash results as the address index index for addressing in the Bloom record table. If the hash group contains several hash functions, the KEY will be hashed to several different locations. Figure 5 In , x represents the hash group corresponding to the nth Bloom record table. Here, different Bloom record tables are allowed to share the same hash group. Therefore, it is only necessary to let all Bloom record tables use the same set of hashes. Therefore, we assume that the subsequent record tables share the hash group of the first record table; y represents the nth time that the data packet enters this processing flow. When y=1, it means that the data packet enters the flow counting module of the present invention for the first time; y=2 means that the data packet enters the flow counting module again after a loopback, y=3 means that the data packet enters the flow counting module again after two loopbacks, and so on. Note that each time the data packet passes through the counting module, the hash groups of each Bloom record table can be shared, but the hash groups between different loopbacks cannot be shared.
[0088] 3. Bloom table module. Since each stream will be hashed to several different locations of the Bloom table module through the HASH group, these modules are used to record the KEYs of those streams that are hashed to their specific locations. The specific algorithm is as follows:
[0089] 1) If a hashed position is empty (as long as there is an empty position), the ID of the stream is recorded at this position, and the flag bit of "the stream has been recorded" is set to 1, otherwise it is 0;
[0090] 2) If a hashed position is not empty, then:
[0091] I) If the KEY of the stream recorded in this position happens to be the KEY of the current stream: then no processing is done on the data packet and it is directly forwarded (and therefore does not pass through subsequent modules). The core idea is: if a stream has been recorded, then it is meaningless to record it again.
[0092] II) If the KEY of the stream recorded in this position is not the KEY of the current stream, a conflict occurs:
[0093] a) If the current Bloom table is not the last level, the KEY of the flow will not be recorded in it. Instead, a signal will be given to remind the next level Bloom table to record it, and the flag bit of "the flow has been recorded" will be set to 1; when the flow ID of the next data packet is the same as the previous flow ID, only the flag bit corresponding to the data packet will be recorded as 1, indicating that it has been recorded, without recording the flow ID of the data packet. In order to prevent the flow count from being affected by the flow size, the judgment of the "already recorded" flag bit needs to be maintained until the end of the entire period to prevent the subsequent levels of record tables from not knowing the status of the current data packet.
[0094] b) If this Bloom record table is the last level record table, then determine whether the current loop count of the data packet has reached the upper limit. If it has not reached the upper limit, then set a "loop" flag for the data packet, so the data packet will loop back and enter the processing flow again; if it has reached the upper limit, it means that a counting error has occurred, and a "error has occurred" flag is given.
[0095] 4. Error detection module. This module mainly detects the flag of "whether an error has occurred". Every time a data packet passes, it will check their flag of "whether an error has occurred". If no error has occurred, no processing will be done; otherwise, the counter of the error detection module will be added by one. When you want to know whether an error has occurred, you only need to check whether this item is 0 to know whether an error has occurred.
[0096] 5. Flow counting module. This module mainly detects the flag of "whether the flow has been recorded". Every time a data packet passes, their flag will be checked. If it shows "the flow has been recorded" (the flag is 1), it means that the flow is a new flow, so the counter in this module is increased by 1; otherwise, no operation is performed. This module can also count a given number of flows. When you want to get the number of flows, you only need to read the counter to get the current number of flows.
[0097] The following is a detailed description of the operation process of our data structure through an example. Here we adopt the method of using the same set of hash functions for different Bloom record tables in the above key point 2.
[0098] 1. Data packet parsing process:
[0099] One of the basic functions in a switch is to read the header fields of a data packet. We can combine some fields of the packet header that we want to focus on (such as source IP, destination IP, source port, destination port, version number) as the KEY.
[0100] 2. Flow Counting Process
[0101] After we get the KEY, we hash it using a hash group (a group of several hashes).
[0102] 1) If Figure 6 As shown, the data packet belonging to network flow A arrives: It is hashed to slot 1 and slot 5. At this time, both slots are empty and can be directly recorded. No error occurs at this time, and the flow counting module is +1;
[0103] 2) If Figure 7 As shown, a packet belonging to network flow B arrives: it is hashed to slot 3 and slot 5. At this time, slot 3 is empty, but slot 5 is not empty, so only B is recorded in slot 3. No error occurs at this time, and the flow counting module +1;
[0104] 3) If Figure 8 As shown, the data packet belonging to network flow C arrives: it is hashed to slot 1 and slot 3. At this time, both slots are not empty, so C is recorded in the slot at the corresponding position of the next level record table. At this time, no error occurs, and the flow counting module +1;
[0105] 4) If Fig. 9 As shown, the data packet belonging to network flow D arrives: It is hashed to slot 2 and slot 6. At this time, both slots are empty and can be directly recorded. No error occurs at this time, and the flow counting module +1;
[0106] 5) If Fig.10 As shown, a packet belonging to network flow E arrives: It is hashed to slot 1 and slot 6. At this time, both slots in the first-level Bloom record table are not empty, so it is passed to the next-level Bloom record table. Slot 6 in the next-level Bloom record table is empty, so flow E is recorded here. No error occurs at this time, and the flow counting module is +1;
[0107] 6) If Fig.11 As shown, the data packet belonging to network flow B arrives again: it is hashed to slot 3 and slot 5. At this time, the network flow recorded in slot 3 is exactly B, and it is determined that these are multiple data packets of the same flow. At this time, no error occurs, and the flow counting module remains unchanged;
[0108] 7) If Fig.12 As shown in the figure, the data packet belonging to network flow F arrives: It is hashed to slot 1 and slot 6. At this time, the corresponding slots of all Bloom record tables are not empty, and a serious conflict occurs. The following three methods can be used to solve it:
[0109] like Fig.13As shown, Solution 1 (another form of Key Point 2): We let different "Bloom Record Tables" use different hash functions to hash the network flow F to different positions in the second-level Bloom Record Table. At this time, the new slot hashed is empty and can be recorded normally. No error occurs at this time, and the flow counting module +1;
[0110] like Fig.14 As shown, Solution 2 (using the flexibility of our data structure): Increase the number of Bloom record tables. Since the third-level Bloom record table is added and the corresponding position is empty, the network flow F can be successfully recorded in it. At this time, no error will occur, and the flow counting module +1;
[0111] like Fig.15 As shown, Solution 3: Use loopback. When it is determined that all Bloom record tables of the same loopback cannot record the ID (KEY) of the network flow due to conflict, a loopback is used to forward the request back to the start end of the process and hash it using a different hash function. Free slots 0 and 4 are found in the first-level Bloom record table, and the flow ID (KEY) is recorded in it. At this time, no error will occur, and the flow counting module +1;
[0112] 8) We can also give a target number of flows, and this module can stop counting when the target number is reached. Assuming that a packet belonging to network flow G arrives at a certain moment, if the target number of flows has been reached at this time, even if it can be recorded normally in the Bloom record table, the backend flow counting module will determine whether the upper limit of the vote has been reached at this time. If the upper limit has been reached, the count will not be increased.
[0113] 3. Working process of error detection module:
[0114] like Fig.16 As shown in the figure, we assume that we only allow two loops at most (in practice, more loops can be deployed). At this time, a data packet belonging to network flow Z arrives: each of its hashes completely conflicts, and it has been looped twice. In the last Bloom record table of the second loop, it is found that there is still a conflict, so a "error occurs" flag is generated at this time. When the error detection module detects this flag, it will add 1 to its own counter. At this time, since it is not 0, it means that an error has occurred.
[0115] IV. The process of obtaining flow records and counting results
[0116] Because the control plane of the programmable switch can read the values from the data plane at any time, when we want to obtain the flow count at a certain moment, we only need to read the value of the flow count module. If we want to obtain all flow records, we only need to read the KEY values recorded in all Bloom record tables.
[0117] The following is a system embodiment corresponding to the above method embodiment. This embodiment can be implemented in conjunction with the above embodiment. The relevant technical details mentioned in the above embodiment are still valid in this embodiment. In order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the above embodiment.
[0118] The present invention also proposes a flow record counting system based on a programmable switch, comprising:
[0119] A parsing module, used for parsing each data packet sent by the sender within the counting period, obtaining a flow ID of the data packet, inputting the flow ID into multiple hash functions in the first hash group at the same time, and using the hash value output by each hash function as the address index of the first Bloom record table;
[0120] A judgment module is used to judge whether the position of the address index in the first Bloom record table is empty. If so, the stream ID is recorded at the position and a flag representing that the stream has been recorded is given, and the counter value of the stream count is increased by 1; otherwise, it is judged whether the content recorded in the position is the same as the stream ID. If so, the subsequent record is directly skipped, otherwise a record conflict occurs and the detection module is called;
[0121] The detection module is used to execute the conflict resolution strategy. If there is still a record conflict, a flag indicating a record error is given, and the error detection counter value is increased by 1;
[0122] The output module is used to output the counter value of the flow count as the flow record counting result and output the counter value of the error detection as the error reference at any time or at the end of the counting cycle.
[0123] The flow record counting system based on a programmable switch, wherein the conflict resolution strategy includes: deploying multiple cascaded Bloom record tables to form a linked list, judging step by step whether the flow ID can be recorded in the current level record table, if so, recording the flow ID in the current level record table to resolve the conflict; if the flow ID already exists, skipping the subsequent recording steps; otherwise, there is still a record conflict.
[0124] The programmable switch-based flow record counting system, wherein the conflict resolution strategy includes: if the conflict is not resolved after the data packet passes through the cascaded Bloom record table for the first time, the data packet is looped back a custom number of times and the Bloom record table is reused; each loopback simultaneously inputs the flow ID into multiple hash functions in the hash group corresponding to the loopback, and the hash value output by each hash function is used as the new address index of the cascaded Bloom record table, and the values of these positions are judged step by step. If they are empty, the flow ID is recorded at the new address index position to resolve the conflict; if the flow ID already exists, the subsequent recording steps are skipped; otherwise, there is still a record conflict.
[0125] The present invention also proposes a storage medium for storing a program for executing any of the flow size-independent flow record counting methods on a programmable switch.
[0126] The present invention also proposes a programmable switch, comprising the storage medium. When a processor of the programmable switch calls and executes a program in the storage medium, the programmable switch performs flow record counting.
[0127] The present invention also proposes a client, which is used for implementing a flow record counting system that is independent of flow size on any of the programmable switches.
Claims
1. A flow record counting method based on programmable switches, It is characterized in that include: Step 1: The programmable switch parses each data packet sent by the sender within the counting period to obtain the flow ID of the data packet, inputs the flow ID into multiple hash functions in the first hash group at the same time, and uses the hash value output by each hash function as the address index of the first Bloom record table; Step 2: Determine whether the position of the address index in the first Bloom record table is empty. If so, record the stream ID at the position and give a flag indicating that the stream has been recorded, and add 1 to the counter value of the stream count; otherwise, determine whether the content recorded in the position is the same as the stream ID. If so, skip the subsequent recording steps directly. Otherwise, a record conflict occurs and execute step 3; Step 3: Execute the conflict resolution strategy. If there is still a record conflict, a flag indicating a record error is given, and the error detection counter value is increased by 1. Step 4: When the counting cycle ends, the counter value of the flow counting is output as the flow record counting result, and the counter value of the error detection is output as the error reference; The conflict resolution strategy includes: Deploy multiple cascaded Bloom record tables to form a linked list, and determine whether the flow ID can be recorded in the current level record table at each level. If so, the flow ID is recorded in the current level record table to resolve the conflict; if the flow ID already exists, skip the subsequent recording steps; otherwise, there is still a record conflict; If the conflict is not resolved after the data packet passes through the cascaded Bloom record table for the first time, the data packet will be looped back a custom number of times and the Bloom record table will be reused; each loop will input the flow ID into multiple hash functions in the hash group corresponding to the loop at the same time, where the multiple hash functions in the hash group corresponding to each loop are different, and the hash value output by each hash function is used as the new address index of the cascaded Bloom record table, and the values of these positions are judged step by step. If they are empty, the flow ID is recorded at the new address index position and the conflict is resolved; if the flow ID already exists, the subsequent recording steps are skipped; otherwise, there is still a record conflict.
2. A flow record counting system based on programmable switches, It is characterized in that include: A parsing module, used for parsing each data packet sent by the sender within the counting period, obtaining a flow ID of the data packet, inputting the flow ID into multiple hash functions in the first hash group at the same time, and using the hash value output by each hash function as the address index of the first Bloom record table; A judgment module is used to judge whether the position of the address index in the first Bloom record table is empty. If so, the stream ID is recorded at the position and a flag representing that the stream has been recorded is given, and the counter value of the stream count is increased by 1; otherwise, it is judged whether the content recorded in the position is the same as the stream ID. If so, the subsequent record is directly skipped, otherwise a record conflict occurs and the detection module is called; The detection module is used to execute the conflict resolution strategy. If there is still a record conflict, a flag indicating a record error is given, and the error detection counter value is increased by 1; An output module is used to output the counter value of the flow count as the flow record counting result and the counter value of the error detection as the error reference at the end of the counting cycle; The conflict resolution strategy includes: Deploy multiple cascaded Bloom record tables to form a linked list, and determine whether the flow ID can be recorded in the current level record table at each level. If so, the flow ID is recorded in the current level record table to resolve the conflict; if the flow ID already exists, skip the subsequent recording steps; otherwise, there is still a record conflict. The conflict resolution strategy includes: if the conflict is not resolved after the data packet passes through the cascaded Bloom record table for the first time, the data packet is looped back a custom number of times and the Bloom record table is reused; each loopback inputs the flow ID into multiple hash functions in the hash group corresponding to the loopback at the same time, wherein the multiple hash functions in the hash group corresponding to each loopback are different, and the hash value output by each hash function is used as the new address index of the cascaded Bloom record table, and the values of these positions are judged step by step. If they are empty, the flow ID is recorded at the new address index position to resolve the conflict; if the flow ID already exists, the subsequent recording steps are skipped; otherwise, there is still a record conflict.
3. A storage medium for storing a program for executing the flow record counting method of a programmable switch as claimed in claim 1.
4. A programmable switch, comprising the storage medium as claimed in claim 3, wherein when a processor of the programmable switch calls and executes a program in the storage medium, the programmable switch performs flow record counting.
Citation Information
Patent Citations
Data center network traffic measurement method based on SDN
CN108282481A
Accurate active large flow identification method and system based on small flow filtering
CN115102907A
