Packet flow detection method and device, storage medium and electronic device

By receiving target detection requests, generating target detection configurations, and using target indexes and processors to detect packets, the problem of low packet traffic detection performance in existing technologies is solved, achieving a flexible detection process and high-efficiency traffic detection performance.

CN116708243BActive Publication Date: 2026-02-06SUZHOU CENTEC COMM CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310768682.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-27
Publication Date
2026-02-06
Estimated Expiration
2043-06-27

AI Technical Summary

Technical Problem

Existing technologies have low packet traffic detection performance and relatively fixed statistical capabilities, which cannot meet the ever-changing statistical requirements, resulting in bloated chip designs.

Method used

By receiving target detection requests, determining target packet parameters and detection templates, generating target detection configurations, and using target indexes and processors to detect packets transmitted on network devices, a flexible detection process is achieved.

Benefits of technology

The improved flow detection performance of the chip enables it to support more detection needs, avoiding the chip bloat problem caused by fixed detection requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116708243B_ABST
    Figure CN116708243B_ABST
Patent Text Reader

Abstract

The application discloses a message flow detection method and device, a storage medium and an electronic device. The method comprises the following steps: receiving a target detection request, wherein the target detection request is used for requesting to detect a target flow parameter of a target message with a target message feature transmitted by a network device; determining the target message parameter of the target message from a reference message parameter, and determining a target detection template used for detecting the target flow parameter from a reference detection template; generating a target detection configuration according to the target message parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target flow parameter of the target message with the target message feature; and detecting the message transmitted by the network device by using the target detection configuration. By using the technical solution, the problem of low detection performance of the message flow in the related art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication, in particular to a message flow detection method and device, a storage medium and an electronic device. BACKGROUND

[0002] At present, network deployment is more and more complex, which brings great difficulty to operation and maintenance personnel. By checking the service statistics of network equipment, the operation and maintenance personnel can quickly locate and solve problems. Due to the diversity of services, different services need to be statistically analyzed from different perspectives. For switches or routers, the statistical function is implemented by a switching chip. At present, for a certain service statistical requirement from a certain service perspective, the corresponding statistical method needs to be designed in the chip for the statistical requirement. For example, for VLAN service flow statistics, the number of packet loss messages in VLAN service of network equipment is counted. Therefore, for this statistical requirement, the index of VLAN service on the network equipment needs to be designed, and the statistical algorithm for counting the packet loss messages is designed for the statistical requirement, so that the chip supports this kind of statistical requirement. However, the statistical ability of such a chip is relatively fixed, and it can only support the statistics of fixed service statistical requirements. If the chip has been taped out, and there is a new statistical requirement at this time, the chip cannot meet the statistical requirement. Therefore, when designing the chip, the function design of the statistical requirement needs to be increased. With the continuous increase of the function design corresponding to the statistical requirement, the chip is designed to be relatively bloated.

[0003] For the problems such as low detection performance of message flow in the related art, an effective solution has not been proposed. SUMMARY

[0004] Embodiments of the present application provide a message flow detection method and device, a storage medium and an electronic device, which at least solve the problem of low detection performance of message flow in the related art.

[0005] According to an embodiment of the embodiment of the present application, a method for detecting packet flow is provided, comprising: receiving a target detection request, wherein the target detection request is used to request detection of a target flow parameter of a target packet with a target packet characteristic transmitted by a network device; determining the target packet parameter of the target packet from a reference packet parameter, and determining a target detection template used to detect the target flow parameter from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet characteristic of a packet to be detected, and the reference detection template records a detection process of detecting a reference flow parameter of a packet; generating a target detection configuration according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target flow parameter of the target packet with the target packet characteristic; and detecting a packet transmitted by the network device using the target detection configuration.

[0006] Optionally, the generating a target detection configuration according to the target packet parameter and the target detection template comprises: generating a target index according to a target index template and a target index parameter, wherein the target index template records an index process used to index a transmission port of a packet, and the target index parameter is a parameter used to represent a packet type of the target packet; and generating a target operator according to a target operator template and a target operation parameter, wherein the target operator template records a statistical logic used to count the target flow parameter, the target operation parameter is a parameter used to represent a flow characteristic of the target packet, the flow characteristic is a characteristic matched with the target flow parameter, the target packet parameter comprises the target index parameter and the target operation parameter, the target detection template comprises the target index template and the target operator template, and the target detection configuration comprises the target index and the target operator.

[0007] Optionally, the generating a target index according to a target index template and a target index parameter comprises: adding the target index parameter to a parameter position corresponding to an index parameter in a target index formula to obtain the target index, wherein the target index template comprises the target index formula, and the target index formula comprises an index shift rule of generating an index.

[0008] Optionally, the generating a target operator according to a target operator template and a target operation parameter comprises: adding the target operation parameter to a parameter position corresponding to an operation parameter in the target operator template to obtain the target operator.

