Data packet information determination method and related device
By using multiple hash functions to process multi-tuple information of data packets and generate data flow type information, the problem of data packet traffic size identification in cloud computing requires a large amount of memory, and efficient and accurate data flow type identification is achieved.
Patent Information
- Application Number
- CN202311376047.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-20
- Publication Date
- 2025-04-22
AI Technical Summary
In cloud computing, the existing technology needs to occupy a large memory space to store and identify the traffic size of data packets, especially in scenarios where memory is limited.
By obtaining the multi-group information carried by the target data packet, processing it using at least two hash functions, data flow type information is generated, and the data flow type to which the data packet belongs is determined based on the information. This method includes hash calculation, finding hash statistics array elements, and updating statistics based on the search results to reduce memory usage.
This method can effectively reduce the memory space required for data traffic size identification, improve the accuracy and efficiency of data flow type identification, and is suitable for scenarios with limited memory.
Smart Images

Figure CN119865305A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of cloud technology, and in particular to a method for determining information of a data packet and a related device. Background Art
[0002] In cloud computing, it is necessary to identify the flow size of data packets, for example, to identify whether the data packet is an elephant flow or a mouse flow.
[0003] In the related art, the five-tuple information of the data packet is mainly stored, and then the five-tuple information is statistically counted, so as to determine the flow size of the data packet according to the size of the count.
[0004] However, the solution of directly storing all the five-tuple information requires a large amount of memory space, which is not suitable for scenarios with limited memory. Therefore, there is an urgent need for a solution that can reduce the memory space required for data flow size recognition. Summary of the invention
[0005] The embodiments of the present application provide a method and a related device for determining information of a data packet, which can reduce the memory space required for identifying the size of data flow.
[0006] On the one hand, an embodiment of the present application provides a method for determining information of a data packet, including:
[0007] Obtain target multi-tuple information carried by the target data packet;
[0008] Processing the target multi-tuple information based on each hash function of at least two hash functions to obtain data flow type information corresponding to each hash function, the data flow type information is used to indicate the data flow type to which the target data packet belongs, the data flow type includes at least one of a first data flow type or a second data flow type, and the data flow corresponding to the first data flow type is greater than the data flow corresponding to the second data flow type;
[0009] Determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function;
[0010] For each hash function, the target tuple information is processed based on the hash function to obtain data stream type information corresponding to the hash function, including:
[0011] Performing hash calculation on the target multi-tuple information based on a hash function to obtain a first hash value, and determining a target position index corresponding to the first hash value;
[0012] Find the target array element from the target hash statistics array corresponding to the hash function based on the target position index;
[0013] If the target array element is successfully found, the data stream type to which the target data packet belongs is determined based on the second hash value and the statistical number in the target array element.
[0014] On the other hand, an embodiment of the present application further provides a method for determining information of a data packet, including:
[0015] Acquire a target data packet from a second chip, the target data packet carrying target multi-tuple information;
[0016] Based on the target multi-tuple information, determine a new target hash statistical array corresponding to each hash function of at least two hash functions, and send the target hash statistical array to the second chip, so that when the second chip receives a new target data packet, it determines the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function;
[0017] The second chip determines the data stream type information based on a method as in any of the embodiments.
[0018] On the other hand, an embodiment of the present application further provides a device for determining information of a data packet, including:
[0019] A first acquisition module, used for acquiring target multi-group information carried by a target data packet;
[0020] A first information determination module is used to process the target multi-group information based on each hash function of at least two hash functions to obtain data flow type information corresponding to each hash function, and determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function, the data flow type information is used to indicate the data flow type to which the target data packet belongs, the data flow type includes at least one of a first data flow type or a second data flow type, and the data flow corresponding to the first data flow type is greater than the data flow corresponding to the second data flow type;
[0021] Wherein, for each hash function, when the first information determination module processes the target tuple information based on the hash function to obtain the data stream type information corresponding to the hash function, it is used to:
[0022] Performing hash calculation on the target multi-tuple information based on a hash function to obtain a first hash value, and determining a target position index corresponding to the first hash value;
[0023] Find the target array element from the target hash statistics array corresponding to the hash function based on the target position index;
[0024] If the target array element is successfully found, the data stream type to which the target data packet belongs is determined based on the second hash value and the statistical number in the target array element.
[0025] On the other hand, an embodiment of the present application further provides a device for determining information of a data packet, including:
[0026] A second acquisition module is used to acquire a target data packet from a second chip, where the target data packet carries target multi-tuple information;
[0027] A second information determination module is used to determine a new target hash statistical array corresponding to each hash function of at least two hash functions based on the target multi-tuple information, and send the target hash statistical array to the second chip, so that when the second chip receives a new target data packet, it determines the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function;
[0028] The second chip determines the data stream type information based on a method as in any of the embodiments.
[0029] On the other hand, an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method of any embodiment of the present application.
[0030] On the other hand, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the method of any embodiment of the present application is implemented.
[0031] On the other hand, an embodiment of the present application further provides a computer program product, including a computer program, which implements the method of any embodiment of the present application when the computer program is executed by a processor.
[0032] The technical solution of this embodiment is to obtain the target tuple information carried by the target data packet; process the target tuple information based on each hash function of at least two hash functions to obtain the data flow type information corresponding to each hash function, determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function, and for each hash function, determine the data flow type to which the target data packet belongs based on the hash function, which may include: performing hash calculation on the target tuple information based on the hash function to obtain a first hash value, and determining the target position index corresponding to the first hash value; searching for the target array element from the target hash statistical array corresponding to the hash function based on the target position index; if the target array element is successfully searched, then determining the data flow type to which the target data packet belongs based on the second hash value and the statistical number of times in the target array element, because the hash value in the array element is obtained by performing hash calculation on the tuple information based on the hash function, and hash calculation is generally also a compression process, that is, the hash value in the array element can reflect the tuple information and the memory occupied by the hash value in the array element is less than the memory occupied by the tuple information, thereby reducing the memory space required for data flow size identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A schematic diagram of an implementation environment provided for an embodiment of the present application;
[0034] Figure 2 A schematic diagram of a flow chart of a method for determining information of a data packet provided in an embodiment of the present application;
[0035] Figure 3 A schematic diagram of searching a target array element from a target hash statistics array provided by the present application;
[0036] Figure 4 A schematic diagram of obtaining a new target hash statistics array corresponding to a hash function provided in an embodiment of the present application;
[0037] Figure 5 A schematic diagram of a flow chart of another method for determining information of a data packet provided in an embodiment of the present application;
[0038] Figure 6 A schematic diagram of a flow chart of another method for determining information of a data packet provided in an embodiment of the present application;
[0039] Figure 7 A schematic diagram of a flow chart of another method for determining information of a data packet provided in an embodiment of the present application;
[0040] Figure 8 A schematic diagram of a framework for identifying data flow types and forwarding data packets provided in an embodiment of the present application;
[0041] Fig. 9 A schematic diagram of the structure of a device for determining information of a data packet provided in an embodiment of the present application;
[0042] Fig.10 A schematic diagram of the structure of another device for determining information of a data packet provided in an embodiment of the present application;
[0043] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.
[0045] It will be understood by those skilled in the art that, unless specifically stated, the singular forms "one", "an", and "the" used herein may also include plural forms. It should be further understood that the terms "including" and "comprising" used in the embodiments of the present application refer to that the corresponding features can be implemented as the presented features, information, data, steps, operations, elements and / or components, but do not exclude the implementation as other features, information, data, steps, operations, elements, components and / or combinations thereof supported by the technical field. It should be understood that when we call an element "connected" or "coupled" to another element, the one element may be directly connected or coupled to the other element, or it may refer to that the one element and the other element establish a connection relationship through an intermediate element. In addition, the "connection" or "coupling" used here may include wireless connection or wireless coupling. The term "and / or" used here indicates at least one of the items defined by the term, such as "A and / or B" indicates implementation as "A", or implementation as "A", or implementation as "A and B". "Multiple" refers to two or more.
[0046] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0047] First, several terms involved in this application are introduced and explained:
[0048] NAT Gateway: Network Address Translation Gateway. Usually provides address translation services for servers that need to access the public network;
[0049] ACL Gateway: AccessControlList Gateway. Usually a packet filtering service set up for security.
[0050] Load balancing gateway: For scenarios with large data traffic, it provides diversion services for incoming data traffic.
[0051] ASIC chip: Application Specific Integrated Circuit. A dedicated integrated chip, specifically referring to the chip of a programmable switch in the present invention.
[0052] See also Figure 1 , Figure 1 A schematic diagram of an implementation environment provided for an embodiment of the present application.
[0053] Figure 1 A schematic diagram of an implementation environment provided by an exemplary embodiment of the present application is shown. The implementation environment includes a first edge node 110 and a second edge node 120, and the first edge node 110 is provided with a first business server 111 and a first gateway 112. The second edge node 120 is provided with a second business server 121 and a second gateway 122. Among them, the devices in the edge nodes communicate data through a communication network. Optionally, the communication network can be a wired network or a wireless network, and the communication network can be at least one of a local area network, a metropolitan area network, and a wide area network. The first gateway and the second gateway are respectively provided with a first chip and a second chip. The first chip can be a CPU (central processing unit) chip. The CPU chip is used to perform various data processing. The second chip can be a switch chip, which mainly processes data forwarding, etc. Generally speaking, the memory of the CPU chip is larger than the memory of the switch chip. Optionally, the switch chip can be an ASIC chip.
[0054] Specifically, this solution can be used for stateful gateways in cloud computing scenarios, such as NAT, ACL gateways, etc. It mainly includes programmable white box switches to carry the forwarding requirements of stateful gateways. For white box switches, such as Intel's Tofino (Programmable Ethernet) switches, it is necessary to support secondary development capabilities, such as programmable packet forwarding processes. CPU chips are mainstream chips in the industry and need to support capabilities such as container deployment and secondary development.
[0055] The edge nodes communicate data through the switch chip, and the switch chips can communicate data through the public network, and the devices inside the edge node can communicate data through the intranet. The first edge node 110 and the second edge node 120 can be edge computing sites set in different geographical locations, and the edge nodes provide services for devices in the nearby area. For example, the first edge node 110 is an edge computing site set in Shanghai, and the second edge node 120 is an edge computing site set in Beijing. The first edge node 110 provides services for devices in the East China region, and the second edge node 120 provides services for devices in the North China region. The first business server 111 and the second business server 121 are used to provide corresponding services for the accessed devices. For example, the services provided by the business server may include live video, online education, etc., and the embodiments of the present application do not limit the services provided by the business server. In some scenarios, the business data between different edge nodes needs to interact to ensure the consistency of the business data between different edge nodes. For example, in the live video scenario, the video interaction data (such as barrage data) received by the business servers in different edge nodes needs to interact to ensure the consistency of the video interaction data seen by live viewers in different regions. In some embodiments, the gateway is used to process the business data based on business needs. For example, network address translation is implemented. Of course, in addition to the above functions, the gateway can also implement other functions according to business requirements, which is not limited in this embodiment.
[0056] Optionally, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0057] In the related art, the five-tuple information of the data packet is mainly stored, and then the five-tuple information is statistically counted, so as to determine the flow size of the data packet according to the size of the count.
[0058] However, the memory on the switch chip is limited, and directly storing the quintuple information and the corresponding statistical times occupies a large amount of on-chip storage space of the switch chip.
[0059] Therefore, the following embodiments illustrate how to solve the problem of reducing the memory space required for data flow size identification in a switch chip.
[0060] Optionally, the present application may relate to the field of cloud computing technology, such as processing the solutions of the embodiments of the present application based on a cloud server, or further processing based on cloud computing after identifying the flow size of the data packet.
[0061] Among them, cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use.
[0062] As a provider of basic cloud computing capabilities, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.
[0063] According to the logical function division, the PaaS (Platform as a Service) layer can be deployed on the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on the PaaS layer. SaaS can also be deployed directly on IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is a variety of business software, such as web portals, SMS mass senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.
[0064] See also Figure 2 , Figure 2 A flowchart of a method for determining information of a data packet provided in an embodiment of the present application. Figure 2 The method shown can be executed by a second chip or a server including the second chip, such as Figure 2 The methods shown may include:
[0065] S210, obtaining target tuple information carried by the target data packet.
[0066] The target data packet may refer to a data packet received by the second chip and subsequently needs to be processed, such as forwarding, etc., which is not limited here. The target tuple information may be stored in the data packet header of the target data packet. Optionally, the target tuple information of the target data packet pkt may include but is not limited to at least two of the source IP address src_ip, the destination IP address dst_ip, the source port src_port, the destination port dst_port and the protocol protocol. In general, a data stream is usually identified by using a five-tuple.
[0067] In this embodiment, after receiving the target data packet, the target tuple information carried by the target data packet can be extracted from the data packet header of the target data packet for subsequent processing.
[0068] S220: Process the target tuple information based on each hash function of at least two hash functions to obtain data stream type information corresponding to each hash function.
[0069] The data flow type information is used to indicate the data flow type to which the target data packet belongs, and the data flow type can reflect the flow size of the target data packet. In this embodiment, the data flow type includes at least one of the first data flow type or the second data flow type, and the data flow corresponding to the first data flow type is greater than the data flow corresponding to the second data flow type.
[0070] Specifically, the first data flow type may be an elephant flow, and the second data flow type may be a mouse flow. An elephant flow may be a process of transmitting a large amount of data continuously through a network link. A mouse flow may be a process of transmitting a small amount of data in a short time through a network link. In other words, a high rate (occupying a large bandwidth) is an elephant flow, and a low rate and a short time is a mouse flow. For example, sending emails, browsing web pages, etc. belong to mouse flows, while virtual machine migration, data migration, video or storage, etc. belong to elephant flows.
[0071] In this embodiment, each of the at least two hash functions may be processed in a certain manner on the tuple information, thereby determining the data stream type information corresponding to each hash function.
[0072] Exemplarily, assuming that the at least two hash functions include hash function 1 and hash function 2, the data flow type information of the target data packet can be determined based on hash function 1, and the data flow type information of the target data packet can be determined based on hash function 2. The following embodiments further illustrate how to determine the data flow type to which the target data packet belongs based on the hash function.
[0073] For each hash function, the target tuple information is processed based on the hash function to obtain data stream type information corresponding to the hash function, including:
[0074] S221. Perform hash calculation on the target tuple information based on a hash function to obtain a first hash value, and determine a target position index corresponding to the first hash value.
[0075] The target position index may refer to an index for searching an array element from a hash statistics array. In this embodiment, optionally, the target position index may be obtained by taking the modulus of the first hash value. Specifically, the remainder obtained by taking the modulus of the first hash value may be used as the target position index.
[0076] S222. Search for a target array element from a target hash statistics array corresponding to the hash function based on the target position index.
[0077] In this embodiment, since the hash statistics arrays corresponding to different hash functions may be different, it is necessary to search for the target array element from the target hash statistics array corresponding to the hash function. Specifically, for the same tuple information, different hash functions will result in different first hash values calculated by different hash functions, which will in turn result in different hash statistics arrays. Therefore, the hash statistics arrays corresponding to different hash functions may be different.
[0078] Optionally, the target hash statistics array may or may not store array elements, depending on the actual situation. Specifically, if array elements are stored, each array element may include a hash calculation result (also called a hash value) flow_id, and statistical data (also called statistical times) c corresponding to the hash calculation result. Specifically, the hash value in the array element is obtained by performing a hash calculation on the tuple information based on a hash function. Since hash calculation is generally also a compression process, that is to say, the hash value in the array element can reflect the tuple information and the memory space occupied by the hash value in the array element is less than the memory space occupied by the tuple information.
[0079] S223: If the target array element is successfully found, the data stream type to which the target data packet belongs is determined based on the second hash value and the statistical number in the target array element.
[0080] In this embodiment, if the target array element is successfully searched, it means that other hash values with the same position index as the first hash value have appeared before, that is, the target tuple information has a probability of being counted before. Therefore, the data flow type to which the target data packet belongs can be determined based on the second hash value in the target array element and the number of statistics.
[0081] S230. Determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function.
[0082] In the present embodiment, the data stream type to which the target data packet belongs may be determined based on the data stream type information determined by one of the hash functions, that is, if the data stream type information determined by one of the hash functions is an elephant stream, then the target data packet is an elephant stream, or if the data stream type information determined by one of the hash functions is a mouse stream, then the target data packet is a mouse stream. In addition, the data stream type to which the target data packet belongs may also be determined based on the data stream type information determined by each hash function, that is, if the data stream type information determined by each hash function is consistent, then the data stream type indicated by the consistent data stream type information is determined as the data stream type to which the target data packet belongs. For example, if the data stream type information determined by each hash function indicates an elephant stream, then the target data packet is an elephant stream, and if the data stream type information determined by each hash function indicates a mouse stream, then the target data packet is a mouse stream.
[0083] Optionally, generally speaking, the identification of elephant flows in specific scenarios is more important. Therefore, in a possible implementation, the target data flow type to which the target data packet belongs is determined based on the data flow type information corresponding to each hash function, including at least one of the following:
[0084] If the data flow type information corresponding to one of the hash functions indicates that the target data packet belongs to the first data flow type, determining that the target data flow type is the first data flow type;
[0085] If the data flow type information corresponding to each hash function indicates that the target data packet belongs to the second data flow type, the target data flow type is determined to be the second data flow type.
[0086] In this embodiment, exemplarily, if the data flow type information determined based on hash function 1 or hash function 2 indicates that the target data packet is an elephant flow, then the target data flow type of the target data packet is determined to be an elephant flow; if the data flow type information determined based on hash function 1 and hash function 2 indicates that the target data packet is a mouse flow, then the target data flow type is determined to be a mouse flow.
[0087] The technical solution of this embodiment is to obtain the target tuple information carried by the target data packet; process the target tuple information based on each hash function of at least two hash functions to obtain the data flow type information corresponding to each hash function, determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function, and for each hash function, determine the data flow type to which the target data packet belongs based on the hash function, which may include: performing hash calculation on the target tuple information based on the hash function to obtain a first hash value, and determining the target position index corresponding to the first hash value; searching for the target array element from the target hash statistical array corresponding to the hash function based on the target position index; if the target array element is successfully searched, then determining the data flow type to which the target data packet belongs based on the second hash value and the statistical number of times in the target array element, because the hash value in the array element is obtained by performing hash calculation on the tuple information based on the hash function, and hash calculation is generally also a compression process, that is, the hash value in the array element can reflect the tuple information and the memory occupied by the hash value in the array element is less than the memory occupied by the tuple information, thereby reducing the memory space required for data flow size identification. Furthermore, since the target multi-tuple information is processed based on each of the at least two hash functions to obtain the data stream type information corresponding to each hash function, that is, the data stream type information of at least two hash functions is combined, the misidentification caused by hash conflicts can be reduced, thereby improving the recognition accuracy of the data stream type. In addition, the data stream type information of the multi-path hash can also be calculated in parallel, which can improve the recognition efficiency of the data stream type.
[0088] In a possible implementation, determining the data flow type to which the target data packet belongs based on the second hash value and the statistical number in the target array element includes:
[0089] matching the second hash value with the first hash value;
[0090] If the second hash value successfully matches the first hash value, it is determined that the target data packet belongs to the first data flow type, and the statistical number in the target array element is increased;
[0091] If the second hash value fails to match the first hash value, the statistical number in the target array element is reduced. If the reduced statistical number is greater than the predetermined first statistical number threshold, it is determined that the target data packet belongs to the second data flow type. If the reduced statistical number is less than or equal to the predetermined second statistical number threshold, it is determined that the target data packet belongs to the first data flow type.
[0092] The first statistical number threshold is greater than or equal to the second statistical number threshold.
[0093] In this embodiment, optionally, matching the second hash value with the first hash value may be performed by performing a consistency comparison between the second hash value and the first hash value. If the second hash value is consistent with the first hash value, it indicates that the second hash value matches the first hash value. If the second hash value is inconsistent with the first hash value, it indicates that the second hash value does not match the first hash value. Specifically, performing a consistency comparison between the second hash value and the first hash value may be a bitwise comparison between the second hash value and the first hash value.
[0094] Specifically, if the second hash value successfully matches the first hash value, it means that the first hash value has appeared, that is, the target tuple information is being counted, that is, the target tuple information is currently defined as the first data stream type, and the target data packet is determined to belong to the first data stream type. At the same time, the statistical number in the target array element is increased.
[0095] If the second hash value fails to match the first hash value, it means that the target tuple information is not currently defined as the first data stream type, and the second hash value with the same position index as the first hash value is not in the backup, then the probability that the tuple information corresponding to the second hash value is the first data stream type has decreased, so it is necessary to reduce the number of statistics in the target array element. Further, if the reduced number of statistics is greater than the first statistical number threshold, it means that the tuple information corresponding to the second hash value is still the first data stream type, and it is determined that the target data packet belongs to the second data stream type; if the reduced number of statistics is less than or equal to the second statistical number threshold, it means that the tuple information corresponding to the second hash value has become the second data stream type, and it can be determined that the target data packet is likely to belong to the first data stream type.
[0096] In a possible implementation, the increasing step size of the statistical number may be consistent with the decreasing step size of the statistical number.
[0097] In another possible implementation, increasing the number of statistics in the target array element includes: acquiring a first adjustment step, and increasing the number of statistics in the target array element based on the first adjustment step;
[0098] Reducing the number of statistics in the target array element includes: acquiring a second adjustment step size, and reducing the number of statistics in the target array element based on the second adjustment step size.
[0099] The first adjustment step length is greater than the second adjustment step length.
[0100] In this embodiment, the increasing step size of the statistical number is greater than the decreasing step size of the statistical number. Optionally, the decreasing step size can be set to 1, and the increasing step size of the statistical number can be set to 2 to the Nth power, where N is an integer not less than 1, for example, the increasing step size can be set to 2 or 8. The size of the increasing step size can be set according to actual conditions and is not limited here.
[0101] Specifically, since the second hash value and the corresponding statistical times are stored in the array as array elements, in the actual execution of the scheme, there will be some different rat flows, and the hash values calculated from the tuple information of these rat flows may be different from the second hash value, but the position index is the same, and the array element where the second hash value is located may be frequently found and fail to match the second hash value. If the tuple information of the rat flow is too diverse, it will affect the accuracy of identifying the data flow type.
[0102] Therefore, this embodiment can reduce the misidentification of data flow types caused by the interference of mouse flow by setting the increase step size of the statistical number to be greater than the decrease step size of the statistical number, thereby improving the recognition accuracy of data flow types.
[0103] Optionally, the number of tuple information of data packets received within a preset time period can be counted, and the increase step size can be determined based on the number of tuple information. For example, the greater the number of tuple information, the larger the increase step size is set, thereby further improving the accuracy of identifying the data flow type.
[0104] In a possible implementation manner, obtaining a first adjustment step size includes:
[0105] Determine a first adjustment step size based on the current counted number of times in the target array element;
[0106] The current statistical number of times in the target array element is negatively correlated with the first adjustment step.
[0107] In this embodiment, the larger the current statistical number is, the smaller the first adjustment step is.
[0108] Specifically, the larger the current statistical times are, the less likely it is to be affected by the mouse flow, so the first adjustment step size can be set smaller to reduce the difficulty in timely identifying a new elephant flow when a new elephant flow appears.
[0109] The technical solution of this embodiment, by determining the first adjustment step based on the current statistical number of times in the target array element, can reduce the difficulty in timely identifying a new elephant flow when a new elephant flow appears, thereby further improving the accuracy of identifying the data flow type.
[0110] In a possible implementation, the target hash statistics array includes at least two storage locations, and searching for a target array element from the target hash statistics array corresponding to the hash function based on the target location index includes:
[0111] determining a target storage location among the at least two storage locations based on the target location index;
[0112] If the target storage location stores an array element, the array element stored in the target storage location is determined as the target array element.
[0113] In this embodiment, the storage location of the target hash statistics array can be distinguished according to the location index. Optionally, the location index corresponding to the target storage location is consistent with the target location index. Among them, the storage location in the target hash statistics array may be empty, without storing array elements, or may store array elements, which is determined according to actual conditions and is not limited here. Optionally, each storage location in the hash statistics array can store one array element or at least two array elements, which can be set as needed and is not limited here.
[0114] See also Figure 3 , Figure 3 A schematic diagram of searching for a target array element from a target hash statistics array provided by the present application. This embodiment is illustrated by taking one of the hash functions as an example, and each hash function can search for a target array element by the method of the embodiment of the present application.
[0115] like Figure 3 As shown, the target hash statistics array includes multiple storage locations, each storage location corresponds to a location index. Figure 3 The maximum capacity of the hash structure is 7. Generally, the data and the subscript are linked through the hash constructor, and the hash address is obtained by the remainder method.
[0116] Exemplarily, assuming that the result of the first hash value remainder method is 5, the target array element is searched from the 5th storage position.
[0117] In a possible implementation manner, if the first preset condition is met, the method further includes at least one of the following:
[0118] For each hash function, the initial statistical number and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function to obtain a new target hash statistical array corresponding to the hash function, so that when a new target data packet is received, the target data flow type of the new target data packet can be determined based on the new target hash statistical arrays corresponding to each hash function.
[0119] The first preset condition includes any one of the following:
[0120] The target array element search failed;
[0121] The reduced statistical number in the target array element is less than or equal to the second statistical number threshold, and the statistical number is reduced when the second hash value in the found target array element fails to match the first hash value.
[0122] In this embodiment, optionally, the initial statistical number may be greater than the second statistical number threshold.
[0123] Specifically, for the first preset condition including the failure to search for the target array element, it means that the hash value with the same position index as the first hash value has not appeared. Therefore, it is more likely that the target tuple information is of the first data flow type. The initial statistical number and the first hash value determined based on the hash function need to be used as the new array element stored in the target storage position in the target hash statistical array corresponding to the hash function, so that when a hash value with the same position index as the first hash value appears subsequently, the array element in the target storage position can be found, thereby determining the data flow type of the new data packet.
[0124] For the first preset condition including that the reduced statistical number in the target array element is less than or equal to the second statistical number threshold, it means that the tuple information corresponding to the second hash value in the target array element may no longer belong to the first data stream type, and the target tuple information is most likely to be of the first data stream type. Therefore, the initial statistical number and the first hash value determined based on the hash function need to be used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function.
[0125] See also Figure 4 , Figure 4 A schematic diagram of obtaining a new target hash statistical array corresponding to a hash function provided in an embodiment of the present application. This embodiment is illustrated by taking one of the hash functions as an example, and each hash function can obtain a corresponding new target hash statistical array by the method of the embodiment of the present application.
[0126] like Figure 4 As shown, in this embodiment, illustratively, assuming that the result of the first Hash value remainder method is 5, a new array element is added to storage location 5, and the new array element includes the first Hash value and the initial statistical number.
[0127] In another possible implementation, the target data packet may be sent to the first chip, and a new target hash statistical array fed back by the first chip may be received. The new target hash statistical array is determined by the first chip in the following manner:
[0128] For each hash function, a hash calculation is performed on the target multi-tuple information carried by the target data packet based on the hash function to obtain a first hash value, and a target position index corresponding to the first hash value is determined, and a target storage position in a target hash statistical array is determined based on the target position index, and an initial statistical number and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function to obtain a new target hash statistical array corresponding to the hash function.
[0129] It is understandable that how to determine the target data flow type of the new target data packet based on the new target hash function corresponding to each hash function can be referred to the description of any of the above embodiments, and will not be elaborated here.
[0130] The technical solution of this embodiment, if the first preset condition is met, is to obtain a new target hash statistical array corresponding to the hash function by, for each hash function, using the initial statistical number and the first hash value determined based on the hash function as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function, so that when a new target data packet is received, the target data flow type of the new target data packet is determined based on the new target hash statistical array corresponding to each hash function. That is to say, when the first preset condition is met, the array elements in the target hash statistical array can be updated in time, so that subsequent identification of new data packets can be more accurate.
[0131] It should be noted that, in addition to identifying data flow type information, the embodiments of the present application can also identify forwarding information of data packets.
[0132] The following embodiments further illustrate how to identify forwarding information of a data packet based on any of the above embodiments.
[0133] See also Figure 5 , Figure 5 A flowchart of another method for determining information of a data packet provided in an embodiment of the present application. Figure 5 The methods shown may include:
[0134] S510: Obtain target tuple information carried by the target data packet.
[0135] S520: Process the target tuple information based on each hash function of at least two hash functions to obtain data stream type information corresponding to each hash function.
[0136] S530. Determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function.
[0137] It can be understood that S510-S530 can refer to the description of any of the above embodiments and will not be elaborated here.
[0138] S540: If the second preset condition is met, obtain a preset first session table entry, and determine target forwarding information of the target data packet based on the first session table entry.
[0139] Among them, the second preset condition may include: the second hash value in the target array element successfully matches the first hash value. Specifically, if the second hash value in the target array element successfully matches the first hash value, it means that the target tuple information has been identified as the first data flow type before this identification, and this identification is also likely to be the first data flow type, and the data packet belonging to the first data flow type has corresponding forwarding information stored in the first session table entry, so that the forwarding information can be determined more quickly for forwarding. Therefore, if the second hash value in the target array element successfully matches the first hash value, the preset first session table entry can be obtained, and the target forwarding information of the target data packet can be determined based on the first session table entry, so that the forwarding information can be determined more quickly for forwarding.
[0140] The first session table entry may refer to a table entry used to determine the forwarding information of a data packet. Optionally, the first session table entry may record a mapping relationship between tuple information and forwarding information. When determining the target forwarding information of a target data packet based on the first session table entry, tuple information consistent with the target tuple information may be queried from the first session table entry, and then the forwarding information mapped by the consistent tuple information may be determined as the target forwarding information of the target data packet.
[0141] It should be noted that, optionally, in this embodiment, the first session table entry may store multi-tuple information of a data packet defined as a first data flow type, but does not store multi-tuple information of a data packet defined as a second data flow type, thereby further reducing the memory space occupied by the first session table entry. Specifically, the definition of the first data flow type may be currently defined as the first data flow type, or may be once defined as the first data flow type, which is not limited here.
[0142] S550: If the first preset condition is met, the target data packet is sent to the first chip through the first interface, so that the first chip determines the target forwarding information of the target data packet, receives the second session table entry from the first chip, and updates the first session table entry based on the second session table entry.
[0143] The first preset condition may include any one of the following:
[0144] The second hash value lookup failed;
[0145] The reduced statistical number in the target array element is less than or equal to the second statistical number threshold, and the statistical number is reduced when the second hash value in the found target array element fails to match the first hash value.
[0146] Specifically, in the present embodiment, for the conditions such as the failure of the second hash value lookup and the reduced statistical number of times in the target array element being less than or equal to the second statistical number threshold, it is indicated that the target data packet has a probability of being the first data flow type. Therefore, the target data packet can be sent to the first chip through the first interface, so that the first chip determines the target forwarding information of the target data packet, receives the second session table entry from the first chip, and updates the first session table entry based on the second session table entry.
[0147] The updating of the first session table entry based on the second session table entry may be a supplement of the second session table entry and the first session table entry, or a replacement of the first session table entry by the second session table entry, which is not limited here.
[0148] S560: If the third preset condition is met, the target data packet is sent to the first chip through the second interface, so that the first chip determines the target forwarding information of the target data packet.
[0149] The third preset condition may include: the reduced statistical number of times in the target array element is greater than a second statistical number threshold.
[0150] In this embodiment, specifically, if the reduced statistical number in the target array element is greater than the second statistical number threshold, it means that the target data packet belongs to the second data flow type. Therefore, the target data packet can be sent to the first chip through the second interface so that the first chip determines the target forwarding information of the target data packet.
[0151] Optionally, in this embodiment, if the third preset condition is met, the first chip does not need to determine the second session table entry, and the first chip only needs to determine the target forwarding information.
[0152] Among them, the first interface and the second interface can be different interfaces. The transmission rate of the first interface can be higher than the transmission rate of the second interface. Specifically, sending the target data packet through the first interface indicates that the data packet is to be forwarded by a fast path, and the first chip needs to determine the second session table entry; while sending the target data packet through the second interface indicates that the data packet is to be forwarded by a slow path. Generally, data reception is divided into fast path processing and slow path processing. The fast path is used to process input data segments in expected and ideal situations. The most common situations in network connections should be detected and optimized as much as possible to achieve the purpose of fast processing. The slow path is used to process data segments in unexpected and non-ideal situations, such as out-of-order data segments and urgent data. In this embodiment, the first data stream type needs to be processed by the fast path, and the second data stream type needs to be processed by the slow path.
[0153] It should be noted that, in some embodiments, only some steps in step S540, S550 or S560 may exist, which can be set as needed and will not be described in detail here.
[0154] The technical solution of this embodiment can also identify the forwarding information of the data packet after identifying the data flow type information.
[0155] For ease of understanding, the following embodiments are described using a framework of how to identify data flow types and forward data packets between the second chip and the first chip.
[0156] See also Figure 6 , Figure 6 A flowchart of another method for determining information of a data packet provided in an embodiment of the present application. The method of this embodiment can be executed by a first chip and a second chip to determine the data stream type information. Figure 6 The methods shown may include:
[0157] S610: The second chip obtains target tuple information carried by the target data packet.
[0158] S620: The second chip processes the target tuple information based on each hash function of the at least two hash functions to obtain data stream type information corresponding to each hash function.
[0159] S630. The second chip determines the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function.
[0160] S640: If the first preset condition is met, the second chip sends the target data packet to the first chip.
[0161] S650: The first chip determines a new target hash statistical array corresponding to each hash function of at least two hash functions based on the target multi-tuple information carried by the target data packet, and sends the target hash statistical array to the second chip.
[0162] In this embodiment, after receiving the new target hash statistical array, if the second chip receives a new target data packet, it determines the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function.
[0163] In a possible implementation, for each hash function, a new target hash statistics array corresponding to the hash function is determined based on the target tuple information, including:
[0164] Performing hash calculation on target tuple information carried by the target data packet based on a hash function to obtain a first hash value;
[0165] Determine a target location index corresponding to the first hash value;
[0166] determining a target storage location in a target hash statistics array based on the target location index;
[0167] The initial statistical times and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function, so as to obtain a new target hash statistical array corresponding to the hash function.
[0168] For details, please refer to Figure 4 The description is not repeated here.
[0169] It is understandable that if the target data flow type of the data packet is determined, reference may be made to the description of any of the above embodiments, which will not be elaborated herein.
[0170] The technical solution of this embodiment determines a new target hash statistics array through the first chip, which can reduce the computing power resource requirements for the second chip.
[0171] See also Figure 7 , Figure 7 A flowchart of another method for determining information of a data packet provided in an embodiment of the present application. This embodiment is described for determining data stream type information and forwarding information. Figure 7 The methods shown may include:
[0172] S710: The second chip obtains target tuple information carried by the target data packet.
[0173] S720: The second chip processes the target tuple information based on each hash function of the at least two hash functions to obtain data stream type information corresponding to each hash function.
[0174] S730. The second chip determines the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function.
[0175] S740: If the second preset condition is met, the second chip obtains a preset first session table entry, and determines target forwarding information of the target data packet based on the first session table entry.
[0176] S750: If the first preset condition is met, the second chip sends the target data packet to the first chip through the first interface.
[0177] S760: If the third preset condition is met, the second chip sends the target data packet to the first chip through the second interface.
[0178] S770: If a target data packet is received through the first interface, the first chip determines target forwarding information of the target data packet based on target tuple information carried by the target data packet.
[0179] S780: The first chip determines a second session table entry based on the target tuple information, and sends the second session table entry to the second chip.
[0180] In this embodiment, the second session table entry may include target tuple information and target forwarding information mapped by the tuple information. Optionally, the first chip may obtain a global session table entry, which records forwarding information mapped by each tuple information, and then search for tuple information consistent with the target tuple information based on the global session table entry, and then add the consistent tuple information and the forwarding information mapped by it to the second session table entry.
[0181] S790: If a second data packet is received through the second interface, the first chip determines target forwarding information of the target data packet based on target tuple information carried by the target data packet.
[0182] In this embodiment, the first chip can determine whether the target data packet is to be forwarded by a fast path or a slow path based on the receiving interface of the target data packet. Specifically, if the target data packet is received through the first interface, it means that fast path forwarding is required, and if the target data packet is received through the second interface, it means that slow path forwarding is required.
[0183] The technical solution of this embodiment can improve the success rate of determining the forwarding information, thereby improving the success rate of data packet forwarding, by determining the target forwarding information through the first chip when the second chip cannot determine the target forwarding information through the preset first session table entry. In addition, the second session table entry can also be fed back to improve the efficiency of the second chip in determining the forwarding information.
[0184] The following embodiments are based on any of the above embodiments and are described by taking the first chip as a CPU chip and the second chip as a programmable switch chip as an example.
[0185] See also Figure 8 , Figure 8 A framework diagram for identifying data flow types and forwarding data packets provided by an embodiment of the present application. In this scenario, it is mainly related to a class of equipment, namely a white box programmable switch for realizing a stateful gateway. The switch has the ability to modify the data packet forwarding logic on demand. The switch can accept data packets (such as servers and other switches, etc.) sent from different devices, and can also forward data packets according to the business arrangement logic requirements. In the scenario of the present invention, the stateful gateway is mainly responsible for the NAT gateway for converting the internal and external network IP addresses. Its core task is to map the internal network IP (Internet Protocol, Internet Protocol) and port of the computer room into the same public network IP and different ports, thereby converging the public network IP and saving the public network IP cost. Due to the limited programmable memory space, it is difficult to support ultra-large-scale NAT sessions, so a typical technology is large flow identification and unloading technology. However, the existing solution uses more additional memory space to record and identify elephant flows, which in turn reduces the sessions that can be stored in the fast path. In order to solve this problem, the present application designs a multi-channel hash elephant flow identification solution, which can identify and replace elephant flows through the limited memory of the forwarding surface.
[0186] Specifically, combined with the framework diagram, the operations at the pipeline level are as follows: Assume that a data packet f1 comes in, find the element corresponding to the FlowManager array, fm = FM[hash(f1)%L]. Among them, FM[hash(f1)%L] can represent the use of the hash function to process the multi-tuple information of the data packet f1 to obtain the hash value and then take the modulus. Then, process according to the following situations:
[0187] 1. fm.flow_id = 0, which means there is an empty position at fm in the array and no flow (element) is recorded. The f1 data packet is forwarded to the CPU. The CPU creates a second session table entry session and sends it to the session table of the pipeline, and sends the record data (register data). The CPU builds a hash linked list H to store the corresponding hash value and all flows that can get the hash value. fm.flow_id = f1, fm.c = fm.c+p.
[0188] 2. fm.flow_id=f1, indicating that the fast path already has an entry, so fm.c=fm.c+p is directly updated.
[0189] Here, p can be 2 or 8.
[0190] 3. fm.flow_id!=f1, indicating that a new flow has arrived, execute fm.c=fm.c-1; perform the following operations according to the situation of fm.c:
[0191] a) fm.c = 0, indicating that the new flow is likely to be an elephant flow. The pipeline transmits the data packet f1 to the CPU through a specific vlan (Virtual Local Area Network) sub-interface (eg, vlan500). After the CPU receives the data packet from vlan500, it replaces the session of the pipeline and updates the corresponding record in fm as fm.flow_id = f1, fm.c = p;
[0192] b) fmc.!=0, indicating that the new flow is not large enough, and the pipeline passes the packet f1 to the CPU for slow path forwarding through the ordinary VLAN sub-interface.
[0193] Specifically, the pipeline operation logic of the white box programmable switch can be as follows:
[0194] (1) After the port of the white box switch receives a data packet, it extracts the field information of the data packet header for subsequent table query, such as the 5-tuple information of the data packet pkt (source IP address src_ip, destination IP address dst_ip, source port src_port, destination port dst_port, protocol protocol);
[0195] (2) Submit the five-tuple information into n hash functions for calculation to obtain n hash results; that is, h1 = hash1(pkt), h2 = hash2(pkt), hn = hashn(pkt);
[0196] (3) Then, n indexes are obtained: idx1 = h1% len; idx2 = h2% len; idxn = hn% len; where len represents the length of the array fm_i that subsequently stores the data flow counts. Each element in the data statistics array contains two contents: the hash calculation result flow_id, and the statistical data c corresponding to the hash result;
[0197] (4) For each data flow count array fm, the following judgment operations are performed:
[0198] (a) fm_i[idxi].flow_id == 0, which means that fm has free space and no flow is recorded, and the f1 data packet is forwarded to the CPU;
[0199] (b) fm_i[idxi].flow_id==hi, which indicates that the fast path already has an entry, and then directly update fm_i[idxi].c=fm_i[idxi].c+p; where p is the accumulated value, which is generally set to 8 or 2;
[0200] (c) fm_i[idxi].flow_id!=hi, indicating that a new flow has arrived, execute fm.c=fm.c-1; perform the following operations according to the situation of fm.c:
[0201] i: fm_i[idxi].c==0, indicating that the new flow is likely to be an elephant flow, and the pipeline passes the data packet f1 to the CPU through a specific vlan sub-interface (eg, vlan 500);
[0202] ii: fm_i[idxi].c!=0, indicating that the new flow is not large enough, and the pipeline passes the packet f1 to the CPU for slow path forwarding through the ordinary VLAN sub-interface;
[0203] (5) End processing of the current data packet.
[0204] The CPU operation logic of the white box switch is as follows:
[0205] (1) The CPU detects the data packet sent from the pipeline and extracts the five-tuple information of the data packet. It queries the fully connected table in the CPU memory to see if there is a corresponding session table entry for the five-tuple. If there is a hit, it jumps to step 2); if there is no hit, it jumps to step a):
[0206] (a) Create corresponding session information for the five-tuple information, insert it into the fully connected table entry, and send the newly created session table entry to the fast path table;
[0207] (b) Submit the five-tuple information into n hash functions for calculation to obtain n hash results; that is, h1 = hash1(pkt), h2 = hash2(pkt), hn = hashn(pkt);
[0208] (c) Then, n indexes can be obtained: idx1 = h1% len; idx2 = h2% len; idxn = hn% len; where len represents the length of the array counter_i that subsequently stores the data flow count;
[0209] (d) For each hash function, find the corresponding location in the hash list array H[i] to store the 5-tuple information of the data packet; that is, H[idx1].append(pkt), H[idx2].append(pkt), H[idxn].append(pkt);
[0210] (e) At the same time, update the fm array data of the pipeline, fm_i[idxi].flow_id=hi, fm_i[idxi].c=fm_i[idxi].c+p;
[0211] (2) If a data packet is received from VLAN sub-interface 500, the hash results h1, h2, hn are calculated in the same way as above, and then the indexes idx1, idx2, idxn are obtained; all flows stored in the hash list H[] are extracted;
[0212] (3) extract these flows from the fast path and replace them with the flow information of the packet received by VLAN sub-interface 500 (i.e., quintuple session information);
[0213] (4) End the current CPU running logic.
[0214] The technical solution of this embodiment has but is not limited to the following technical effects:
[0215] Improved accuracy: Multi-way hashing can improve the accuracy of elephant flow identification because it can reduce the possibility of hash collisions.
[0216] Improve efficiency: The multi-way hashing algorithm can improve the efficiency of elephant flow identification because it can process multiple hash functions in parallel.
[0217] Improve network performance: By identifying and managing elephant flows, the overall performance and throughput of the network can be effectively improved.
[0218] Improve resource utilization: By identifying and managing elephant flows, network resources can be used more effectively and waste of resources can be avoided.
[0219] Provide better user experience: By prioritizing elephant streams, a better user experience can be provided, such as reducing video buffering and increasing web page loading speed.
[0220] See also Fig. 9 , Fig. 9 A schematic diagram of a structure of a device for determining information of a data packet provided in an embodiment of the present application. The device 900 of this embodiment can be applied to a second chip, wherein the device 900 of this embodiment can include a first acquisition module 910 and a first information determination module 920, wherein:
[0221] A first acquisition module 910 is used to acquire target multi-tuple information carried by a target data packet;
[0222] A first information determination module 920 is used to process the target multi-group information based on each hash function of at least two hash functions to obtain data flow type information corresponding to each hash function, and determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function, the data flow type information is used to indicate the data flow type to which the target data packet belongs, the data flow type includes at least one of a first data flow type or a second data flow type, and the data flow corresponding to the first data flow type is greater than the data flow corresponding to the second data flow type;
[0223] For each hash function, when the first information determination module 920 processes the target tuple information based on the hash function to obtain the data stream type information corresponding to the hash function, it is used to:
[0224] Performing hash calculation on the target multi-tuple information based on a hash function to obtain a first hash value, and determining a target position index corresponding to the first hash value;
[0225] Find the target array element from the target hash statistics array corresponding to the hash function based on the target position index;
[0226] If the target array element is successfully found, the data stream type to which the target data packet belongs is determined based on the second hash value and the statistical number in the target array element.
[0227] Optionally, when determining the data flow type to which the target data packet belongs based on the second hash value and the statistical number in the target array element, the first information determination module 920 may be used to:
[0228] matching the second hash value with the first hash value;
[0229] If the second hash value successfully matches the first hash value, it is determined that the target data packet belongs to the first data flow type, and the statistical number in the target array element is increased;
[0230] If the second hash value fails to match the first hash value, the statistical number in the target array element is reduced, and if the statistical number after the reduction is greater than the predetermined first statistical number threshold, it is determined that the target data packet belongs to the second data flow type, and if the statistical number after the reduction is less than or equal to the predetermined second statistical number threshold, it is determined that the target data packet belongs to the first data flow type;
[0231] The first statistical number threshold is greater than or equal to the second statistical number threshold.
[0232] Optionally, when increasing the statistical number of times in the target array element, the first information determination module 920 may be used to:
[0233] Obtaining a first adjustment step, and increasing the number of statistics in the target array element based on the first adjustment step;
[0234] When reducing the number of statistics in the target array element, the first information determination module 920 can be used to:
[0235] Obtaining a second adjustment step length, and reducing the number of statistics in the target array element based on the second adjustment step length;
[0236] The first adjustment step length is greater than the second adjustment step length.
[0237] Optionally, when acquiring the first adjustment step, the first information determining module 920 may be used to:
[0238] Determine a first adjustment step size based on the current counted number of times in the target array element;
[0239] The current statistical number of times in the target array element is negatively correlated with the first adjustment step.
[0240] Optionally, the target hash statistics array includes at least two storage locations, and when the first information determination module 920 searches for a target array element from the target hash statistics array corresponding to the hash function based on the target location index, it can be used to:
[0241] determining a target storage location among the at least two storage locations based on the target location index;
[0242] If the target storage location stores an array element, the array element stored in the target storage location is determined as the target array element.
[0243] Optionally, if the first preset condition is met, the first information determination module 920 is further configured to perform at least one of the following:
[0244] For each hash function, an initial statistical number and a first hash value determined based on the hash function are used as new array elements stored in a target storage position in a target hash statistical array corresponding to the hash function, to obtain a new target hash statistical array corresponding to the hash function, so as to determine a target data flow type of a new target data packet based on the new target hash statistical array corresponding to each hash function when a new target data packet is received;
[0245] The target data packet is sent to the first chip, and a new target hash statistics array fed back by the first chip is received. The new target hash statistics array is determined by the first chip in the following manner:
[0246] For each hash function, a hash calculation is performed on the target multi-tuple information carried by the target data packet based on the hash function to obtain a first hash value, and a target position index corresponding to the first hash value is determined, and a target storage position in a target hash statistical array is determined based on the target position index, and an initial statistical number and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function to obtain a new target hash statistical array corresponding to the hash function;
[0247] The first preset condition includes any one of the following:
[0248] The target array element search failed;
[0249] The reduced statistical number in the target array element is less than or equal to the second statistical number threshold, and the statistical number is reduced when the second hash value in the found target array element fails to match the first hash value.
[0250] Optionally, when the first information determination module 920 determines the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function, it can be used for at least one of the following:
[0251] If the data flow type information corresponding to one of the hash functions indicates that the target data packet belongs to the first data flow type, determining that the target data flow type is the first data flow type;
[0252] If the data flow type information corresponding to each hash function indicates that the target data packet belongs to the second data flow type, the target data flow type is determined to be the second data flow type.
[0253] Optionally, the first information determination module 920 may also be used for at least one of the following:
[0254] If the second preset condition is met, obtaining a preset first session table entry, and determining target forwarding information of the target data packet based on the first session table entry;
[0255] If the first preset condition is met, the target data packet is sent to the first chip through the first interface, so that the first chip determines the target forwarding information of the target data packet, receives the second session table entry from the first chip, and updates the first session table entry based on the second session table entry;
[0256] If the third preset condition is met, the target data packet is sent to the first chip through the second interface, so that the first chip determines the target forwarding information of the target data packet;
[0257] The first preset condition includes any one of the following:
[0258] The second hash value lookup failed;
[0259] The reduced statistical number of times in the target array element is less than or equal to a second statistical number threshold, and the statistical number is reduced when the second hash value in the found target array element fails to match the first hash value;
[0260] The second precondition includes:
[0261] The second hash value in the target array element successfully matches the first hash value;
[0262] The third precondition includes:
[0263] The reduced statistical number of times in the target array element is greater than the second statistical number threshold.
[0264] See also Fig.10 , Fig.10 A schematic diagram of the structure of another device for determining information of a data packet provided in an embodiment of the present application. The device 1000 of this embodiment can be applied to a first chip, wherein the device 1000 of this embodiment can include a second acquisition module 1010 and a second information determination module 1020, wherein:
[0265] A second acquisition module 1010 is used to acquire a target data packet from a second chip, where the target data packet carries target multi-tuple information;
[0266] The second information determination module 1020 is used to determine a new target hash statistical array corresponding to each hash function of at least two hash functions based on the target multi-tuple information, and send the target hash statistical array to the second chip, so that when the second chip receives a new target data packet, it determines the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function.
[0267] Optionally, for each hash function, when determining a new target hash statistics array corresponding to the hash function based on the target tuple information, the second information determination module 1020 may be used to:
[0268] Performing hash calculation on target tuple information carried by the target data packet based on a hash function to obtain a first hash value;
[0269] Determine a target location index corresponding to the first hash value;
[0270] determining a target storage location in a target hash statistics array based on the target location index;
[0271] The initial statistical times and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function, so as to obtain a new target hash statistical array corresponding to the hash function.
[0272] Optionally, the second information determination module 1020 is further used for at least one of the following:
[0273] If a target data packet is received through the first interface, target forwarding information of the target data packet is determined based on target multi-group information carried by the target data packet, a second session table item is determined based on the target multi-group information, and the second session table item is sent to the second chip, so that the first chip updates the first session table item preset by the first chip based on the second session table item;
[0274] If the second data packet is received through the second interface, the target forwarding information of the target data packet is determined based on the target tuple information carried by the target data packet.
[0275] The device of the embodiments of the present application can execute the method provided by the embodiments of the present application, and the implementation principles are similar. The actions performed by each module in the device of each embodiment of the present application correspond to the steps in the method of each embodiment of the present application. For the detailed functional description of each module of the device, please refer to the description in the corresponding method shown in the previous text, which will not be repeated here.
[0276] An embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory, and the processor executes the above-mentioned computer program to implement the steps of the method of any embodiment of the present application.
[0277] In an alternative embodiment, an electronic device is provided, such as Fig.11 As shown, Fig.11 The electronic device 1100 shown includes: a processor 1101 and a memory 1103. The processor 1101 and the memory 1103 are connected, such as through a bus 1102. Optionally, the electronic device 1100 may also include a transceiver 1104, which may be used for data interaction between the electronic device and other electronic devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 1104 is not limited to one, and the structure of the electronic device 1100 does not constitute a limitation on the embodiments of the present application.
[0278] Processor 1101 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 1101 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.
[0279] The bus 1102 may include a path to transmit information between the above components. The bus 1102 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 1102 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.11 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0280] The memory 1103 may be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compressed optical disk, laser disc, optical disk, digital versatile disc, Blu-ray disc, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0281] The memory 1103 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 1101. The processor 1101 is used to execute the computer program stored in the memory 1103 to implement the steps shown in the above method embodiment.
[0282] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0283] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.
[0284] It should be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.
[0285] The above are only optional implementation methods for some implementation scenarios of the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the technical concept of the scheme of the present application, other similar implementation methods based on the technical ideas of the present application are also within the protection scope of the embodiments of the present application.
Claims
1. A method for determining information of a data packet, characterized in that: include: Obtain target multi-tuple information carried by the target data packet; Processing the target multi-group information based on each hash function of at least two hash functions to obtain data flow type information corresponding to each hash function, wherein the data flow type information is used to indicate a data flow type to which the target data packet belongs, wherein the data flow type includes at least one of a first data flow type or a second data flow type, and a data flow corresponding to the first data flow type is greater than a data flow corresponding to the second data flow type; Determine the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function; Wherein, for each hash function, the target tuple information is processed based on the hash function to obtain data stream type information corresponding to the hash function, including: Performing a hash calculation on the target tuple information based on the hash function to obtain a first hash value, and determining a target position index corresponding to the first hash value; Searching for a target array element from a target hash statistics array corresponding to the hash function based on the target position index; If the target array element is successfully found, the data stream type to which the target data packet belongs is determined based on the second hash value and the statistical number in the target array element.
2. The method according to claim 1, characterized in that The determining the data stream type to which the target data packet belongs based on the second hash value and the statistical number of times in the target array element includes: matching the second hash value with the first hash value; If the second hash value successfully matches the first hash value, it is determined that the target data packet belongs to the first data flow type, and the statistical number in the target array element is increased; If the second hash value fails to match the first hash value, the statistical number in the target array element is reduced, and if the statistical number after the reduction is greater than a predetermined first statistical number threshold, it is determined that the target data packet belongs to the second data flow type; if the statistical number after the reduction is less than or equal to the predetermined second statistical number threshold, it is determined that the target data packet belongs to the first data flow type; The first statistical number threshold is greater than or equal to the second statistical number threshold.
3. The method according to claim 2, characterized in that The increasing the statistical number of times in the target array element comprises: Obtaining a first adjustment step, and increasing the number of statistics in the target array element based on the first adjustment step; The reducing the number of statistics in the target array element comprises: Acquire a second adjustment step length, and reduce the number of statistics in the target array element based on the second adjustment step length; Wherein, the first adjustment step length is greater than the second adjustment step length.
4. The method according to claim 3, characterized in that The obtaining of the first adjustment step includes: Determining the first adjustment step size based on the current statistical number of times in the target array element; The current statistical number of times in the target array element is negatively correlated with the first adjustment step.
5. The method according to claim 1, characterized in that The target hash statistics array includes at least two storage locations, and searching for a target array element from the target hash statistics array corresponding to the hash function based on the target location index includes: determining a target storage location among the at least two storage locations based on the target location index; If the target storage location stores an array element, the array element stored in the target storage location is determined as the target array element.
6. The method according to claim 5, characterized in that If the first preset condition is met, the method further includes at least one of the following: For each hash function, an initial statistical number and a first hash value determined based on the hash function are used as new array elements stored in a target storage position in a target hash statistical array corresponding to the hash function, to obtain a new target hash statistical array corresponding to the hash function, so as to determine the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function when a new target data packet is received; The target data packet is sent to the first chip, and a new target hash statistical array fed back by the first chip is received, where the new target hash statistical array is determined by the first chip in the following manner: For each hash function, a hash calculation is performed on the target multi-tuple information carried by the target data packet based on the hash function to obtain a first hash value, and a target position index corresponding to the first hash value is determined, and a target storage position in the target hash statistical array is determined based on the target position index, and an initial statistical number and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function to obtain a new target hash statistical array corresponding to the hash function; The first preset condition includes any one of the following: The target array element search fails; The reduced statistical number in the target array element is less than or equal to a second statistical number threshold, and the statistical number is reduced when the second hash value in the target array element found fails to match the first hash value.
7. The method according to claim 1, characterized in that The determining the target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function includes at least one of the following: If the data flow type information corresponding to one of the hash functions indicates that the target data packet belongs to the first data flow type, determining that the target data flow type is the first data flow type; If the data flow type information corresponding to each hash function indicates that the target data packet belongs to the second data flow type, the target data flow type is determined to be the second data flow type.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises at least one of the following: If the second preset condition is met, obtaining a preset first session table entry, and determining target forwarding information of the target data packet based on the first session table entry; If the first preset condition is met, the target data packet is sent to the first chip through the first interface, so that the first chip determines the target forwarding information of the target data packet, receives the second session table entry from the first chip, and updates the first session table entry based on the second session table entry; If the third preset condition is met, sending the target data packet to the first chip through the second interface, so that the first chip determines the target forwarding information of the target data packet; The first preset condition includes any one of the following: The second hash value search fails; The reduced statistical number of times in the target array element is less than or equal to a second statistical number threshold, and the statistical number is reduced when the second hash value in the target array element found fails to match the first hash value; The second preset condition includes: The second hash value in the target array element successfully matches the first hash value; The third preset condition includes: The reduced statistical number of times in the target array element is greater than a second statistical number threshold.
9. A method for determining information of a data packet, characterized in that: include: Acquire a target data packet from a second chip, wherein the target data packet carries target multi-tuple information; Based on the target tuple information, determine a new target hash statistical array corresponding to each hash function of at least two hash functions, and send the target hash statistical array to the second chip, so that when the second chip receives a new target data packet, it determines the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function; The second chip determines the data stream type information based on the method described in any one of claims 1-7.
10. The method according to claim 9, characterized in that For each hash function, determining a new target hash statistics array corresponding to the hash function based on the target tuple information includes: Performing a hash calculation on the target tuple information carried by the target data packet based on the hash function to obtain a first hash value; Determine a target location index corresponding to the first hash value; Determining a target storage location in the target hash statistics array based on the target location index; The initial statistical number and the first hash value determined based on the hash function are used as new array elements stored in the target storage position in the target hash statistical array corresponding to the hash function to obtain a new target hash statistical array corresponding to the hash function.
11. The method according to claim 9 or 10, characterized in that: The method further comprises at least one of the following: If the target data packet is received through the first interface, target forwarding information of the target data packet is determined based on target tuple information carried by the target data packet, a second session table item is determined based on the target tuple information, and the second session table item is sent to the second chip, so that the first chip updates the first session table item preset by the first chip based on the second session table item; If the second data packet is received through the second interface, the target forwarding information of the target data packet is determined based on the target tuple information carried by the target data packet.
12. A device for determining information of a data packet, characterized in that: include: A first acquisition module, used for acquiring target multi-group information carried by a target data packet; a first information determination module, configured to process the target multi-group information based on each of the at least two hash functions to obtain data flow type information corresponding to each hash function, and determine a target data flow type to which the target data packet belongs based on the data flow type information corresponding to each hash function, wherein the data flow type information is used to indicate the data flow type to which the target data packet belongs, the data flow type including at least one of a first data flow type or a second data flow type, and a data flow corresponding to the first data flow type is greater than a data flow corresponding to the second data flow type; Wherein, for each hash function, when the first information determination module processes the target tuple information based on the hash function to obtain the data stream type information corresponding to the hash function, is used to: Performing a hash calculation on the target tuple information based on the hash function to obtain a first hash value, and determining a target position index corresponding to the first hash value; Searching for a target array element from a target hash statistics array corresponding to the hash function based on the target position index; If the target array element is successfully found, the data stream type to which the target data packet belongs is determined based on the second hash value and the statistical number in the target array element.
13. A device for determining information of a data packet, characterized in that: include: A second acquisition module, used for acquiring a target data packet from a second chip, wherein the target data packet carries target multi-tuple information; a second information determination module, configured to determine a new target hash statistical array corresponding to each hash function of at least two hash functions based on the target multi-tuple information, and send the target hash statistical array to the second chip, so that when the second chip receives a new target data packet, it determines the target data flow type of the new target data packet based on the new target hash statistical array corresponding to each hash function; The second chip determines the data stream type information based on the method described in any one of claims 1-7.
14. An electronic device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the method according to any one of claims 1 to 8, or implements the method according to any one of claims 9 to 11.
15. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 8, or implements the method described in any one of claims 9 to 11.