Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present application as detailed in the accompanying claims.
The terminology used in the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first message may also be referred to as a second message, and similarly, a second message may also be referred to as a first message, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
In order to solve the above problems, an embodiment of the present invention provides a method for processing a packet, so as to reduce a packet loss rate in a packet processing process. Referring to fig. 1, fig. 1 is a flowchart of a message processing method shown in the present application, which is applied to a network device.
S11: and determining the actual bandwidth required by the important flow cache queue according to each message included in the preset important flow cache queue.
An important traffic buffer queue can be preset, and as the name implies, the message of the important traffic to be sent can be stored in the important traffic buffer queue. When the messages are processed, the important flow cache queue is changed in real time, so that the actual bandwidth required by the important flow cache queue can be determined in real time according to each message included in the preset important flow cache queue.
S12: and selecting a designated member port from the aggregation ports of the network equipment according to the total bandwidth and the actual bandwidth of the network equipment.
The multiple ports on the network device for forwarding the message may form an aggregate port, and in general, not all member ports of the aggregate port are required to participate in forwarding the message, so a part of member ports may be selected from the aggregate ports of the network device according to the total bandwidth and the actual bandwidth of the network device, and the part of member ports may be defined as designated member ports.
S13: and forwarding each message contained in the important traffic buffer queue through the designated member port.
According to the technical scheme provided by the application, the actual bandwidth required by the important flow cache queue can be determined according to each message contained in the preset important flow cache queue, then the appointed member port is selected from the aggregation port of the network equipment according to the total bandwidth and the actual bandwidth of the network equipment, and each message contained in the important flow cache queue is forwarded through the appointed member port.
Specifically, in S11, determining an actual bandwidth required by the important traffic buffer queue according to each packet included in the preset important traffic buffer queue, and the implementation process specifically includes:
counting the total message length and the message number of all messages included in the important flow cache queue;
dividing the total length of the messages by the number of the messages to obtain the average length of the messages of the important flow cache queue;
determining a first average value of the maximum message length and the minimum message length in the message lengths of all messages included in the important flow cache queue;
determining whether the average length of the message is smaller than a first average value;
if the average length of the message is equal to or greater than the first average value, determining the total length of the message as the actual bandwidth required by the important flow cache queue;
if the average message length is smaller than the first average value, determining a second average value of the minimum message length and the first average value, determining whether the average message length is smaller than the second average value, and if the average message length is smaller than the second average value, determining a first set multiple of the total message length as an actual bandwidth required by the important flow cache queue; if the average length of the message is greater than or equal to the second average value, determining a second set multiple of the total length of the message as an actual bandwidth required by the important flow cache queue.
Since additional information such as a preamble is required when a message is transmitted, the bandwidth required when the message is transmitted is greater than the length of the message itself, and the smaller the message is, the larger the additional information is. Thus, the smaller the average length of the messages in the critical traffic buffer queues, the more additional bandwidth is required. In order to prevent the problem of congestion during packet sending caused by too small reserved bandwidth, more bandwidth needs to be allocated to the messages of the important traffic buffer queue. Wherein, the first set multiple may be, but is not limited to, 120%, and the second set multiple may be, but is not limited to, 110%.
Specifically, in S12, the implementation process specifically includes selecting a designated member port from the aggregation ports of the network device according to the total bandwidth and the actual bandwidth of the network device:
selecting a member port with an opened state from all member ports of an aggregation port of the network equipment to obtain a candidate member port set;
calculating the difference between the total bandwidth and the actual bandwidth of the network device;
and selecting the member ports with the sum of bandwidths not exceeding and closest to the difference value from the candidate member port set according to a preset algorithm to obtain the designated member port.
The states of the member ports of the aggregation port of the network device may be on or off, and here, the member ports with the on states need to be selected from the states, and the member ports form a candidate member port set A; if the total bandwidth of the network device is B0, the actual bandwidth required by the important traffic buffer queue is B, the difference between B0 and B may be calculated, a member port set A1 with the sum of bandwidths not exceeding and closest to the difference is selected from the candidate member port sets according to a preset algorithm, and is used for forwarding the message of the non-important traffic buffer queue, and the remaining member port sets (a-A1) are designated member ports for forwarding the important traffic buffer queue. The preset algorithm can be various, two algorithms are listed below for explanation, and one algorithm is an algorithm of 0/1 knapsack problem; another algorithm is to sequentially order the bandwidths of the member ports of the aggregate port from small to large, then remove the port with the smallest bandwidth from the aggregate port until the sum of the bandwidths of all the removed port sets A1 does not exceed and is closest to the difference value, and the rest member port set (a-A1) is the required designated member port.
In an alternative embodiment, the method further comprises:
receiving a first message sent by a terminal or other network equipment;
acquiring first quintuple information of a first message, wherein the first quintuple information comprises a first source internet protocol (Internet Protocol, IP) address, a first destination IP address, a first source port, a first destination port and a protocol;
searching first quintuple information in a preset access control list;
if the first quintuple information is found in the access control list, the second quintuple information comprising the second source IP address of the first destination IP address, the second destination IP address of the first destination port, the second source port of the second destination port and the protocol is found in the important flow information table, and if the second quintuple information is not found in the important flow information table, the second quintuple information is built in the important flow information table.
The terminal or other network device sends messages to the network device, where the messages may be defined as first messages, quintuple information carried by the first messages may be defined as first quintuple information, and then it is determined whether the first quintuple information needs to be stored in an important traffic information table according to an access control list on the network device. If the first quintuple information is found in the preset access control list, the flow to which the first message belongs is indicated to be important flow, so that the second quintuple information including the first destination IP address as the second source IP address, the first source IP address as the second destination IP address, the first destination port as the second source port, the second source port as the second destination port and the protocol can be found in the important flow information list, if the second quintuple information is not found in the important flow information list, the second quintuple information is established in the important flow information list, the first quintuple information and the second quintuple information can be found by comparing, and the second quintuple information is that the source destination IP address in the first quintuple information is exchanged and the original destination port is exchanged; if the first quintuple information is not found in the preset access control list, the flow to which the first message belongs is indicated to be unimportant flow, and the second quintuple information is not required to be found in the important flow information list.
In an alternative embodiment, the method further comprises:
acquiring a generated second message;
searching third quintuple information of the second message in the important flow information table;
if the third quintuple information is found in the important flow information table, adding the second message into an important flow cache queue;
and if the third quintuple information is not found in the important flow information table, adding the second message into the unimportant flow cache queue.
Two buffer queues may be provided for important traffic and non-important traffic, one for important traffic and one for non-important traffic. The network device generally responds to the received messages, the messages can be defined as second messages, which queue the second messages are added to can be determined according to an important flow information table, if the quintuple information of the second messages is defined as third quintuple information, the third quintuple information can be searched in the important flow information table, if the third quintuple information is searched in the important flow information table, the flow to which the second messages belong is indicated as important flow, and the second messages are added to an important flow cache queue; if the third quintuple information is not found in the important flow information table, which indicates that the flow to which the second message belongs is unimportant flow, the second message is added into the unimportant flow cache queue.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a message processing apparatus shown in the present application, and the apparatus is applied to a network device, and includes:
a determiningmodule 21, configured to determine an actual bandwidth required by the important traffic buffer queue according to each packet included in the preset important traffic buffer queue;
a selectingmodule 22, configured to select a designated member port from the aggregation ports of the network device according to the total bandwidth and the actual bandwidth of the network device;
and theforwarding module 23 is configured to forward each packet included in the important traffic buffer queue through the designated member port.
According to the technical scheme provided by the application, the actual bandwidth required by the important flow cache queue can be determined according to each message contained in the preset important flow cache queue, then the appointed member port is selected from the aggregation port of the network equipment according to the total bandwidth and the actual bandwidth of the network equipment, and each message contained in the important flow cache queue is forwarded through the appointed member port.
Specifically, the determiningmodule 21 is configured to determine, according to each packet included in the preset important traffic buffer queue, an actual bandwidth required by the important traffic buffer queue, and specifically is configured to:
counting the total message length and the message number of all messages included in the important flow cache queue;
dividing the total length of the messages by the number of the messages to obtain the average length of the messages of the important flow cache queue;
determining a first average value of the maximum message length and the minimum message length in the message lengths of all messages included in the important flow cache queue;
determining whether the average length of the message is smaller than a first average value;
if the average length of the message is equal to or greater than the first average value, determining the total length of the message as the actual bandwidth required by the important flow cache queue;
if the average message length is smaller than the first average value, determining a second average value of the minimum message length and the first average value, determining whether the average message length is smaller than the second average value, and if the average message length is smaller than the second average value, determining a first set multiple of the total message length as an actual bandwidth required by the important flow cache queue; if the average length of the message is greater than or equal to the second average value, determining a second set multiple of the total length of the message as an actual bandwidth required by the important flow cache queue.
Specifically, the selectingmodule 22 is configured to select, from the aggregate ports of the network device, a designated member port according to the total bandwidth and the actual bandwidth of the network device, specifically configured to:
selecting a member port with an opened state from all member ports of an aggregation port of the network equipment to obtain a candidate member port set;
calculating the difference between the total bandwidth and the actual bandwidth of the network device;
and selecting the member ports with the sum of bandwidths not exceeding and closest to the difference value from the candidate member port set according to a preset algorithm to obtain the designated member port.
In an alternative embodiment, the apparatus further comprises:
the receiving module is used for receiving a first message sent by the terminal or other network equipment;
the first acquisition module is used for acquiring first quintuple information of a first message, wherein the first quintuple information comprises a first source IP address, a first destination IP address, a first source port, a first destination port and a protocol;
the first searching module is used for searching the first quintuple information in a preset access control list;
the establishing module is configured to, if the first quintuple information is found in the access control list, find second quintuple information including the first destination IP address being the second source IP address, the first source IP address being the second destination IP address, the first destination port being the second source port, the second source port being the second destination port, and the protocol in the important traffic information table, and if the second quintuple information is not found in the important traffic information table, establish the second quintuple information in the important traffic information table.
In an alternative embodiment, the apparatus further comprises:
the second acquisition module is used for acquiring the generated second message;
the second searching module is used for searching the third quintuple information of the second message in the important flow information table;
the adding module is used for adding the second message into the important flow cache queue if the third quintuple information is found in the important flow information table; and if the third quintuple information is not found in the important flow information table, adding the second message into the unimportant flow cache queue.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purposes of the present application. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The embodiment of the application further provides an electronic device, please refer to fig. 3, which includes aprocessor 310, acommunication interface 320, amemory 330 and acommunication bus 340, wherein theprocessor 310, thecommunication interface 320 and thememory 330 complete communication with each other through thecommunication bus 340.
Amemory 330 for storing a computer program;
theprocessor 310 is configured to implement the message processing method according to any of the above embodiments when executing the program stored in thememory 330.
Thecommunication interface 320 is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), 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 (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
According to the technical scheme provided by the application, the actual bandwidth required by the important flow cache queue can be determined according to each message contained in the preset important flow cache queue, then the appointed member port is selected from the aggregation port of the network equipment according to the total bandwidth and the actual bandwidth of the network equipment, and each message contained in the important flow cache queue is forwarded through the appointed member port.
Accordingly, embodiments of the present application further provide a computer readable storage medium having instructions stored therein, which when executed on a computer, cause the computer to perform the method for processing a message according to any of the foregoing embodiments.
According to the technical scheme provided by the application, the actual bandwidth required by the important flow cache queue can be determined according to each message contained in the preset important flow cache queue, then the appointed member port is selected from the aggregation port of the network equipment according to the total bandwidth and the actual bandwidth of the network equipment, and each message contained in the important flow cache queue is forwarded through the appointed member port.
The foregoing description of the preferred embodiments of the present invention is not intended to limit the invention to the precise form disclosed, and any modifications, equivalents, improvements and alternatives falling within the spirit and principles of the present invention are intended to be included within the scope of the present invention.