[0009] Optionally, before the step of generating the target detection configuration according to the target packet parameter and the target detection template, the method further comprises: determining whether the target detection request is in an enabled state on the network device according to the target packet parameter; and generating the target detection configuration according to the target packet parameter and the target detection template in the case that the target detection request is in the enabled state.

[0010] Optionally, the step of determining whether the target detection request is in the enabled state on the network device according to the target packet parameter comprises: matching the target packet parameter with a packet transmission parameter on the network device according to a target matching logic to obtain a matching result, wherein the target matching logic is used to indicate a target numerical relationship between the target packet parameter and the packet transmission parameter, and the target matching logic is a matching logic corresponding to the target detection request; and determining that the target detection request is in the enabled state on the network device in the case that the matching result is used to represent that the numerical relationship between the target packet parameter and the packet transmission parameter is consistent with the target numerical relationship.

[0011] Optionally, the step of detecting the packet transmitted on the network device using the target detection configuration comprises: using a target index to retrieve a target transmission port of the target packet; and using a target calculator to count the packet transmitted in the target transmission port, wherein the target detection configuration comprises the target index and the target calculator.

[0012] According to another embodiment of the embodiment of the present application, a packet flow detection device is further provided, comprising: a receiving module, configured to receive a target detection request, wherein the target detection request is used to request to detect a target flow parameter of a target packet with a target packet characteristic transmitted on a network device; a first determining module, configured to determine a target packet parameter of the target packet from a reference packet parameter, and determine a target detection template used to detect the target flow parameter from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet characteristic of a to-be-detected packet, and the reference detection template records a detection process of detecting a reference flow parameter of a packet; a first generating module, configured to generate a target detection configuration according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target flow parameter of the target packet with the target packet characteristic; and a detecting module, configured to detect the packet transmitted on the network device using the target detection configuration.

[0013] According to a further aspect of the embodiments of the present application, a computer readable storage medium is provided, which stores a computer program. The computer program is configured to perform the packet flow detection method when executed.

[0014] According to a further aspect of the embodiments of the present application, an electronic device is provided, which comprises a memory, a processor, and a computer program stored in the memory and executable on the processor. The processor is configured to perform the packet flow detection method by executing the computer program.

[0015] In the embodiments of the present application, a target detection request is received, wherein the target detection request is used to request detection of a target flow parameter of a target packet with a target packet feature transmitted by a network device. The target packet parameter of the target packet is determined from a reference packet parameter, and a target detection template used to detect the target flow parameter is determined from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet feature of a packet to be detected, and the reference detection template records a detection process of detecting a reference flow parameter of a packet. A target detection configuration is generated according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target flow parameter of the target packet with the target packet feature. The packet transmitted by the network device is detected using the target detection configuration. That is, the reference packet parameter used to represent the packet feature of the packet to be detected is set, and the reference detection template recording the detection process of detecting the reference flow parameter of the packet is set. Then, when it is necessary to detect the target flow parameter of the target packet with the target packet feature transmitted by the network device, the target packet parameter of the target packet is determined from the reference packet parameter, and the target detection template used to detect the target flow parameter is determined from the reference detection template. Then, the target detection configuration recording the detection process of detecting the target flow parameter of the target packet with the target packet feature is generated according to the target packet parameter and the target detection template. That is, the target detection configuration in the present application is generated according to the selected target packet parameter and the target detection template. Therefore, the detection configuration is automatically generated according to the received detection request, so that the flow detection performance of the chip is effectively improved, and the chip can support more detection requirements instead of only supporting fixed detection requirements. By using the above technical solution, the problem of low packet flow detection performance in the related art is solved, and the technical effect of improving the packet flow detection performance is achieved. BRIEF DESCRIPTION OF DRAWINGS

[0016] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate the embodiments of the present application and, together with the description, serve to explain the principles of the present application.

[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the embodiments or prior art description will be briefly introduced as follows. Obviously, for those of ordinary skill in the art, the other drawings can be obtained based on these drawings without any creative effort.

[0018] Figure 1 is a hardware environment schematic diagram of a packet flow detection method according to an embodiment of the present application;

[0019] Figure 2 is a flow chart of a packet flow detection method according to an embodiment of the present application;

[0020] Figure 3 is an optional chip schematic diagram according to an embodiment of the present application Figure 1 ;

[0021] Figure 4 is an optional chip schematic diagram according to an embodiment of the present application Figure 2 ;

[0022] Figure 5 is an optional target detection configuration generation schematic diagram according to an embodiment of the present application;

[0023] Figure 6 is an optional detection engine module schematic diagram according to an embodiment of the present application;

[0024] Figure 7 is an optional flow parameter detection schematic diagram according to an embodiment of the present application;

[0025] Figure 8 is a structural block diagram of a packet flow detection device according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] In order to make the technical personnel in the art better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without any creative effort should belong to the scope of protection of the present application.

