CN116192743A - Message forwarding method, device, communication equipment and storage medium - Google Patents

Message forwarding method, device, communication equipment and storage medium Download PDF

Info

Publication number
CN116192743A
CN116192743A CN202310073766.1A CN202310073766A CN116192743A CN 116192743 A CN116192743 A CN 116192743A CN 202310073766 A CN202310073766 A CN 202310073766A CN 116192743 A CN116192743 A CN 116192743A
Authority
CN
China
Prior art keywords
interface
message
forwarding
address
change information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310073766.1A
Other languages
Chinese (zh)
Inventor
周国浪
郭巍松
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202310073766.1A priority Critical patent/CN116192743A/en
Publication of CN116192743A publication Critical patent/CN116192743A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]

Abstract

The embodiment of the invention provides a message forwarding method, a message forwarding device, communication equipment and a storage medium, comprising the following steps: under the condition that the switch inlet receives a message, a preset next-hop IP address is routed according to a strategy of the inlet, and an outlet of the switch is searched; verifying the outgoing interface of the switch through the ARP request to determine a target outgoing interface; and determining a forwarding path according to the target output interface, and forwarding the message to the next hop. According to the embodiment of the invention, the interface is searched out through the next hop IP address preconfigured by the policy route of the input interface, so that the searching speed of the message forwarding interface is improved, and in the process of determining the target output interface, an ARP request is introduced to achieve the effect of accurately searching out the interface, thereby improving the function of searching the message forwarding interface based on the policy route, and realizing efficient and flexible message forwarding.

Description

