A data packet generation method, switch test method and device
By grouping the flow table entries of OpenFlow switches and generating target data packets, the problem of low efficiency in switch testing is solved, and automated batch processing and improved accuracy are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 深圳市万里眼技术有限公司
- Filing Date
- 2026-02-11
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies for testing OpenFlow switches are inefficient, requiring manual searching of flow table entries and manual editing of data packets, resulting in low testing efficiency.
The flow table entries are grouped according to the switch number and the switch output port number to generate target data packets. The flow table entries are processed in batches automatically to improve testing efficiency.
By generating data packets through flow table entries, test preparation time is reduced, the efficiency and accuracy of switch testing are improved, and manual intervention is reduced.
Smart Images

Figure CN121728004B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data communication technology, and in particular to a data message generation method, a switch testing method and apparatus. Background Technology
[0002] In the field of data communication testers, OpenFlow is a network communication protocol primarily used for communication between OpenFlow controllers and OpenFlow switches in software-defined network architectures. After an OpenFlow controller simulation tester configures flow tables for an OpenFlow switch, it is generally necessary to verify whether the OpenFlow switch correctly forwards data flows according to the flow table. The verification method involves constructing a data flow that matches the flow table entries and injecting it into the OpenFlow switch, then observing whether the OpenFlow switch forwards the data flow to the corresponding port according to the flow table entries. Currently, this is typically done manually by finding each flow table entry related to the output port of the switch under test, and then manually editing the data packets for testing, resulting in very low testing efficiency for OpenFlow switches.
[0003] Therefore, improving testing efficiency is a problem that needs to be solved in this field. Summary of the Invention
[0004] This application discloses a data packet generation method, a switch testing method, and an apparatus to solve the problem of low efficiency in switch testing.
[0005] In a first aspect, this application provides a data packet generation method applied to a data communication tester, comprising: grouping multiple flow table entries according to a switch number and a switch outgoing port number to obtain multiple flow table groups; wherein, at least one of the switch number and the switch outgoing port number of multiple flow table entries belonging to different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries belonging to the same flow table group are all the same; each flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, the multiple forwarding rule fields being used to define the forwarding rules of the switch; obtaining one or more target data packets based on one or more flow table entries in a target flow table group; the target flow table group is one of the multiple flow table groups, each target data packet being used to test whether the outgoing port of the switch under test corresponding to the switch number and the switch outgoing port number of the target flow table group is normal, and each target data packet including multiple field values corresponding to the multiple forwarding rule fields in its corresponding flow table entry.
[0006] This application can group flow table entries according to the switch number and the switch output port number. For the output port of the switch, data packets for testing can be obtained automatically in batches. Compared with the method of manually searching for flow table entries one by one, this significantly improves the processing efficiency of data packets. In addition, compared with testing one by one according to the disordered flow table entries and repeatedly switching test objects between multiple switches under test or multiple output ports of the same switch under test, this application can reduce the test preparation time of data communication tester and switch under test by grouping flow table entries, and improve the overall testing efficiency of the switch.
[0007] In one possible implementation, before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: identifying the switch number and switch outgoing port number of the switch under test currently connected to the data communication tester; and determining the target flow table group from the plurality of flow table groups based on the switch number and switch outgoing port number of the switch under test currently connected to the data communication tester.
[0008] In this embodiment, the data communication tester can automatically determine the target flow table group from multiple flow table groups by identifying the switch number and the switch output port number of the currently connected switch under test, thereby reducing manual intervention by relevant personnel and improving efficiency.
[0009] In one possible implementation, before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: determining a target flow table group from a plurality of said flow table groups according to the obtained target flow table group selection instruction.
[0010] In this implementation, relevant personnel can actively participate in selecting the target flow table group corresponding to the current switch under test from multiple flow table groups, ensuring the consistency between the target flow table group and the switch under test, and improving the accuracy of the test.
[0011] In one possible implementation, the step of grouping multiple flow table entries based on switch number and switch outgoing port number includes: configuring a first grouping label for each of the multiple flow table entries based on the switch number and switch outgoing port number; the first grouping label includes a switch number and a corresponding switch outgoing port number; and grouping the multiple flow table entries based on the first grouping label.
[0012] In this embodiment, each flow table entry is configured with a corresponding first grouping tag, and multiple flow table entries are grouped based on the first grouping tag. This can optimize the accuracy and efficiency of the data communication tester in the flow table entry grouping process.
[0013] In one possible implementation, before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: determining a target flow table group from multiple flow table groups based on a second packet label corresponding to the switch under test and the matching relationship between the first packet label and the second packet label; the second packet label includes a switch number and a corresponding switch outgoing port number.
[0014] In this embodiment, the switch under test corresponds to the second packet label. By matching the first packet label with the second packet label, the target flow table group can be determined from multiple flow table groups. In this way, the data communication tester can automatically match the second packet label of the switch under test with the first packet label of multiple flow table groups, reducing manual intervention by relevant personnel and improving efficiency.
[0015] In one possible implementation, obtaining one or more target data packets based on one or more flow table entries in the target flow table group includes: generating one or more default data packets according to a pre-configured default packet template; modifying one or more of the default data packets based on the forwarding rule fields and corresponding field values in one or more flow table entries in the target flow table group to obtain one or more target data packets.
[0016] In this embodiment, the data packet generation method is pre-configured, and then the generated default data packet is modified using the forwarding rule field and field value in the target flow table group to obtain the target data packet used for switch testing. This reduces the manual involvement of relevant personnel and improves efficiency.
[0017] Secondly, this application provides a switch testing method applied to a data communication tester, comprising: sending one or more target data packets to a corresponding switch under test; the target data packets being data packets obtained by the data packet generation method described above; acquiring one or more data packets to be verified forwarded by the switch under test through a target output port; the target output port being a switch output port corresponding to the target data packets; and verifying the data packets to be verified based on the target data packets to obtain a data communication test result corresponding to the target output port.
[0018] In this application, the data communication tester can use the target data packet obtained by the above data packet generation method to perform communication testing on the switch under test, and obtain the data packet to be verified forwarded by the target outgoing port of the switch under test. By verifying the target data packet and the data packet to be verified, the data communication test result corresponding to the switch under test can be obtained. In this way, by using the target data packet obtained by the above data packet generation method to perform communication testing on the switch under test, the manual participation of relevant personnel is reduced and the testing efficiency is improved.
[0019] In one possible implementation, verifying the data packet to be verified based on the target data packet includes: verifying whether the number of the target data packets is equal to the number of the data packets to be verified.
[0020] In this embodiment, the data of the data packets to be verified and the target data packets forwarded by the switch under test are verified to verify whether the switch under test is forwarding data normally, thus ensuring the accuracy of the switch test.
[0021] In one possible implementation, the method further includes: after obtaining the data communication test result corresponding to the target output port, determining another output port of the switch under test as the next output port to be tested, or determining one output port of another switch under test as the next output port to be tested; and performing data communication test on the next output port to be tested using a target data packet with the same switch number and switch output port number as the next output port to be tested.
[0022] In this embodiment, after the test of one target output port of the switch under test is completed, the next output port to be tested can be directly determined, which is another output port of the switch under test or an output port of another switch under test. The target data packet corresponding to the next output port to be tested is used to perform data communication test. This reduces the manual involvement of relevant personnel in the switch testing process. The data communication test of the switch under test is carried out by using the target data packet through the data communication tester, which optimizes the test efficiency and test accuracy.
[0023] Thirdly, this application provides a data message generation apparatus for use in a data communication tester, comprising:
[0024] The grouping module is used to group multiple flow table entries according to the switch number and the switch outgoing port number to obtain multiple flow table groups; wherein, at least one of the switch number and the switch outgoing port number of multiple flow table entries belonging to different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries belonging to the same flow table group are all the same; the flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, and the multiple forwarding rule fields are used to define the forwarding rules of the switch.
[0025] The data packet generation module is used to obtain one or more target data packets based on one or more flow table entries in the target flow table group; the target flow table group is one of the multiple flow table groups, each target data packet is used to test whether the outgoing port of the switch to be tested corresponding to the switch number and switch outgoing port number of the target flow table group is normal, and each target data packet includes multiple field values corresponding to multiple forwarding rule fields in its corresponding flow table entry.
[0026] Fourthly, this application provides a switch testing device, applied to a data communication tester, comprising:
[0027] A data packet sending module is used to send one or more target data packets to the corresponding switch under test; the target data packets are data packets obtained by the data packet generation device described above.
[0028] The data packet acquisition module is used to acquire one or more data packets to be verified forwarded by the switch under test through the target outgoing port; the target outgoing port is the switch outgoing port corresponding to the target data packet.
[0029] The data packet verification module is used to verify the data packet to be verified based on the target data packet, and obtain the data communication test result corresponding to the target output port.
[0030] Fifthly, this application provides a data communication tester, comprising:
[0031] Memory, used to store computer programs;
[0032] A processor for executing the computer program to implement the method as described above.
[0033] In one possible implementation, the processor is a hardware processor used to read the computer program.
[0034] Sixthly, this application provides a switch for connecting a data communication tester, wherein the data communication tester is as described above.
[0035] In a seventh aspect, this application provides a computer-readable storage medium for storing a computer program that, when executed by a processor, implements the method described above.
[0036] Eighthly, this application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the method described above.
[0037] Therefore, this application first groups multiple flow table entries according to the switch number and the switch outgoing port number to obtain multiple flow table groups; wherein, at least one of the switch number and the switch outgoing port number of multiple flow table entries belonging to different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries belonging to the same flow table group are all the same; each flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, and the multiple forwarding rule fields are used to define the forwarding rules of the switch; then, one or more target data packets are obtained based on one or more flow table entries in the target flow table group; the target flow table group is one of the multiple flow table groups, and each target data packet is used to test whether the outgoing port of the switch under test corresponding to the switch number and the switch outgoing port number of the target flow table group is normal, and each target data packet includes multiple field values corresponding to the multiple forwarding rule fields in its corresponding flow table entry. In this way, this application can group flow table entries according to the switch number and the switch output port number, and can automatically obtain data packets for testing in batches for the output ports of the switch, which significantly improves the data packet processing efficiency. Compared with testing one by one according to the disordered flow table entries, and repeatedly switching test objects between multiple switches under test or multiple output ports of the same switch under test, this application can reduce the test preparation time of the data communication tester and the switch under test by grouping flow table entries, and can improve the overall test efficiency of the switch. Attached Figure Description
[0038] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0039] Figure 1 A schematic diagram of a controller and switch network based on the OpenFlow communication protocol is provided for an embodiment of this application;
[0040] Figure 2 This application provides a schematic diagram of a switch test-related data flow.
[0041] Figure 3 A flowchart of a data packet generation method provided in an embodiment of this application;
[0042] Figure 4 A flowchart of a switch testing method provided in this application embodiment;
[0043] Figure 5 A schematic diagram of a switch testing system architecture provided in this application embodiment;
[0044] Figure 6 A schematic diagram of a data packet generation device provided in an embodiment of this application;
[0045] Figure 7 This is a schematic diagram of a switch testing device provided in an embodiment of this application. Detailed Implementation
[0046] OpenFlow is a network communication protocol widely used in data centers, cloud services, and other scenarios. An OpenFlow architecture typically includes OpenFlow switches and an OpenFlow controller. An OpenFlow switch is a network device that supports the OpenFlow protocol and is responsible for forwarding data at the data layer. OpenFlow switches can be physical switches / routers or virtualized switches / routers. The OpenFlow controller resides at the control layer and is responsible for managing and controlling the forwarding behavior of the OpenFlow switch through the OpenFlow protocol.
[0047] OpenFlow switches forward data flows based on matching flow tables. By default, the flow table is empty, and data flows cannot be forwarded. After the OpenFlow controller configures flow tables for the OpenFlow switches via the OpenFlow protocol, the OpenFlow switches can forward data flows by looking up the flow tables. A flow table contains multiple flow table entries, each including matching conditions and actions, used to define the switch's data forwarding rules. The matching conditions include information such as SMAC (Source MAC), DMAC (Destination MAC), SIP (Source Network Address), DIP (Destination Network Address), Protocol Type, and L4 Port. The action is to forward the data to a specific outgoing port. When an OpenFlow switch receives a data packet, it iterates through the flow table entries, retrieves the matching conditions from each entry, and matches them against the corresponding fields in the data packet. If a match is found, the switch retrieves the action from the flow table entry and forwards the packet according to the action. If the flow table entry does not match, it moves on to the next flow table entry for matching. If none of the flow table entries match, the packet is discarded.
[0048] Understandably, after the OpenFlow controller simulation tester configures flow tables for the OpenFlow switch, it is generally necessary to verify whether the OpenFlow switch correctly forwards data flows according to the flow table. The verification method is to construct a data flow that matches the flow table entries and inject it into the OpenFlow switch, then observe whether the OpenFlow switch forwards the data flow to the corresponding port according to the actions of the flow table entries. For example... Figure 1 As shown, the output port 3 of the controller based on the OpenFlow communication protocol is connected to the switch based on the OpenFlow communication protocol to send control-related data (i.e., the flow table sent to the OpenFlow switch).
[0049] Furthermore, in the field of data communication testers, the flow table entries configured in commonly used data communication testers are often disorganized and without rules. For example, the first flow table entry might involve output port 'a' of switch A, the next flow table entry might involve output port 'b' of switch B, and the following flow table entry might involve output port 'c' of switch A. Therefore, it is necessary to manually find each flow table entry related to the output port of the switch under test, and then manually edit the data packets one by one, resulting in low testing efficiency. Figure 2 As shown, the controller, based on the OpenFlow communication protocol, acts as a tester, connecting to port 1 of the switch under test via outgoing port 3 (address 10.10.10.10) and port 2 via outgoing port 4 (address 10.10.10.11). The tester sends control-related flow table data to the switch via outgoing port 3, configuring the switch's flow tables (control data flow stream1: sip 10.10.10.10, dip 2.2.2.2, udp port (User Datagram Protocol port) 5555; control data flow stream2: sip 3.3.3.3 dip 10.10.10.11). The tester can then use the communication path with the switch to send test packets and verify the data packets forwarded by the switch's outgoing port 2 (forwarding rule flow1: dip 2.2.2.2, udp port 5555, out port2; forwarding rule flow2: sip 3.3.3.3, udp...). Are port 5555 and out port 2 functioning correctly?
[0050] To address the above issues, this application provides a data packet generation method. This method groups flow table entries based on the switch number and the switch's output port number, enabling automated batch generation of test data packets for each switch's output port. Compared to manually searching for flow table entries one by one, this significantly improves data packet processing efficiency. Furthermore, compared to testing flow table entries sequentially in a disordered order, repeatedly switching between multiple switches under test or multiple output ports of the same switch under test, this application reduces the test preparation time for the data communication tester and the switch under test through flow table entry grouping, thereby improving the overall testing efficiency of the switch. The technical solution of this application will be described below with reference to specific embodiments.
[0051] Example 1
[0052] like Figure 3 As shown, this embodiment discloses a data packet generation method, applied to a data communication tester, including:
[0053] Step S11: Group multiple flow table entries according to the switch number and the switch outgoing port number to obtain multiple flow table groups; wherein, at least one of the switch number and the switch outgoing port number of multiple flow table entries belonging to different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries belonging to the same flow table group are the same; a flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, and the multiple forwarding rule fields are used to define the forwarding rules of the switch. For example, the forwarding rule fields may include one or more of matching conditions, matching values, and actions. In this embodiment, the data communication tester can group all configured flow table entries, specifically by grouping multiple flow table entries according to the switch number and the switch outgoing port number corresponding to the flow table entries to obtain multiple flow table groups; it is understood that at least one of the switch number and the switch outgoing port number corresponding to multiple flow table entries in different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries corresponding to the same flow table group are the same. In this way, the data communication tester can manage multiple configured flow table entries in a unified group, using the switch number and the switch's outgoing port number as grouping criteria to obtain multiple flow table groups. Thus, each flow table entry in the flow table group managed by the tester corresponds to the same outgoing port number of the same switch number, allowing direct communication testing of the switch under test using the flow table entries in the corresponding flow table group. It should be noted that these flow table entries include multiple forwarding rule fields that define the data forwarding rules of the switch, as well as the corresponding field values for each forwarding rule field. These values are used to modify data packets to obtain test data packets used to test whether the switch's outgoing port is functioning correctly, i.e., the target data packets.
[0054] In one possible implementation, multiple flow table entries are grouped based on switch ID and switch outgoing port ID, including: configuring a first grouping label for each flow table entry based on the switch ID and switch outgoing port ID; the first grouping label includes a switch ID and a corresponding switch outgoing port ID; and grouping the multiple flow table entries based on the first grouping label. Specifically, during the grouping process, a grouping label, denoted as the first grouping label, can be configured for each flow table entry; this grouping label includes a switch ID and a corresponding switch outgoing port ID; by configuring the grouping label in this way, each flow table entry can be grouped; each flow table entry in the resulting flow table group corresponds to the same first grouping label; this optimizes the accuracy and efficiency of the data communication tester in the flow table entry grouping process. For example, if the first grouping label includes the switch ID switch1 and the corresponding switch outgoing port ID port1, then each flow table entry in the relevant flow table group corresponds to switch1 and port1.
[0055] In another possible implementation, before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: determining the target flow table group from multiple flow table groups based on the second packet label corresponding to the switch under test and the matching relationship between the first packet label and the second packet label. Specifically, the second packet label corresponding to the switch under test can be configured based on the switch number and its corresponding outgoing port numbers; it can be understood that the second packet label here corresponds to a switch number and a switch outgoing port number. Then, based on the matching relationship between the second packet label and the first packet label, a target flow table group corresponding to the switch under test can be determined from multiple flow table groups. In this way, the data communication tester can automatically determine the target flow table group corresponding to the switch under test based on the first packet label corresponding to the flow table group and the second packet label corresponding to the switch under test. This reduces manual intervention by relevant personnel and improves the efficiency of data communication testing. For example, if the switch to be tested is numbered switch1 and its outgoing ports are port1 and port2, then the second group label includes two types: one is switch1 and port1, and the other is switch1 and port2. In this case, communication testing needs to be performed on port1 of switch1. Therefore, a flow table group matching switch1 and port1 is determined from the first group label corresponding to each flow table group; this is the target flow table group. In a specific embodiment, the flow table entry number of multiple flow table entries, their corresponding switch number, and their corresponding switch outgoing port number are shown in Table 1 below.
[0056] Table 1 Flow Table Details
[0057]
[0058] In a specific embodiment, the flow table groups and corresponding flow table entries after grouping each flow table entry according to the grouping label are shown in Table 2 below.
[0059] Table 2 Flow table grouping information
[0060]
[0061] Step S12: Obtain one or more target data packets based on one or more flow table entries in the target flow table group; the target flow table group is one of multiple flow table groups, and each target data packet is used to test whether the outgoing port of the switch to be tested corresponding to the switch number and switch outgoing port number of the target flow table group is normal. Each target data packet includes multiple field values corresponding to multiple forwarding rule fields in its corresponding flow table entry.
[0062] In this embodiment, as shown in the above steps, the data communication tester can group flow table entries into multiple flow table groups based on the switch number and the switch's output port number. Furthermore, before performing communication testing on the switch under test, it is necessary to determine one or more target data packets in the target flow table group corresponding to the switch under test from among the multiple flow table groups. This allows the target data packets to be used to perform data communication testing on the switch under test corresponding to the switch number and output port number of the target flow table group, verifying whether the output port of the switch under test corresponding to the output port number is functioning correctly. It should be noted that the target data packet includes field values corresponding to the forwarding rule fields. These field values are the field values of the flow table entries in the target flow table group. The target data packet can be used to perform data communication testing on the switch under test. In a specific embodiment, the data packet can be a standard Ethernet packet, containing: a MAC (physical address) header, an IP (Internet Protocol) header, and TCP / UDP (Transmission Control Protocol / User Datagram Protocol) headers, etc.
[0063] In one possible implementation, before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: identifying the switch number and port number of the switch under test currently connected to the data communication tester; and determining the target flow table group from multiple flow table groups based on the switch number and port number of the switch under test currently connected to the data communication tester. Specifically, the data communication tester can directly identify the switch number and port number of the switch under test currently connected to the data communication tester, and automatically determine the target flow table group from multiple flow table groups, reducing manual intervention by relevant personnel and improving efficiency. For example, if the switch number of the switch under test currently connected to the data communication tester is switch1 and the connected port number is port2, then the flow table group corresponding to switch1 and port2 from multiple flow table groups can be determined as the target flow table group.
[0064] In one possible implementation, before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the process may further include: determining the target flow table group from multiple flow table groups according to an acquired target flow table group selection instruction. Specifically, the data communication tester can obtain the target flow table group selection instruction issued by relevant personnel, meaning that relevant personnel can view the grouped flow table groups and select one as the target flow table group for data communication testing of the switch under test. In this way, relevant personnel can actively participate in selecting the target flow table group corresponding to the current switch under test from multiple flow table groups, ensuring the consistency between the target flow table group and the switch under test.
[0065] In another possible implementation, obtaining one or more target data packets based on one or more flow table entries in the target flow table group may include: generating one or more default data packets according to a pre-configured default packet template; and modifying one or more default data packets based on the forwarding rule fields and corresponding field values in one or more flow table entries in the target flow table group to obtain the corresponding one or more target data packets. Specifically, in the process of obtaining target data packets for data communication testing of the switch under test based on flow table entries in the target flow table group, one or more default data packets can first be generated according to a pre-configured default packet template, and then the generated default data packets can be modified using the forwarding rule fields and corresponding field values of the flow table entries in the target flow table group. For example, the forwarding rule fields of the current flow table entry in the target flow table group can be matched sequentially with the default data packets, and the corresponding fields of the default data packets can be modified using the field values of the forwarding rule fields in the current flow table entry to obtain the target data packets. In specific embodiments, the flow table entry matching conditions can be defined by the OpenFlow protocol, including: SMAC, DMAC, SIP, DIP, Protocol Type, L4 Port, and other information. In the process of modifying the default data packet to obtain the target data packet, firstly, one flow table entry from the target flow table group is obtained. The matching condition (i.e., forwarding rule condition) and matching value (field value) of this flow table entry are extracted. The location of the matching condition is found in the default data packet, and the content at that location is replaced with the matching value. The modified packet is the target data packet required for testing. The above operation is repeated to generate a data packet for each flow table entry. The generated default data packets are shown in Table 3 below.
[0066] Table 3 Default Data Message
[0067]
[0068] Therefore, this application can group flow table entries according to the switch number and the switch output port number. For the output port of the switch, data packets for testing can be obtained automatically in batches. Compared with the method of manually searching for flow table entries one by one, this significantly improves the processing efficiency of data packets. In addition, compared with testing one by one according to the disordered flow table entries and repeatedly switching test objects between multiple switches under test or multiple output ports of the same switch under test, this application can reduce the test preparation time of data communication tester and switch under test by grouping flow table entries, and eliminate the need to manually edit data packet content, making the operation simple and improving the overall testing efficiency of the switch.
[0069] Example 2
[0070] Based on the above embodiments, it can be seen that the data communication tester can group data packets according to the switch number and switch output port number corresponding to each flow table entry, and determine the target data packets that can be used for data communication testing of the switch under test based on the grouped flow table groups; furthermore, such as Figure 4 As shown, this embodiment provides a switch testing method applied to a data communication tester. It can utilize the target data packets corresponding to the aforementioned flow table groups to perform data communication tests on the switch under test. Specifically, it includes:
[0071] Step S21: Send one or more target data packets to the corresponding switch under test; the target data packets are data packets obtained by the data packet generation method described above.
[0072] Understandably, the target data packet obtained through the above data packet generation method corresponds to a switch number and a switch output port number, and this switch number and switch output port number correspond to the switch under test; then the data communication tester can send the target data packet to the switch under test to test whether the corresponding output port is normal.
[0073] Step S22: Obtain one or more data packets to be verified forwarded by the switch under test through the target outgoing port; the target outgoing port is the switch outgoing port corresponding to the target data packet.
[0074] In this embodiment, after the data communication tester sends the target data packet to the switch under test, the switch under test can forward the target data packet according to the configured flow table entry, and forward the data packet through the corresponding outgoing port. Here, the outgoing port that forwards the data packet may be the outgoing port connected to the data communication tester (i.e., the outgoing port corresponding to the switch outgoing port number corresponding to the target data packet), or it may be other outgoing ports. At this time, the data communication tester can obtain one or more data packets forwarded by the switch under test from the target outgoing port connected to the switch under test, i.e., the data packets to be verified.
[0075] Step S23: Verify the data packet to be verified based on the target data packet to obtain the data communication test result corresponding to the target output port.
[0076] The data communication tester, through the steps described above, can acquire the data packets to be verified forwarded by the switch under test. It then verifies both the target data packets and the acquired data packets to obtain the data communication test results corresponding to the target outgoing port of the switch under test. Specifically, the verification process involves checking whether the number of target data packets sent by the data communication tester to the switch under test matches the number of data packets to be verified received from the switch. If the numbers match, it indicates that the switch under test can forward data normally according to the flow table entries. The entire testing process requires no manual intervention from personnel; the data communication tester uses the target data packets to perform the data communication test on the switch under test, optimizing testing efficiency and accuracy.
[0077] In one possible implementation, the method may further include: after obtaining the data communication test result corresponding to the target outgoing port, determining another outgoing port of the switch under test as the next outgoing port to be tested, or determining an outgoing port of another switch under test as the next outgoing port to be tested; and performing data communication testing on the next outgoing port to be tested using target data packets with the same switch number and switch outgoing port number as the next outgoing port to be tested. Specifically, after the current outgoing port test is completed, data communication testing can be performed on another outgoing port of the switch under test. At this time, the corresponding outgoing port is determined as the next outgoing port to be tested, and the target flow table group with the same switch outgoing port number and switch number can be directly determined from multiple flow table groups using the switch outgoing port number corresponding to the next outgoing port to be tested and the switch number of the switch under test. Then, the target data packets corresponding to the target flow table group are used to perform data communication testing on the next outgoing port to be tested. Correspondingly, if switching requires testing a switch, the switch ID of the other switch to be tested and the corresponding output port ID of the output port to be tested are needed. The flow table group that matches both the switch ID and the output port ID from multiple flow table groups is identified as the target flow table group. Then, the target data packets corresponding to this target flow table group can be used to perform data communication tests on the next output port of the next switch to be tested. For example, if the current switch to be tested has the switch ID "switch1" and the output port ID "port1", and the next switch to be tested has the switch ID "switch2" and the output port ID "port1", then the flow table group corresponding to "switch2" and "port1" can be directly identified as the target flow table group, and the target data packets corresponding to this target flow table group can be used to perform data communication tests on the next switch to be tested.
[0078] In another possible implementation, Figure 5The diagram shows the architecture of a switch testing system comprised of a tester and a switch based on the OpenFlow communication protocol. The OpenFlow tester configures OpenFlow flow tables for the OpenFlow switch and sends data streams to verify whether the OpenFlow switch can correctly forward data according to the configured flow tables. The OpenFlow tester has multiple Ethernet ports, one of which, port 3, is connected to the OpenFlow switch via fiber optic or network cable. This port is used to transmit control messages. Specifically, during control message transmission, the OpenFlow tester first establishes an OpenFlow connection with the OpenFlow switch, and then sends OpenFlow flow table configurations to the OpenFlow switch. The OpenFlow tester also uses two other ports, port 3 and port 4, which are also connected to ports 1 and 2 of the OpenFlow switch via fiber optic or network cable. One port is used to send data streams, and the other is used to receive data streams. By counting the number of sent and received data streams, the correctness of the OpenFlow switch's forwarding can be verified. It is understandable that the port used for control flow and the port used for sending data streams can be combined. Accordingly, the OpenFlow switch, which is the switch under test, contains multiple Ethernet ports, and its main function is to forward data packets between these ports. Specifically, when an Ethernet port of the OpenFlow switch receives a data packet, it checks the OpenFlow flow table to match the data packet content. If a match is found, the data packet is sent out from the output port specified in the action of the OpenFlow flow table.
[0079] Therefore, the data communication tester can use the target data packets obtained by the above data packet generation method to perform communication tests on the switch under test, and obtain the data packets to be verified forwarded by the target outgoing port of the switch under test. By verifying the target data packets and the data packets to be verified, the corresponding data communication test results of the switch under test can be obtained. In this way, by using the target data packets obtained by the above data packet generation method to perform communication tests on the switch under test, the manual involvement of relevant personnel is reduced and the testing efficiency is improved.
[0080] Example 3
[0081] like Figure 6 As shown, this embodiment discloses a data packet generation device, applied to a data communication tester, comprising:
[0082] Grouping module 11 is used to group multiple flow table entries according to the switch number and the switch outgoing port number to obtain multiple flow table groups; wherein, at least one of the switch number and the switch outgoing port number of multiple flow table entries belonging to different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries belonging to the same flow table group are the same; the flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, and the multiple forwarding rule fields are used to define the forwarding rules of the switch.
[0083] The data packet generation module 12 is used to obtain one or more target data packets based on one or more flow table entries in the target flow table group. The target flow table group is one of multiple flow table groups. Each target data packet is used to test whether the outgoing port of the switch under test corresponding to the switch number and switch outgoing port number of the target flow table group is normal. Each target data packet includes multiple field values corresponding to multiple forwarding rule fields in its corresponding flow table entry.
[0084] Therefore, this application can group flow table entries according to the switch number and the switch output port number, and can automatically obtain data packets for testing in batches for the output ports of the switch, which significantly improves the processing efficiency of data packets. Compared with testing one by one according to the disordered flow table entries, and repeatedly switching test objects between multiple switches under test or multiple output ports of the same switch under test, this application can reduce the test preparation time of the data communication tester and the switch under test by grouping flow table entries, and can improve the overall testing efficiency of the switch.
[0085] Correspondingly, such as Figure 7 As shown, this embodiment discloses a switch testing device, applied to a data communication tester, comprising:
[0086] The data packet sending module 21 is used to send one or more target data packets to the corresponding switch under test; the target data packets are data packets obtained by the data packet generation device described above.
[0087] Data packet acquisition module 22 is used to acquire one or more data packets to be verified forwarded by the switch under test through the target outgoing port; the target outgoing port is the switch outgoing port corresponding to the target data packet;
[0088] The data packet verification module 23 is used to verify the data packet to be verified based on the target data packet, and obtain the data communication test result corresponding to the target output port.
[0089] Therefore, the data communication tester can use the target data packets obtained by the above data packet generation method to perform communication tests on the switch under test, and obtain the data packets to be verified forwarded by the target outgoing port of the switch under test. By verifying the target data packets and the data packets to be verified, the corresponding data communication test results of the switch under test can be obtained. In this way, by using the target data packets obtained by the above data packet generation method to perform communication tests on the switch under test, the manual involvement of relevant personnel is reduced and the testing efficiency is improved.
[0090] Furthermore, this embodiment discloses a data communication tester, including:
[0091] Memory, used to store computer programs;
[0092] A processor is used to execute computer programs to implement the methods described above.
[0093] In one possible implementation, the processor is a hardware processor used to read computer programs. In specific embodiments, the processor can also be a software processor, such as a GPU (Graphics Processing Unit), a DSP (Digital Signal Processor), or a microcontroller.
[0094] Furthermore, this embodiment discloses a switch for connecting a data communication tester, which is the data communication tester described above.
[0095] Furthermore, this embodiment discloses a computer-readable storage medium for storing a computer program, which, when executed by a processor, implements the method described above.
[0096] Furthermore, this embodiment discloses a computer program product, including a computer program / instructions, which, when executed by a processor, implements the method described above.
[0097] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0098] Each of the above modules or units can be implemented through software, hardware, or a combination of both. In this application, "implemented through software" means that the processor reads and executes program instructions stored in memory to implement the functions corresponding to the above modules or units. Here, the processor refers to a processing circuit capable of executing program instructions, including but not limited to at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or an artificial intelligence processor, or other processing circuits capable of running program instructions. In other embodiments, the processor may also include circuits with other processing functions (such as hardware circuits for hardware acceleration, bus and interface circuits, etc.). Processors can be presented as integrated chips, for example, as integrated chips whose processing functions only include executing software instructions, or they can be presented as SoCs (system on a chip), that is, on a single chip, in addition to the processing circuits (usually called "cores") that can run program instructions, there are also other hardware circuits for implementing specific functions (of course, these hardware circuits can also be implemented separately based on ASICs or FPGAs). Correspondingly, in addition to executing software instructions, the processing functions can also include various hardware acceleration functions (such as AI calculations, encoding and decoding, compression and decompression, etc.).
[0099] In this application, "implemented in hardware" means that the functions of the above-mentioned modules or units are implemented through hardware processing circuits that do not have program instruction processing capabilities. These hardware processing circuits can be composed of discrete hardware components or integrated circuits. To reduce power consumption and size, integrated circuits are typically used. Hardware processing circuits can include ASICs (application-specific integrated circuits) or PLDs (programmable logic devices); PLDs can include FPGAs (field-programmable gate arrays), CPLDs (complex programmable logic devices), and so on. These hardware processing circuits can be a single packaged semiconductor chip (e.g., packaged as an ASIC); or they can be integrated with other circuits (e.g., CPUs, DSPs) and packaged into a single semiconductor chip. For example, multiple hardware circuits and a CPU can be formed on a silicon substrate and packaged into a single chip; this type of chip is also called a SoC. Alternatively, circuits for implementing FPGA functions and a CPU can be formed on a silicon substrate and encapsulated into a single chip; this type of chip is also called a SoPC (system on a programmable chip).
[0100] It should be noted that when this application is implemented through software, hardware, or a combination of both, different software or hardware can be used, and it is not limited to using only one type of software or hardware. For example, one module or unit can be implemented using a CPU, while another module or unit can be implemented using a DSP. Similarly, when implemented using hardware, one module or unit can be implemented using an ASIC, while another module or unit can be implemented using an FPGA. Of course, it is not limited to using the same software (e.g., all through a CPU) or the same hardware (e.g., all through an ASIC) to implement some or all modules or units. Furthermore, those skilled in the art will understand that software is generally more flexible but less performant than hardware, while hardware is the opposite. Therefore, those skilled in the art can choose software, hardware, or a combination of both based on actual needs.
[0101] The above-described preferred embodiments have further detailed the purpose, technical solutions, and advantages of this application. It should be understood that the above description is only a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for generating data packets, characterized in that, Applications in data communication testers include: Multiple flow table entries are grouped according to the switch number and the switch outgoing port number to obtain multiple flow table groups; wherein, multiple flow table entries belonging to different flow table groups have at least one different switch number and switch outgoing port number, and multiple flow table entries belonging to the same flow table group have the same switch number and switch outgoing port number; each flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, and the multiple forwarding rule fields are used to define the forwarding rules of the switch. One or more target data packets are obtained based on one or more flow table entries in the target flow table group; the target flow table group is one of the multiple flow table groups, each target data packet is used to test whether the outgoing port of the switch to be tested corresponding to the switch number and the switch outgoing port number of the target flow table group is normal, and each target data packet includes multiple field values corresponding to multiple forwarding rule fields in its corresponding flow table entry; The step of grouping multiple flow table entries based on the switch number and the switch output port number includes: Configure a first packet label for each of the multiple flow table entries based on the switch number and the switch outgoing port number; the first packet label includes a switch number and a corresponding switch outgoing port number. Grouping multiple flow table entries based on the first grouping label; Before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: Based on the second packet label corresponding to the switch under test, and the matching relationship between the first packet label and the second packet label, a target flow table group is determined from the multiple flow table groups; the second packet label includes a switch number and a corresponding switch outgoing port number.
2. The data packet generation method according to claim 1, characterized in that, Before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: Identify the switch number and switch output port number of the switch currently connected to the data communication tester; Based on the switch number and switch output port number of the switch to be tested currently connected to the data communication tester, the target flow table group is determined from the multiple flow table groups.
3. The data packet generation method according to claim 1, characterized in that, Before obtaining one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: The target flow table group is determined from the plurality of flow table groups based on the obtained target flow table group selection instruction.
4. The data packet generation method according to any one of claims 1 to 3, characterized in that, The process of obtaining one or more target data packets based on one or more flow table entries in the target flow table group includes: Generate one or more default data packets based on the pre-configured default message template; Based on the forwarding rule fields and corresponding field values in one or more flow table entries in the target flow table group, one or more default data packets are modified to obtain one or more target data packets.
5. A method for testing a switch, characterized in that, Applications in data communication testers include: One or more target data packets are sent to the corresponding switch under test; the target data packets are data packets obtained by the data packet generation method as described in any one of claims 1 to 4. Obtain one or more data packets to be verified forwarded by the switch under test through the target outgoing port; the target outgoing port is the switch outgoing port corresponding to the target data packet; The data packet to be verified is verified based on the target data packet to obtain the data communication test result corresponding to the target output port.
6. The switch testing method according to claim 5, characterized in that, The verification of the data packet to be verified based on the target data packet includes: Verify whether the number of the target data packets is equal to the number of the data packets to be verified.
7. The switch testing method according to claim 5 or 6, characterized in that, Also includes: After obtaining the data communication test results corresponding to the target output port, another output port of the switch under test is determined as the next output port to be tested, or an output port of another switch under test is determined as the next output port to be tested. Data communication tests are performed on the next output port to be tested using target data packets that have the same switch number and switch output port number as the next output port to be tested.
8. A data packet generation apparatus, characterized in that, Applications in data communication testers include: The grouping module is used to group multiple flow table entries according to the switch number and the switch outgoing port number to obtain multiple flow table groups; wherein, at least one of the switch number and the switch outgoing port number of multiple flow table entries belonging to different flow table groups is different, and the switch number and the switch outgoing port number of multiple flow table entries belonging to the same flow table group are all the same; the flow table entry includes multiple forwarding rule fields and field values corresponding one-to-one with the multiple forwarding rule fields, and the multiple forwarding rule fields are used to define the forwarding rules of the switch. The data packet generation module is used to obtain one or more target data packets based on one or more flow table entries in the target flow table group; the target flow table group is one of the multiple flow table groups, each target data packet is used to test whether the outgoing port of the switch under test corresponding to the switch number and switch outgoing port number of the target flow table group is normal, and each target data packet includes multiple field values corresponding to multiple forwarding rule fields in its corresponding flow table entry; The process of grouping multiple flow table entries by the grouping module includes: configuring a first grouping label for each flow table entry based on the switch number and the switch outgoing port number; the first grouping label includes a switch number and a corresponding switch outgoing port number; and grouping the multiple flow table entries based on the first grouping label. Before the data packet generation module obtains one or more target data packets based on one or more flow table entries in the target flow table group, the method further includes: determining the target flow table group from multiple flow table groups according to the second packet label corresponding to the switch under test and the matching relationship between the first packet label and the second packet label; the second packet label includes a switch number and a corresponding switch output port number.
9. A switch testing device, characterized in that, Applications in data communication testers include: A data packet sending module is used to send one or more target data packets to a corresponding switch under test; the target data packet is a data packet obtained by the data packet generation device as described in claim 8. The data packet acquisition module is used to acquire one or more data packets to be verified forwarded by the switch under test through the target outgoing port; the target outgoing port is the switch outgoing port corresponding to the target data packet. The data packet verification module is used to verify the data packet to be verified based on the target data packet, and obtain the data communication test result corresponding to the target output port.
10. A data communication tester, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the method as claimed in any one of claims 1 to 7.
11. The data communication tester according to claim 10, characterized in that, The processor is a hardware processor used to read the computer program.
12. A switch for connecting a data communication tester, characterized in that, The data communication tester is the data communication tester as described in claim 10 or 11.
13. A computer-readable storage medium, characterized in that, Used to store a computer program, which, when executed by a processor, implements the method as described in any one of claims 1 to 7.
14. A computer program product, characterized in that, Includes a computer program / instruction that, when executed by a processor, implements the method as described in any one of claims 1 to 7.