[0027] It should be noted that the terms "first", "second" and the like in the description and in the claims of the present application as well as above-mentioned appended drawings are intended to distinguish between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so distinguished can be interchanged, where appropriate, so that the embodiments of the present application described herein can be carried out in other than the precise arrangements or order disclosed herein. Furthermore, the terms "comprise" and "include" and variations thereof as used in the description and in the claims of the present application are intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus that comprises, includes, houses, has, contains or comprises elements not expressly listed or inherent to such process, method, article, or apparatus does not, therefore, exclude such elements.

[0028] The method embodiments provided by the embodiments of the present application can be executed in a computer terminal, a device terminal or similar computing device. Taking the case of running on a computer terminal, Figure 1 is a hardware environment schematic diagram of a packet flow detection method according to an embodiment of the present application. As shown in Figure 1 , the computer terminal can include one or more (only one is shown in Figure 1 ) processors 102 (the processor 102 can include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. In an exemplary embodiment, the above-mentioned computer terminal can further include a transmission device 106 for communication function and an input and output device 108. Those skilled in the art can understand that Figure 1 The structure shown is only schematic, which does not limit the structure of the above-mentioned computer terminal. For example, the computer terminal can include more or fewer components than those shown in Figure 1 , or have a different configuration with the same function or more function than that shown in Figure 1 . Figure 1

[0029] The memory 104 can be used to store computer programs, for example, software programs of application software and modules, such as the computer program corresponding to the message pushing sending method in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above-mentioned method. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, which can be connected to the computer terminal through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network and a combination thereof. ​

[0030] The transmission device 106 is configured to receive or send data via a network. The network can include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a network interface controller (NIC) configured to connect to other network devices via a base station to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module configured to communicate with the Internet via a wireless manner.

[0031] In the present embodiment, a packet flow detection method is provided, which is applied to the computer terminal, Figure 2 FIG. 1 is a flowchart of a packet flow detection method according to an embodiment of the present application. The flowchart includes the following steps:

[0032] In step S202, a target detection request is received, wherein the target detection request is configured to request detection of a target flow parameter of a target packet having a target packet characteristic transmitted by a network device.

[0033] In step S204, a target packet parameter of the target packet is determined from reference packet parameters, and a target detection template for detecting the target flow parameter is determined from reference detection templates, wherein the reference packet parameters are parameters for characterizing packet characteristics of a packet to be detected, and the reference detection templates record detection processes for detecting reference flow parameters of packets.

[0034] In step S206, a target detection configuration is generated according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process for detecting the target flow parameter of the target packet having the target packet characteristic.

[0035] In step S208, the target detection configuration is used to detect packets transmitted by the network device.

[0036] Through the above steps, the reference message parameters for characterizing the message features of the to-be-detected message are set, and the reference detection template recording the detection process of detecting the reference traffic parameters of the message is set. Then, when it is necessary to detect the target traffic parameters of the target message with the target message features transmitted by the network device, the target message parameters of the target message are determined from the reference message parameters, and the target detection template for detecting the target traffic parameters is determined from the reference detection template. Therefore, the target detection configuration recording the detection process of detecting the target traffic parameters of the target message with the target message features is generated according to the target message parameters and the target detection template, that is, the target detection configuration in the present application is generated according to the selected target message parameters and the target detection template. Therefore, the detection configuration is automatically generated according to the received detection request, so as to effectively improve the traffic detection performance of the chip, so that the chip can support more detection requirements, instead of only supporting fixed detection requirements. By adopting the technical scheme, the problems such as low detection performance of message traffic in the related art are solved, and the technical effect of improving the detection performance of message traffic is achieved.

[0037] The message traffic detection method of the present application can be applied on a chip with a statistical function, but is not limited thereto.

[0038] In the technical scheme provided in the above step S202, the network device is a device for transmitting messages, which can include, but is not limited to, switches, routers, and the like, and the present application does not limit this.

[0039] Optionally, in the present embodiment, the target message features can include, but are not limited to, the protocol type of the message, the sending port type of the message, the receiving port type of the message, whether the message is lost, the COS value (Class Of Service) of the message, the queue priority Priority of the message, color, and the like, and the present application does not limit this.

[0040] Optionally, in the present embodiment, the traffic parameters are used to characterize the feature quantity of a certain type of feature message, which can include, but are not limited to, the number of message, the number of bytes, the number of lost packets, and the like, and the present application does not limit this.

[0041] In the technical scheme provided in the above step S204, the reference message parameters are pre-configured for all message parameters that can be used for traffic detection. The more the number and / or types of the configured reference message parameters are, the higher the detection capability of the message traffic detection supported by the chip is.

[0042] Optionally, in the embodiment, the packet parameter is a parameter used to represent the attribute of the packet, which can include, but is not limited to, the protocol type of the packet, the protocol keyword, the port information of the packet transmission, the COS (Class Of Service) value of the packet, the queue priority Priority of the packet, the color, the ttl, the dscp, the packet length, the character number of a certain field, etc., and the present application does not limit the same.

[0043] Optionally, in the embodiment, the reference detection template is a pre-configured detection template that can be used in the traffic detection, and the more the types of the configured detection templates are, the higher the detection capability of the chip supporting the packet traffic detection is.

[0044] Optionally, in the embodiment, the reference detection template can include, but is not limited to, an index template and an operator template, and the index template can record the index flow used to index the transmission port of the packet, and the operator template can record the statistical logic used to count a certain type of traffic parameter, and the present application does not limit the same.

[0045] In the technical solution provided in the above step S206, the way of generating the target detection configuration can include adding the target packet parameter to the corresponding parameter position in the target detection template, or can also be modifying the corresponding packet parameter in the target detection template using the target packet parameter, and the present application does not limit the same.

[0046] In the technical solution provided in the above step S208, the packet transmitted by the network device is detected using the target detection configuration, so as to obtain the target traffic parameter.

[0047] The packet traffic detection method claimed in the present application can be applied on a chip or a network device with a statistical function, which can be designed as a detection engine for detecting the packet traffic, and is used to detect the transmitted packet, and can be arranged at the packet input port of the chip or the network device, or can also be arranged at the packet output port of the chip or the network device, Figure 3 is a schematic diagram of an optional chip according to an embodiment of the present application Figure 1 As shown in Figure 3 , the detection engine with the detection logic of the above packet traffic detection method is arranged at the packet input port of the chip, and is used to count the packet input into the chip. Figure 4 is a schematic diagram of an optional chip according to an embodiment of the present application Figure 2 As shown in Figure 4 , the detection engine with the detection logic of the above packet traffic detection method is arranged at the packet output port of the chip, and is used to count the packet output from the chip.

[0048] In practical applications, the DsStatsConfig table entry can be set to store reference detection templates, and reference message parameters can be stored through the device's flexible object container. Figure 5 This is a schematic diagram generated according to an optional target detection configuration according to an embodiment of this application, such as... Figure 5 As shown, the DsStatsConfig table entry stores reference detection templates, and the flexible object container stores reference packet parameters, mainly including packet information: vlanId, vlanCos, TTL, dscp, packet length, etc.; packet processing information: object initial index statsPtr, whether the packet was lost, packet ingress port number, packet egress port number, packet queue priority, and coloring information, etc. After the packet passes through IPE or EPE, the target detection template is filtered from the DsStatsConfig table entry according to the target detection request, and the target packet parameters are filtered from the flexible object container. Then, based on the target packet parameters and the target detection template, a target detection configuration for detecting target traffic parameters is generated.

[0049] As an optional embodiment, generating the target detection configuration based on the target message parameters and the target detection template includes:

[0050] A target index is generated based on a target index template and target index parameters. The target index template records the indexing process for indexing the transmission ports of a message, and the target index parameters are parameters used to characterize the message type of the target message.

[0051] A target processor is generated based on a target processor template and target processing parameters. The target processor template records statistical logic for calculating the target traffic parameters. The target processing parameters are parameters used to characterize the traffic features of the target packets. The traffic features are features that match the target traffic parameters. The target packet parameters include the target index parameters and the target processing parameters. The target detection template includes the target index template and the target processor template. The target detection configuration includes the target index and the target processor.

[0052] Optionally, in this embodiment, the method of generating the target index based on the target index template and the target index parameters may include, but is not limited to, modifying the corresponding parameters in the target index template using the target index parameters, or adding the target index parameters to the corresponding parameter positions at the end of the target index. This solution does not limit this.

[0053] Optionally, in this embodiment, the target operator can be generated according to the target operator template and the target operator parameter in the following manner, but is not limited thereto: modifying the related parameters in the target operator template using the target operator parameter, or inputting the target operator parameter into the corresponding parameter position in the target operator template, and the present solution does not limit the same.

[0054] Optionally, in this embodiment, the traffic characteristics can include, but are not limited to, the number of certain packets (such as the number of normally transmitted packets, the number of lost packets), the packet length, the byte number, the packet loss reason, and the like, and the present solution does not limit the same.

[0055] Optionally, in this embodiment, the operator template can include, but is not limited to, an adder, a subtractor, and a shifter, wherein the adder template is data=(data+arg), the subtractor template is data=(data-arg), and the shifter template is data=1<<arg, wherein data is the old statistical value, and arg is the target operator parameter. For packetCount calculation, the adder is used, and arg is a fixed value 1. For BytesCount calculation, the adder is used, and arg is the packet length packetLength. For recording the packet loss reason bitmap, the shifter is used, and arg is the packet loss reason.

[0056] As an optional embodiment, the target index is generated according to the target index template and the target index parameter, and the method comprises the following steps:

[0057] The target index parameter is added to the parameter position corresponding to the index parameter in the target index formula to obtain the target index, wherein the target index template comprises the target index formula, and the target index formula comprises an index shift rule for generating an index.

[0058] Optionally, in this embodiment, the index template can be in the following form: index=((data1&mask1)<<shift1)+((data2&mask2)>>shift2), wherein data1 and data2 are target index parameters, for example, an index is generated based on vlanId+cos, and the index=((vlanId&0xFFFF)<<3)+(cos&0x7).

[0059] In the embodiments of the present application, the index template is set, so that the index can be flexibly generated according to the detection request for detecting the traffic, avoiding the conventional manner of setting a fixed index, thereby improving the index capability of indexing the packet transmission port.

[0060] As an optional embodiment, the generating the target calculator according to the target calculator template and the target calculation parameter comprises:

[0061] adding the target calculation parameter into the parameter position corresponding to the calculation parameter in the target calculator template to obtain the target calculator.

[0062] In the embodiments of the present application, the calculator template is set, and then the detection requirement of detecting parameters of different flow characteristics can be flexibly generated according to the calculation parameter and the calculator template, which avoids configuring a fixed calculator for detection according to the request requirement in the related art, thereby improving the detection capability of the flow parameter.

[0063] As an optional embodiment, before the generating the target detection configuration according to the target message parameter and the target detection template, the method comprises:

[0064] determining whether the target detection request is in an enabled state on the network device according to the target message parameter;

[0065] in a case where the target detection request is in the enabled state, generating the target detection configuration according to the target message parameter and the target detection template.

[0066] Optionally, in the present embodiment, when the network device has a message with the target message parameter, it is determined that the target detection request is in the enabled state on the network device. For example, the target message parameter is vlanId, and when the network device has a port corresponding to the vlanId, the network device has corresponding message data in transmission, so that the detection request is in the enabled state on the network device.

[0067] Optionally, in the present embodiment, the determination of the enabled state of the target detection request on the network device according to the target message parameter can be, but is not limited to, detecting whether there is a message carrying the target message parameter on the network device, or when the message parameter is a parameter for representing a message transmission port, determining the enabled state of the target detection request on the network device by detecting whether there is a corresponding message transmission port on the network device, which is not limited in the present solution.

[0068] Optionally, in the present embodiment, before the generating the target detection configuration, the enabled state of the target detection request on the network device is detected, so as to optimize the detection process of the flow parameter. Therefore, in the detection engine, three functional modules can be, but are not limited to, divided according to functions, which are respectively used for judging the enabled state of the target detection request on the network device, generating the target index and generating the target calculator. Figure 6 is a schematic diagram of an optional detection engine module according to the embodiments of the present application, as Figure 6As shown, the detection engine is sequentially provided with an enabling detection module, an index generation module and an operator generation module. The enabling detection module selects one comparison object data from the flexible object container, and performs logical comparison between the comparison object and the comparison values A and B of DsStatsConfig, and logically forms the following conditions:

[0069] Condition 1: data>A, data>=A, data==A, data<A, data<=A, data! =A

[0070] Condition 2: data>B, data>=B, data==B, data<B, data<=B, data! =B

[0071] If condition 1 and condition 2 are met simultaneously, or one of them is met, the statistical enabling condition is met.

[0072] The index generation module selects two data from the flexible object container, and selects a target index module from DsStatsConfig, and performs operation to generate:

[0073] Index = ((data1&mask1)<<shift1)+((data2&mask2)>>shift2)

[0074] For example, an index is generated based on vlanId+cos:

[0075] Statistical index = ((vlanId&0xFFFF)<<3)+(cos&0x7)

[0076] The operator generation module selects a corresponding operator template according to the statistical requirement, and the operator template includes:

[0077] 1: adder data=(data+arg)

[0078] 2: subtractor data=(data-arg)

[0079] 3: shifter: data=1<<arg

[0080] Wherein data is the old statistical value, and arg is the new parameter value,

[0081] For packetCount calculation, the adder is used, and arg is a fixed value 1,

[0082] For BytesCount calculation, the adder is used, and arg is the packet length packetLength

[0083] For recording the reason bitmap of packet loss, a shifter is used, and arg is the reason of packet loss.

[0084] As an optional embodiment, the determining whether the target detection request is in the enabled state on the network device according to the target packet parameter comprises:

[0085] matching the target packet parameter and a packet transmission parameter on the network device according to target matching logic, to obtain a matching result, wherein the target matching logic is used to indicate a target numerical relationship between the target packet parameter and the packet transmission parameter, and the target matching logic is matching logic corresponding to the target detection request;

[0086] in a case where the matching result is used to represent that the numerical relationship between the target packet parameter and the packet transmission parameter is consistent with the target numerical relationship, it is determined that the target detection request is in the enabled state on the network device.

[0087] Optionally, in the embodiment, the target matching logic can include, but is not limited to, data>A, data>=A, data==A, data<A, data<=A, and data!=A, wherein date is the target packet parameter, and A is the packet transmission parameter.

[0088] Optionally, in the embodiment, according to different statistics requirements, the number of target matching logics can be set to be multiple, for example, vlanId+cos are counted, at this time, one matching logic is set to match the packet corresponding to vlanId, and another matching logic is set to match the packet corresponding to cos, at this time, at least one matching result in the two matching logics represents that the numerical relationship between the target packet parameter and the packet transmission parameter is consistent with the numerical relationship corresponding to the target matching logic, and then it can be determined that the target detection request is in the enabled state on the network device.

[0089] As an optional embodiment, the detecting the packet transmitted on the network device using the target detection configuration comprises:

[0090] using a target index to call a target transmission port of the target packet;

[0091] using a target operator to count the packet transmitted in the target transmission port, wherein the target detection configuration comprises the target index and the target operator.

[0092] Figure 7 is a flow parameter detection schematic diagram according to an embodiment of the present application, as Figure 7As shown, in this embodiment, the packet loss detection request is based on vlan+cos packet number and packet loss reason, which can be decomposed into 1. Statistic enabling condition: only for packet loss packets; 2. Statistic Memory index: vlanId[11:0]<<3+cos[2:0]; 3. Statistic calculation: 1) adder data = data + 1, 2) shifter data |= 1 << discardType (packet loss reason), and the processing flow is as follows:

