Disclosure of Invention
Embodiments of the present invention provide a method and an apparatus for sending a BGP route, so as to preferentially send a BGP route with a large bearer traffic, thereby improving network stability.
In order to achieve the above object, an embodiment of the present invention provides a method for sending a BGP route, where the method is applied to a BGP network including a BGP device and a BGP neighbor device, and after a BGP neighbor relationship is established between the BGP device and the BGP neighbor device, the method includes the following steps:
the BGP equipment determines priority information of each BGP route;
the BGP equipment transmits BGP routes to the BGP neighbor equipment according to a specified route publishing strategy by using the priority information of each BGP route; wherein:
the specific route publishing strategy is to preferentially publish the BGP route with high priority.
The determining, by the BGP device, priority information of each BGP route specifically includes:
the BGP equipment starts a network flow Netstream function on an interface configured with a BGP protocol, and the Netstream function is used for carrying out flow statistics according to a message destination IP address;
the BGP equipment inquires the statistical result of the Netstream function to obtain the statistical count of the flow matched with the target IP address of each message, and determines the statistical count of the flow matched with the target IP address of the message as the priority information of the BGP route corresponding to the target IP address of the message; wherein:
the larger the statistical count corresponding to the BGP route is, the higher the priority of the BGP route is;
or, the BGP device obtains route attribute information of each BGP route, where the route attribute information of the BGP route has a priority route attribute or does not have a priority route attribute;
the BGP device determines that a BGP route having the priority route attribute has a higher priority than a BGP route having no priority route attribute.
The BGP device sends the BGP route to the BGP neighbor device according to the specified route publishing policy using the priority information of each BGP route, specifically including:
the BGP equipment adds the statistical counts corresponding to the BGP routes to records of the BGP routes on a Radix tree, and when the BGP routes are sent to the BGP neighbor equipment, the BGP routes corresponding to the statistical counts are sequentially obtained from the Radix tree according to the sequence of the statistical counts from large to small, and the obtained BGP routes are sent to the BGP neighbor equipment;
or, when the BGP route has the priority route attribute, the BGP device adds the priority route attribute to the record of the BGP route in the Radix tree, and preferentially obtains the BGP route having the priority route attribute from the Radix tree and transmits the obtained BGP route to the BGP neighbor device when transmitting the BGP route to the BGP neighbor device.
After the BGP device sends the BGP routes to the BGP neighbor devices according to the specified route publishing policy using the priority information of each BGP route, the method further includes:
when the BGP equipment does not need to send BGP routes to the BGP neighbor equipment according to a specified route publishing strategy, the BGP equipment clears the statistical count corresponding to each BGP route recorded on the Radix tree; or clearing the priority routing attribute recorded on the Radix tree.
The method further comprises the following steps: after the BGP equipment sends the BGP route with the statistical count not being 0 to the BGP neighbor equipment and before the BGP route with the statistical count being 0 is sent, the BGP equipment processes a message for maintaining a BGP neighbor relation;
or, after the BGP device sends the BGP route with the priority route attribute to the BGP neighbor device, and before sending the BGP route without the priority route attribute, the BGP device processes a packet for maintaining a BGP neighbor relationship.
The embodiment of the invention provides a Border Gateway Protocol (BGP) device, which is applied to a BGP network comprising the BGP device and BGP neighbor devices, wherein after the BGP device establishes a BGP neighbor relation with the BGP neighbor devices, the BGP device comprises:
the determining module is used for determining the priority information of each BGP route;
the sending module is used for sending the BGP routes to the BGP neighbor equipment according to a specified route publishing strategy by using the priority information of each BGP route; wherein:
the specific route publishing strategy is to preferentially publish the BGP route with high priority.
The determining module is specifically configured to enable a network traffic Netstream function on an interface configured with a BGP protocol, where the Netstream function is configured to perform traffic statistics according to a destination IP address of a packet; inquiring the statistical result of the Netstream function to obtain the statistical count of the flow matched with the IP address of each message destination, and determining the statistical count of the flow matched with the IP address of the message destination as the priority information of the BGP route corresponding to the IP address of the message destination; wherein: the larger the statistical count corresponding to the BGP route is, the higher the priority of the BGP route is; or obtaining the route attribute information of each BGP route, wherein the route attribute information of the BGP routes has priority route attributes or does not have priority route attributes; it is determined that BGP routes having priority route attributes have a higher priority than BGP routes not having priority route attributes.
The sending module is specifically configured to add the statistical counts corresponding to the BGP routes to records of the BGP routes on the Radix tree, and when the BGP routes are sent to the BGP neighbor devices, sequentially obtain the BGP routes corresponding to each statistical count from the Radix tree according to a descending order of the statistical counts, and send the obtained BGP routes to the BGP neighbor devices;
or, when the BGP route has the priority route attribute, adding the priority route attribute to the record of the BGP route in the Radix tree, and when sending the BGP route to the BGP neighboring device, preferentially obtaining the BGP route having the priority route attribute from the Radix tree, and sending the obtained BGP route to the BGP neighboring device.
Further comprising: the clearing module is used for clearing the statistical counts corresponding to the BGP routes recorded on the Radix tree when the BGP routes do not need to be sent to the BGP neighbor equipment according to the specified route publishing strategy; or clearing the priority routing attribute recorded on the Radix tree.
Further comprising: the processing module is used for processing a message for maintaining the BGP neighbor relation after the BGP route with the statistical count not being 0 is sent to the BGP neighbor equipment and before the BGP route with the statistical count being 0 is sent; or, after sending the BGP route with the priority route attribute to the BGP neighbor device, and before sending the BGP route without the priority route attribute, processing a packet for maintaining the BGP neighbor relationship.
Compared with the prior art, the embodiment of the invention at least has the following advantages: in the embodiment of the invention, when a large number of BGP routes need to be sent, BGP routes with large bearing service volume can be preferentially sent by BGP equipment, so that the situation that network flow can be forwarded after waiting for a long time is avoided, and the stability of a network is improved.
Detailed Description
For the problems in the prior art, embodiments of the present invention provide a method for sending a BGP route, which is applied to a BGP network including a BGP device and BGP neighbor devices, and when the BGP device needs to send a large number of BGP routes to the BGP neighbor devices, the BGP route with a large bearer traffic can be preferentially sent, so that network traffic is prevented from being forwarded after waiting for a long time, and network stability is improved.
In the embodiment of the present invention, after a BGP neighbor relationship is established between a BGP device and a BGP neighbor device, as shown in fig. 1, a sending method of a BGP route includes the following steps:
instep 101, the BGP device determines priority information for each BGP route.
102, BGP equipment sends BGP routes to BGP neighbor equipment according to a specified route publishing strategy by using priority information of each BGP route; wherein: the specific route publishing policy is specifically to preferentially publish the BGP routes with high priority. For example, when the priority of BGP route 1 is higher than the priority of BGP route 2, the BGP device first sends BGP route 1 to the BGP neighbor.
In the embodiment of the present invention, the BGP device determines the priority information of each BGP route, and sends the BGP route to the BGP neighbor device according to the specified route publishing policy by using the priority information of each BGP route, which specifically includes, but is not limited to, the following manners:
the first method is as follows:
the determining, by the BGP device, the priority information of each BGP route specifically includes: the BGP equipment enables a Netstream (network traffic) function on all interfaces configured with a BGP protocol (the Netstream function is used for carrying out traffic statistics according to the IP address of a message destination); then, the BGP equipment inquires the statistical result of the Netstream function to obtain the statistical count of the flow matched with the target IP address of each message, and determines the statistical count of the flow matched with the target IP address of the message as the priority information of the BGP route corresponding to the target IP address of the message; wherein: the larger the statistical count corresponding to the BGP route is, the higher the priority of the BGP route is.
In the embodiment of the invention, in order to realize the function of releasing BGP routes according to the priority, a command line delay-send enable can be configured under a BGP view; under the default condition, the function is in a closed state, namely the command line delaminanate-send enable is not enabled, BGP equipment issues BGP routes according to the existing flow, and the process is not repeated; when the command line delay-sent enable is enabled under the BGP view, the BGP device publishes the BGP routes according to the technical scheme provided by the embodiment of the present invention, that is, the BGP device determines the priority information of each BGP route, and preferentially publishes the BGP route with high priority.
In the first mode, the BGP device needs to determine priority information of the BGP route based on a statistical result of the Netstream function; therefore, when the BGP device does not enable the Netstream function (i.e., does not perform traffic statistics according to the destination IP address of the message), the BGP device needs to first enable the Netstream function on all interfaces configured with the BGP protocol, and configure the Netstream function to perform traffic statistics according to the destination IP address of the message, so that the Netstream performs traffic statistics according to the destination IP address of the message; based on this, the BGP device can obtain the statistical count of the traffic matched with the destination IP address of each message by querying the statistical result of the Netstream function, and determine that the statistical count of the traffic matched with the destination IP address of the message is the priority information of the BGP route corresponding to the destination IP address of the message.
Specifically, after the BGP device enables the BGP route function issued according to the priority, it may create an access Netstream timer, where the default period is 10s, and the BGP device queries the statistical result of the Netstream function every 10s to obtain the statistical count of each BGP route (i.e., the priority information of the BGP route).
The BGP device sends the BGP route to the BGP neighbor device according to the specified route publishing policy, using the priority information of each BGP route, specifically including: the BGP device adds the statistical counts corresponding to the BGP routes to a record of the BGP routes in a Radix tree (i.e., a key value lookup tree based on binary representation, where in a specific implementation, the BGP routes may be stored in corresponding positions of the Radix tree using prefix information of the BGP routes, and the BGP routes may be read from the corresponding positions of the Radix tree using the prefix information of the BGP routes), and when sending the BGP routes to a BGP neighbor device, sequentially obtains the BGP routes corresponding to the statistical counts from the Radix tree (the Radix tree is a Radix tree at the sending end, and the Radix tree is an example for description in the following) according to the order of the statistical counts from large to small, and sends the obtained BGP routes to the BGP neighbor device.
Specifically, after obtaining the statistical count of each BGP route (i.e., priority information of the BGP route), the BGP device needs to add the statistical count corresponding to the BGP route to the Radix tree (i.e., update the statistical count of the BGP route in the Radix tree); when the BGP equipment transmits the BGP route to the BGP neighbor equipment, the BGP route corresponding to each statistical count is sequentially obtained from a Radix tree according to the sequence of the statistical counts from large to small, the BGP route is added into an update message and transmitted to the BGP neighbor equipment, so that the BGP route is transmitted in priority, the BGP route with large bearing service volume is preferentially transmitted, the situation that network traffic can be forwarded after waiting for a long time is avoided, and the stability of the network is improved.
If the BGP device needs to send a large number of BGP routes to the BGP neighbor device, the BGP task is used for updating the BGP route for a long time, and other BGP transactions (e.g., BGP neighbor relationship maintenance, etc.) are not processed until the BGP route update is completed, so that a message (e.g., keepalive message) from the BGP neighbor device for maintaining the BGP neighbor relationship cannot be timely and effectively processed, the BGP neighbor relationship oscillates, and the oscillation of the BGP route over the entire network is further triggered.
Based on the above discovery, in the embodiment of the present invention, after the BGP device sends the BGP route whose statistical count is not 0 to the BGP neighbor device, and before the BGP route whose statistical count is 0 is sent, the BGP device may further process a message for maintaining a BGP neighbor relationship; therefore, when a large number of BGP routes need to be sent to BGP neighbor equipment, the CPU and other resources can be flexibly regulated and controlled, after the BGP routes with high priority are sent, messages for maintaining BGP neighbor relations are processed, and then the BGP routes with low priority are sent, so that the stability of the network is further improved.
After the BGP route of the high priority is sent, the CPU resource for sending the BGP route can be released in a short time to process a message (e.g., a keepalive message) for maintaining the BGP neighbor relationship, thereby reducing neighbor oscillation caused by failing to process the message for maintaining the BGP neighbor relationship in time due to sending the BGP route for a long time, maintaining stability of the neighbor relationship, and avoiding route oscillation.
In the embodiment of the present invention, after the BGP device transmits the BGP routes to the BGP neighbor devices according to the specified route publishing policy and by using the priority information of each BGP route, when the BGP device is configured with a function of publishing the BGP routes according to the priority (that is, the BGP device does not transmit a BGP route to the BGP neighbor devices according to the specified route publishing policy any longer, and does not perform processing according to the technical scheme provided in the embodiment of the present invention), the BGP device further needs to clear the statistical counts corresponding to each BGP route recorded on the Radix tree, clear the Netstream access timer, and process the subsequent BGP route transmission process according to the existing flow.
The second method comprises the following steps:
the determining, by the BGP device, the priority information of each BGP route specifically includes: BGP equipment obtains route attribute information of each BGP route, wherein the route attribute information of the BGP routes can have priority route attributes or no priority route attributes; the BGP device then determines that the BGP route having the priority route attribute has a higher priority than the BGP route having no priority route attribute.
In the embodiment of the invention, in order to realize the function of releasing BGP routes according to the priority, a command line delay-send enable can be configured under a BGP view; under the default condition, the function is in a closed state, namely the command line delaminanate-send enable is not enabled, BGP equipment issues BGP routes according to the existing flow, and the process is not repeated; when the command line delay-sent enable is enabled under the BGP view, the BGP device publishes the BGP routes according to the technical scheme provided by the embodiment of the present invention, that is, the BGP device determines the priority information of each BGP route, and preferentially publishes the BGP route with high priority.
In the second mode, the BGP device needs to determine priority information of the BGP route based on whether each BGP route has a priority route attribute; therefore, in the embodiment of the present invention, by adding a priority route attribute to the BGP route, the user configures, through a policy, the BGP route with a higher priority (for example, the BGP route with a large carrying traffic) to have the priority route attribute, and configures the BGP route with a lower priority to have no priority route attribute; based on this, the BGP device may determine that the BGP routes having the priority route attribute have a higher priority than the BGP routes not having the priority route attribute.
The BGP device sends the BGP route to the BGP neighbor device according to the specified route publishing policy, using the priority information of each BGP route, specifically including: when the BGP route has the priority route attribute, the BGP equipment adds the priority route attribute to the record of the BGP route on the Radix tree, preferentially obtains the BGP route with the priority route attribute from the Radix tree when transmitting the BGP route to BGP neighbor equipment, and transmits the obtained BGP route to the BGP neighbor equipment.
Specifically, when the BGP device sends the BGP route to the BGP neighbor device, the BGP device needs to preferentially obtain the BGP route having the priority route attribute from the Radix tree, and add the obtained BGP route to the update message and send the update message to the BGP neighbor device, thereby implementing prioritized sending of the BGP route, so that the BGP route with a large bearer traffic and a high priority is preferentially sent, thereby avoiding that network traffic needs to be forwarded after waiting for a long time, and improving stability of the network.
If the BGP device needs to send a large number of BGP routes to the BGP neighbor device, the BGP task is used for updating the BGP route for a long time, and other BGP transactions (e.g., BGP neighbor relationship maintenance, etc.) are not processed until the BGP route update is completed, so that a message (e.g., keepalive message) from the BGP neighbor device for maintaining the BGP neighbor relationship cannot be timely and effectively processed, the BGP neighbor relationship oscillates, and the oscillation of the BGP route over the entire network is further triggered.
Based on the above discovery, in the embodiment of the present invention, after the BGP device sends the BGP route with the priority route attribute to the BGP neighbor device, and before the BGP device sends the BGP route without the priority route attribute, the BGP device may further process a packet for maintaining the BGP neighbor relationship; therefore, when a large number of BGP routes need to be sent to BGP neighbor equipment, the CPU and other resources can be flexibly regulated and controlled, after the BGP routes with high priority are sent, messages for maintaining BGP neighbor relations are processed, and then the BGP routes with low priority are sent, so that the stability of the network is further improved.
After the BGP route of the high priority is sent, the CPU resource for sending the BGP route can be released in a short time to process a message (e.g., a keepalive message) for maintaining the BGP neighbor relationship, thereby reducing neighbor oscillation caused by failing to process the message for maintaining the BGP neighbor relationship in time due to sending the BGP route for a long time, maintaining stability of the neighbor relationship, and avoiding route oscillation.
In the embodiment of the present invention, after the BGP device transmits the BGP route to the BGP neighbor device according to the specified route publishing policy and by using the priority information of each BGP route, when the BGP device configures a function of publishing the BGP route according to the priority (that is, the BGP device does not transmit the BGP route to the BGP neighbor device according to the specified route publishing policy any longer and does not need to process according to the technical scheme provided in the embodiment of the present invention), the BGP device further needs to clear the priority route attribute recorded on the Radix tree, and the transmission process of the subsequent BGP route is processed according to the existing flow, which is not described herein again.
Based on the same inventive concept as the above method, an embodiment of the present invention further provides a BGP device, which is applied to a BGP network including the BGP device and a BGP neighbor device, where after a BGP neighbor relationship is established between the BGP device and the BGP neighbor device, as shown in fig. 2, the BGP device includes:
a determining module 11, configured to determine priority information of each BGP route;
a sending module 12, configured to send, to the BGP neighbor device, a BGP route according to a specified route publishing policy by using priority information of each BGP route; wherein:
the specific route publishing strategy is to preferentially publish the BGP route with high priority.
The determining module 11 is specifically configured to enable a network traffic Netstream function on an interface configured with a BGP protocol, where the Netstream function is configured to perform traffic statistics according to a destination IP address of a packet; inquiring the statistical result of the Netstream function to obtain the statistical count of the flow matched with the IP address of each message destination, and determining the statistical count of the flow matched with the IP address of the message destination as the priority information of the BGP route corresponding to the IP address of the message destination; wherein: the larger the statistical count corresponding to the BGP route is, the higher the priority of the BGP route is; or obtaining the route attribute information of each BGP route, wherein the route attribute information of the BGP routes has priority route attributes or does not have priority route attributes; it is determined that BGP routes having priority route attributes have a higher priority than BGP routes not having priority route attributes.
The sending module 12 is specifically configured to add the statistical counts corresponding to the BGP routes to the records of the BGP routes in the Radix tree, and when sending the BGP routes to the BGP neighbor devices, sequentially obtain, from the Radix tree, the BGP routes corresponding to the statistical counts in descending order of the statistical counts, and send the obtained BGP routes to the BGP neighbor devices;
or, when the BGP route has the priority route attribute, adding the priority route attribute to the record of the BGP route in the Radix tree, and when sending the BGP route to the BGP neighboring device, preferentially obtaining the BGP route having the priority route attribute from the Radix tree, and sending the obtained BGP route to the BGP neighboring device.
The BGP device further includes: a clearing module 13, configured to clear the statistical counts corresponding to the BGP routes recorded in the Radix tree when it is no longer necessary to send a BGP route to the BGP neighbor device according to the specified route publishing policy; or clearing the priority routing attribute recorded on the Radix tree.
The BGP device further includes: a processing module 14, configured to process a packet for maintaining a BGP neighbor relationship after sending the BGP route whose statistical count is not 0 to the BGP neighbor device and before sending the BGP route whose statistical count is 0; or, after sending the BGP route with the priority route attribute to the BGP neighbor device, and before sending the BGP route without the priority route attribute, processing a packet for maintaining the BGP neighbor relationship.
The modules of the device can be integrated into a whole or can be separately deployed. The modules can be combined into one module, and can also be further split into a plurality of sub-modules.
Through the above description of the embodiments, those skilled in the art will clearly understand that the present invention may be implemented by software plus a necessary general hardware platform, and certainly may also be implemented by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute the methods according to the embodiments of the present invention.
Those skilled in the art will appreciate that the drawings are merely schematic representations of one preferred embodiment and that the blocks or flow diagrams in the drawings are not necessarily required to practice the present invention.
Those skilled in the art will appreciate that the modules in the devices in the embodiments may be distributed in the devices in the embodiments according to the description of the embodiments, and may be correspondingly changed in one or more devices different from the embodiments. The modules of the above embodiments may be combined into one module, or further split into multiple sub-modules.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The above disclosure is only for a few specific embodiments of the present invention, but the present invention is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present invention.