Data message generation method, switch test method and device
By grouping the flow table entries of OpenFlow switches and automating data packet generation, the problem of low switch testing efficiency is solved, and efficient switch testing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-11
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies for testing OpenFlow switches are inefficient, requiring manual searching of flow table entries and editing of data packets, resulting in low testing efficiency.
By grouping flow table entries according to switch number and outgoing port number, target data packets are generated, and flow table groups are tested automatically, reducing manual intervention and improving testing efficiency.
It enables batch automated generation of data packets, reducing test preparation time and improving the efficiency and accuracy of switch testing.
Smart Images

Figure CN121728004A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data communication, and particularly relates to a data packet generation method and a switch testing method and device. BACKGROUND
[0002] In the field of data communication testers, OpenFlow is a network communication protocol, which is mainly used for communication between an OpenFlow controller and an OpenFlow switch in a software-defined network architecture. After the OpenFlow controller simulates a tester to configure a flow table for the OpenFlow switch, it is generally necessary to verify whether the OpenFlow switch correctly forwards a data stream according to the flow table. The verification method is to construct a data stream matching the flow table item and inject it into the OpenFlow switch, and to observe whether the OpenFlow switch forwards the data stream to the corresponding port according to the action of the flow table item. At present, the related flow table items of the to-be-tested port of the to-be-tested switch are found in the flow table items one by one by manual operation, and then the data packets are manually edited and tested one by one, which leads to a very low testing efficiency of the OpenFlow switch.
[0003] Therefore, how to improve the testing efficiency is a problem to be solved in the field. SUMMARY
[0004] The present application discloses a data packet generation method, a switch testing method and device, which are used to solve the problem of low testing efficiency of a switch.
[0005] In a first aspect, the present application provides a data packet generation method applied to a data communication tester, which comprises: grouping a plurality of flow table items according to switch numbers and switch port numbers to obtain a plurality of flow table groups; wherein at least one of the switch numbers and the switch port numbers of the plurality of flow table items belonging to different flow table groups is different, and the switch numbers and the switch port numbers of the plurality of flow table items belonging to the same flow table group are all the same; the flow table item comprises a plurality of forwarding rule fields and field values corresponding to the plurality of forwarding rule fields one by one, and the plurality of forwarding rule fields are used to define the forwarding rule of the switch; obtaining one or more target data packets corresponding to one or more flow table items in a target flow table group; the target flow table group is one of the plurality of flow table groups, and each target data packet is used to test whether the out port of a to-be-tested switch corresponding to the switch number and the switch port number of the target flow table group is normal, and each target data packet comprises a plurality of field values corresponding to the plurality of forwarding rule fields in the flow table item corresponding to the target data packet.
[0006] The application can group flow table items according to switch numbers and switch egress port numbers, and can automatically obtain data packets for testing in batches for the egress port of the switch. Compared with the manual flow table item searching mode, the application can obviously improve the processing efficiency of the data packets. In addition, compared with the mode of repeatedly switching the test object between multiple test switches or multiple egress ports of the same test switch, the application can reduce the test preparation time of the data communication tester and the test switch, and can improve the overall test efficiency of the switch.
[0007] In a possible implementation, before the one or more target data packets corresponding to the one or more flow table items in the target flow table group are obtained, the method further includes: identifying a switch number and a switch egress port number of a test switch connected to the data communication tester at a current time; and determining the target flow table group from the multiple flow table groups according to the switch number and the switch egress port number of the test switch connected to the data communication tester at the current time.
[0008] In the embodiment, the data communication tester can automatically determine the target flow table group from the multiple flow table groups by identifying the switch number and the switch egress port number of the test switch connected at the current time, thereby reducing the manual participation of the related personnel and improving the efficiency.
[0009] In a possible implementation, before the one or more target data packets corresponding to the one or more flow table items in the target flow table group are obtained, the method further includes: determining the target flow table group from the multiple flow table groups according to the obtained target flow table group selection instruction.
[0010] In the embodiment, the related personnel can actively participate in selecting the target flow table group corresponding to the test switch from the multiple flow table groups, thereby ensuring the consistency of the target flow table group and the test switch and improving the test accuracy.
[0011] In a possible implementation, the grouping of the multiple flow table items according to the switch number and the switch egress port number includes: configuring a first grouping tag for each flow table item in the multiple flow table items according to the switch number and the switch egress port number of the switch; the first grouping tag includes a switch number and a corresponding switch egress port number; and the multiple flow table items are grouped based on the first grouping tag.
[0012] In the embodiment, each flow table item is configured with a corresponding first grouping tag, and the grouping of the multiple flow table items is realized based on the first grouping tag. In this way, the accuracy and efficiency of the data communication tester in the flow table item grouping process can be optimized.
[0013] In a possible implementation, before the one or more target data packets are obtained based on the one or more flow table entries in the target flow table group, the method further includes: determining the target flow table group from the plurality of flow table groups according to a second group label corresponding to the to-be-tested switch and a matching relationship between the first group label and the second group label; and the second group label includes a switch number and a corresponding switch egress port number.
[0014] In this embodiment, the target flow table group can be determined from the plurality of flow table groups according to the second group label corresponding to the to-be-tested switch and the matching relationship between the first group label and the second group label, so that the data communication tester can automatically implement the matching between the second group label of the to-be-tested switch and the first group label of the plurality of flow table groups, and the manual participation of related personnel is reduced, and the efficiency is improved.
[0015] In a possible implementation, the one or more target data packets are obtained based on the one or more flow table entries in the target flow table group, including: generating one or more default data packets according to a preconfigured default packet template; and modifying the one or more default data packets based on a forwarding rule field and a corresponding field value in the one or more flow table entries in the target flow table group, to obtain the corresponding one or more target data packets.
[0016] In this embodiment, the generation manner of the data packet is preconfigured, and then the generated default data packet is modified based on the forwarding rule field and the field value in the target flow table group, to obtain the target data packet for testing the switch, so that the manual participation of related personnel is reduced, and the efficiency is improved.
[0017] In a second aspect, the application provides a switch testing method applied to a data communication tester, including: sending one or more target data packets to a corresponding to-be-tested switch; the target data packet is a data packet obtained by using the data packet generation method described above; obtaining one or more to-be-verified data packets forwarded by the to-be-tested switch through a target egress port; the target egress port is a switch egress port corresponding to the target data packet; verifying the to-be-verified data packet based on the target data packet, to obtain a data communication test result corresponding to the target egress port.
[0018] In the present 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 to-be-tested switch, and obtain the to-be-verified data packet forwarded by the target out port of the to-be-tested switch. The data communication testing result corresponding to the to-be-tested switch can be obtained through verification between the target data packet and the to-be-verified data packet. In this way, the target data packet obtained by the above data packet generation method is used to perform communication testing on the to-be-tested switch, which reduces the manual participation of relevant personnel and improves the testing efficiency.
[0019] In a possible implementation, the verification of the target data packet on the to-be-verified data packet comprises: verifying whether the number of the target data packet is equal to the number of the to-be-verified data packet.
[0020] In the present embodiment, the data of the to-be-verified data packet and the target data packet forwarded by the to-be-tested switch are verified, which can verify whether the to-be-tested switch normally forwards data and ensure the testing accuracy of the switch.
[0021] In a possible implementation, the method further comprises: after obtaining the data communication testing result corresponding to the target out port, determining another out port of the to-be-tested switch as a next to-be-tested out port, or determining an out port of another to-be-tested switch as the next to-be-tested out port; and performing data communication testing on the next to-be-tested out port by using a target data packet with the same switch number and switch out port number as the next to-be-tested out port.
[0022] In the present embodiment, after testing of one target out port of the to-be-tested switch is completed, the next to-be-tested out port, another out port of the to-be-tested switch or an out port of another to-be-tested switch can be directly determined, and data communication testing is performed by using the target data packet corresponding to the next to-be-tested out port. In this way, the manual participation of relevant personnel in the testing process of the switch is reduced, and the testing efficiency and testing accuracy are optimized.
[0023] In a third aspect, the present application provides a data packet generation device applied to a data communication tester, comprising: The grouping module is configured to group a plurality of flow table entries according to a switch number and a switch out port number, to obtain a plurality of flow table groups. At least one of the switch number and the switch out port number of the plurality of flow table entries belonging to different flow table groups is different, and the switch number and the switch out port number of the plurality of flow table entries belonging to the same flow table group are the same. The flow table entry comprises a plurality of forwarding rule fields and field values corresponding to the plurality of forwarding rule fields one by one. The plurality of forwarding rule fields are used to define the forwarding rule 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 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.
[0024] Fourthly, this application provides a switch testing device, applied to a data communication tester, comprising: 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. 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.
[0025] Fifthly, this application provides a data communication tester, comprising: Memory, used to store computer programs; A processor for executing the computer program to implement the method as described above.
[0026] In one possible implementation, the processor is a hardware processor used to read the computer program.
[0027] Sixthly, this application provides a switch for connecting a data communication tester, wherein the data communication tester is as described above.
[0028] 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.
[0029] Eighthly, this application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the method described above.
[0030] 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
[0031] 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.
[0032] 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; Figure 2 This application provides a schematic diagram of a switch test-related data flow. Figure 3 A flowchart of a data packet generation method provided in an embodiment of this application; Figure 4 A flowchart of a switch testing method provided in this application embodiment; Figure 5 A schematic diagram of a switch testing system architecture provided in this application embodiment; Figure 6A schematic diagram of a data packet generation device provided in an embodiment of this application; Figure 7 This is a schematic diagram of a switch testing device provided in an embodiment of this application. Detailed Implementation
[0033] 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.
[0034] 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.
[0035] 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 1As 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).
[0036] 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?
[0037] 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.
[0038] Example 1
[0039] like Figure 3 As shown, this embodiment discloses a data packet generation method, applied to a data communication tester, including: 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.
[0040] 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.
[0041] 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.
[0042] Table 1 Flow Table Details
[0043] 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.
[0044] Table 2 Flow table grouping information
[0045] 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.
[0046] 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.
[0047] 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.
[0048] 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.
[0049] 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.
[0050] Table 3 Default Data Message
[0051] 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.
[0052] Example 2
[0053] 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: 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.
[0054] 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.
[0055] 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.
[0056] 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.
[0057] 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.
[0058] 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.
[0059] 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.
[0060] 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.
[0061] 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.
[0062] Example 3
[0063] like Figure 6 As shown, this embodiment discloses a data packet generation device, applied to a data communication tester, comprising: 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. 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.
[0064] 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.
[0065] Correspondingly, such as Figure 7 As shown, this embodiment discloses a switch testing device, applied to a data communication tester, comprising: 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. 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; 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.
[0066] 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.
[0067] Furthermore, this embodiment discloses a data communication tester, including: Memory, used to store computer programs; A processor is used to execute computer programs to implement the methods described above.
[0068] 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.
[0069] Furthermore, this embodiment discloses a switch for connecting a data communication tester, which is the data communication tester described above.
[0070] 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.
[0071] Furthermore, this embodiment discloses a computer program product, including a computer program / instructions, which, when executed by a processor, implements the method described above.
[0072] 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.
[0073] 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.).
[0074] 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).
[0075] 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.
[0076] 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 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.
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 claim 1, characterized in that, The grouping of multiple flow table entries based on the switch number and the switch outgoing 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. The multiple flow table entries are grouped based on the first grouping label.
5. The data packet generation method according to claim 4, 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: 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.
6. The data packet generation method according to any one of claims 1 to 5, 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.
7. 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 6. 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.
8. The switch testing method according to claim 7, 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.
9. The switch testing method according to claim 7 or 8, 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.
10. 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 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.
11. 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 10. 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.
12. 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 9.
13. The data communication tester according to claim 12, characterized in that, The processor is a hardware processor used to read the computer program.
14. A switch for connecting a data communication tester, characterized in that, The data communication tester is the data communication tester as described in claim 12 or 13.
15. 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 9.
16. 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 9.
Citation Information
Patent Citations
Network system and method of controlling path
CN103329488A
MPLS network control system and method based on SDN
CN104486218A
Message statistics method and network equipment
CN110113230A
Integrated Diagnostic Instrument
US20190369126A1