[0093] 1. After the packet enters the chip, the packet is parsed first to analyze the characteristics of the packet, such as parsing the vlanId and vlanCos of the packet;

[0094] 2. Use vlan to read vlan table item to obtain statsPtr and statsCfgId from the vlan table item;

[0095] 3. The packet is processed by the flexible statistics engine at the end of the IPE (ingress process engine);

[0096] 4. Read the stats configuration information of DsStatsConfig through statsCfgId, and the configuration information includes:

[0097] a) Select index calculation parameters from the information container: in the example, statsPtr and cos are selected from the container

[0098] b) Select the enabling parameter from the information container: whether the packet is discarded isPacketDiscard

[0099] c) Select the statistical calculation parameter from the information container: packetDiscardType

[0100] d) Statistic operation ALU operation code, using two operators, A adder and B shifter

[0101] 5. Statistic enabling condition operator: use logical equality operation if (arg == value) arg is isPacketDiscard and value is a fixed value 1;

[0102] 6. Index operation: the index calculation formula of statistics,

[0103] Index = ((data1 & mask1) << shift1) + ((data2 & mask2) >> shift2)

[0104] Example statistical index = ((statsPtr & 0xFFFF) « 3) + ((cos & 0x7) » 0)

[0105] 7. Statistics ALU operations:

