Method and device for acquiring queue length and computer readable storage medium
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a method and an apparatus for obtaining a queue length, and a computer-readable storage medium.
Background
In a Software Defined Network (SDN), ports of OpenFlow switches support adding priority queues, as shown in fig. 1, generally, the number of queues of each OpenFlow switch port is 3, each queue allows allocating different bandwidths, the sum of bandwidths of all queues does not exceed the total bandwidth of the port, and the size of the queue bandwidth directly determines the capacity of the queue to forward data. As can be seen from fig. 1, in the data plane, each time a new packet arrives at the switch, the switch matches the destination address of the header of the packet with a flow table entry matching field in a flow table (similar to a routing table in a conventional network device) one by one, and once matching is successful, the packet performs operations such as direct output (output), enqueue (set _ queue), flood (flow), drop (drop) and the like according to an action set specified by the flow table entry. If the enqueue operation is performed, the data packet header contains priority information, and the data packets with different priorities enter queues with different bandwidths, so that the data packets with high priorities still have larger bandwidths when the network is congested, and lower forwarding delay is kept.
Based on this, in order to provide better quality of service and fully utilize port bandwidth resources, a bandwidth allocation policy of each queue on a port of the OpenFlow switch is very important. As known, the basis of the bandwidth allocation strategy is the current queuing delay of the queue, and the current queuing delay of the queue is obtained according to the following formula (1), namely the current queuing delay t of the queue is equal to the current average queue length AvgQ of the queue1And current queue bandwidth bw1The ratio of (A) to (B);
t=AvgQ1/bw1(1)
wherein the current average queue length AvgQ of the queue1The calculation formula is shown in the following formula (2):
AvgQ1=(1-wq)*AvgQ0+wq*qLen1(2) in the formula, AvgQ0Is the average queue length, qLen, of the moment before the queue1The length of the queue (i.e. the length of the real-time queue) is the current queue length of the queue, wq is a weight value used for measuring the length qLen of the real-time queue1Average queue length AvgQ of queue current1The degree of influence of (c) is sized according to the actual network conditions and system characteristics.
As can be seen from the above equation (2), the basis for determining the current average queue length of the queue is the current queue length of the queue, i.e. the real-time queue length qLen1. However, the OpenFlow protocol does not provide an interface method for directly obtaining the length of a real-time queue, which is obtained by indirect calculation in the existing real-time queueIn the column length calculation method, the real-time queue length qLen1Is obtained according to the following formula (3), namely the real-time queue length qLen1Is equal to the accumulated Byte number in _ Byte entering the queue at a certain moment1(namely the accumulated Byte number of enqueue) minus the accumulated Byte number out _ Byte of dequeue at the same moment1(i.e., the number of dequeued accumulated bytes).
qLen1=in_Byte1-out_Byte1(3)
As can be seen from the above equation (3), the conventional real-time queue length calculation method requires that the enqueue accumulated data amount and the dequeue accumulated data amount must be acquired synchronously, i.e., the enqueue accumulated data amount and the dequeue accumulated data amount must be acquired at the same time. However, in practical applications, it is not guaranteed that the obtained enqueue and dequeue data are at the same time, as shown in fig. 2, in one query, the query includes a query of the enqueue accumulated data amount and the dequeue accumulated data amount of the queue, and from the time line shown in the figure, the query time of the enqueue accumulated data amount and the dequeue accumulated data amount inevitably has a certain time difference, so that the queried enqueue accumulated data amount is larger than the actual enqueue accumulated data amount, or the queried dequeue accumulated data amount is smaller than the actual dequeue accumulated data amount, and further, the actually obtained real-time queue length qLen is further made to be the same as the actual dequeue accumulated data amount1With some error. In addition, when congestion occurs in the queue, part of the data packets may be lost, and when the real-time queue length is calculated, the in _ Byte in the above equation (3) is used1And out _ Byte1Is the accumulated value by a certain time, so the missing part will also be calculated in the difference of the in-and-out queue; moreover, the accumulated number of lost packets is accumulated over time, which results in larger and larger errors of the obtained real-time queue length.
From the above three formulas, if the real-time queue length qLen1Inaccurate acquisition directly causes the current queuing delay calculation error of the port queue of the OpenFlow switch, and bandwidth resources cannot be allocated by effectively utilizing a bandwidth allocation strategy on the basis, so that the utilization rate of the bandwidth resources is seriously reduced, and the network service quality is influenced.
Disclosure of Invention
In order to solve the foregoing technical problems, embodiments of the present invention are intended to provide a method, an apparatus, and a computer-readable storage medium for obtaining a queue length, so as to obtain a more accurate real-time queue length, thereby improving the utilization of bandwidth resources and the network quality of service.
The technical scheme of the invention is realized as follows:
in a first aspect, an embodiment of the present invention provides a method for obtaining a queue length, where the method includes:
acquiring enqueue data increment and dequeue data increment of an OpenFlow switch port queue in a first preset time period; the first preset time period refers to the time length between the current time and the previous time;
calculating the real-time queue length of the OpenFlow switch port queue by utilizing the enqueue data increment and dequeue data increment of the OpenFlow switch port queue in the first preset time period and the queue length of the OpenFlow switch port queue in the second preset time period; and the second preset time period is a time period before the first preset time period.
In the foregoing scheme, the acquiring enqueue data increment and dequeue data increment of the OpenFlow switch port queue within the first preset time period specifically includes:
acquiring the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue at the current moment and the previous moment;
and respectively calculating enqueue data increment and dequeue data increment of the OpenFlow switch port queue in the first preset time period according to the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue obtained at the current time and at the previous time.
In the foregoing scheme, the calculating an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue within the first preset time period according to the enqueue accumulated data amount and the dequeue accumulated data amount of the OpenFlow switch port queue obtained at the current time and at the previous time respectively specifically includes:
taking a numerical value obtained by subtracting the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the current moment as an enqueue data increment of the OpenFlow switch port queue within the first preset time period; and the number of the first and second groups,
and taking a numerical value obtained by subtracting the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the current moment as a dequeuing data increment of the OpenFlow switch port queue in the first preset time period.
In the foregoing solution, the calculating a real-time queue length of the OpenFlow switch port queue by using an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue in the first preset time period and a queue length of the OpenFlow switch port queue in the second preset time period specifically includes:
incrementing enqueue data of the OpenFlow switch port queue within the first preset time period
And dequeue data increments
And the queue length of the OpenFlow switch port queue in a second preset time period
Substituting the real-time queue length of the OpenFlow switch port queue into the following formula (4) to obtain the real-time queue length of the OpenFlow switch port queue
In the above aspect, the method further includes:
calculating the average queue length of the OpenFlow switch port queue calculated in the second preset time period
And real-time queue length of the OpenFlow switch port queue
Substituting the following formula (5) to calculate the current average queue length of the OpenFlow switch port queue
In the formula, wq is a weight value, and the numeric area is (0, 1);
acquiring the current queue bandwidth of the port queue of the OpenFlow switch;
queuing the OpenFlow switch port queue to a current average queue length
And a current queue bandwidth of the OpenFlow switch port queue
Substituting the following formula (6) to calculate the current queuing delay t of the port queue of the OpenFlow switch:
and reallocating the bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
In a second aspect, an embodiment of the present invention provides an apparatus for obtaining a queue length, where the apparatus includes: the device comprises a data increment acquisition module and a real-time queue length calculation module; wherein the content of the first and second substances,
the data increment obtaining module is configured to obtain enqueue data increments and dequeue data increments of the OpenFlow switch port queue within a first preset time period; the first preset time period refers to the time length between the current time and the previous time;
the real-time queue length calculation module is configured to calculate a real-time queue length of the OpenFlow switch port queue by using an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue in the first preset time period and a queue length of the OpenFlow switch port queue in a second preset time period; and the second preset time period is a time period before the first preset time period.
In the foregoing scheme, the data increment obtaining module specifically includes: the data query submodule and the data increment calculation submodule; wherein the content of the first and second substances,
the data query submodule is configured to acquire enqueue accumulated data volume and dequeue accumulated data volume of the OpenFlow switch port queue at the current moment and the previous moment;
the data increment calculation sub-module is configured to calculate an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue within the first preset time period according to the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue acquired at the current time and at the previous time.
In the above scheme, the data increment calculation sub-module is specifically configured to:
taking a numerical value obtained by subtracting the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the current moment as an enqueue data increment of the OpenFlow switch port queue within the first preset time period; and the number of the first and second groups,
and taking a numerical value obtained by subtracting the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the current moment as a dequeuing data increment of the OpenFlow switch port queue in the first preset time period.
In the above scheme, the real-time queue length calculating module is specifically configured to:
incrementing enqueue data of the OpenFlow switch port queue within the first preset time period
And dequeue data increments
And the queue length of the OpenFlow switch port queue in a second preset time period
Substituting the real-time queue length of the OpenFlow switch port queue into the following formula (7) to obtain the real-time queue length of the OpenFlow switch port queue
In the above scheme, the apparatus further comprises a queuing delay calculation module and a policy management module; wherein the content of the first and second substances,
the queuing delay calculation module is configured to calculate the average queue length of the port queue of the OpenFlow switch in the second preset time period
And real-time queue length of the OpenFlow switch port queue
Substituting the following formula (8) to obtain the OpenFlow switch port queueAverage queue length of current queue
In the formula, wq is a weight value, and the numeric area is (0, 1);
the queuing delay calculation module is configured to obtain a current queue bandwidth of the port queue of the OpenFlow switch;
the queuing delay calculation module is configured to queue the current average queue length of the port queue of the OpenFlow switch
And a current queue bandwidth of the OpenFlow switch port queue
And substituting the following formula (9) to calculate the current queuing time delay t of the port queue of the OpenFlow switch:
the policy management module is configured to reallocate bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
In a third aspect, an embodiment of the present invention provides an apparatus for obtaining a queue length, where the apparatus includes: a memory, a processor, and a computer program stored on the memory and executable on the processor; wherein, the processor implements the above method steps for obtaining the queue length when executing the program.
In a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing one or more programs, which are executable by one or more processors to implement the method steps for obtaining queue length described above.
The embodiment of the invention provides a method for acquiring queue length, which creatively utilizes the data increment of an out/in queue to recursively calculate the current queue length of an OpenFlow switch port queue, namely the real-time queue length, and only needs to ensure that the enqueue data increment and the dequeue data increment are the increment in the same time length without ensuring the synchronism of the queue in and out data; meanwhile, an error caused by packet loss is not an accumulated value any more but a single value within a certain preset time period, and therefore if the set time period is sufficiently small, the error can be ignored. Therefore, by using the method for acquiring the real-time queue length provided by the embodiment of the invention, the more accurate real-time queue length can be acquired, so that the subsequent bandwidth adjustment strategy can exert a better effect, and the utilization rate of bandwidth resources is effectively improved; meanwhile, when the queue is congested, the congestion condition can be timely found, so that higher-quality service is provided for the user. In addition, the embodiment of the invention also provides equipment for acquiring the queue length and a computer readable storage medium.
Drawings
Fig. 1 is a schematic diagram of a port queue of an OpenFlow switch according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a data query according to an embodiment of the present invention;
fig. 3 is a schematic diagram illustrating a method for obtaining a real-time queue length according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a relationship between a real-time queue length and a queue length in a second preset time period according to an embodiment of the present invention;
fig. 5 is a schematic diagram illustrating another method for obtaining a real-time queue length according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a method for obtaining an enqueue data increment and a dequeue data increment according to an embodiment of the present invention;
fig. 7 is a schematic structural diagram of an apparatus for obtaining a real-time queue length according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of another apparatus for obtaining a real-time queue length according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of another apparatus for obtaining a real-time queue length according to an embodiment of the present invention;
fig. 10 is a schematic workflow diagram of an apparatus for obtaining a real-time queue length according to an embodiment of the present invention;
fig. 11 is a schematic diagram of a single-terminal loopback test method according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of an apparatus for obtaining a real-time queue length according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
Example one
As shown in fig. 3, the figure illustrates a method for obtaining a queue length according to an embodiment of the present invention, and as can be seen from the figure, the method mainly includes the following steps:
s110, acquiring enqueue data increment and dequeue data increment of an OpenFlow switch port queue in a first preset time period; the first preset time period refers to the time length between the current time and the previous time;
it can be understood that the enqueue data increment and dequeue data increment of the OpenFlow switch port queue are increment amounts within the same time length, and it is not necessary to guarantee that the enqueue data amount of the OpenFlow switch port queue is queried at the same time.
S120, calculating the real-time queue length of the OpenFlow switch port queue by utilizing the enqueue data increment and the dequeue data increment of the OpenFlow switch port queue in the first preset time period and the queue length of the OpenFlow switch port queue in the second preset time period; and the second preset time period is a time period before the first preset time period.
It can be understood that, in the step S120, since the enqueue data increment and the dequeue data increment of the OpenFlow switch port queue are used as a basis for calculating the length of the real-time queue, it is not necessary to guarantee the enqueue data amount of the port queue to be queried at the same time, but it is only necessary to guarantee that the enqueue data increment is the data increment acquired within the same time duration, so that the method shown in fig. 3 reduces the real-time queue length acquisition error caused by the asynchronization of data query in the prior art; meanwhile, because the error generated by packet loss is no longer an accumulated value but a single value within a preset time period, if the set time length is small enough, the error can be ignored, and therefore, the method shown in fig. 3 can also effectively reduce the influence of the packet loss on the length of the real-time queue.
For example, for step S110, the obtaining an enqueue data increment and a dequeue data increment of an OpenFlow switch port queue in a first preset time period specifically includes the following steps:
s1101, acquiring enqueue accumulated data volume and dequeue accumulated data volume of the OpenFlow switch port queue at the current moment and at the previous moment;
and S1102, respectively calculating an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue within the first preset time period according to the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue acquired at the current time and at the previous time.
Specifically, for step S1102, the calculating an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue within the first preset time period according to the enqueue accumulated data amount and the dequeue accumulated data amount of the OpenFlow switch port queue obtained at the current time and at the previous time may include:
taking a numerical value obtained by subtracting the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the current moment as an enqueue data increment of the OpenFlow switch port queue within the first preset time period; and the number of the first and second groups,
and taking a numerical value obtained by subtracting the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the current moment as a dequeuing data increment of the OpenFlow switch port queue in the first preset time period.
Here, it should be noted that the time points of acquiring the enqueue accumulated data amount and the dequeue accumulated data amount may be different, that is, it is not necessary to guarantee the synchronicity of querying the enqueue accumulated data amount and the dequeue accumulated data amount, as long as the time lengths between the current time and the previous time are equal. In this way, the enqueue data increment and the dequeue data increment in the preset time period are used for calculating the real-time queue length of the port queue of the OpenFlow switch, so that the acquisition error of the real-time queue length caused by the asynchronism of data query in the conventional calculation method (corresponding to the above formula (3)) can be eliminated.
For example, for step S120, the calculating a real-time queue length of the OpenFlow switch port queue by using an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue in the first preset time period and a queue length of the OpenFlow switch port queue in the second preset time period may specifically include:
incrementing enqueue data of the OpenFlow switch port queue within the first preset time period
And dequeue data increments
And the queue length of the OpenFlow switch port queue in a second preset time period
Substituting the real-time queue length of the OpenFlow switch port queue into the following formula (10) to obtain the real-time queue length of the OpenFlow switch port queue
It can be understood that, as shown in fig. 4, in a first preset time period, a difference value between an enqueue data increment and a dequeue data increment of an OpenFlow switch port queue is a data amount staying in the OpenFlow switch port queue in the time period, and therefore, adding the data amount staying in the OpenFlow switch port queue in the time period to a queue length of the OpenFlow switch port queue in a second preset time period is a real-time queue length of the OpenFlow switch port queue.
Illustratively, the method shown in fig. 3 further includes:
s130, calculating the current average queue length of the OpenFlow switch port queue according to the following formula (11)
In the formula (I), the compound is shown in the specification,
representing a second preset time period deltat
0The calculated average queue length of the OpenFlow switch port queue; wq is weight, and the value range is (0, 1);
representing a real-time queue length of the OpenFlow switch port queue;
here, it should be noted that in a real SDN network, data is usually bursty, and a queue may be suddenly filled at a certain time and then be quickly emptied. Therefore, the above equation (11), i.e., the Random Early Detection equation (RED) pair is adoptedReal-time queue length
And performing low-pass filtering, ignoring burst characteristics of data, and focusing on long-term change of the queue length, namely the average queue length of the queue, so as to obtain more real and reliable queuing delay.
S140, acquiring the current queue bandwidth of the OpenFlow switch port queue;
s150, calculating a current queuing delay t of the port queue of the OpenFlow switch according to the following formula (12):
in the formula (I), the compound is shown in the specification,
representing the current average queue length of the OpenFlow switch port queue;
representing a current queue bandwidth of the OpenFlow switch port queue;
and S160, reallocating the bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
It can be understood that when the current queuing delay of the OpenFlow switch port queue is large, it indicates that the queue is in a congestion state, and in order to improve the congestion state of the queue, a larger bandwidth may be allocated to the queue, so as to accelerate the data forwarding rate and relieve the data congestion of the queue.
The embodiment of the invention provides a method for acquiring the length of a real-time queue, which mainly utilizes enqueue data increment and dequeue data increment of an OpenFlow switch port queue in a first preset time period and the queue length of the OpenFlow switch port queue in a second preset time period to calculate the length of the real-time queue of the OpenFlow switch port queue. The method comprises the steps that the data increment of an ingress/egress queue is obtained on the basis of obtaining the real-time queue length of an OpenFlow switch port queue, so that the synchronism of inquiring the accumulated data quantity of the ingress/egress queue is not required, and only the enqueue data increment and the dequeue data increment are ensured to be the increment within the same time length; meanwhile, the error caused by packet loss is no longer an accumulated value but a single value within the first preset time period, and therefore, if the set first preset time period is sufficiently small, the error can be ignored. Therefore, the method for obtaining the length of the real-time queue provided by the embodiment of the invention can reduce the calculation error of the length of the real-time queue caused by the asynchronism of data query, and can effectively reduce the error brought by the packet loss of the data to the calculation of the length of the real-time queue, thereby obtaining more accurate queuing delay and effectively improving the utilization rate of bandwidth resources and the network service quality.
Example two
For facilitating understanding of the above technical solution, as shown in fig. 5, this figure shows a specific implementation process for acquiring a queue length and allocating a queue bandwidth by using a real-time queue length according to an embodiment of the present invention, and as can be seen from the figure, this process mainly includes the following implementation steps:
s210, acquiring the enqueue accumulated byte number, the dequeue accumulated byte number and the queue bandwidth of the OpenFlow switch port queue at the current moment and the previous moment;
s220, respectively calculating an enqueue byte number increment and a dequeue byte number increment of the OpenFlow switch port queue within a first preset time period according to the enqueue accumulated byte number and the dequeue accumulated byte number of the OpenFlow switch port queue obtained at the current time and at the previous time; the first preset time period refers to the time length between the current time and the previous time;
it is understood that the data increment refers to an amount of data increase in a certain period of time. Therefore, here, the enqueue byte count increment of the OpenFlow switch port queue in the first preset time period is equal to the enqueue accumulated byte count of the OpenFlow switch port queue acquired at the current time minus the enqueue accumulated byte count of the OpenFlow switch port queue acquired at the previous time. Similarly, the dequeue byte number increment of the OpenFlow switch port queue in the first preset time period is equal to the dequeue accumulated byte number of the OpenFlow switch port queue obtained at the current moment minus the dequeue accumulated byte number of the OpenFlow switch port queue obtained at the previous moment.
As shown in fig. 6, when calculating the enqueue byte number increment and the dequeue byte number increment of the OpenFlow switch port queue in the first preset time period, it is only necessary to ensure that the enqueue data increment and the dequeue data increment are increment amounts within the same time length without ensuring that the time for querying the accumulated enqueue/enqueue data amount is equal.
S230, calculating the real-time queue length of the OpenFlow switch port queue according to the following formula (13)
In the formula (I), the compound is shown in the specification,
and
respectively represent the first preset time period deltat
1Enqueue byte number increment and dequeue byte number increment of an internal OpenFlow switch port queue;
represents the second preset time period deltat
0The queue length of the OpenFlow switch port queue is set;
s240, calculating the current average queue length of the OpenFlow switch port queue according to the following formula (14)
In the formula (I), the compound is shown in the specification,
is represented by the second preset time period deltat
0The calculated average queue length of the OpenFlow switch port queue; wq is weight, and the value range is (0, 1);
s250, calculating the current queuing delay t of the port queue of the OpenFlow switch according to the following formula (15):
in the formula (I), the compound is shown in the specification,
a current queue bandwidth of the OpenFlow switch port queue;
and S260, reallocating the bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
EXAMPLE III
Based on the same technical concept as described above, as shown in fig. 7, which illustrates an apparatus 30 for obtaining queue length according to an embodiment of the present invention, as can be seen from the figure, the apparatus 30 may include: a data increment acquisition module 310 and a real-time queue length calculation module 320; wherein the content of the first and second substances,
the data increment obtaining module 310 may be configured to obtain an enqueue data increment and a dequeue data increment of an OpenFlow switch port queue within a first preset time period; the first preset time period refers to the time length between the current time and the previous time;
the real-time queue length calculating module 320 may be configured to calculate a real-time queue length of the OpenFlow switch port queue by using an enqueue data increment and an dequeue data increment of the OpenFlow switch port queue in the first preset time period and a queue length of the OpenFlow switch port queue in a second preset time period; and the second preset time period is a time period before the first preset time period.
In the foregoing scheme, the data increment obtaining module 310, as shown in fig. 8, may specifically include: a data query sub-module 3101 and a data increment calculation sub-module 3102; wherein the content of the first and second substances,
the data query sub-module 3101 may be configured to obtain an enqueue accumulated data volume and a dequeue accumulated data volume of the OpenFlow switch port queue at a current time and a previous time;
the data increment calculation sub-module 3102 may be configured to calculate an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue within the first preset time period according to the enqueue accumulated data amount and the dequeue accumulated data amount of the OpenFlow switch port queue obtained at the current time and at the previous time.
In the above scheme, the data increment calculation sub-module 3102 may be specifically configured to:
taking a numerical value obtained by subtracting the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the current moment as an enqueue data increment of the OpenFlow switch port queue within the first preset time period; and the number of the first and second groups,
and taking a numerical value obtained by subtracting the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the current moment as a dequeuing data increment of the OpenFlow switch port queue in the first preset time period.
In the above scheme, the real-time queue length calculating module 320 may be specifically configured to:
incrementing enqueue data of the OpenFlow switch port queue within the first preset time period
And dequeue data increments
And the queue length of the OpenFlow switch port queue in a second preset time period
Substituting the real-time queue length of the OpenFlow switch port queue into the following formula (16) to obtain the real-time queue length of the OpenFlow switch port queue
In the above solution, as shown in fig. 9, the apparatus 30 may further include a queuing delay calculation module 330 and a policy management module 340; wherein the content of the first and second substances,
the queuing
delay calculation module 330 is configured to calculate the average queue length of the port queue of the OpenFlow switch in the second preset time period
And real-time queue length of the OpenFlow switch port queue
Calculating the current average queue length of the OpenFlow switch port queue by substituting the following formula (17)
In the formula, wq is a weight value, and the numeric area is (0, 1);
the queuing delay calculation module 330 is configured to obtain a current queue bandwidth of the port queue of the OpenFlow switch;
the queuing
delay calculation module 330 is configured to queue the current average queue length of the OpenFlow switch port queue
And a current queue bandwidth of the OpenFlow switch port queue
Substituting the following formula (18) to calculate the current queuing delay t of the port queue of the OpenFlow switch:
the policy management module 340 is configured to reallocate bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
Example four
In order to facilitate understanding of the above technical solution, in the embodiment of the present invention, a work flow of the apparatus in practical application will be described in conjunction with the apparatus 30, specifically referring to fig. 10, and as can be seen from the figure, the work flow mainly includes the following steps:
s410, the data query sub-module 3101 is connected with the OpenFlow switch;
s420, the module sends inquiry commands of enqueuing and dequeuing accumulated data volume to the OpenFlow switch through the connection between the module and the OpenFlow switch;
here, it should be noted that, in practical applications, the connection between the data query sub-module 3101 and the OpenFlow switch may be a Secure Shell Protocol (SSH) connection based on a Transmission Control Protocol (TCP). Since a certain time is required for initially establishing the connection, a static long connection may be used in order to avoid the need to re-establish the connection every data query.
S430, when the OpenFlow switch receives the query command issued by the module 3101, the OpenFlow switch sends the current enqueue cumulative data amount, dequeue cumulative data amount, and queue bandwidth of the port queue to the module 3101;
s440, after receiving the enqueue accumulated data amount, the dequeue accumulated data amount, and the queue bandwidth of the port queue sent by the OpenFlow switch, the module 3101 calls the data increment calculation sub-module 3102, the real-time queue length calculation module 320, and the queuing delay calculation module 330 in sequence, so as to calculate the current queuing delay of the port queue;
s450, the module 3101 sends the current queuing delay of the port queue to the policy management module 340;
s460, when the policy management module 340 receives the current queuing delay of the port queue, generating a bandwidth allocation policy according to the current queuing delay of each port queue;
s470, the policy management module 340 issues the policy to the OpenFlow switch;
s480, the OpenFlow switch allocates bandwidth for each port queue again according to the strategy;
s490, the OpenFlow switch feeds back the adjusted queue bandwidth of the port queue to the module 3101.
Here, it should be noted that the workflow shown in fig. 10 is only for explaining a specific cooperation flow between the OpenFlow switch and each of the virtual modules for implementing the above technical solution, and the apparatus 30 may be a terminal independent from the OpenFlow switch, such as a Personal Computer (PC), or a Computer-readable storage medium inserted in the OpenFlow switch, where the device implementation of the apparatus 30 is not limited herein.
In order to verify the technical effect obtained by the above technical solution, assuming that the apparatus 30 is a terminal independent from an OpenFlow switch, as shown in fig. 11, this figure shows a flowchart of testing the actual queuing delay of each port queue by a single-terminal loopback test method, and the main principle of the test is as follows: the terminal realizes the mutual communication between the path 1 and the path 3 shown in fig. 11, after the communication is successful, the terminal starts a data receiving program for monitoring whether data is transmitted, starts a data sending program, and continuously sends data packets to the OpenFlow switch, and each data packet carries a unique sequence number and a unique timestamp (i.e., system time when sending the packet). For each data packet, the data receiving program of the terminal may monitor that the terminal receives the same data packet twice in sequence: the first time is as follows: the data packet is directly captured by a data receiving program locally, and the data receiving program records the time delay of receiving the data packet at this time; the second time is that: the data packet is transmitted back to the terminal along the direction of the path 1- > path 2- > path 3 shown in fig. 11 and received by the data receiving program, and the data receiving program records the time delay of receiving the data packet this time. Since the transmission time of the data packet on the path 1 and the path 3 is very long, the difference value of the receiving delay of the two data packets is the actual queuing delay of the data packet in the port queue.
In fact, a method for obtaining the length of the real-time queue according to the embodiment of the present invention has performed a large number of tests on an entity OpenFlow switch, and test results thereof are shown in table 1 below, which shows queuing delays of queues with different bandwidths obtained by the following three methods when a transmission frequency of a packet is 10000 packets/sec and a size of each packet is 1KB, where queuing delay 1 shown in table 1 is an actual queuing delay obtained by a single-terminal loopback test method shown in fig. 11, queuing delay 2 is a queuing delay obtained by using the method for obtaining the length of the real-time queue according to the embodiment of the present invention, and queuing delay 3 is a queuing delay obtained by using the method described in the background art.
TABLE 1 queuing delay (unit: ms) for queues with different bandwidths
|
Queue 0 (Bandwidth 60M)
|
Queue 1 (Bandwidth 30M)
|
Queue 2 (Bandwidth 10M)
|
Queuing delay 1
|
123
|
248
|
746
|
Queuing delay 2
|
114
|
234
|
739
|
Time delay in queuing 3
|
142
|
275
|
760 |
As can be seen from the test results shown in table 1 above, the queuing delay obtained by using the method for obtaining the length of the real-time queue according to the embodiment of the present invention is closer to the actual queuing delay of the port queue.
EXAMPLE five
Based on the same technical concept as described above, as shown in fig. 12, the figure illustrates an apparatus 60 for obtaining queue length according to an embodiment of the present invention, and as can be seen from the figure, the apparatus 60 may include: a memory 610, a processor 620 and a computer program 630 stored on the memory 610 and executable on the processor 620, the processor 620 implementing the following steps when executing the program 630:
acquiring enqueue data increment and dequeue data increment of an OpenFlow switch port queue in a first preset time period; the first preset time period refers to the time length between the current time and the previous time;
calculating the real-time queue length of the OpenFlow switch port queue by utilizing the enqueue data increment and dequeue data increment of the OpenFlow switch port queue in the first preset time period and the queue length of the OpenFlow switch port queue in the second preset time period; and the second preset time period is a time period before the first preset time period.
In practical applications, the Memory 610 may be a volatile Memory (volatile Memory), such as a Random-Access Memory (RAM); or a non-volatile Memory (non-volatile Memory), such as a Read-Only Memory (ROM), a flash Memory (flash Memory), a hard disk (HDD), or a Solid-State Drive (SSD); or a combination of the above types of memories and provides a computer program to the processor 620.
The Processor 620 may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It will be appreciated that the electronic devices used to implement the processor functions described above may be other devices, and embodiments of the present invention are not limited in particular.
For example, the obtaining of the enqueue data increment and the dequeue data increment of the OpenFlow switch port queue in the first preset time period may be further executed by the processor 620, so as to implement the following steps:
acquiring the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue at the current moment and the previous moment;
and respectively calculating enqueue data increment and dequeue data increment of the OpenFlow switch port queue in the first preset time period according to the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue obtained at the current time and at the previous time.
Specifically, the enqueue data increment and the dequeue data increment of the OpenFlow switch port queue in the first preset time period are respectively calculated according to the enqueue accumulated data amount and the dequeue accumulated data amount of the OpenFlow switch port queue acquired at the current time and at the previous time, and the method can be further executed by the processor 620 to implement the following steps:
taking a numerical value obtained by subtracting the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the current moment as an enqueue data increment of the OpenFlow switch port queue within the first preset time period; and the number of the first and second groups,
and taking a numerical value obtained by subtracting the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the current moment as a dequeuing data increment of the OpenFlow switch port queue in the first preset time period.
Illustratively, the calculating a real-time queue length of the OpenFlow switch port queue by using an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue in the first preset time period and a queue length of the OpenFlow switch port queue in the second preset time period may be further executed by the processor 620, so as to implement the following steps:
incrementing enqueue data of the OpenFlow switch port queue within the first preset time period
And dequeue data increments
And within a second preset time periodQueue length of the OpenFlow switch port queue
Substituting the following formula (19) to calculate the real-time queue length of the port queue of the OpenFlow switch
Illustratively, the processor 620 may also implement the following steps when executing the program 630:
calculating the average queue length of the OpenFlow switch port queue calculated in the second preset time period
And real-time queue length of the OpenFlow switch port queue
Substituting the following formula (20) to calculate the current average queue length of the OpenFlow switch port queue
In the formula, wq is a weight value, and the numeric area is (0, 1);
acquiring the current queue bandwidth of the port queue of the OpenFlow switch;
queuing the OpenFlow switch port queue to a current average queue length
And a current queue bandwidth of the OpenFlow switch port queue
Substituting the following formula (21) to calculate the current queuing delay t of the port queue of the OpenFlow switch:
and reallocating the bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
EXAMPLE six
The technical solution of any of the above embodiments essentially or partially contributes to the prior art, or all or part of the technical solution may be embodied in the form of a software product stored in a computer-readable storage medium, which includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (processor) to execute all or part of the steps of the method described in this embodiment. And the aforementioned computer-readable storage media comprise: a U-disk, a removable hard disk, a Read Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
Specifically, the computer program instructions corresponding to the method for obtaining queue length in this embodiment may be stored in a computer-readable storage medium such as an optical disc, a hard disk, a usb disk, or the like, where the computer-readable storage medium stores one or more programs, and the one or more programs are executable by one or more processors to implement the following steps:
acquiring enqueue data increment and dequeue data increment of an OpenFlow switch port queue in a first preset time period; the first preset time period refers to the time length between the current time and the previous time;
calculating the real-time queue length of the OpenFlow switch port queue by utilizing the enqueue data increment and dequeue data increment of the OpenFlow switch port queue in the first preset time period and the queue length of the OpenFlow switch port queue in the second preset time period; and the second preset time period is a time period before the first preset time period.
For example, the obtaining of the enqueue data increment and the dequeue data increment of the OpenFlow switch port queue within the first preset time period may be executed by the one or more processors to implement the following steps:
acquiring the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue at the current moment and the previous moment;
and respectively calculating enqueue data increment and dequeue data increment of the OpenFlow switch port queue in the first preset time period according to the enqueue accumulated data volume and the dequeue accumulated data volume of the OpenFlow switch port queue obtained at the current time and at the previous time.
Specifically, the one or more processors may be configured to calculate an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue within the first preset time period according to the enqueue accumulated data amount and the dequeue accumulated data amount of the OpenFlow switch port queue obtained at the current time and at the previous time, and implement the following steps:
taking a numerical value obtained by subtracting the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the enqueue accumulated data volume of the OpenFlow switch port queue obtained at the current moment as an enqueue data increment of the OpenFlow switch port queue within the first preset time period; and the number of the first and second groups,
and taking a numerical value obtained by subtracting the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the previous moment from the dequeuing accumulated data volume of the OpenFlow switch port queue obtained at the current moment as a dequeuing data increment of the OpenFlow switch port queue in the first preset time period.
Illustratively, the calculating a real-time queue length of the OpenFlow switch port queue by using an enqueue data increment and a dequeue data increment of the OpenFlow switch port queue in the first preset time period and a queue length of the OpenFlow switch port queue in the second preset time period may be executed by the one or more processors to implement the following steps:
incrementing enqueue data of the OpenFlow switch port queue within the first preset time period
And dequeue data increments
And the queue length of the OpenFlow switch port queue in a second preset time period
Substituting the real-time queue length of the OpenFlow switch port queue into the following formula (22) to obtain the real-time queue length of the OpenFlow switch port queue
Illustratively, the one or more programs described above are also executable by the one or more processors to perform the steps of:
calculating the average queue length of the OpenFlow switch port queue calculated in the second preset time period
And real-time queue length of the OpenFlow switch port queue
Substituting the following formula (23) to calculate the current average queue length of the OpenFlow switch port queue
In the formula, wq is a weight value, and the numeric area is (0, 1);
acquiring the current queue bandwidth of the port queue of the OpenFlow switch;
queuing the OpenFlow switch port queue to a current average queue length
And a current queue bandwidth of the OpenFlow switch port queue
And substituting the following formula (24) to calculate the current queuing delay t of the port queue of the OpenFlow switch:
and reallocating the bandwidth to the OpenFlow switch port queue according to the current queuing delay of the OpenFlow switch port queue.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.