Message forwarding method, device, communication equipment and storage medium
By employing a binary search method and ARP request verification of the outgoing interface in the switch, combined with the Redis message mechanism to handle route changes, the problem of low efficiency in outgoing interface lookup in policy routing is solved, achieving efficient and flexible packet forwarding.
Patent Information
- Application Number
- CN202310073766.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-29
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2043-01-29
AI Technical Summary
In existing technologies, policy-based routing based on switches is inefficient and inaccurate in finding interfaces, resulting in decreased packet forwarding efficiency.
The system employs a binary search method to retrieve routing table information and verifies the accuracy of the interface through ARP requests. It also combines the Redis message mechanism to process routing change information, achieving asynchronous merging and offsetting.
It improves the efficiency and accuracy of outgoing interface lookup, enhances the efficiency and flexibility of packet forwarding, and ensures rapid response capabilities when routes change.
Smart Images

Figure CN116192743B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and in particular to a message forwarding method, device, communication equipment and storage medium. Background Art
[0002] During network communication, packets are forwarded by configuring the next hop for the packets. Ordinary routing can only forward packets based on the network segment where the packet's destination IP address is located. Policy routing is an effective enhancement of the traditional IP routing mechanism, with stronger control over packets. It can forward packets based on the third-layer source IP or destination IP, the second-layer source MAC and destination MAC addresses, or even the fourth-layer port number.
[0003] Currently, based on the data packets received by the switch at the interface, refer to Figure 6 The schematic diagram of the architecture of message forwarding in the prior art shown in the figure, based on the principle of access control lists (AccessControlLists, ACL), adopts the inbound direction specified policy of ACL to achieve the purpose of policy routing filtering data messages, detects the message header, and when it is detected that a data message matching the corresponding data flow classification characteristics passes through, searches for the corresponding policy routing table entry, and implements the policy routing function according to the next hop IP address or the default route IP address specified by the policy routing table entry.
[0004] However, the current policy routing function requires an IP address that can be used to find the outbound interface. All routing tables must be traversed to find the outbound interface based on the IP address. When a large number of routes are configured on the device or the routes change frequently, the speed of finding the outbound interface is slow and the accuracy is low, which greatly reduces the efficiency of finding the policy routing outbound interface and further affects the efficiency of packet forwarding. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a message forwarding method, apparatus, system, communication device and storage medium to solve the problem that the prior art cannot efficiently and accurately find the outgoing interface, so as to achieve efficient message forwarding. The specific technical solution is as follows:
[0006] In a first aspect of the present invention, a message forwarding method is first provided, the method comprising:
[0007] When the switch input interface receives a message, the output interface of the switch is searched according to the next hop IP address pre-configured by the policy routing of the input interface;
[0008] Verify the outbound interface of the switch through an ARP request to determine the target outbound interface;
[0009] A forwarding path is determined according to the target outbound interface, and the message is forwarded to the next hop.
[0010] Optionally, when the switch inbound interface receives a message, searching the outbound interface of the switch according to the next-hop IP address pre-configured by the policy routing of the inbound interface includes:
[0011] In the case where the switch input interface receives a message, a binary search method is used to search for routing table information;
[0012] The routing table information is matched according to the next-hop IP address configured by the policy routing of the inbound interface; and the outbound interface corresponding to the next-hop IP address is determined according to the matching result.
[0013] Optionally, verifying the outbound interface of the switch through an ARP request to determine the target outbound interface includes:
[0014] Sending an ARP request, wherein the ARP request includes a correspondence between an IP address and a MAC address;
[0015] According to the ARP request, query the FDB table entry, wherein the FDB table entry includes a correspondence between a MAC address and an outbound interface;
[0016] The IP address of the ARP request and the outbound interface of the FDB table entry are verified to obtain a corresponding relationship between the IP address and the outbound interface, and determine the target outbound interface.
[0017] Optionally, determining a forwarding path according to the target outbound interface and forwarding the message to a next hop includes:
[0018] According to the target outbound interface, obtain the routing information of the next hop in the routing table;
[0019] According to the routing information, query the routing device corresponding to the next hop IP address to determine the forwarding path;
[0020] The message is forwarded to the routing device corresponding to the next-hop IP address according to the forwarding path.
[0021] Optionally, the determining a forwarding path according to the target outbound interface and forwarding the message to a next hop further includes:
[0022] Obtain routing change information through the redis message mechanism;
[0023] caching the route change information and preprocessing the route change information;
[0024] According to the preprocessed route change information, the next hop IP address pre-configured by the policy routing of the inbound interface is updated.
[0025] Optionally, the caching the route change information and preprocessing the route change information includes:
[0026] Cache the acquired route change information into a preset queue according to the route change sequence;
[0027] Obtaining the route change information of the head of the preset queue, and performing asynchronous merging or offsetting processing on the route change information of the head of the queue;
[0028] Cache pre-processed route change information.
[0029] Optionally, updating the next hop IP address pre-configured for the policy routing of the inbound interface according to the pre-processed routing change information includes:
[0030] Modifying the preprocessed route change information according to the preprocessed route change information;
[0031] The processed route change information is obtained, and the next hop IP address pre-configured by the policy routing of the inbound interface is updated so that the message is forwarded to the updated next hop.
[0032] In a second aspect of the present invention, a message forwarding device is provided, the device comprising:
[0033] A search module, used for searching the output interface of the switch according to the next hop IP address pre-configured by the policy routing of the input interface when the switch input interface receives the message;
[0034] A determination module, used to verify the outbound interface of the switch through an ARP request and determine the target outbound interface;
[0035] The forwarding module is used to determine a forwarding path according to the target outbound interface and forward the message to the next hop.
[0036] Optionally, the search module includes:
[0037] A search submodule, used for searching routing table information by using a binary search method when the switch input interface receives a message;
[0038] A matching submodule, used to match the routing table information according to the next hop IP address configured by the policy routing of the inbound interface;
[0039] The first determination submodule is used to determine the outbound interface corresponding to the next-hop IP address according to the matching result.
[0040] Optionally, the determining module includes:
[0041] A sending submodule, used to send an ARP request, wherein the ARP request includes a correspondence between an IP address and a MAC address;
[0042] A query submodule, used to query an FDB table entry according to the ARP request, wherein the FDB table entry includes a correspondence between a MAC address and an outbound interface;
[0043] The second determination submodule is used to verify the IP address of the ARP request and the outbound interface of the FDB table entry, obtain the corresponding relationship between the IP address and the outbound interface, and determine the target outbound interface.
[0044] Optionally, the forwarding module includes:
[0045] An acquisition submodule, used to acquire the routing information of the next hop in the routing table according to the target outbound interface;
[0046] A third determination submodule is used to query the routing device corresponding to the next hop IP address according to the routing information to determine the forwarding path;
[0047] The forwarding submodule is used to forward the message to the routing device corresponding to the next-hop IP address according to the forwarding path.
[0048] Optionally, the device further comprises:
[0049] The acquisition module is used to obtain route change information through the redis message mechanism;
[0050] A processing module, used for caching the route change information and preprocessing the route change information;
[0051] The updating module is used to update the next hop IP address pre-configured by the policy routing of the inbound interface according to the pre-processed routing change information.
[0052] Optionally, the processing module includes:
[0053] A first cache submodule, configured to cache the acquired route change information into a preset queue according to the route change sequence;
[0054] A first processing submodule is used to obtain the route change information of the head of the preset queue, and perform asynchronous merging or offsetting processing on the route change information of the head of the queue;
[0055] The second cache submodule is used to cache the pre-processed route change information.
[0056] Optionally, the update module includes:
[0057] A second processing module, configured to modify the preprocessed route change information according to the preprocessed route change information;
[0058] The update submodule is used to obtain the processed route change information and update the next hop IP address pre-configured by the policy routing of the inbound interface so as to forward the message to the updated next hop.
[0059] In a third aspect of the implementation of the present invention, there is also provided a communication device, comprising: a transceiver, a memory, a processor, and a program stored in the memory and executable on the processor;
[0060] The processor is used to read the program in the memory to implement the message forwarding method described in any one of the first aspects above.
[0061] In a fourth aspect of the implementation of the present invention, a computer-readable storage medium is further provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes any of the message forwarding methods described in the first aspect above.
[0062] The message forwarding method provided by the embodiment of the present invention, when the switch input interface receives the message, searches for the output interface of the switch according to the next hop IP address pre-configured by the policy routing of the input interface, that is, according to the next hop IP address pre-configured by the policy routing, combined with the data structure of the output interface information, realizes rapid search, and improves the search efficiency of the output interface; verifies the output interface of the switch through an ARP request, determines the target output interface, and adopts the ARP request method to verify the accuracy of the corresponding relationship between the IP address and the output interface, so as to accurately find the next hop specified by the IP address, ensure the accuracy of the target output interface, thereby determining the forwarding path according to the target output interface, and forwarding the message to the next hop. The present invention accelerates the search rate by searching for the output interface according to the IP address, and in the process of determining the target output interface, further introduces the ARP request to achieve the effect of accurately searching for the output interface, thereby improving the function of searching for the output interface based on the policy routing, and realizing efficient and flexible message forwarding. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.
[0064] Figure 1 One of the step flow charts of a message forwarding method provided by an embodiment of the present invention;
[0065] Figure 2 yes Figure 1 A method flow chart of step 102 of a message forwarding method provided by an embodiment of the present invention;
[0066] Figure 3 This is a second step flow chart of a message forwarding method provided by an embodiment of the present invention;
[0067] Figure 4 yes Figure 3 A method flow chart of step 105 of a message forwarding method provided by an embodiment of the present invention;
[0068] Figure 5 is a device block diagram of a message forwarding device provided by an embodiment of the present invention;
[0069] Figure 6 It is a schematic diagram of the architecture of a message forwarding method in the prior art provided by an embodiment of the present invention;
[0070] Figure 7 It is a schematic diagram of an application scenario of the message forwarding method provided by an embodiment of the present invention;
[0071] Figure 8 It is a schematic diagram of route change information in the message forwarding method provided by an embodiment of the present invention;
[0072] Fig. 9 It is a structural diagram of a communication device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0073] To make the purpose, technical scheme and advantages of the embodiments of the present invention clearer, the embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings. However, it will be appreciated by those skilled in the art that in the embodiments of the present invention, many technical details are proposed in order to enable the reader to better understand the present application. However, even without these technical details and various changes and modifications based on the following embodiments, the technical scheme claimed in the present application can be implemented. The division of the following embodiments is for the convenience of description, and should not constitute any limitation on the specific implementation of the present invention. The various embodiments can be combined and referenced with each other without contradiction.
[0074] Reference Figure 1 , shows one of the step flow charts of the message forwarding method provided by an embodiment of the present invention, the method may include:
[0075] Step 101, when the switch inbound interface receives a message, the switch outbound interface is searched according to the next hop IP address pre-configured by the policy routing of the inbound interface.
[0076] In an embodiment of the present invention, in order to enable the switch to forward received data packets to a routing device specified by a user, a policy routing is set on the interface of the switch for receiving packets. The switch detects the received data packets at the interface. When the switch receives packets at the input interface, if a data packet matching the corresponding data flow classification feature is detected, the corresponding policy routing table entry is searched, and the output interface of the switch is searched according to the next hop IP address pre-configured in the policy routing table entry, so as to forward the packet to the next hop through the output interface.
[0077] It should be noted that Policy Based Routing (PBR) is a mechanism for forwarding messages according to certain policies. Each policy defines one or more matching rules and corresponding operations. Figure 7 , Figure 7 It is a schematic diagram of the application scenario of the message forwarding method provided by an embodiment of the present invention. The input interface of the switch is used to receive messages. After an input interface applies policy routing, all messages received by the interface will be checked. The messages that meet the policy will be processed according to the operations defined in the policy. The policy routing of the input interface can be based on the third-layer source IP or destination IP, the second-layer source MAC and destination MAC address, or even the fourth-layer port number. The route is selected according to the field in the data message to make the method of finding the output interface more flexible.
[0078] Specifically, in step 101, when the switch inbound interface receives a message, searching the switch outbound interface according to the next hop IP address pre-configured by the policy routing of the inbound interface may include the following steps:
[0079] First, when the switch inbound interface receives a message, a binary search method is used to search for routing table information;
[0080] Secondly, match the routing table information according to the next-hop IP address configured by the policy routing of the inbound interface;
[0081] Secondly, based on the matching result, determine the outbound interface corresponding to the next-hop IP address.
[0082] It should be noted that, in order to solve the problem that the prior art needs to traverse all routing tables in the process of finding the outgoing interface through the IP address, when a large number of routes are configured on the device, or the routing information changes frequently, it will lead to a very low efficiency in finding the outgoing interface. In the embodiment of the present invention, when the switch inbound interface receives a message, a binary search method is used to search for routing table information. Since the routing table uses a MAP data structure. The data structure of MAP is characterized by the use of a red-black tree, in which the KEY values are all sorted, and the use of a binary search method requires that the data to be searched is itself ordered.
[0083] In this embodiment, when the switch input interface receives a message, a binary search method is used to search the routing table information, and the routing table information is matched according to the next-hop IP address configured by the policy routing of the input interface. According to the matching result, the output interface corresponding to the next-hop IP address is determined to meet the demand for fast search, so that the routing table can be quickly searched even when there are a lot of routes, further improving the efficiency of the output interface search.
[0084] Step 102: Verify the outbound interface of the switch through an ARP request to determine the target outbound interface.
[0085] In the embodiment of the present invention, after searching for the outbound interface of the switch according to the next-hop IP address pre-configured according to the policy routing of the inbound interface, since the next-hop IP address may be a routing address generated by other routing protocols, or configured statically, in order to ensure the accuracy of the outbound interface, the outbound interface of the switch that is searched is verified through an ARP request. When the verification passes, the outbound interface of the switch that is searched according to the next-hop IP address is determined as the target outbound interface.
[0086] It should be noted that in this embodiment, the ARP request method is used to verify the accuracy of the correspondence between the IP address and the outbound interface. ARP (Address Resolution Protocol) is a TCP / IP protocol that obtains the MAC address based on the IP address. When the switch sends information, it broadcasts the ARP request containing the IP address to all routes on the local area network, and receives the return message to determine the target MAC address. The host on the local area network can autonomously send an ARP reply message. For example, the ARP request is sent regularly according to the IP address in the next hop, wherein the information received by the ARP request contains the correspondence between IP and MAC. According to the ARP request, the FDB table entry is queried. The FDB table entry contains the correspondence between the switch outbound interface and the destination MAC address of the message, that is, the FDB table entry contains the correspondence between MAC and the outbound interface, thereby obtaining the correspondence between the IP address and the interface, which can ensure that the next hop determined according to the outbound interface is the next hop specified by the IP address configured by the user, and realize more accurate forwarding of messages.
[0087] In the embodiment of the present invention, in the process of determining the target outgoing interface, an ARP request is introduced to achieve the effect of accurately finding the outgoing interface, thereby improving the function of finding the message forwarding outgoing interface based on policy routing and realizing efficient and flexible message forwarding.
[0088] Step 103: determine the forwarding path according to the target outbound interface and forward the message to the next hop.
[0089] In the embodiment of the present invention, after receiving the data message, the switch selects a forwarding path according to the next-hop IP address pre-configured in the policy routing table entry and the target outbound interface to determine the next-hop routing device, and forwards the message to the next-hop routing device, thereby achieving efficient and flexible message forwarding.
[0090] Specifically, according to the target outbound interface, the routing information of the next hop in the routing table is obtained, and according to the routing information, the routing device corresponding to the next hop IP address is queried to determine the forwarding path, and the message is forwarded to the routing device corresponding to the next hop IP address according to the forwarding path.
[0091] The message forwarding method provided by the embodiment of the present invention, when the switch input interface receives the message, searches for the output interface of the switch according to the next hop IP address pre-configured by the policy routing of the input interface, that is, according to the next hop IP address pre-configured by the policy routing, combined with the data structure of the output interface information, realizes rapid search, and improves the search efficiency of the output interface; verifies the output interface of the switch through an ARP request, determines the target output interface, and adopts the ARP request method to verify the accuracy of the corresponding relationship between the IP address and the output interface, so as to accurately find the next hop specified by the IP address, ensure the accuracy of the target output interface, thereby determining the forwarding path according to the target output interface, and forwarding the message to the next hop. The present invention accelerates the search rate by searching for the output interface according to the IP address, and in the process of determining the target output interface, further introduces the ARP request to achieve the effect of accurately searching for the output interface, thereby improving the function of searching for the output interface based on the policy routing, and realizing efficient and flexible message forwarding.
[0092] Further, refer to Figure 2 , Figure 2 yes Figure 1 The method flow chart of step 102 of the message forwarding method provided in the embodiment of the present invention, step 102 includes:
[0093] Step 1021: Send an ARP request, wherein the ARP request includes a correspondence between an IP address and a MAC address.
[0094] Specifically, the advantage of specifying the next-hop IP address is that the outbound interface can be changed dynamically according to the state of the link. For the next-hop routing device that determines the target outbound interface, it is necessary to verify whether the correspondence between the next-hop IP address and the outbound interface is accurate. This is done by sending an ARP request, where the ARP request includes the correspondence between the IP address and the MAC address, so as to verify whether the correspondence between the next-hop IP address and the outbound interface is accurate based on the correspondence between the MAC address and the outbound interface obtained in the next step.
[0095] It should be noted that policy routing can forward messages based on the source IP or destination IP of the third layer, the source MAC and destination MAC address of the second layer, or even the port number of the fourth layer. Therefore, policy routing is an effective enhancement of the traditional IP routing mechanism. The embodiment of the present invention does not specifically limit the specific location of the output interface determined by policy routing, and any output interface that meets the verification conditions can be used, so that the route can be selected according to the fields in the data message, and more flexible message forwarding can be achieved.
[0096] Step 1022: query the FDB table entry according to the ARP request, wherein the FDB table entry includes the correspondence between the MAC address and the outbound interface.
[0097] Step 1023: Verify the IP address of the ARP request and the outbound interface of the FDB entry, obtain the corresponding relationship between the IP address and the outbound interface, and determine the target outbound interface.
[0098] It should be noted that in the above steps 1021-1023, the ARP request method is used to verify the accuracy of the correspondence between the IP address and the outgoing interface. First, according to the IP address in the next hop, an ARP request is sent, wherein the ARP request includes the correspondence between the IP address and the MAC address; in response to the ARP request, the FDB table entry is queried, and the FDB table entry contains the correspondence between the MAC address and the outgoing interface. According to the ARP request and the MAC address of the FDB table entry, the IP address and the outgoing interface associated with the MAC address are determined, and the IP address of the ARP request and the outgoing interface of the FDB table entry are verified to obtain the correspondence between the IP address and the outgoing interface. After the verification is passed, the target outgoing interface is determined, so that the next hop can be guaranteed to be the next hop actually required, that is, the next hop specified by the IP address configured by the user is finally found.
[0099] In this embodiment, an ARP request is sent to query the FDB table entry, the IP address of the ARP request and the outgoing interface of the FDB table entry are verified, the correspondence between the IP address and the outgoing interface is obtained, and the target outgoing interface is determined. That is, the correspondence between the IP and the outgoing interface is verified by using the ARP request method, thereby verifying the accuracy of the correspondence between the IP address and the outgoing interface, thereby greatly improving the accuracy of determining the target outgoing interface, further improving the accuracy and success rate of message forwarding, and achieving efficient message forwarding.
[0100] Reference Figure 3 , shows a second step flow chart of the message forwarding method provided by an embodiment of the present invention, the method may include:
[0101] Step 101, when the switch inbound interface receives a message, the switch outbound interface is searched according to the next hop IP address pre-configured by the policy routing of the inbound interface.
[0102] Step 102: Verify the outbound interface of the switch through an ARP request to determine the target outbound interface.
[0103] Step 103: determine the forwarding path according to the target outbound interface and forward the message to the next hop.
[0104] The above steps 101-103 are referred to the previous discussion and will not be repeated here.
[0105] Step 104: Obtain route change information through the redis message mechanism.
[0106] In the embodiment of the present invention, the existing method is to register a callback function to obtain route change notifications, that is, to register a function in the process of route change, so that the next hop is updated when the route changes. However, if a large number of routes are added or deleted, the existing method of updating the next hop is to update one by one according to the route changes, which will result in very slow update efficiency, thereby affecting message forwarding. Therefore, in order to improve the efficiency of updating when the route changes, this embodiment introduces an asynchronous mode processing method, that is, using the redis message mechanism to obtain route change information.
[0107] It should be noted that, in this embodiment, the redis message mechanism is used and implemented using the List type. The message queue is mainly implemented by storing and reading through lpush and rpop. lpush can store the latest message at the head of the message queue (List collection), and rpop can read the tail of the message queue, thus realizing first-in-first-out.
[0108] In order to enable those skilled in the art to more clearly understand the message forwarding method disclosed in the above embodiments of the present invention, refer to Figure 8 The schematic diagram of the route change information shown in the figure shows that the acquired route information is stored in the form of a preset queue, and the route change information is acquired from the head of the queue for preprocessing. At this time, the updated route change information is appended to the tail of the queue, and the processing of route changes is optimized from synchronous one-by-one processing to asynchronous merging processing, which improves the processing efficiency of the next hop change caused by the route change, and further realizes efficient message forwarding. Of course, the above is only a specific example. In actual use, step 104 can also obtain route change information through other methods of the redis message mechanism, which will not be repeated here.
[0109] Step 105: cache the route change information and pre-process the route change information.
[0110] In the embodiment of the present invention, the route change information is cached as a preset queue, and the route change information is obtained from the head of the queue for pre-processing.
[0111] Specifically, when there are many routing changes, the routing change information obtained by the cache may have a relationship where the changes cancel each other out. Therefore, among a large number of routing change messages, many can be merged and processed. For example, when the IP address of a certain interface of the router changes to another interface, all routing information of the former interface will be deleted, and the routing of the latter interface will be added. If the two interfaces are connected to many other routing devices, and there are many other network segments in these routing devices, there will be a large number of routing deletions and additions. Since the added and deleted routing information is the same, according to the cached routing change information, it can be pre-processed first, and some routing information can be merged, and then some modifications can be made to the pre-processed routing change information through policy routing to achieve the purpose of improving the update efficiency.
[0112] Step 106: Update the next hop IP address pre-configured by the policy routing of the inbound interface according to the pre-processed route change information.
[0113] In steps 104-106, after the forwarding path is determined according to the target outbound interface and the message is forwarded to the next hop, the route change information is obtained through the redis message mechanism, the route change information is cached, the route change information is pre-processed, and the next hop IP address pre-configured by the policy routing of the inbound interface is updated according to the pre-processed route change information. The processing process of route changes can be optimized from synchronous one-by-one processing to asynchronous merging processing, so as to improve the processing speed of next hop changes caused by route changes.
[0114] It should be noted that the present embodiment does not limit the specific execution location of steps 104-106. In the present embodiment, for ease of understanding, the execution of steps 104-106 after step 103 is taken as an example for explanation. In actual use, steps 104-106 may also be performed before step 101, and each case will not be described one by one here.
[0115] The message forwarding method provided by the embodiment of the present invention introduces an asynchronous mode of processing and adopts the form of a redis message mechanism to pre-process the route change information first, thereby realizing rapid update processing of the route change information, thereby obtaining the next-hop IP address pre-configured by the updated policy routing of the incoming interface. Compared with the prior art, the introduction of asynchronous processing can significantly improve the efficiency of real-time message forwarding, and the processing process of the route change is optimized from synchronous one-by-one processing to asynchronous merging processing, so as to achieve the improvement of the processing process of the next-hop change caused by the route change. In terms of function, in the process of finding the outgoing interface according to the IP address, the function of finding the outgoing interface is further consolidated, thereby improving the function and performance of the policy routing.
[0116] Further, refer to Figure 4 , Figure 4 yes Figure 3 The method flow chart of step 105 of the message forwarding method provided in the embodiment of the present invention, step 105 includes:
[0117] Step 1051, cache the acquired route change information into a preset queue according to the route change sequence.
[0118] In an embodiment of the present invention, in order to realize asynchronous processing of route change information, a redis message mechanism is adopted, and lpush and rpop are used to store and read message queues. According to the route change sequence, the acquired route change information is cached in a preset queue. lpush caches the latest route change information at the head of the preset queue, and caches the latest updated route change information at the tail of the preset queue, thereby realizing asynchronous processing of route change messages in a first-in-first-out manner.
[0119] Step 1052, obtaining the route change information of the head of the preset queue, and performing asynchronous merging or offsetting processing on the route change information of the head of the queue.
[0120] It should be noted that, in this embodiment, the time and quantity of obtaining the route change information of the head of the preset queue are not specifically limited. The route change information updated within the preset time of the head of the preset queue can be obtained regularly, and the route change information of the head of the queue can be asynchronously merged or offset; the update of the route change information can also be monitored in real time. If the route change information is updated, the route change information of the head of the preset queue is obtained, and the route change information of the head of the queue is asynchronously merged or offset. Of course, the above is only a specific example. In actual use, obtaining the route change information of the head of the preset queue can also be set according to the actual message forwarding requirements, which will not be repeated here.
[0121] Step 1053: cache the pre-processed route change information.
[0122] It should be noted that in the above steps 1051-1053, the obtained route change information is cached in a preset queue according to the route change sequence, the route change information at the head of the preset queue is obtained, the route change information at the head of the queue is asynchronously merged or offset, and the pre-processed route change information is cached, so as to update the next-hop IP address pre-configured by the policy routing of the input interface according to the pre-processed route change information.
[0123] In this embodiment, by caching route change information, it can be pre-processed first, merged or offset some route change information, and then the pre-processed route change information can be modified by policy routing, saving data processing resources and reducing the processing workload of route change information, effectively improving the efficiency of message forwarding.
[0124] Specifically, step 106 updates the next hop IP address pre-configured by the policy routing of the inbound interface according to the pre-processed route change information, and may include the following steps:
[0125] Firstly, modifying the preprocessed route change information according to the preprocessed route change information;
[0126] Secondly, the processed route change information is obtained, and the next hop IP address pre-configured by the policy routing of the inbound interface is updated so that the message is forwarded to the updated next hop.
[0127] In this embodiment, after obtaining the route change information of the head of the preset queue, asynchronously merging or offsetting the route change information of the head of the queue, and caching the preprocessed route change information, the preprocessed route change information is modified based on the preprocessed route change information to optimize the route change information and avoid preprocessing errors such as merging or offsetting, thereby obtaining the processed route change information and updating the next hop IP address pre-configured by the policy routing of the inbound interface to forward the message to the updated next hop.
[0128] Reference Figure 5 , shows a device block diagram of a message forwarding device provided by an embodiment of the present invention, and the device may include:
[0129] A search module 201 is used to search the output interface of the switch according to the next hop IP address pre-configured by the policy routing of the input interface when the switch input interface receives a message;
[0130] A determination module 202 is used to verify the outbound interface of the switch through an ARP request to determine a target outbound interface;
[0131] The forwarding module 203 is used to determine a forwarding path according to the target outbound interface and forward the message to the next hop.
[0132] Optionally, the search module 201 includes:
[0133] A search submodule, used for searching routing table information by using a binary search method when the switch input interface receives a message;
[0134] A matching submodule, used to match the routing table information according to the next hop IP address configured by the policy routing of the inbound interface;
[0135] The first determination submodule is used to determine the outbound interface corresponding to the next-hop IP address according to the matching result.
[0136] Optionally, the determining module 202 includes:
[0137] A sending submodule, used to send an ARP request, wherein the ARP request includes a correspondence between an IP address and a MAC address;
[0138] A query submodule, used to query an FDB table entry according to the ARP request, wherein the FDB table entry includes a correspondence between a MAC address and an outbound interface;
[0139] The second determination submodule is used to verify the IP address of the ARP request and the outbound interface of the FDB table entry, obtain the corresponding relationship between the IP address and the outbound interface, and determine the target outbound interface.
[0140] Optionally, the forwarding module 203 includes:
[0141] An acquisition submodule, used to acquire the routing information of the next hop in the routing table according to the target outbound interface;
[0142] A third determination submodule is used to query the routing device corresponding to the next hop IP address according to the routing information to determine the forwarding path;
[0143] The forwarding submodule is used to forward the message to the routing device corresponding to the next-hop IP address according to the forwarding path.
[0144] Optionally, the device further comprises:
[0145] The acquisition module is used to obtain route change information through the redis message mechanism;
[0146] A processing module, used for caching the route change information and preprocessing the route change information;
[0147] The updating module is used to update the next hop IP address pre-configured by the policy routing of the inbound interface according to the pre-processed routing change information.
[0148] Optionally, the processing module includes:
[0149] A first cache submodule, configured to cache the acquired route change information into a preset queue according to the route change sequence;
[0150] A first processing submodule is used to obtain the route change information of the head of the preset queue, and perform asynchronous merging or offsetting processing on the route change information of the head of the queue;
[0151] The second cache submodule is used to cache the pre-processed route change information.
[0152] Optionally, the update module includes:
[0153] A second processing module, configured to modify the preprocessed route change information according to the preprocessed route change information;
[0154] The update submodule is used to obtain the processed route change information and update the next hop IP address pre-configured by the policy routing of the inbound interface so as to forward the message to the updated next hop.
[0155] The message forwarding device provided by the embodiment of the present invention comprises a search module for searching the outgoing interface of the switch according to the next hop IP address pre-configured by the policy routing of the ingoing interface when the switch ingoing interface receives the message, that is, according to the next hop IP address pre-configured by the policy routing, a fast search is realized in combination with the data structure of the outgoing interface information, thereby improving the search efficiency of the outgoing interface; a determination module is used to verify the outgoing interface of the switch through an ARP request, determine the target outgoing interface, and use the ARP request method to verify the accuracy of the corresponding relationship between the IP address and the outgoing interface, so as to accurately find the next hop specified by the IP address, thereby ensuring the accuracy of the target outgoing interface; a forwarding module is used to determine the forwarding path according to the target outgoing interface, and forward the message to the next hop. The present invention accelerates the search rate by searching the outgoing interface according to the IP address, and in the process of determining the target outgoing interface, further introduces the ARP request to achieve the effect of accurately searching the outgoing interface, thereby improving the function of searching the outgoing interface for message forwarding based on the policy routing, thereby realizing efficient and flexible message forwarding.
[0156] The embodiment of the present invention also provides a communication device, such as Fig. 9 As shown, it includes a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302, and the memory 303 communicate with each other through the communication bus 304.
[0157] Memory 303, used for storing computer programs;
[0158] The processor 301, when used to execute the program stored in the memory 303, can implement the following steps:
[0159] When the switch inbound interface receives a message, it searches for the switch outbound interface based on the next-hop IP address pre-configured by the inbound interface's policy routing. It verifies the switch outbound interface through an ARP request to determine the target outbound interface. It determines the forwarding path based on the target outbound interface and forwards the message to the next hop.
[0160] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0161] The communication interface is used for communication between the above terminal and other devices.
[0162] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0163] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can 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 gates or transistor logic devices, discrete hardware components.
[0164] In another embodiment of the present invention, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the message forwarding method described in any one of the above embodiments.
[0165] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer executes the message forwarding method described in any one of the above embodiments.
[0166] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidStateDisk (SSD)), etc.
[0167] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0168] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0169] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A message forwarding method, characterized in that: The method comprises: When the switch input interface receives a message, searching the output interface of the switch according to the next-hop IP address pre-configured by the policy routing of the input interface; Verify the outbound interface of the switch through an ARP request to determine the target outbound interface; Determine a forwarding path according to the target outbound interface, and forward the message to the next hop; Obtain routing change information through the redis message mechanism; caching the route change information and preprocessing the route change information; According to the preprocessed route change information, the next hop IP address pre-configured by the policy routing of the inbound interface is updated.
2. The message forwarding method according to claim 1, characterized in that: When the switch input interface receives a message, searching the output interface of the switch according to the next hop IP address pre-configured by the policy routing of the input interface includes: In the case where the switch input interface receives a message, a binary search method is used to search for routing table information; Match the routing table information according to the next hop IP address configured by the policy routing of the inbound interface; According to the matching result, the outbound interface corresponding to the next-hop IP address is determined.
3. The message forwarding method according to claim 1, characterized in that ,, verifying the outbound interface of the switch through an ARP request to determine the target outbound interface includes: Sending an ARP request, wherein the ARP request includes a correspondence between an IP address and a MAC address; According to the ARP request, query the FDB table entry, wherein the FDB table entry includes a correspondence between a MAC address and an outbound interface; The IP address of the ARP request and the outbound interface of the FDB table entry are verified to obtain a corresponding relationship between the IP address and the outbound interface, and determine the target outbound interface.
4. The message forwarding method according to claim 1, characterized in that: The step of determining a forwarding path according to the target outbound interface and forwarding the message to a next hop includes: According to the target outbound interface, obtain the routing information of the next hop in the routing table; According to the routing information, query the routing device corresponding to the next hop IP address to determine the forwarding path; The message is forwarded to the routing device corresponding to the next-hop IP address according to the forwarding path.
5. The message forwarding method according to claim 1, characterized in that: The caching the route change information and preprocessing the route change information includes: Cache the acquired route change information into a preset queue according to the route change sequence; Obtaining the route change information of the head of the preset queue, and performing asynchronous merging or offsetting processing on the route change information of the head of the queue; Cache pre-processed route change information.
6. The message forwarding method according to claim 1, characterized in that: The updating of the next hop IP address pre-configured by the policy routing of the inbound interface according to the pre-processed routing change information includes: Modifying the preprocessed route change information according to the preprocessed route change information; The processed route change information is obtained, and the next hop IP address pre-configured by the policy routing of the inbound interface is updated so that the message is forwarded to the updated next hop.
7. A message forwarding device, characterized in that: The device comprises: A search module, configured to search for an outbound interface of the switch according to a next-hop IP address pre-configured by the policy routing of the inbound interface when the inbound interface of the switch receives a message; A determination module, used to verify the outbound interface of the switch through an ARP request and determine the target outbound interface; A forwarding module, used to determine a forwarding path according to the target outbound interface and forward the message to the next hop; The acquisition module is used to obtain route change information through the redis message mechanism; A processing module, used for caching the route change information and preprocessing the route change information; The updating module is used to update the next hop IP address pre-configured by the policy routing of the inbound interface according to the pre-processed routing change information.
8. A communication device, characterized in that: include: A transceiver, a memory, a processor, and a program stored on the memory and executable on the processor; The processor is used to read the program in the memory to implement the steps in the message forwarding method as described in any one of claims 1-6.
9. A readable storage medium for storing a program, characterized in that: When the program is executed by the processor, the steps in the message forwarding method as described in any one of claims 1 to 6 are implemented.