[0106] A) PacketCout accumulation, adder data = data + 1

[0107] B) Discard reason, shifter data | = 1 « discardType (discard reason).

[0108] Those skilled in the art can clearly understand that the method according to the above-mentioned embodiments can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a plurality of instructions for making a terminal device (which can be a mobile phone, computer, server, or network device, etc.) execute the method of each embodiment of the present application.

[0109] Figure 8 is a structural block diagram of a packet flow detection device according to an embodiment of the present application; as shown in the figure, it includes: a receiving module 82, configured to receive a target detection request, wherein the target detection request is used to request detection of a target traffic parameter of a target packet with a target packet characteristic transmitted by a network device; Figure 8

[0110] A first determining module 84, configured to determine the target packet parameter of the target packet from a reference packet parameter, and determine a target detection template used to detect the target traffic parameter from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet characteristic of a to-be-detected packet, and the reference detection template records a detection process of detecting a reference traffic parameter of a packet;

[0111] A first generating module 86, configured to generate a target detection configuration according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target traffic parameter of the target packet with the target packet characteristic;

[0112] A detection module 88, configured to detect a packet transmitted by the network device by using the target detection configuration.

[0113] ​Through the above embodiments, the reference message parameters for characterizing the message features of the to-be-detected message are set, and the reference detection template recording the detection process of the reference traffic parameters of the message is set, and then when it is necessary to detect the target traffic parameters of the target message with the target message feature transmitted by the network device, the target message parameters of the target message are determined from the reference message parameters, and the target detection template for detecting the target traffic parameters is determined from the reference detection template, so as to generate the target detection configuration recording the detection process of the target traffic parameters of the target message with the target message feature according to the target message parameters and the target detection template, that is, the target detection configuration in the present application is generated according to the selected target message parameters and the target detection template, thereby automatically generating the detection configuration according to the received detection request, effectively improving the traffic detection performance of the chip, and enabling the chip to support more detection requirements instead of only supporting fixed detection requirements. By adopting the above technical scheme, the problems such as low detection performance of message traffic in the related art are solved, and the technical effect of improving the detection performance of message traffic is achieved.