Message forwarding method, device, communication equipment and storage medium
Technical Field
The present invention relates to the field of network communications technologies, and in particular, to a method and apparatus for forwarding a message, a communication device, and a storage medium.
Background
In the network communication process, message forwarding is carried out by configuring a next hop mode for the message, wherein the common route can only carry out forwarding according to the network segment where the destination IP address of the message is located, the strategy route is effective enhancement of the traditional IP routing mechanism, has stronger control capability on the message, and can carry out message forwarding according to the source IP or the destination IP of three layers, the source MAC and the destination MAC address of two layers and even the port number of four layers.
At present, based on the data message received by the switch at the interface, referring to the architecture diagram of message forwarding in the prior art shown in fig. 6, according to the principle of the access control list (AccessControlLists, ACL), the goal of strategically routing and filtering the data message is achieved by adopting an entry direction designation strategy of an ACL, the message header is detected, when the data message matched with the classification characteristic of the corresponding data stream is detected to pass, the corresponding strategic routing table entry is searched, and the function of strategic routing is realized according to the next hop IP address or default routing IP address designated by the strategic routing table entry.
However, at present, an IP address capable of finding out an interface needs to be given to implement a policy routing function, and all routing tables must be traversed to find out an interface according to the IP address, so that when the number of routes configured on a device is large or the routes are frequently changed, the speed of finding out the interface is slow, the accuracy is not high, that is, the searching efficiency of the policy routing interface is greatly reduced, and the efficiency of forwarding a message is further affected.
Disclosure of Invention
The embodiment of the invention aims to provide a message forwarding method, a device, a system, communication equipment and a storage medium, which solve the problem that interfaces cannot be efficiently and accurately found out in the prior art so as to realize efficient message forwarding, and specifically adopts the following technical scheme:
In a first aspect of the present invention, there is first provided a method for forwarding a message, where the method includes:
under the condition that a switch input interface receives a message, a preset next-hop IP address is routed according to a strategy of the input interface, and an output interface of the switch is searched;
verifying the outgoing interface of the switch through an ARP request to determine a target outgoing interface;
and determining a forwarding path according to the target out interface, and forwarding the message to the next hop.
Optionally, in the case that the switch ingress interface receives a packet, the searching for the egress interface of the switch according to the preconfigured next hop IP address of the ingress interface policy route includes:
under the condition that the switch access interface receives the message, a binary search method is adopted to search the information of the routing table;
matching the routing table information according to the next hop IP address configured by the policy routing of the access interface; and determining an outgoing interface corresponding to the next hop IP address according to the matching result.
Optionally, the verifying the outgoing interface of the switch through the ARP request, determining the target outgoing interface, includes:
sending an ARP request, wherein the ARP request comprises a corresponding relation between an IP address and an MAC address;
Inquiring an FDB table item according to the ARP request, wherein the FDB table item comprises a corresponding relation between an MAC address and an output interface;
and verifying the IP address of the ARP request and the outbound interface of the FDB table entry to obtain the corresponding relation between the IP address and the outbound interface, and determining the target outbound interface.
Optionally, the determining a forwarding path according to the target outgoing interface, forwarding the packet to a next hop includes:
acquiring the route information of the next hop in the route table according to the target output interface;
inquiring routing equipment corresponding to the next hop IP address according to the routing information, and determining a forwarding path;
and forwarding the message to the routing equipment corresponding to the next-hop IP address according to the forwarding path.
Optionally, after determining a forwarding path according to the target outgoing interface and forwarding the packet to the next hop, the method further includes:
obtaining route change information through a redis message mechanism;
caching the route change information, and preprocessing the route change information;
and updating the preset next hop IP address of the strategy route of the access interface according to the preprocessed route change information.
Optionally, the caching the route change information, and preprocessing the route change information includes:
Caching the acquired route change information to a preset queue according to a route change time sequence;
acquiring route change information of the head of a queue in the preset queue, and carrying out asynchronous merging or counteracting treatment on the route change information of the head of the queue;
and caching the route change information after preprocessing.
Optionally, the updating the pre-configured next hop IP address of the policy route of the ingress interface according to the pre-processed route change information includes:
modifying the route change information after pretreatment according to the route change information after pretreatment;
and acquiring the processed route change information, and updating a preset next hop IP address of the policy route of the access interface so as to forward the message to the updated next hop.
In a second aspect of the present invention, there is also provided a packet forwarding apparatus, including:
the searching module is used for searching an outlet interface of the switch according to a preset next-hop IP address of a strategy route of the inlet interface under the condition that the switch inlet interface receives a message;
the determining module is used for verifying the outgoing interface of the switch through an ARP request and determining a target outgoing interface;
And the forwarding module is used for determining a forwarding path according to the target outgoing interface and forwarding the message to the next hop.
Optionally, the search module includes:
the searching sub-module is used for searching the routing table information by adopting a binary search method under the condition that the switch access interface receives the message;
a matching sub-module, configured to match the routing table information according to the next hop IP address configured by the policy routing of the ingress interface;
and the first determining submodule is used for determining an outgoing interface corresponding to the next hop IP address according to the matching result.
Optionally, the determining module includes:
a sending submodule, configured to send an ARP request, where the ARP request includes a correspondence between an IP address and an MAC address;
the inquiring submodule is used for inquiring FDB table entries according to the ARP request, wherein the FDB table entries comprise the corresponding relation between the MAC address and the output interface;
and the second determining submodule is used for verifying the IP address of the ARP request and the outgoing interface of the FDB table entry to obtain the corresponding relation between the IP address and the outgoing interface and determining the target outgoing interface.
Optionally, the forwarding module includes:
the obtaining submodule is used for obtaining the route information of the next hop in the route table according to the target output interface;
A third determining submodule, configured to query routing equipment corresponding to the next hop IP address according to the routing information, and determine a forwarding path;
and the forwarding sub-module is used for forwarding the message to the routing equipment corresponding to the next hop IP address according to the forwarding path.
Optionally, the apparatus further comprises:
the acquisition module is used for acquiring route change information through a redis message mechanism;
the processing module is used for caching the route change information and preprocessing the route change information;
and the updating module is used for updating the next hop IP address pre-configured by the policy route of the access interface according to the pre-processed route change information.
Optionally, the processing module includes:
the first buffer sub-module is used for buffering the acquired route change information to a preset queue according to the route change time sequence;
the first processing sub-module is used for acquiring the route change information of the head of the queue in the preset queue and carrying out asynchronous combination or offset processing on the route change information of the head of the queue;
and the second caching submodule is used for caching the preprocessed route change information.
Optionally, the updating module includes:
the second processing module is used for modifying the route change information after pretreatment according to the route change information after pretreatment;
And the updating sub-module is used for acquiring the processed route change information, updating the preset next hop IP address of the strategy route of the access interface, and forwarding the message to the updated next hop.
In a third aspect of the present invention, there is also provided a communication device comprising: a transceiver, a memory, a processor, and a program stored on the memory and executable on the processor;
the processor is configured to read a program in the memory to implement the method for forwarding a message according to any one of the first aspect.
In a fourth aspect of the present invention, there is also provided a computer readable storage medium having instructions stored therein, which when run on a computer, cause the computer to perform the method for forwarding a message according to any one of the first aspect.
According to the message forwarding method provided by the embodiment of the invention, under the condition that the switch input interface receives a message, the preset next-hop IP address is routed according to the strategy of the input interface, and the switch output interface is searched, namely, the preset next-hop IP address is routed according to the strategy, and the data structure of the interface information is combined, so that the quick search is realized, and the search efficiency of the output interface is improved; and verifying the outgoing interface of the switch through an ARP request, determining a target outgoing interface, verifying the accuracy of the corresponding relation between the IP address and the outgoing interface in an ARP request mode, facilitating the accurate finding of the next hop designated by the IP address, ensuring the accuracy of the target outgoing interface, determining a forwarding path according to the target outgoing interface, and forwarding the message to the next hop. The invention realizes the acceleration searching speed by searching the interface according to the IP address, further introduces ARP request to achieve the effect of precisely searching the interface in the process of determining the target out interface, thereby improving the function of searching the message forwarding out interface based on the strategy route and realizing the efficient and flexible message forwarding.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is one of the step flowcharts of a message forwarding method provided in an embodiment of the present invention;
fig. 2 is a flowchart of a method of step 102 of a message forwarding method according to the embodiment of the present invention shown in fig. 1;
FIG. 3 is a second flowchart of a message forwarding method according to an embodiment of the present invention;
fig. 4 is a flowchart of a method of step 105 of a message forwarding method according to the embodiment of the present invention shown in fig. 3;
fig. 5 is a device block diagram of a message forwarding device according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a packet forwarding method in the prior art according to an embodiment of the present invention;
fig. 7 is a schematic diagram of an application scenario of a message forwarding method provided by an embodiment of the present invention;
fig. 8 is a schematic diagram of route change information in a packet forwarding method according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a communication device according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the following detailed description of the embodiments of the present invention will be given with reference to the accompanying drawings. However, those of ordinary skill in the art will understand that in various embodiments of the present invention, numerous technical details have been set forth in order to provide a better understanding of the present application. However, the technical solutions claimed in the present application can be implemented without these technical details and with various changes and modifications based on the following embodiments. The following embodiments are divided for convenience of description, and should not be construed as limiting the specific implementation of the present invention, and the embodiments can be mutually combined and referred to without contradiction.
Referring to fig. 1, one of the step flowcharts of the packet forwarding method provided by the embodiment of the present invention is shown, where the method may include:
step 101, under the condition that the switch inlet receives the message, the preset next hop IP address is routed according to the strategy of the inlet, and the outlet of the switch is searched.
In the embodiment of the invention, in order to realize that the switch forwards the received data message to the routing equipment appointed by the user, the interface of the switch for receiving the message sets a strategy route, the switch detects the received data message at the interface, when the switch receives the message at the interface, and detects the data message matched with the classification characteristic of the corresponding data stream, the switch searches the corresponding strategy route list item, and searches the outgoing interface of the switch according to the next hop IP address preconfigured by the strategy route list item so as to be convenient for forwarding the message to the next hop through the outgoing interface.
It should be noted that, the policy routing (PolicyBasedRouting, PBR) is a mechanism for forwarding a message according to a certain policy, and each policy defines one or more matching rules and corresponding operations. Referring to fig. 7, fig. 7 is a schematic application scenario of a packet forwarding method provided by the embodiment of the present invention, where an ingress interface of a switch is configured to receive a packet, after a policy route is applied to an ingress interface, all packets received by the ingress interface are checked, the packets conforming to the policy are processed according to an operation defined in the policy, and the policy route of the ingress interface may be according to a three-layer source IP or a destination IP, or may be a two-layer source MAC and a destination MAC address, or even a four-layer port number, and the route is selected according to a field in a data packet, so that a manner of finding the interface is more flexible.
Specifically, step 101, when the switch ingress interface receives a packet, searches for an egress interface of the switch according to a preset next hop IP address of a policy route of the ingress interface, and may include the following steps:
firstly, under the condition that a switch access interface receives a message, a binary search method is adopted to search the information of a routing table;
secondly, according to the next hop IP address configured by the policy routing of the access interface, matching the routing table information;
and secondly, determining an outgoing interface corresponding to the next hop IP address according to the matching result.
It should be noted that, in order to solve the problem that in the prior art, in the process of finding out an interface through an IP address, all routing tables need to be traversed, when a large number of routes are configured on a device, or when route information changes frequently, the efficiency of finding out the interface is very low, in the embodiment of the present invention, when a switch receives a message through an interface, a binary search method is used to search for the information of the routing tables, and because the routing tables use MAP data structures. The data structure of MAP is characterized by adopting red black tree, wherein KEY values are ordered, and the binary search method is adopted to require the searched data to be ordered.
In this embodiment, when the switch ingress interface receives a packet, a binary search method is used to search the routing table information, the configured next hop IP address is routed according to the policy of the ingress interface, the routing table information is matched, and according to the matching result, the egress interface corresponding to the next hop IP address is determined, so as to meet the requirement of quick search, thereby quickly searching the routing table even under the condition of very many routes, and further improving the efficiency of searching the egress interface.
Step 102, verifying the outgoing interface of the switch through the ARP request, and determining the target outgoing interface.
In the embodiment of the invention, after searching the outgoing interface of the switch according to the preset next-hop IP address of the policy routing of the incoming interface, the outgoing interface of the switch searched according to the next-hop IP address is determined as a target outgoing interface when the verification passes because the next-hop IP address may be a routing address generated by other routing protocols or the configuration is static to ensure the accuracy of the outgoing interface.
It should be noted that, in this embodiment, the accuracy of the correspondence between the IP address and the outgoing interface is verified by using an ARP request method. ARP (Address resolution protocol) is a TCP/IP protocol for acquiring MAC address according to IP address, when the exchanger sends information, the ARP request containing IP address is broadcast to all routes on local area network, and receives return message, so as to determine target MAC address, host on local area network can autonomously send ARP response message. For example, an ARP request is sent periodically according to an IP address in a next hop, where the information requested by the ARP request has a correspondence between IP and MAC, and according to the ARP request, an FDB table entry is queried, where the FDB table entry has a correspondence between an outgoing interface of a switch and a destination MAC address of a message, that is, the FDB table entry has a correspondence between MAC and an outgoing interface, so as to obtain a correspondence between an IP address and an interface, and ensure that the next hop determined according to the outgoing interface is the next hop specified by the IP address configured by the user, thereby implementing more accurate forwarding of the message.
In the embodiment of the invention, in the process of determining the target output interface, the ARP request is introduced to achieve the effect of precisely finding out the interface, thereby improving the function of finding out the message forwarding output interface based on the strategy route and realizing efficient and flexible message forwarding.
And step 103, determining a forwarding path according to the target out interface, and forwarding the message to the next hop.
In the embodiment of the invention, after receiving the data message, the switch selects the forwarding path according to the next hop IP address preconfigured by the strategy routing table item and the target outgoing interface so as to determine the routing equipment of the next hop and forward the message to the routing equipment of the next hop, thereby realizing efficient and flexible message forwarding.
Specifically, according to the target out interface, the route information of the next hop in the route table is obtained, according to the route information, the route equipment corresponding to the next hop IP address is queried, the forwarding path is determined, and the message is forwarded to the route equipment corresponding to the next hop IP address according to the forwarding path.
According to the message forwarding method provided by the embodiment of the invention, under the condition that the switch input interface receives a message, the preset next-hop IP address is routed according to the strategy of the input interface, and the switch output interface is searched, namely, the preset next-hop IP address is routed according to the strategy, and the data structure of the interface information is combined, so that the quick search is realized, and the search efficiency of the output interface is improved; and verifying the outgoing interface of the switch through an ARP request, determining a target outgoing interface, verifying the accuracy of the corresponding relation between the IP address and the outgoing interface in an ARP request mode, facilitating the accurate finding of the next hop designated by the IP address, ensuring the accuracy of the target outgoing interface, determining a forwarding path according to the target outgoing interface, and forwarding the message to the next hop. The invention realizes the acceleration searching speed by searching the interface according to the IP address, further introduces ARP request to achieve the effect of precisely searching the interface in the process of determining the target out interface, thereby improving the function of searching the message forwarding out interface based on the strategy route and realizing the efficient and flexible message forwarding.
Further, referring to fig. 2, fig. 2 is a flowchart of a method of step 102 of the message forwarding method provided in the embodiment of the present invention in fig. 1, where step 102 includes:
step 1021, an ARP request is sent, where the ARP request includes a correspondence between an IP address and a MAC address.
Specifically, the advantage of specifying the IP address of the next hop is that the outgoing interface can be dynamically changed according to the state of the link, and for the next hop routing device for determining the target outgoing interface, it needs to verify whether the correspondence between the IP address of the next hop and the outgoing interface is accurate, 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 IP address of the next hop and the outgoing interface is accurate according to the correspondence between the MAC address obtained in the next step and the outgoing interface.
It should be noted that, the policy routing may be based on the source IP or the destination IP of the three layers, or may be a source MAC address and a destination MAC address of the two layers, or even a port number of the four layers, to forward the message. Policy routing is thus an effective enhancement to traditional IP routing mechanisms. The embodiment of the invention determines the specific position of the interface without specific limitation for the policy route, and can adopt any one of the output interfaces meeting the verification condition, thereby selecting the route according to the field in the data message and realizing more flexible message forwarding.
Step 1022, inquiring the FDB table entry according to the ARP request, where the FDB table entry includes a correspondence between the MAC address and the egress interface.
Step 1023, verifying the IP address of the ARP request and the outbound interface of the FDB table item to obtain the corresponding relation between the IP address and the outbound interface, and determining the target outbound interface.
It should be noted that in the steps 1021-1023, the accuracy of the corresponding relationship between the IP address and the outgoing interface is verified by using an ARP request. Firstly, according to an IP address in the next hop, an ARP request is sent, wherein the ARP request comprises the corresponding relation between the IP address and the MAC address; in response to the ARP request, inquiring the FDB table item, wherein the FDB table item has the corresponding relation between the MAC address and the outbound interface, determining the IP address and the outbound interface associated with the MAC address according to the ARP request and the MAC address of the FDB table item, verifying the IP address of the ARP request and the outbound interface of the FDB table item to obtain the corresponding relation between the IP address and the outbound interface, and determining the target outbound interface after verification passes, so that the next hop is ensured to be the next hop actually required, namely the next hop appointed by the IP address configured by the user is finally found.
In this embodiment, by sending an ARP request, querying an FDB entry, verifying the IP address of the ARP request and the egress interface of the FDB entry to obtain the corresponding relationship between the IP address and the egress interface, and determining the destination egress interface, that is, verifying the corresponding relationship between the IP and the egress interface by using the ARP request, thereby verifying the accuracy of the corresponding relationship between the IP address and the egress interface, so as to greatly improve the accuracy of determining the destination egress interface, further improve the accuracy and success rate of message forwarding, and implement efficient message forwarding.
Referring to fig. 3, a second step flowchart of a packet forwarding method provided by an embodiment of the present invention is shown, where the method may include:
step 101, under the condition that the switch inlet receives the message, the preset next hop IP address is routed according to the strategy of the inlet, and the outlet of the switch is searched.
Step 102, verifying the outgoing interface of the switch through the ARP request, and determining the target outgoing interface.
And step 103, determining a forwarding path according to the target out interface, and forwarding the message to the next hop.
Steps 101 to 103 are not repeated again with reference to the foregoing.
Step 104, obtaining the route change information through a redis message mechanism.
In the embodiment of the invention, a callback function is registered to acquire a route change notification, namely, in the process of registering a function to route change, the next hop is updated when the route changes, however, if a large number of routes are added or deleted, the existing mode of updating the next hop is carried out one by one according to the route change, which results in very slow updating efficiency and influences on message forwarding. Therefore, in order to improve the update efficiency during the route change, the present embodiment introduces an asynchronous mode processing manner, that is, adopts a redis message mechanism to obtain the route change information.
It should be noted that, in this embodiment, list type is used to implement the message queue through redis message mechanism, mainly through push and rpop storing and reading, where push can store the latest message to the head of the message queue (List set), and rpop can read the tail of the message queue, thus implementing first-in first-out.
In order to enable a person skilled in the art to more clearly understand the message forwarding method disclosed in the above embodiment of the present invention, referring to the schematic diagram of the route change information shown in fig. 8, the obtained route information is stored in a preset queue form, route change information is obtained from the head of the queue for preprocessing, at this time, updated route change information is added to the tail of the queue, and the route change processing procedure is optimized from synchronous processing to asynchronous merging processing, so that the processing efficiency of the next hop change caused by route change is improved, and efficient message forwarding is further realized. Of course, the above is merely a specific illustration, and in the actual use process, step 104 may also obtain the route change information through other manners of the redis message mechanism, which is not described herein in detail.
And 105, caching the route change information and preprocessing the route change information.
In the embodiment of the 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 preprocessing.
Specifically, the route change information obtained by the buffer memory may have a relationship in which the changes cancel each other when the route changes are large, and therefore, many of the messages of the route change can be merged. Illustratively, the IP address of one interface of the router is changed over another interface, all routing information of the former interface is deleted, and the routing of the latter interface is added. If the two interfaces are connected with a plurality of other routing devices, a plurality of other network segments in the routing devices are deleted and added, and because the same routing information is added and deleted, the routing devices can be preprocessed according to the cached routing change information, the information processing of some routes is combined, and the routing change information after the preprocessing is modified by the strategy routing, so that the updating efficiency is improved.
And step 106, updating the pre-configured next hop IP address of the policy route of the access interface according to the pre-processed route change information.
In step 104-106, after determining a forwarding path according to the target outgoing interface and forwarding the message to the next hop, namely, obtaining route change information through a redis message mechanism, caching the route change information, preprocessing the route change information, updating a policy route preconfigured next hop IP address of the incoming interface according to the preprocessed route change information, and realizing a mode of optimizing the processing procedure of the route change from synchronous one-by-one processing to asynchronous merging processing so as to achieve the processing speed of the next hop change caused by the route change.
In this embodiment, the specific execution positions of steps 104 to 106 are not limited, and in this embodiment, steps 104 to 106 are executed as an example after step 103 for the sake of understanding. In the actual use process, steps 104-106 may also be performed before step 101, and each case will not be described in detail herein.
The message forwarding method provided by the embodiment of the invention adopts a processing mode of introducing an asynchronous mode, adopts a form of redis message mechanism, carries out preprocessing on route change information first, realizes quick update processing of the route change information, and thus obtains the updated policy route preconfigured next hop IP address of the access interface.
Further, referring to fig. 4, fig. 4 is a flowchart of a method of step 105 of the message forwarding method provided in the embodiment of the present invention in fig. 3, where step 105 includes:
step 1051, according to the route change time sequence, the obtained route change information is cached to a preset queue.
In the embodiment of the invention, in order to realize asynchronous processing of route change information, an information queue is realized by storing and reading lpush and rpop of a redis message mechanism, the acquired route change information is cached to a preset queue according to a route change time sequence, the lpush caches route change information with the latest time sequence to the head of the preset queue, and the latest updated route change information is cached to the tail of the preset queue, thereby realizing asynchronous processing of the route change information in a first-in first-out mode.
Step 1052, obtaining the route change information of the head of the queue in the preset queue, and performing asynchronous merging or counteracting processing on the route change information of the head of the queue.
It should be noted that, in this embodiment, the time and the number of obtaining the route change information of the head of the queue in the preset queue are not limited in this embodiment, and route change information updated in the preset time of the head of the queue in the preset queue may be obtained at regular time, and the route change information of the head of the queue may be asynchronously combined or counteracted; the updating condition of the route change information can also be monitored in real time, the route change information of the head of the queue in the preset queue is obtained when the route change information is monitored to update, and the route change information of the head of the queue is asynchronously combined or counteracted. Of course, the foregoing is merely specific to illustration, and the obtaining of the route change information of the head of the queue in the preset queue in the actual use process may also be set according to the actual message forwarding requirement, which is not described herein in detail.
In step 1053, the preprocessed route change information is cached.
It should be noted that, in the steps 1051 to 1053, the obtained route change information is cached to the preset queue according to the route change time sequence, the route change information of the head of the queue in the preset queue is obtained, the route change information of the head of the queue is asynchronously combined or offset, and the route change information after the pretreatment is cached, so that the next hop IP address preconfigured by the policy route of the ingress interface is updated according to the route change information after the pretreatment.
In this embodiment, the route change information is buffered, which can be preprocessed, combined or offset some route change information, and the preprocessed route change information is modified by policy routing, so that data processing resources are saved, the processing workload of the route change information is reduced, and the efficiency of forwarding the message is effectively improved.
Specifically, step 106 updates the policy of the ingress interface to route the preconfigured next hop IP address according to the preprocessed route change information, and may include the following steps:
firstly, modifying the route change information after pretreatment according to the route change information after pretreatment;
And secondly, acquiring the processed route change information, and updating a preset next hop IP address of the policy route of the access interface so as to forward the message to the updated next hop.
In this embodiment, after obtaining route change information of a queue head in a preset queue, asynchronously combining or canceling the route change information of the queue head, caching the route change information after preprocessing, modifying the route change information after preprocessing according to the route change information after preprocessing, optimizing the route change information, avoiding preprocessing errors such as combining or canceling, and the like, thereby obtaining the route change information after processing, updating a policy route preconfigured next hop IP address of an ingress interface, and forwarding a message to the updated next hop.
Referring to fig. 5, a block diagram of a device for forwarding a packet according to an embodiment of the present invention is shown, where the device may include:
a searching module 201, configured to, when the switch ingress interface receives a packet, search an egress interface of the switch according to a policy routing preconfigured next hop IP address of the ingress interface;
a determining module 202, configured to verify an outgoing interface of the switch through an ARP request, and determine a target outgoing interface;
And the forwarding module 203 is configured to determine a forwarding path according to the target outgoing interface, and forward the packet to a next hop.
Optionally, the search module 201 includes:
the searching sub-module is used for searching the routing table information by adopting a binary search method under the condition that the switch access interface receives the message;
a matching sub-module, configured to match the routing table information according to the next hop IP address configured by the policy routing of the ingress interface;
and the first determining submodule is used for determining an outgoing interface corresponding to the next hop IP address according to the matching result.
Optionally, the determining module 202 includes:
a sending submodule, configured to send an ARP request, where the ARP request includes a correspondence between an IP address and an MAC address;
the inquiring submodule is used for inquiring FDB table entries according to the ARP request, wherein the FDB table entries comprise the corresponding relation between the MAC address and the output interface;
and the second determining submodule is used for verifying the IP address of the ARP request and the outgoing interface of the FDB table entry to obtain the corresponding relation between the IP address and the outgoing interface and determining the target outgoing interface.
Optionally, the forwarding module 203 includes:
the obtaining submodule is used for obtaining the route information of the next hop in the route table according to the target output interface;
A third determining submodule, configured to query routing equipment corresponding to the next hop IP address according to the routing information, and determine a forwarding path;
and the forwarding sub-module is used for forwarding the message to the routing equipment corresponding to the next hop IP address according to the forwarding path.
Optionally, the apparatus further comprises:
the acquisition module is used for acquiring route change information through a redis message mechanism;
the processing module is used for caching the route change information and preprocessing the route change information;
and the updating module is used for updating the next hop IP address pre-configured by the policy route of the access interface according to the pre-processed route change information.
Optionally, the processing module includes:
the first buffer sub-module is used for buffering the acquired route change information to a preset queue according to the route change time sequence;
the first processing sub-module is used for acquiring the route change information of the head of the queue in the preset queue and carrying out asynchronous combination or offset processing on the route change information of the head of the queue;
and the second caching submodule is used for caching the preprocessed route change information.
Optionally, the updating module includes:
the second processing module is used for modifying the route change information after pretreatment according to the route change information after pretreatment;
And the updating sub-module is used for acquiring the processed route change information, updating the preset next hop IP address of the strategy route of the access interface, and forwarding the message to the updated next hop.
The message forwarding device provided by the embodiment of the invention is used for searching the outgoing interface of the switch according to the preset next-hop IP address of the policy route of the incoming interface under the condition that the incoming interface of the switch receives the message, namely, according to the preset next-hop IP address of the policy route, the searching module combines the data structure of the outgoing interface information to realize quick searching, and improves the searching efficiency of the outgoing interface; the determining module is used for verifying the outgoing interface of the switch through the ARP request, determining a target outgoing interface, verifying the accuracy of the corresponding relation between the IP address and the outgoing interface in an ARP request mode, facilitating the accurate finding of the next hop designated by the IP address, and ensuring the accuracy of the target outgoing interface; and the forwarding module is used for determining a forwarding path according to the target outgoing interface and forwarding the message to the next hop. The invention realizes the acceleration searching speed by searching the interface according to the IP address, further introduces ARP request to achieve the effect of precisely searching the interface in the process of determining the target out interface, thereby improving the function of searching the message forwarding out interface based on the strategy route and realizing the efficient and flexible message forwarding.
The embodiment of the present invention also provides a communication device, as shown in fig. 9, including a processor 301, a communication interface 302, a memory 303, and a communication bus 304, where the processor 301, the communication interface 302, and the memory 303 perform communication with each other through the communication bus 304,
a memory 303 for storing a computer program;
the processor 301, when executing the program stored in the memory 303, may implement the following steps:
under the condition that the switch inlet receives a message, a preset next-hop IP address is routed according to a strategy of the inlet, and an outlet of the switch is searched; verifying the outgoing interface of the switch through the ARP request to determine a target outgoing interface; and determining a forwarding path according to the target output interface, and forwarding the message to the next hop.
The communication bus mentioned by the above terminal may be a peripheral component interconnect standard (PeripheralComponent Interconnect, abbreviated as PCI) bus or an extended industry standard architecture (ExtendedIndustryStandard Architecture, abbreviated as EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the terminal and other devices.
The memory may include Random Access Memory (RAM) or non-volatile memory (non-volatile memory), such as at least one disk memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also Digital Signal Processors (DSP), application specific integrated circuits (ASIC ApplicationSpecific IntegratedCircuit), field-programmable gate arrays (Field-ProgrammableGate Array FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In yet another embodiment of the present invention, a computer readable storage medium is provided, where instructions are stored, which when executed on a computer, cause the computer to perform the method for forwarding a message according to any of the foregoing embodiments.
In yet another embodiment of the present invention, a computer program product comprising instructions, which when run on a computer, causes the computer to perform the method of forwarding a message according to any of the above embodiments is also provided.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may 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 loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, 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 may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk SolidStateDisk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the 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 (10)

1. A method for forwarding a message, the method comprising:
under the condition that a switch input interface receives a message, a preset next-hop IP address is routed according to a strategy of the input interface, and an output interface of the switch is searched;
verifying the outgoing interface of the switch through an ARP request to determine a target outgoing interface;
and determining a forwarding path according to the target out interface, and forwarding the message to the next hop.
2. The method for forwarding a message according to claim 1, wherein, when the switch ingress interface receives the message, the routing the preconfigured next hop IP address according to the policy of the ingress interface searches for the egress interface of the switch, including:
under the condition that the switch access interface receives the message, a binary search method is adopted to search the information of the routing table;
matching the routing table information according to the next hop IP address configured by the policy routing of the access interface;
And determining an outgoing interface corresponding to the next hop IP address according to the matching result.
3. The method for forwarding a message according to claim 1, wherein the verifying the outgoing interface of the switch through the ARP request, determining the target outgoing interface, includes:
sending an ARP request, wherein the ARP request comprises a corresponding relation between an IP address and an MAC address;
inquiring an FDB table item according to the ARP request, wherein the FDB table item comprises a corresponding relation between an MAC address and an output interface;
and verifying the IP address of the ARP request and the outbound interface of the FDB table entry to obtain the corresponding relation between the IP address and the outbound interface, and determining the target outbound interface.
4. The method for forwarding the message according to claim 1, wherein determining a forwarding path according to the target outgoing interface forwards the message to a next hop, comprises:
acquiring the route information of the next hop in the route table according to the target output interface;
inquiring routing equipment corresponding to the next hop IP address according to the routing information, and determining a forwarding path;
and forwarding the message to the routing equipment corresponding to the next-hop IP address according to the forwarding path.
5. The method for forwarding a message according to claim 1, wherein determining a forwarding path according to the target outgoing interface, and forwarding the message to a next hop, further comprises:
Obtaining route change information through a redis message mechanism;
caching the route change information, and preprocessing the route change information;
and updating the preset next hop IP address of the strategy route of the access interface according to the preprocessed route change information.
6. The method for forwarding a message according to claim 5, wherein said caching the route change information and preprocessing the route change information includes:
caching the acquired route change information to a preset queue according to a route change time sequence;
acquiring route change information of the head of a queue in the preset queue, and carrying out asynchronous merging or counteracting treatment on the route change information of the head of the queue;
and caching the route change information after preprocessing.
7. The method for forwarding a packet according to claim 5, wherein updating the next hop IP address pre-configured by the policy routing of the ingress interface according to the pre-processed route change information includes:
modifying the route change information after pretreatment according to the route change information after pretreatment;
and acquiring the processed route change information, and updating a preset next hop IP address of the policy route of the access interface so as to forward the message to the updated next hop.
8. A message forwarding device, the device comprising:
the searching module is used for searching an outlet interface of the switch according to a preset next-hop IP address of a strategy route of the inlet interface under the condition that the switch inlet interface receives a message;
the determining module is used for verifying the outgoing interface of the switch through an ARP request and determining a target outgoing interface;
and the forwarding module is used for determining a forwarding path according to the target outgoing interface and forwarding the message to the next hop.
9. A communication device, comprising: a transceiver, a memory, a processor, and a program stored on the memory and executable on the processor;
the processor is configured to read a program in the memory to implement the steps in the message forwarding method according to any one of claims 1 to 7.
10. A readable storage medium storing a program, wherein the program when executed by a processor performs the steps of the message forwarding method according to any of claims 1-7.
CN202310073766.1A 2023-01-29 2023-01-29 Message forwarding method, device, communication equipment and storage medium Pending CN116192743A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310073766.1A CN116192743A (en) 2023-01-29 2023-01-29 Message forwarding method, device, communication equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310073766.1A CN116192743A (en) 2023-01-29 2023-01-29 Message forwarding method, device, communication equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116192743A true CN116192743A (en) 2023-05-30

Family

ID=86432179

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310073766.1A Pending CN116192743A (en) 2023-01-29 2023-01-29 Message forwarding method, device, communication equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116192743A (en)

Similar Documents

Publication Publication Date Title
EP2640021B1 (en) Longest prefix match searches with variable numbers of prefixes
KR101774951B1 (en) Technologies for distributed routing table lookup
KR102033999B1 (en) Method and apparatus for communication in content centric network
US8228908B2 (en) Apparatus for hardware-software classification of data packet flows
CN110943924B (en) Method for segmenting source routing in a network and storage medium
US10079780B2 (en) Packet processing method and device
US9602428B2 (en) Method and apparatus for locality sensitive hash-based load balancing
US20140181140A1 (en) Terminal device based on content name, and method for routing based on content name
US6853620B2 (en) Bus protocol
US7346059B1 (en) Header range check hash circuit
KR20170037818A (en) Information-centric networking with small multi-path or single-path forwarding state
US9268813B2 (en) Terminal device based on content name, and method for routing based on content name
US20220045950A1 (en) Single lookup entry for symmetric flows
CN110430135B (en) Message processing method and device
US20130198830A1 (en) Access relay method and access gateway device
US9391896B2 (en) System and method for packet forwarding using a conjunctive normal form strategy in a content-centric network
US7408933B2 (en) Distributed router with ping-pong preventing function and ping-pong preventing method using the same
CN111654437B (en) Message forwarding method and device based on data center
CN113630428B (en) Acquisition method and acquisition system for service data
US20030016677A1 (en) Fabric bus architeture
US20170012874A1 (en) Software router and methods for looking up routing table and for updating routing entry of the software router
US10229459B1 (en) Method and apparatus for routing in transaction management systems
CN116192743A (en) Message forwarding method, device, communication equipment and storage medium
EP2795881A1 (en) Apparatus and methods for efficient network address translation and application level gateway processing
CN114124804A (en) Communication method, device and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination