Testing method for route matching algorithm, device, and storage medium
By generating test messages and rules containing next-hop identifiers, the network processor's routing matching algorithm is automatically tested, solving the problem of inaccurate routing lookup engine testing and ensuring the correctness of data packet forwarding.
Patent Information
- Application Number
- PCT/IB2025/051679
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-03-25
- Filing Date
- 2025-02-17
- Publication Date
- 2025-10-02
AI Technical Summary
In the prior art, the testing method for the route matching algorithm of the network processor is not accurate enough, resulting in packet forwarding errors and being unable to effectively evaluate the correctness of the route lookup engine.
By generating test messages and routing forwarding rules corresponding to routing entries, including next-hop identifiers, and using routing matching algorithms for automated testing, it is ensured that the next-hop identifier corresponding to the next-hop address is saved in the test messages and routing forwarding rules, thereby achieving accurate testing of the routing matching algorithm.
This system implements automated testing of the routing matching algorithm in the network processor, improves the testing accuracy of the routing lookup engine, and ensures the correctness of data packet forwarding.
Smart Images

Figure IB2025051679_02102025_PF_FP_ABST
Abstract
Description
[0001]This disclosure claims priority to Chinese patent application number 202410346169.6, filed with the China Patent Office on March 25, 2024, entitled "Testing Method, Device, and Storage Medium for Route Matching Algorithm," the entire contents of which are incorporated herein by reference. Technical Field: This disclosure relates to the field of computer technology and, more specifically, to a testing method, device, and storage medium for route matching algorithms. Background: To adapt to evolving network technologies, a new type of microprocessor, the network processor (NP), has emerged. A NP is a programmable device specifically designed to handle various communications tasks, such as packet processing, protocol analysis, route lookup, voice / data aggregation, firewalls, and Quality of Service (QoS). NPs typically implement route lookup tasks through an internally deployed route lookup engine. A routing lookup engine implements route matching using a specific routing matching algorithm, such as the Longest Prefix Match (LPM) algorithm. Therefore, when evaluating a new network processor, it's necessary to test the correctness of the routing matching algorithm. This disclosure provides a method, device, and storage medium for testing routing matching algorithms in network processors, enabling testing of routing matching algorithms in network processors. A first aspect of the present disclosure provides a method for testing a routing matching algorithm, which is applied to a testing device and includes: generating, based on preset routing entries and device information of a device to be tested, a test message and a routing forwarding rule corresponding to each routing entry; the test message and the routing forwarding rule both including a next hop identifier, the next hop identifier in the test message being used to represent the next hop address in the routing entry corresponding to the test message, and the next hop identifier in the routing forwarding rule being used to represent the next hop address in the routing entry corresponding to the routing forwarding rule; sending a test message corresponding to the routing forwarding rule and each routing entry to the device to be tested; receiving multiple target test messages returned by the device to be tested, the target test messages being obtained by the device to be tested based on the routing forwarding rule corresponding to the routing entry and the test message, the target test messages including the next hop identifier and a target identifier, the target identifier being used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device to be tested; and determining, based on the multiple target test messages, whether the routing matching algorithm is abnormal.In some embodiments, based on preset routing entries and device information of the device to be tested, generating test messages and routing forwarding rules corresponding to each routing entry includes: determining a parameter expression corresponding to the device information; converting the next hop address in each routing entry into a next hop identifier represented by the parameter expression, and obtaining the routing forwarding rules and test messages for each routing entry. In some embodiments, the generating of test messages corresponding to each routing entry based on preset routing entries and device information of the device to be tested includes: if there are no overlapping routing entries among the routing entries, using the network address in the routing prefix of each routing entry as the first destination address in the test message corresponding to each routing entry, and generating the test message corresponding to each routing entry based on the first destination address and the device information; the overlapping routing entries are routing entries in which the routing entries have some of the same network segments; if there are overlapping routing entries among the routing entries, determining the second destination address of the test message corresponding to each routing entry based on the routing prefix in the overlapping routing entry and the routing prefix in each routing entry, and generating the test message corresponding to each routing entry based on the second destination address and the device information. In some embodiments, determining the second destination address of the test message corresponding to each of the routing entries based on the routing prefix in the overlapping routing entry and the routing prefix in each of the routing entries includes: determining a first network address set corresponding to the overlapping routing entry based on the routing prefix in the overlapping routing entry; and determining a second network address set corresponding to each of the routing entries based on the routing prefix in each of the routing entries; determining a union of the first network address set and the second network address set; and selecting an address from the union as the second destination address. In some embodiments, determining whether the route matching algorithm is abnormal based on the multiple target test messages includes: obtaining a test result of the route matching algorithm for each of the target test messages based on a target identifier and a next hop identifier included in each of the target test messages; if the target identifier and next hop identifier included in each of the target test messages are the same, the test result indicates that the route matching algorithm has passed the test for each of the target test messages; and obtaining a final test result of the route matching algorithm based on the test result; if the test results for each of the target test messages indicate that the test has passed, the final test result indicates that the test has passed.A second aspect of the present disclosure provides a method for testing a routing matching algorithm, which is applied to a device to be tested, and includes: receiving a test message and a routing forwarding rule corresponding to each routing entry sent by the test device; the test message includes a next hop identifier, where the next hop identifier is used to represent the next hop address in the routing entry corresponding to the test message; using the routing matching algorithm to be tested, based on the routing forwarding rule corresponding to each routing entry, generating a target test message corresponding to each test message, where the target test message includes the next hop identifier and a target identifier, where the target identifier is used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm; and sending each of the target test messages to the test device. In some embodiments, a route matching algorithm to be tested is used to generate target test messages corresponding to each test message based on the route forwarding rules corresponding to each route entry. This includes: using the route matching algorithm to be tested, searching for a target route forwarding rule that matches each test message from each of the route forwarding rules; storing the next hop identifier in the target route forwarding rule as the target identifier in the test message that matches the target route forwarding rule, thereby obtaining a target test message for the test message that matches the target route forwarding rule. A third aspect of the present disclosure provides a route matching algorithm testing system, comprising: a test device and a device to be tested; the test device is configured to execute the route matching algorithm testing method described in the first aspect; and the device to be tested is configured to execute the route matching algorithm testing method described in the second aspect.A fourth aspect of the present disclosure provides a testing apparatus for a routing matching algorithm, which is applied to a testing device and includes: a first generating module, configured to generate, based on preset routing entries and device information of a device under test, a test message and a routing forwarding rule corresponding to each routing entry; the test message and the routing forwarding rule both including a next hop identifier, the next hop identifier in the test message being used to identify the next hop address in the routing entry corresponding to the test message, and the next hop identifier in the routing forwarding rule being used to identify the next hop address in the routing entry corresponding to the routing forwarding rule; a first sending module, configured to issue the routing forwarding rule to the device under test and send test messages corresponding to each routing entry; a first receiving module, configured to receive multiple target test messages returned by the device under test, the target test messages being obtained by the device under test based on the routing forwarding rule corresponding to the routing entry and the test message, the target test messages including the next hop identifier and a target identifier, the target identifier being used to identify the next hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device under test; and a determining module, configured to determine, based on the multiple target test messages, whether the routing matching algorithm is abnormal. A fifth aspect of the present disclosure provides a route matching algorithm testing device, applied to a device under test, comprising: a second receiving module, configured to receive test messages and route forwarding rules corresponding to each route entry sent by the test device; the test message including a next hop identifier, which represents the next hop address in the route entry corresponding to the test message; a second generating module, configured to employ the route matching algorithm under test and, based on the route forwarding rules corresponding to each route entry, generate a target test message corresponding to each test message; the target test message including the next hop identifier and a target identifier, which represents the next hop identifier in the route forwarding rule matched by the route matching algorithm; and a second sending module, configured to send each target test message to the test device. A sixth aspect of the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor executing the computer program to implement the method described in the first or second aspect. A seventh aspect of the present disclosure provides a computer-readable storage medium, storing a computer program thereon, the program being executed by the processor to implement the method described in the first or second aspect.An embodiment of an eighth aspect of the present disclosure provides a program product, comprising a computer program that, when executed by a processor, implements the method described in the first or second aspect above. The technical solutions provided in the embodiments of the present disclosure have at least the following technical effects or advantages: In the embodiments of the present disclosure, when a test device generates a test message and a routing forwarding rule, it stores a next-hop identifier corresponding to the next-hop address of the routing entry in the test message and the routing forwarding rule. This allows the device under test to store the target identifier in the target test message when generating a target test message based on the test message and the routing forwarding rule, and ultimately test the routing matching algorithm in the device under test based on the target identifier and the next-hop identifier in the target test message. The solution provided in this embodiment enables automated testing of the routing matching algorithm in the device under test. Additional aspects and advantages of the present disclosure will be described in part in the following description and will become apparent from the following description or learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS Various other advantages and benefits will become apparent to those skilled in the art upon reading the detailed description of the preferred embodiments below. The drawings are provided for illustration purposes only and are not to be construed as limiting the present disclosure. Throughout the drawings, like reference symbols represent like components. In the drawings: FIG1 illustrates a flow chart of a method for testing a route matching algorithm according to an embodiment of the present disclosure; FIG2 illustrates a schematic diagram of overlapping routes according to an embodiment of the present disclosure; FIG3 illustrates a flow chart of a method for testing a route matching algorithm according to an embodiment of the present disclosure; FIG4 illustrates a flow chart of a method for testing a route matching algorithm according to an embodiment of the present disclosure; FIG5 illustrates a structural diagram of a system for testing a route matching algorithm according to an embodiment of the present disclosure; FIG6 illustrates a structural diagram of a device for testing a route matching algorithm according to an embodiment of the present disclosure; FIG7 illustrates a structural diagram of a device for testing a route matching algorithm according to an embodiment of the present disclosure; FIG8 illustrates a schematic diagram of an electronic device according to an embodiment of the present disclosure; and FIG9 illustrates a schematic diagram of a storage medium according to an embodiment of the present disclosure. Specific Implementations Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be implemented in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided to facilitate a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.It should be noted that, unless otherwise specified, technical or scientific terms used in this disclosure should have the common meanings understood by persons skilled in the art to which this disclosure relates. In related art, when a network processor receives an IP (Internet Protocol) data packet, it parses the destination IP address in the IP data packet. Then, using the parsed destination IP address, the network processor searches a routing table based on a route matching algorithm, searches the routing table for a route entry corresponding to the destination IP address, obtains the next-hop IP address from the routing entry, and sends the received IP data packet to the device corresponding to the next-hop IP address. Based on the matching process of the route matching algorithm in the aforementioned network processing, it can be found that if the routing matching algorithm matches an incorrect routing entry, the next-hop IP address found will be an incorrect next-hop IP address. Further forwarding of the IP data packet to the next hop will also be incorrect, ultimately causing the IP data packet to deviate from the correct forwarding path. To alleviate the problems existing in related art, this disclosure proposes a method, device, and storage medium for testing a route matching algorithm. The method includes: The following describes a method, device, and storage medium for testing a route matching algorithm according to embodiments of the present disclosure, in conjunction with the accompanying drawings. This method can be applied to test devices, including but not limited to terminal devices or servers. As shown in Figure 1, the method specifically includes the following steps: Step 101: Based on preset routing entries and device information of the device under test, a test message and routing forwarding rule corresponding to each routing entry are generated. Both the test message and the routing forwarding rule include a next-hop identifier. The next-hop identifier in the test message represents the next-hop address in the routing entry corresponding to the test message, while the next-hop identifier in the routing forwarding rule represents the next-hop address in the routing entry corresponding to the routing forwarding rule. Step 102: The routing forwarding rule is issued to the device under test, along with test messages corresponding to each routing entry. Step 103: Multiple target test messages are received from the device under test. The target test messages are processed by the device under test based on the routing forwarding rules corresponding to the routing entries and the test messages. The target test messages include a next-hop identifier and a target identifier. The target identifier represents the next-hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device under test. Step 104: Based on the multiple target test messages, determining whether the routing matching algorithm is abnormal is performed. The routing entry is a table entry used to guide data packet forwarding. The routing entry records the next hop address to the destination IP.The route header includes parameters such as the destination network / mask, protocol type, priority, cost, flags, next hop, and outbound interface. The destination network / mask is used to determine the network segment address range of the route entry. When the destination IP address in the IP packet is used to query the routing entries in the routing table based on the route matching algorithm, the route entry within the network segment address range that includes the destination IP address is used as the routing entry that matches the IP packet. In this embodiment, device information is used to uniquely identify a device under test or a class of devices under test. When the device information uniquely identifies a device under test, the device information may include information such as the device number or name of the device under test. When the device information uniquely identifies a class of devices under test, the device information may include the device type of the device under test. In this embodiment, the next hop identifier may be equal to the next hop address, or the next hop identifier may be obtained by conversion based on the next hop. When the device information of the device under test indicates that the device under test can directly resolve and identify the next hop address in the routing entry, the next hop identifier is equal to the next hop address. If the device information of the device under test indicates that the device under test is unable to directly resolve and identify the next-hop address in a routing entry, the next-hop address is converted to a next-hop identifier. In an optional embodiment, the device information of the device under test is bound to a parameter expression that indicates the resolution and identification capabilities of the device under test. When generating the test message and routing forwarding rules, the next-hop address in each routing entry is converted to a next-hop identifier expressed in the parameter expression. It should be understood that after the parameter expression conversion, the field corresponding to the next-hop address in the routing forwarding rule is populated with the next-hop identifier corresponding to the next-hop address, and a field in the test message is populated with the next-hop identifier corresponding to the next-hop address included in the routing entry corresponding to the test message. Because the expression of the next-hop address cannot change during message forwarding, in this embodiment, when generating the test message, the next-hop identifier is stored in a field other than the field corresponding to the next-hop address. For example, the next-hop identifier can be stored in the payload field of the test message. In this embodiment, the test message generated by the same routing entry and the next hop identifier included in the routing forwarding rule are both converted from the next hop address included in the routing entry, so the test message generated by the same routing entry and the next hop identifier included in the routing forwarding rule are the same.In one example, using a parameter expressed in decimal form, when converting a next-hop address to a next-hop identifier, the next-hop addresses are converted one by one, starting from decimal 0. Specifically, for the first routing entry in each routing entry, the next-hop address in the first routing entry is converted to 0. Then, a second routing entry is obtained. If the next-hop address in the second routing entry is the same as that in the first routing entry, the next-hop address in the second routing entry is also converted to 0. If the next-hop address in the second routing entry is different from that in the first routing entry, the next-hop address in the second routing entry is converted to 1. The conversion of the next-hop addresses in each routing entry is completed in this manner. It should be understood that the first routing entry and the second routing entry are each any one of the routing entries. In this embodiment, two routing entries may share some of the same network segments. If these two routing entries are left unprocessed, and the destination IP addresses in the test messages generated by the two routing entries are identical, the routing matching algorithm in the device under test will match these two test messages to identical routing forwarding rules. However, in reality, since the two test messages are generated by different routing entries, the routing forwarding rules they match should be different. This erroneous matching result can affect subsequent testing of the routing matching algorithm. To mitigate this issue, routing entries are processed based on the specific situation during test message generation. Specifically, in an optional embodiment, based on preset routing entries and device information of the device to be tested, test messages corresponding to each routing entry are generated. The method includes: if there are no overlapping routing entries, using the network address in the routing prefix of each routing entry as the first destination address in the test message corresponding to each routing entry, and generating the test message corresponding to each routing entry based on the first destination address and the device information. Overlapping routing entries are routing entries that have some of the same network segments. If there are overlapping routing entries, determining the second destination address of the test message corresponding to each routing entry based on the routing prefix in the overlapping routing entry and the routing prefix in each routing entry, and generating the test message corresponding to each routing entry based on the second destination address and the device information. A routing entry includes a routing prefix, which includes a destination network / mask. The destination network and mask together determine the network segment range of the routing entry.For example, the routing prefix 192.168.1.0 / 28 covers an address range of 192.168.1.0 to 192.168.1.15, or a total of 16 addresses. Another example is the routing prefix 192.168.1.0 / 24, which covers an address range of 192.168.1.0 to 192.168.1.255, or a total of 256 addresses. If the network segment ranges corresponding to two routing entries overlap, the two routing entries are considered overlapping. For example, the routing entries corresponding to the two routing prefixes 192.168.1.0 / 28 and 192.168.1.0 / 24 shown in the preceding example are overlapping. In this embodiment, if no overlapping routing entries exist, the network address in the routing prefix of each routing entry can be any network address within the network segment range of the routing entry. For example, for a routing entry with the routing prefix 192.168.1.0 / 28, if no overlapping routing entries exist, a network address randomly selected from the address range 192.168.1.0 to 192.168.1.255 covered by the routing prefix can be used as the first destination address of the test message corresponding to the routing entry. It should be understood that the second destination address falls within the network address range covered by the routing prefix of each routing entry, but not within the network address range covered by the routing prefix of the overlapping routing entry. This configuration ensures that the destination addresses in the test message generated by two overlapping routing entries are different. In specific implementation, the second destination address of the test message for the routing entry with the overlapping routing entry is determined by taking a set union. In an optional embodiment, determining the second destination address of a test message corresponding to each routing entry based on a routing prefix in the overlapping routing entry and a routing prefix in each routing entry includes: determining a first network address set corresponding to the overlapping routing entry based on the routing prefix in the overlapping routing entry; and determining a second network address set corresponding to each routing entry based on the routing prefix in each routing entry; determining a union of the first network address set and the second network address set; and selecting an address from the union as the second destination address. In an application, an address from the union may be randomly selected as the second destination address. For example, the smallest address in the union may be selected as the second destination address, or the largest address in the union may be selected as the second destination address.As an example, given the three routing prefixes 192.168.0.0 / 16, 192.168.1.0 / 24, and 192.168.1.0 / 28 as shown in Figure 2, the network address range covered by the first routing prefix is 192.168.0.0 to 192.168.255.255, the network address range covered by the second routing prefix is 192.168.1.0 to 192.168.1.255, and the network address range covered by the third routing prefix is 192.168.1.0 to 192.168.1.15. According to the method for determining the second destination address disclosed above, the network address 192.168.1.0 / 28 is finally determined. The second destination address in the test message generated by the routing entry corresponding to this routing prefix is 192.168.1.0. The second destination address in the test message generated by the routing entry corresponding to this routing prefix is 192.168.1.0 / 24. The second destination address in the test message generated by the routing entry corresponding to this routing prefix is 192.168.1.32. The second destination address in the test message generated by the routing entry corresponding to this routing prefix is 192.168.0.0 / 16. In this embodiment, to improve test accuracy, the test device checks all received target test messages. If any target test message fails the check, it indicates that there is a defect in the route matching algorithm of the device under test. If all target test messages pass the check, it indicates that the route matching algorithm of the device under test has passed the test. In a specific implementation, in an optional embodiment, testing the route matching algorithm of the device to be tested based on multiple target test messages may include the following steps: obtaining a test result of the route matching algorithm for each target test message based on the target identifier and next hop identifier included in each target test message; if the target identifier and next hop identifier included in each target test message are the same, the test result indicates that the route matching algorithm test for each target test message has passed; obtaining a final test result of the route matching algorithm based on the test result; if the test results for each target test message all indicate that the test has passed, the final test result indicates that the test has passed. It should be understood that if the target identifier and next hop identifier included in each target test message are different, the test result indicates that the route matching algorithm test for each target test message has failed. If at least one test result among the test results for each target test message indicates that the test has failed, the final test result indicates that the test has failed.In this embodiment, if the route matching algorithm operates correctly, the route forwarding rule matched by the route matching algorithm for the test message and the test message originate from the same routing entry. Simultaneously, the target test message generated on the device under test based on the test message and the route forwarding rule also originates from the routing entry. Therefore, the destination identifier and next-hop identifier in the target test message are both converted from the next-hop address in the routing entry, resulting in the target identifier and next-hop identifier being identical. If the route matching algorithm operates incorrectly, the route forwarding rule matched by the route matching algorithm for the test message and the test message originate from different routing entries. Therefore, the destination identifier included in the target test message generated on the device under test based on the test message and the matched route forwarding rule and the next-hop identifier included in the test message originate from different routing entries. Therefore, in this case, the destination identifier and next-hop identifier in the target test message are different. In the solution provided by this embodiment, when generating a test message and routing forwarding rules, the test device stores the next hop identifier corresponding to the next hop address of the routing entry in the test message and routing forwarding rules. This allows the device under test to store the target identifier in the target test message when generating a target test message based on the test message and routing forwarding rules. Ultimately, the route matching algorithm in the device under test can be tested based on the target identifier and next hop identifier in the target test message. The solution provided by this embodiment enables automated testing of the route matching algorithm in the device under test. Based on the same inventive concept, embodiments of the present disclosure provide a method for testing a route matching algorithm. This method can be applied to a device under test capable of running a route matching algorithm. The device under test can be any routing device with route matching functionality, including but not limited to a network processor and a router. As shown in Figure 3, the method may include the following steps: Step 301: Receive a test message and routing forwarding rules corresponding to each routing entry sent by a test device; the test message includes a next-hop identifier, which represents the next-hop address in the routing entry corresponding to the test message; Step 302: Generate a target test message corresponding to each test message using the routing matching algorithm to be tested and based on the routing forwarding rules corresponding to each routing entry; the target test message includes a next-hop identifier and a target identifier, which represents the next-hop identifier in the routing forwarding rule matched by the routing matching algorithm; Step 303: Send each target test message to the test device. The routing matching algorithm in this embodiment includes, but is not limited to, a longest prefix match algorithm.In this embodiment, when searching for a routing forwarding rule that matches each test message, the routing matching algorithm compares the destination address in each test message with the address range covered by the routing prefix of each routing forwarding rule. The routing forwarding rule corresponding to the address range that includes the destination address of each test message is selected as the routing forwarding rule that matches the test message. In this embodiment, when generating routing forwarding rules, the test device converts the next hop address in the field corresponding to the next hop address in the routing entry into a next hop identifier. Therefore, after finding a routing forwarding rule that matches each test message, the test device extracts the next hop identifier from the field corresponding to the next hop address. This next hop identifier is then stored as the target identifier in the test message to generate a target test message. In this embodiment, if the routing entry that generates the routing forwarding rule matched by the routing matching algorithm and the routing entry that generates the test message are the same routing entry, the next hop identifier and the target identifier in the target test message are the same identifier. In a case where the routing entry for generating the routing forwarding rule matched by the routing matching algorithm and the routing entry for generating the test message are different routing entries, the next hop identifier and the target identifier in the target test message are different identifiers.Based on the same inventive concept, a testing method for a route matching algorithm as shown in FIG4 is provided. The method is described from the perspective of a test system composed of a test device and a device under test. As shown in FIG4 , the method may include the following steps: Step 401: The test device generates a test message and a route forwarding rule corresponding to each route entry based on preset route entries and device information of the device under test; the test message and the route forwarding rule both include a next hop identifier. The next hop identifier in the test message is used to identify the next hop address in the route entry corresponding to the test message, and the next hop identifier in the route forwarding rule is used to identify the next hop address in the route entry corresponding to the route forwarding rule; Step 402: The test device sends the test message and the route forwarding rule corresponding to each route entry to the device under test; Step 403: The device under test receives the test message and the route forwarding rule corresponding to each route entry sent by the test device; the test message includes the next hop identifier, which is used to identify the next hop address in the route entry corresponding to the test message; Step 404: The device under test uses the route matching algorithm to be tested and, based on the route forwarding rule corresponding to each route entry, A target test message corresponding to each test message is generated respectively, the target test message including a next hop identifier and a target identifier, the target identifier being used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm; Step 405: The device under test sends each target test message to the test device; Step 406: The test device receives multiple target test messages returned by the device under test, the target test message being obtained by the device under test based on the routing forwarding rule corresponding to the routing entry and the test message, the target test message including a next hop identifier and a target identifier, the target identifier being used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device under test; Step 407: The test device obtains a test result of the routing matching algorithm for each target test message based on the target identifier and the next hop identifier included in each target test message; if the target identifier and the next hop identifier included in each target test message are the same, the test result indicates that the routing matching algorithm test for each target test message has passed; Step 408: The test device obtains a final test result of the routing matching algorithm based on the test result. When the test results of each target test message indicate that the test has passed, the final test result indicates that the test has passed.Based on the same inventive concept, a test system for a routing matching algorithm as shown in FIG5 is provided. The system includes a testing device 51 and a device under test 52. The testing device 51 includes a test message generating module 511, a routing forwarding rule generating module 512, a sending module 513, and a receiving module 514. The test message generating module 511 is configured to generate a test message corresponding to each routing entry based on preset routing entries and device information of the device under test, and send the test message to the device under test through the sending module 513. The test message includes a next hop identifier, and the next hop identifier in the test message is used for the next hop address in the routing entry corresponding to the test message. The routing forwarding rule generating module 512 is configured to generate a routing forwarding rule corresponding to each routing entry based on preset routing entries and device information of the device under test, and send the routing forwarding rule to the device under test 52. The routing forwarding rule includes a next hop identifier, and the next hop identifier in the routing forwarding rule is used to represent the next hop address in the routing entry corresponding to the routing forwarding rule. The module is configured to receive test messages and routing forwarding rules corresponding to each routing entry sent by a test device; utilize the route matching algorithm to be tested, and based on the routing forwarding rules corresponding to each routing entry, generate target test messages corresponding to each test message, and send each target test message to the receiving module 514; the target test message includes a next hop identifier and a target identifier, with the target identifier representing the next hop identifier in the routing forwarding rule matched by the routing matching algorithm; and the receiving module 514 is configured to determine whether the routing matching algorithm is abnormal based on multiple target test messages. In this embodiment, the device to be tested may be a network processor used in a cloud network scenario. In this cloud network scenario, each routing entry may be a tenant route, the test message generated by the test message generation module may be a VxLAN message, and the routing forwarding rule generated by the routing forwarding rule generation module may be a Verlay routing forwarding rule. The next hop identifier may be replaced by the SIP (Source IP) in the tunnel header. Different route entries generate unique SIPos. For ease of understanding, the following uses two route entries with route prefixes 192.168.1.0 / 24 and 192.168.2.0 / 24 as examples to illustrate the route matching algorithm in the device under test. For ease of description, the route entry with the route prefix 192.168.1.0 / 24 is referred to as the first route entry, and the route entry with the route prefix 192.168.2.0 / 24 is referred to as the second route entry.Assume that the next hop identifier in the first routing entry is 172.16.1.1, and the next hop identifier in the second routing entry is 172.16.2.1. On the test device side, the test message generation module generates a first test message corresponding to the first routing entry and a second test message corresponding to the second routing entry. The payload field of the first test message is filled with 172.16.1.1, and the payload field of the second test message is filled with 172.16.2.1. The routing forwarding rule generation module generates a first routing forwarding rule corresponding to the first routing entry and a second routing forwarding rule corresponding to the second routing entry. The next hop address field of the first routing forwarding rule is stored with 172.16.1.1, and the next hop address field of the second routing forwarding rule is stored with 172.16.2.1. These two test messages and the routing forwarding rule are sent to the device under test. The device under test searches for a matching routing rule for the first test message based on a routing matching algorithm. If the matching routing rule found is the first routing forwarding rule, the SMAC field in the first test message is populated with 172.16.1.1 from the first routing forwarding rule, generating a first target test message. If the matching routing forwarding rule found is the second routing forwarding rule, the SMAC field in the first test message is populated with 172.16.2.1 from the second routing forwarding rule, generating a first target test message. The device under test sends the first target test message to the receiving module of the test device. The process of the device under test generating the second target test message based on the second test message is similar to the process of generating the first target test message based on the first test message described above. To avoid redundancy, this description is not repeated here. The receiving module of the test device extracts the data filled in the payload field and the smac field in the first target test message. If the data filled in the payload field and the smac field are the same, that is, both are 172.16.1.1, then it means that the routing matching algorithm has passed the test of the first routing entry. If the data filled in the payload field and the smac field are different, that is, the payload field is 172.16.1.1 and the smac field is 172.16.2.1, then it means that the routing matching algorithm has failed the test of the first routing entry.If the route matching algorithm passes both the first route entry and the second route entry tests, the route matching algorithm test is confirmed to have passed. If the route matching algorithm fails the first route entry and / or the second route entry tests, the route matching algorithm test is confirmed to have failed. An embodiment of the present disclosure further provides a testing device for a routing matching algorithm. As shown in FIG6 , the device may include: a first generating module 61, configured to generate, based on preset routing entries and device information of a device under test, a test message and a routing forwarding rule corresponding to each routing entry; the test message and the routing forwarding rule both including a next hop identifier, the next hop identifier in the test message being used to represent the next hop address in the routing entry corresponding to the test message, and the next hop identifier in the routing forwarding rule being used to represent the next hop address in the routing entry corresponding to the routing forwarding rule; a first sending module 62, configured to send the test message and the routing forwarding rule corresponding to each routing entry to the device under test; a first receiving module 63, configured to receive multiple target test messages returned by the device under test, the target test messages being obtained by the device under test based on the routing forwarding rule corresponding to the routing entry and the test message, the target test messages including the next hop identifier and a target identifier, the target identifier being used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device under test; Determination module 64 is configured to determine whether the route matching algorithm is abnormal based on the multiple target test messages. In some embodiments, first generation module 61 is configured to: determine a parameter expression corresponding to the device information; convert the next hop address in each route entry into a next hop identifier represented in the parameter expression, and obtain a routing forwarding rule and test message for each route entry. In some embodiments, first generation module 61 is configured to: if there are no overlapping route entries, use the network address in the route prefix of each route entry as the first destination address in the test message corresponding to each route entry, and generate a test message corresponding to each route entry based on the first destination address and the device information. Overlapping route entries are route entries that share some of the same network segments. If there are overlapping route entries, determine the second destination address of the test message corresponding to each route entry based on the route prefix in the overlapping route entry and the route prefix in each route entry, and generate a test message corresponding to each route entry based on the second destination address and the device information.In some embodiments, the first generation module 61 is configured to: determine a first network address set corresponding to the overlapping route entries based on the route prefixes in the overlapping route entries; and, based on the route prefixes in each route entry, determine a second network address set corresponding to each route entry; determine a union of the first network address set and the second network address set; and select an address from the union as the second destination address. In some embodiments, the determination module 64 is configured to: obtain a test result of the route matching algorithm for each target test message based on the target identifier and next hop identifier included in each target test message; if the target identifier and next hop identifier included in each target test message are the same, the test result indicates that the route matching algorithm has passed the test for each target test message; and obtain a final test result of the route matching algorithm based on the test result; if the test results for each target test message indicate that the test has passed, the final test result indicates that the test has passed. An embodiment of the present disclosure further provides a testing device for a route matching algorithm. As shown in FIG7 , the device may include: a second receiving module 71, configured to receive a test message and a route forwarding rule corresponding to each route entry sent by a test device; the test message including a next hop identifier, which represents the next hop address in the route entry corresponding to the test message; a second generating module 72, configured to employ the route matching algorithm to be tested and, based on the route forwarding rule corresponding to each route entry, generate a target test message corresponding to each test message; the target test message including the next hop identifier and a target identifier, which represents the next hop identifier in the route forwarding rule matched by the route matching algorithm; and a second sending module 73, configured to send each target test message to the test device. In some embodiments, the second generation module 72 uses the route matching algorithm to be tested to search for a target route forwarding rule matching each test message from each of the route forwarding rules; stores the next hop identifier in the target route forwarding rule as the target identifier in the test message matching the target route forwarding rule, and obtains a target test message for the test message matching the target route forwarding rule. The route matching algorithm testing apparatus and the route matching algorithm testing method provided in the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods employed, executed, or implemented therein. The embodiments of the present disclosure also provide an electronic device for executing the aforementioned route matching algorithm testing method.Please refer to FIG8 , which illustrates a schematic diagram of an electronic device provided in some embodiments of the present disclosure. As shown in FIG8 , electronic device 8 includes: a processor 800, a memory 801, a bus 802, and a communication interface 803. The processor 800, communication interface 803, and memory 801 are connected via bus 802. Memory 801 stores a computer program executable on processor 800. When processor 800 executes the computer program, it executes the route matching algorithm testing method provided in any of the aforementioned embodiments of the present disclosure. Memory 801 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk drive. Communication between the device network element and at least one other network element is achieved via at least one communication interface 803 (which may be wired or wireless). This communication connection may utilize the Internet, a wide area network, a local area network, a metropolitan area network, or the like. Bus 802 may be an ISA bus, a PCI bus, or an EISA bus. Buses may be classified as address buses, data buses, control buses, and the like. Memory 801 is used to store programs. Processor 800 executes the programs after receiving execution instructions. The route matching algorithm testing method disclosed in any of the aforementioned embodiments of the present disclosure can be applied to or implemented by processor 800. Processor 800 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the aforementioned method can be completed by hardware integrated logic circuits or software instructions within processor 800. Processor 800 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of the present disclosure. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present disclosure may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.The software module can be located in a storage medium well-established in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 801. Processor 800 reads information from memory 801 and, in conjunction with its hardware, completes the steps of the aforementioned method. The electronic device provided in the embodiments of the present disclosure and the method for testing the route matching algorithm provided in the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods employed, executed, or implemented therein. The embodiments of the present disclosure also provide a computer-readable storage medium corresponding to the method for testing the route matching algorithm provided in the aforementioned embodiments. Please refer to FIG. 9 , which shows a computer-readable storage medium as an optical disc 30 storing a computer program (i.e., a program product). When executed by a processor, the computer program executes the method for testing the route matching algorithm provided in any of the aforementioned embodiments. The embodiments of the present disclosure also provide a computer program product corresponding to the method for testing the route matching algorithm provided in the aforementioned embodiments, comprising a computer program. When executed by a processor, the computer program implements the method for testing the route matching algorithm provided in any of the aforementioned embodiments. It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or other optical or magnetic storage media, and these are not described in detail here. The computer-readable storage medium provided in the above-described embodiments of the present disclosure and the method for testing the route matching algorithm provided in the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the method employed, executed, or implemented by the application program stored therein. It should be noted that the description provided herein describes numerous specific details. However, it is understood that the embodiments of the present disclosure can be practiced without these specific details. In some instances, well-known structures and technologies are not described in detail to avoid obscuring the understanding of this description. Similarly, it should be understood that, in order to streamline the present disclosure and facilitate understanding of one or more of the various inventive aspects, in the above description of exemplary embodiments of the present disclosure, various features of the present disclosure are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed approach should not be interpreted as reflecting a schematic representation that the claimed disclosure requires more features than are expressly recited in each claim.More specifically, as reflected in the following claims, inventive aspects lie in less than all features of a single disclosed embodiment. The claims following this detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of the present disclosure. Furthermore, those skilled in the art will appreciate that while some embodiments described herein may include some features and not others, combinations of features from different embodiments are intended to fall within the scope of the present disclosure and form distinct embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination. The foregoing descriptions are merely preferred embodiments of the present disclosure, but the scope of the present disclosure is not limited thereto. Any variations or substitutions readily conceivable by those skilled in the art within the technical scope of this disclosure are intended to be encompassed by the scope of this disclosure. Therefore, the scope of the present disclosure should be determined by the scope of the claims.
Claims
Claims 1. A method for testing a routing matching algorithm, wherein: The method is applied to a test device, and includes: generating a test message and a routing forwarding rule corresponding to each routing entry based on preset routing entries and device information of the device to be tested; the test message and the routing forwarding rule both include a next hop identifier, the next hop identifier in the test message is used to represent the next hop address in the routing entry corresponding to the test message, and the next hop identifier in the routing forwarding rule is used to represent the next hop address in the routing entry corresponding to the routing forwarding rule; issuing the routing forwarding rule to the device to be tested and sending the test message corresponding to each routing entry; receiving multiple target test messages returned by the device to be tested, the target test message being obtained by the device to be tested based on the routing forwarding rule corresponding to the routing entry and the test message processed, the target test message including the next hop identifier and the target identifier, the target identifier being used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device to be tested; and determining whether the routing matching algorithm is abnormal based on the multiple target test messages.
2. The method according to claim 1, wherein: Based on preset routing entries and device information of the device to be tested, test messages and routing forwarding rules corresponding to each routing entry are generated, including: determining a parameter expression corresponding to the device information; converting the next hop address in each routing entry into a next hop identifier represented by the parameter expression, and obtaining the routing forwarding rule and test message for each routing entry.
3. The method according to claim 1, wherein: The generating, based on preset routing entries and device information of the device to be tested, respectively, a test message corresponding to each routing entry includes: in a case where no overlapping routing entries exist among the routing entries, using a network address in a routing prefix of each routing entry as a first destination address in a test message corresponding to each routing entry, and generating a test message corresponding to each routing entry based on the first destination address and the device information; the overlapping routing entries are routing entries in which the routing entries have some of the same network segments; in a case where overlapping routing entries exist among the routing entries, determining a second destination address of the test message corresponding to each routing entry based on a routing prefix in the overlapping routing entry and a routing prefix in each routing entry, and generating a test message corresponding to each routing entry based on the second destination address and the device information.
4. The method according to claim 3, wherein: Determining the second destination address of the test message corresponding to each routing entry based on the routing prefix in the overlapping routing entry and the routing prefix in each routing entry includes: determining a first network address set corresponding to the overlapping routing entry based on the routing prefix in the overlapping routing entry; and, determining a second network address set corresponding to each routing entry based on the routing prefix in each routing entry; determining a union of the first network address set and the second network address set; and selecting an address from the union as the second destination address.
5. The method according to any one of claims 1 to 4, wherein: Determining whether the routing matching algorithm is abnormal based on the multiple target test messages includes: Obtaining a test result of the routing matching algorithm for each target test message based on the target identifier and the next hop identifier included in each target test message; In a case where the target identifier and the next hop identifier included in each target test message are the same, the test result indicates that the route matching algorithm test for each target test message passes; A final test result of the route matching algorithm is obtained based on the test result. When the test result of each target test message indicates that the test has passed, the final test result indicates that the test has passed.
6. A method for testing a routing matching algorithm, wherein: The method is applied to a device to be tested, and includes: receiving a test message and a routing forwarding rule corresponding to each routing entry sent by the test device; the test message includes a next hop identifier, and the next hop identifier is used to represent the next hop address in the routing entry corresponding to the test message; using a routing matching algorithm to be tested, based on the routing forwarding rule corresponding to each routing entry, generating a target test message corresponding to each test message, the target test message including the next hop identifier and a target identifier, and the target identifier is used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm; and sending each of the target test messages to the test device.
7. The method according to claim 6, wherein: The method comprises: using the route matching algorithm to be tested and, based on the route forwarding rule corresponding to each route entry, respectively generating a target test message corresponding to each test message, including: using the route matching algorithm to be tested and, from each of the route forwarding rules, searching for a target route forwarding rule that matches each of the test messages; storing a next hop identifier in the target route forwarding rule as a target identifier in the test message that matches the target route forwarding rule, to obtain a target test message of the test message that matches the target route forwarding rule.
8. A test system for a routing matching algorithm, wherein: include: Test equipment and equipment to be tested; The testing device is used to execute the testing method of the routing matching algorithm according to any one of claims 1 to 5; The device to be tested is used to execute the testing method of the routing matching algorithm according to any one of claims 6-7.
9. A test device for a routing matching algorithm, wherein: The system is applied to a test device and includes: a first generating module, configured to generate a test message and a routing forwarding rule corresponding to each routing entry based on preset routing entries and device information of the device to be tested; the test message and the routing forwarding rule both include a next hop identifier, the next hop identifier in the test message is used to represent the next hop address in the routing entry corresponding to the test message, and the next hop identifier in the routing forwarding rule is used to represent the next hop address in the routing entry corresponding to the routing forwarding rule; a first sending module, configured to issue the routing forwarding rule to the device to be tested and send the test message corresponding to each routing entry; a first receiving module, configured to receive a plurality of target test messages returned by the device to be tested, the target test messages being obtained by the device to be tested based on the routing forwarding rule corresponding to the routing entry and the test message processed, the target test messages including the next hop identifier and a target identifier, the target identifier being used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm in the device to be tested; and a determining module, configured to determine whether the routing matching algorithm is abnormal based on the plurality of target test messages.
10. A test device for a routing matching algorithm, wherein: Applicable to the equipment under test, including: a second receiving module, configured to receive a test message and a routing forwarding rule corresponding to each routing entry sent by a test device; the test message including a next hop identifier, which is used to represent the next hop address in the routing entry corresponding to the test message; a second generating module, configured to employ a routing matching algorithm to be tested and, based on the routing forwarding rule corresponding to each routing entry, generate a target test message corresponding to each test message, the target test message including the next hop identifier and a target identifier, which is used to represent the next hop identifier in the routing forwarding rule matched by the routing matching algorithm; and a second sending module, configured to send each target test message to the test device.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: The processor runs the computer program to implement the method according to any one of claims 1 to 5 or any one of claims 6 to 7.
12. A computer-readable storage medium having a computer program stored thereon, wherein: The program is executed by a processor to implement the method according to any one of claims 1 to 5 or any one of claims 6 to 7.
13. A program product, wherein The method comprises a computer program, which implements the method according to any one of claims 1 to 5 or any one of claims 6 to 7 when executed by a processor. 16
Citation Information
Patent Citations
Method and device for detecting link packet changing
CN105591830A
Link layer path detection method, device and system
CN109412851A
Static routing test method and device
CN110808906A
Gateway forwarding anomaly detection method and device, medium and product
CN114826987A