[0114] Optionally, the first generation module comprises: a first generation unit, configured to generate a target index according to a target index template and a target index parameter, wherein the target index template records an index process for indexing a transmission port of a message, and the target index parameter is a parameter for characterizing a message type of the target message; and a second generation unit, configured to generate a target operator according to a target operator template and a target operation parameter, wherein the target operator template records a statistical logic for statistics of the target traffic parameter, and the target operation parameter is a parameter for characterizing a traffic feature of the target message, the traffic feature is a feature matched with the target traffic parameter, the target message parameter comprises the target index parameter and the target operation parameter, the target detection template comprises the target index template and the target operator template, and the target detection configuration comprises the target index and the target operator.

[0115] Optionally, the first generation unit is configured to: add the target index parameter to a parameter position corresponding to an index parameter in a target index formula to obtain the target index, wherein the target index template comprises the target index formula, and the target index formula comprises an index shift rule for generating an index.

[0116] Optionally, the second generation unit is configured to: add the target operation parameter to a parameter position corresponding to an operation parameter in the target operator template to obtain the target operator.

[0117] Optionally, the apparatus comprises a second determining module configured to determine whether the target detection request is in an enabled state on the network device according to the target packet parameter before the target detection configuration is generated according to the target packet parameter and the target detection template; and a second generating module configured to generate the target detection configuration according to the target packet parameter and the target detection template if the target detection request is in the enabled state.

[0118] Optionally, the second determining module comprises a matching unit configured to match the target packet parameter with a packet transmission parameter on the network device according to a target matching logic to obtain a matching result, wherein the target matching logic is used to indicate a target numerical relationship between the target packet parameter and the packet transmission parameter, and the target matching logic corresponds to the target detection request; and a determining unit configured to determine that the target detection request is in the enabled state on the network device if the matching result indicates that the numerical relationship between the target packet parameter and the packet transmission parameter is consistent with the target numerical relationship.

[0119] Optionally, the detecting module comprises a calling unit configured to call a target transmission port of the target packet using a target index; and a counting unit configured to count packets transmitted in the target transmission port using a target calculator, wherein the target detection configuration comprises the target index and the target calculator.

[0120] Embodiments of the present application also provide a storage medium comprising a stored program, wherein the program performs any of the above packet flow detection methods when executed.

[0121] Optionally, in the present embodiment, the storage medium can be configured to store program code for performing the following steps: receiving a target detection request, wherein the target detection request is used to request detection of a target flow parameter of a target packet with a target packet characteristic transmitted on a network device; determining a target packet parameter of the target packet from a reference packet parameter, and determining a target detection template for detecting the target flow parameter from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet characteristic of a to-be-detected packet, and the reference detection template records a detection process for detecting a reference flow parameter of a packet; generating a target detection configuration according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process for detecting the target flow parameter of the target packet with the target packet characteristic; and detecting a packet transmitted on the network device using the target detection configuration.

[0122] The embodiment of the present application further provides an electronic device comprising a memory and a processor, the memory storing a computer program, and the processor is configured to execute the computer program to perform the steps in any of the packet flow detection method embodiments.

[0123] Optionally, the electronic device can further comprise a transmission device connected with the processor and an input and output device connected with the processor.

[0124] Optionally, in the embodiment, the processor can be configured to execute the following steps by the computer program: receiving a target detection request, wherein the target detection request is used to request detection of a target flow parameter of a target packet transmitted by a network device, and determining the target flow parameter of the target packet from a reference packet parameter and determining a target detection template used to detect the target flow parameter from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet feature of a packet to be detected, and the reference detection template records a detection process of detecting a reference flow parameter of a packet; generating a target detection configuration according to the target flow parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target flow parameter of the target packet with the target packet feature; and detecting the packet transmitted by the network device by using the target detection configuration.

[0125] Optionally, in the embodiment, the storage medium can include but is not limited to a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk and various storage program codes.

[0126] Optionally, specific examples in the embodiment can refer to the examples described in the above embodiments and optional implementation manners, and the embodiment will not be described here.

[0127] Obviously, those skilled in the art should understand that the above-mentioned modules or steps of the present application can be realized by a general computing device, which can be concentrated on a single computing device or distributed on a network composed of multiple computing devices, and optionally, they can be realized by program codes executable by a computing device, so that they can be stored in a storage device and executed by a computing device, and in some cases, the steps shown or described can be executed in different order, or they can be manufactured into individual integrated circuit modules, or multiple modules or steps can be manufactured into a single integrated circuit module. Thus, the present application is not limited to any specific hardware and software combination.

[0128] The above merely preferred embodiments of the present application, it should be noted that for those of ordinary skill in the art, without departing from the principles of the present application, can also make a number of improvements and refinements, these improvements and refinements should also be considered as the scope of protection of the present application.

Claims

1. A method for detecting packet traffic, the method comprising: The method comprises the following steps: receiving a target detection request, wherein the target detection request is used for requesting to detect a target traffic parameter of a target packet with a target packet characteristic transmitted by a network device; determining the target packet parameter of the target packet from a reference packet parameter and determining a target detection template used for detecting the target traffic parameter from a reference detection template, wherein the reference packet parameter is a parameter used for characterizing a packet characteristic of a packet to be detected, and the reference detection template records a detection process of detecting a reference traffic parameter of a packet; generating a target detection configuration according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target traffic parameter of the target packet with the target packet characteristic; detecting a packet transmitted by the network device using the target detection configuration.

2. The method of claim 1, wherein, The step of generating the target detection configuration according to the target packet parameter and the target detection template comprises the following steps: generating a target index according to a target index template and a target index parameter, wherein the target index template records an index process used for indexing a transmission port of a packet, and the target index parameter is a parameter used for characterizing a packet type of the target packet; generating a target calculator according to a target calculator template and a target calculation parameter, wherein the target calculator template records a statistical logic used for counting the target traffic parameter, the target calculation parameter is a parameter used for characterizing a traffic characteristic of the target packet, the traffic characteristic is a characteristic matched with the target traffic parameter, the target packet parameter comprises the target index parameter and the target calculation parameter, the target detection template comprises the target index template and the target calculator template, and the target detection configuration comprises the target index and the target calculator.

3. The method of claim 2, wherein, The step of generating the target index according to the target index template and the target index parameter comprises the following steps: adding the target index parameter to a parameter position corresponding to the index parameter in a target index formula to obtain the target index, wherein the target index template comprises the target index formula, and the target index formula comprises an index shift rule of generating an index.

4. The method of claim 2, wherein, The step of generating the target calculator according to the target calculator template and the target calculation parameter comprises the following steps: adding the target calculation parameter to a parameter position corresponding to the calculation parameter in the target calculator template to obtain the target calculator.

5. The method of claim 1, wherein, Before the step of generating the target detection configuration according to the target packet parameter and the target detection template, the method comprises the following steps: determining whether the target detection request is in an enabled state on the network device according to the target packet parameter; generating the target detection configuration according to the target packet parameter and the target detection template in a case that the target detection request is in the enabled state.

6. The method of claim 5, wherein, The step of determining whether the target detection request is in the enabled state on the network device according to the target packet parameter comprises the following steps: match the target packet parameter and the packet transmission parameter on the network device according to target matching logic, to obtain a matching result, wherein the target matching logic is used to indicate a target numerical relationship between the target packet parameter and the packet transmission parameter, and the target matching logic is matching logic corresponding to the target detection request; in a case where the matching result is used to represent that a numerical relationship between the target packet parameter and the packet transmission parameter is consistent with the target numerical relationship, it is determined that the target detection request is in an enabled state on the network device.

7. The method of claim 1, wherein, the detection of the packet transmitted on the network device using the target detection configuration comprises: using a target index to call a target transmission port of the target packet; using a target operator to count the packet transmitted in the target transmission port, wherein the target detection configuration comprises the target index and the target operator.

8. A packet flow detection apparatus, characterized by comprising: comprise: a receiving module configured to receive a target detection request, wherein the target detection request is used to request detection of a target traffic parameter of a target packet with a target packet characteristic transmitted on a network device; a first determining module configured to determine a target packet parameter of the target packet from a reference packet parameter, and determine a target detection template used to detect the target traffic parameter from a reference detection template, wherein the reference packet parameter is a parameter used to represent a packet characteristic of a to-be-detected packet, and the reference detection template records a detection process of detecting a reference traffic parameter of a packet; a first generating module configured to generate a target detection configuration according to the target packet parameter and the target detection template, wherein the target detection configuration records a detection process of detecting the target traffic parameter of the target packet with the target packet characteristic; a detecting module configured to detect a packet transmitted on the network device using the target detection configuration.

9. A computer readable storage medium, characterized in that, the computer-readable storage medium comprises a stored program, wherein the program is executed to perform the method in any one of claims 1 to 7. 10.An electronic device comprising a memory and a processor, the electronic device characterized by, the memory stores a computer program, and the processor is configured to execute the method in any one of claims 1 to 7 by using the computer program. the memory stores a computer program, and the processor is configured to execute the method in any one of claims 1 to 7 by using the computer program.

Citation Information

Patent Citations

  • Link detection method and device, electronic equipment and storage medium

    CN114629822A

  • Multicast route searching method and device, storage medium and electronic device

    CN116095001A